From 2df2dba9e828261e8278bca02817e212128d76aa Mon Sep 17 00:00:00 2001 From: Roy Stogner Date: Thu, 28 May 2026 15:28:18 -0500 Subject: [PATCH 1/3] Leave GDB_COMMAND undefined if it's undefined This way we can use the preprocessor to check when it's undefined, not just the compiler. --- m4/libmesh_core_features.m4 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/m4/libmesh_core_features.m4 b/m4/libmesh_core_features.m4 index bf3f02d20f0..9dea78752dc 100644 --- a/m4/libmesh_core_features.m4 +++ b/m4/libmesh_core_features.m4 @@ -19,8 +19,14 @@ AC_ARG_WITH([gdb-command], [gdb_command="$withval"], [gdb_command="no"]) -AC_DEFINE_UNQUOTED(GDB_COMMAND, "$gdb_command", [command to invoke gdb]) -AC_MSG_RESULT([configuring gdb command... "$gdb_command"]) +AS_IF([test "$gdb_command" != no], + [ + AC_DEFINE_UNQUOTED(GDB_COMMAND, "$gdb_command", [command to invoke gdb]) + AC_MSG_RESULT([configuring gdb command... "$gdb_command"]) + ], + [ + AC_MSG_RESULT([configuring with no gdb"]) + ]) # ------------------------------------------------------------- From 280883f57f4a2dd8fe6f1b894cd7596e41dbc424 Mon Sep 17 00:00:00 2001 From: Roy Stogner Date: Thu, 28 May 2026 15:47:44 -0500 Subject: [PATCH 2/3] Better GDB_COMMAND handling Don't futz with comparing GDB_COMMAND to "no" at run-time (this fixes an "unreachable code" warning for me with GDB_COMMAND=no with my clang++ and newer C++ standards) Do allow for run-time `--gdb=` even if it was disabled at compile-time. --- src/base/print_trace.C | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/base/print_trace.C b/src/base/print_trace.C index 7e8b7e0fef6..8a88043eb46 100644 --- a/src/base/print_trace.C +++ b/src/base/print_trace.C @@ -133,7 +133,6 @@ std::string process_trace(const char * name) // source code, a really helpful feature when debugging something... bool gdb_backtrace(std::ostream & out_stream) { -#ifdef LIBMESH_GDB_COMMAND // Eventual return value, true if gdb succeeds, false otherwise. bool success = true; @@ -156,8 +155,15 @@ bool gdb_backtrace(std::ostream & out_stream) libmesh_try { +#ifdef LIBMESH_GDB_COMMAND std::string gdb_command = libMesh::command_line_value("gdb",std::string(LIBMESH_GDB_COMMAND)); +#else + if (!libMesh::on_command_line("--gdb")) + return false; + std::string gdb_command = + libMesh::command_line_value("gdb",std::string()); +#endif std::ostringstream command; command << gdb_command @@ -188,9 +194,6 @@ bool gdb_backtrace(std::ostream & out_stream) std::remove(temp_file); return success; -#else - return false; -#endif } } // end anonymous namespace @@ -210,8 +213,10 @@ void print_trace(std::ostream & out_stream) // Let the user disable GDB backtraces by configuring with // --without-gdb-command or with a command line option. - if ((std::string(LIBMESH_GDB_COMMAND) != std::string("no") && - !libMesh::on_command_line("--no-gdb-backtrace")) || + if ( +#ifdef LIBMESH_GDB_COMMAND + !libMesh::on_command_line("--no-gdb-backtrace") || +#endif libMesh::on_command_line("--gdb")) gdb_worked = gdb_backtrace(out_stream); From 0082cdb52c6b19ab9e85221cd38439929cc21edc Mon Sep 17 00:00:00 2001 From: Roy Stogner Date: Thu, 28 May 2026 15:59:03 -0500 Subject: [PATCH 3/3] Re-bootstrap --- configure | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 68b5c9981eb..3d7470fc1d5 100755 --- a/configure +++ b/configure @@ -61111,11 +61111,22 @@ esac fi +if test "$gdb_command" != no +then : + printf "%s\n" "#define GDB_COMMAND \"$gdb_command\"" >>confdefs.h -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: configuring gdb command... \"$gdb_command\"" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: configuring gdb command... \"$gdb_command\"" >&5 printf "%s\n" "configuring gdb command... \"$gdb_command\"" >&6; } + +else case e in #( + e) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: configuring with no gdb\"" >&5 +printf "%s\n" "configuring with no gdb\"" >&6; } + ;; +esac +fi # -------------------------------------------------------------