Skip to content

Commit 280883f

Browse files
committed
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.
1 parent 2df2dba commit 280883f

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/base/print_trace.C

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ std::string process_trace(const char * name)
133133
// source code, a really helpful feature when debugging something...
134134
bool gdb_backtrace(std::ostream & out_stream)
135135
{
136-
#ifdef LIBMESH_GDB_COMMAND
137136
// Eventual return value, true if gdb succeeds, false otherwise.
138137
bool success = true;
139138

@@ -156,8 +155,15 @@ bool gdb_backtrace(std::ostream & out_stream)
156155

157156
libmesh_try
158157
{
158+
#ifdef LIBMESH_GDB_COMMAND
159159
std::string gdb_command =
160160
libMesh::command_line_value("gdb",std::string(LIBMESH_GDB_COMMAND));
161+
#else
162+
if (!libMesh::on_command_line("--gdb"))
163+
return false;
164+
std::string gdb_command =
165+
libMesh::command_line_value("gdb",std::string());
166+
#endif
161167

162168
std::ostringstream command;
163169
command << gdb_command
@@ -188,9 +194,6 @@ bool gdb_backtrace(std::ostream & out_stream)
188194
std::remove(temp_file);
189195

190196
return success;
191-
#else
192-
return false;
193-
#endif
194197
}
195198

196199
} // end anonymous namespace
@@ -210,8 +213,10 @@ void print_trace(std::ostream & out_stream)
210213

211214
// Let the user disable GDB backtraces by configuring with
212215
// --without-gdb-command or with a command line option.
213-
if ((std::string(LIBMESH_GDB_COMMAND) != std::string("no") &&
214-
!libMesh::on_command_line("--no-gdb-backtrace")) ||
216+
if (
217+
#ifdef LIBMESH_GDB_COMMAND
218+
!libMesh::on_command_line("--no-gdb-backtrace") ||
219+
#endif
215220
libMesh::on_command_line("--gdb"))
216221
gdb_worked = gdb_backtrace(out_stream);
217222

0 commit comments

Comments
 (0)