Skip to content

Commit d83aee3

Browse files
committed
memory analyzer: fail when gdb cannot be started
When gdb wasn't available, the forked child would not terminate and the parent would wait forever.
1 parent 2f7dcb5 commit d83aee3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/memory-analyzer/gdb_api.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ void gdb_apit::create_gdb_process()
132132

133133
// Only reachable, if execvp failed
134134
int errno_value = errno;
135-
dprintf(pipe_output[1], "errno in child: %s\n", strerror(errno_value));
135+
dprintf(pipe_output[1], "Starting gdb failed: %s\n", strerror(errno_value));
136+
dprintf(pipe_output[1], "(gdb) \n");
137+
throw gdb_interaction_exceptiont("could not run gdb");
136138
}
137139
else
138140
{
139141
// parent process
140-
gdb_state = gdb_statet::CREATED;
141-
142142
close(pipe_input[0]);
143143
close(pipe_output[1]);
144144

@@ -149,6 +149,11 @@ void gdb_apit::create_gdb_process()
149149
command_stream = fdopen(pipe_input[1], "w");
150150

151151
std::string line = read_most_recent_line();
152+
if(has_prefix(line, "Starting gdb failed:"))
153+
throw gdb_interaction_exceptiont(line);
154+
155+
gdb_state = gdb_statet::CREATED;
156+
152157
CHECK_RETURN(
153158
has_prefix(line, R"(~"done)") ||
154159
has_prefix(line, R"(~"Reading)"));

0 commit comments

Comments
 (0)