From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Fix for internal-error: linux_nat_post_attach_wait: Assertion `pid == new_pid && WIFSTOPPED (status)' failed.
Date: Thu, 15 Oct 2009 18:10:00 -0000 [thread overview]
Message-ID: <8ac60eac0910151110r12e99653ne86660fb83cfa3b2@mail.gmail.com> (raw)
In-Reply-To: <200910142329.06920.pedro@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 532 bytes --]
On Wed, Oct 14, 2009 at 3:29 PM, Pedro Alves <pedro@codesourcery.com> wrote:
> I've no preference really. Any of those is fine with me.
> If someone else wants to suggest something, I'm sure they'll
> speak up now. :-)
Nobody did, so I've checked in the "Unable to attach: ..." variant ...
> Something else I noticed:
...
> Should be:
>
> enum target_signal signo = target_signal_from_host (WTERMSIG (status));
With that fix.
(Attached patch has been checked in, here just for reference.)
Thanks,
--
Paul Pluzhnikov
[-- Attachment #2: gdb-assert-10757-20091015.txt --]
[-- Type: text/plain, Size: 2152 bytes --]
Index: linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-nat.c,v
retrieving revision 1.151
diff -u -p -u -r1.151 linux-nat.c
--- linux-nat.c 9 Oct 2009 01:57:12 -0000 1.151
+++ linux-nat.c 15 Oct 2009 18:02:58 -0000
@@ -1338,7 +1338,16 @@ linux_nat_post_attach_wait (ptid_t ptid,
*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
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. */
prev parent reply other threads:[~2009-10-15 18:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-13 18:41 Paul Pluzhnikov
2009-10-13 20:53 ` Pedro Alves
2009-10-14 18:21 ` Paul Pluzhnikov
2009-10-14 19:08 ` Pedro Alves
2009-10-14 21:01 ` Paul Pluzhnikov
2009-10-14 21:16 ` Pedro Alves
2009-10-14 21:28 ` Paul Pluzhnikov
2009-10-14 22:29 ` Pedro Alves
2009-10-15 2:17 ` Doug Evans
2009-10-15 18:10 ` Paul Pluzhnikov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8ac60eac0910151110r12e99653ne86660fb83cfa3b2@mail.gmail.com \
--to=ppluzhnikov@google.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox