aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2009-10-15 18:06:15 +0000
committerPaul Pluzhnikov <ppluzhnikov@google.com>2009-10-15 18:06:15 +0000
commitdacc9cb281a484b6c44be5a8395c27cbac833b88 (patch)
tree772d9bc6a42db1773099a7faa3f4c4a0e80f6bcb
parent191e181311dc21b3af8169ea7711a3d8c8bb6be4 (diff)
downloadgdb-dacc9cb281a484b6c44be5a8395c27cbac833b88.zip
gdb-dacc9cb281a484b6c44be5a8395c27cbac833b88.tar.gz
gdb-dacc9cb281a484b6c44be5a8395c27cbac833b88.tar.bz2
2009-10-15 Paul Pluzhnikov <ppluzhnikov@google.com>
* linux-nat.c (linux_nat_post_attach_wait): Adjust assert. (lin_lwp_attach_lwp, linux_nat_attach): Handle disappearing LWP.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/linux-nat.c47
2 files changed, 51 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 130268f..d3e3deb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-15 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ * linux-nat.c (linux_nat_post_attach_wait): Adjust assert.
+ (lin_lwp_attach_lwp, linux_nat_attach): Handle disappearing LWP.
+
2009-10-15 Michael Snyder <msnyder@vmware.com>
* record.c (record_insn_max_num): Make unsigned.
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index bde7311..fd12d44 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1338,7 +1338,16 @@ linux_nat_post_attach_wait (ptid_t ptid, int first, int *cloned,
*cloned = 1;
}
- gdb_assert (pid == new_pid && WIFSTOPPED (status));
+ gdb_assert (pid == new_pid);
+
+ if (!WIFSTOPPED (status))
+ {
+ /* The pid we tried to attach has apparently just exited. */
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog, "LNPAW: Failed to stop %d: %s",
+ pid, status_to_str (status));
+ return status;
+ }
if (WSTOPSIG (status) != SIGSTOP)
{
@@ -1396,6 +1405,9 @@ lin_lwp_attach_lwp (ptid_t ptid)
target_pid_to_str (ptid));
status = linux_nat_post_attach_wait (ptid, 0, &cloned, &signalled);
+ if (!WIFSTOPPED (status))
+ return -1;
+
lp = add_lwp (ptid);
lp->stopped = 1;
lp->cloned = cloned;
@@ -1495,6 +1507,39 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty)
status = linux_nat_post_attach_wait (lp->ptid, 1, &lp->cloned,
&lp->signalled);
+ if (!WIFSTOPPED (status))
+ {
+ if (WIFEXITED (status))
+ {
+ int exit_code = WEXITSTATUS (status);
+
+ target_terminal_ours ();
+ target_mourn_inferior ();
+ if (exit_code == 0)
+ error (_("Unable to attach: program exited normally."));
+ else
+ error (_("Unable to attach: program exited with code %d."),
+ exit_code);
+ }
+ else if (WIFSIGNALED (status))
+ {
+ enum target_signal signo;
+
+ target_terminal_ours ();
+ target_mourn_inferior ();
+
+ signo = target_signal_from_host (WTERMSIG (status));
+ error (_("Unable to attach: program terminated with signal "
+ "%s, %s."),
+ target_signal_to_name (signo),
+ target_signal_to_string (signo));
+ }
+
+ internal_error (__FILE__, __LINE__,
+ _("unexpected status %d for PID %ld"),
+ status, (long) GET_LWP (ptid));
+ }
+
lp->stopped = 1;
/* Save the wait status to report later. */