diff options
author | Patrick Palka <patrick@parcs.ath.cx> | 2015-07-28 15:00:58 -0400 |
---|---|---|
committer | Patrick Palka <patrick@parcs.ath.cx> | 2015-08-15 13:32:47 -0400 |
commit | e3ae3c4345fa14f2f3b0b2c5d4d23760af9f74f5 (patch) | |
tree | 3becc238774281fa8eee63ce6747a872a47c8ec9 /gdb/inferior.c | |
parent | 604b263620af66e3bf881f146e329b4de06104a5 (diff) | |
download | binutils-gdb-e3ae3c4345fa14f2f3b0b2c5d4d23760af9f74f5.tar.gz |
Fix invoking "[kill|detach] inferiors" on inferiors that are not running
Invoking either of the above commands on an inferior that's not running
triggers the following assert failure:
.../binutils-gdb/gdb/thread.c:514: internal-error: any_thread_of_process: Assertion `pid != 0' failed.
The fix is straightforward. This patch also adds a test to check the
basic functionality of these commands, along with testing this fix in
particular. Tested on x86_64 Linux.
gdb/ChangeLog:
* inferior.c (detach_inferior_command): Don't call
any_thread_of_process when pid is 0.
(kill_inferior_command): Likewise.
gdb/testsuite/ChangeLog:
* gdb.base/kill-detach-inferiors-cmd.exp: New test file.
* gdb.base/kill-detach-inferiors-cmd.c: New test file.
Diffstat (limited to 'gdb/inferior.c')
-rw-r--r-- | gdb/inferior.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/inferior.c b/gdb/inferior.c index 5e98df58942..2e44f175bb1 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -625,6 +625,11 @@ detach_inferior_command (char *args, int from_tty) } pid = gdb_inferior_id_to_pid (num); + if (pid == 0) + { + warning (_("Inferior ID %d is not running."), num); + continue; + } tp = any_thread_of_process (pid); if (!tp) @@ -661,6 +666,11 @@ kill_inferior_command (char *args, int from_tty) } pid = gdb_inferior_id_to_pid (num); + if (pid == 0) + { + warning (_("Inferior ID %d is not running."), num); + continue; + } tp = any_thread_of_process (pid); if (!tp) |