Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: RFA: fix PR breakpoints/13776
Date: Tue, 28 Feb 2012 17:51:00 -0000	[thread overview]
Message-ID: <878vjmswbr.fsf@fleche.redhat.com> (raw)

I'd appreciate comments on this patch.
I have no idea whether it is the best way to fix the problem.

Bug 13776 concerns 'next'ing over an exit.  For the trivial:

    #include <stdlib.h> 
    int
    main (void)
    {
      exit (0);
    }

We get this behavior:

    (gdb) start
    Temporary breakpoint 1, main () at exit0.c:5
    5      exit (0);
    (gdb) next
    [Inferior 1 (process 2428) exited normally]
    warning: Error removing breakpoint 0
    warning: Error removing breakpoint 0
    warning: Error removing breakpoint 0

The bug is that exit_inferior ends up calling delete_longjmp_breakpoint,
which tries to delete the longjmp breakpoints -- but as the inferior is
dead, this fails.

This patch fixes this problem by moving the breakpoint_init_inferior
call earlier in generic_mourn_inferior.  This causes the breakpoints to
be marked as uninserted before they are deleted.

While doing this I noticed that after the inferior exits, we are left
with a step-resume breakpoint:

(gdb) maint info b
Num     Type           Disp Enb Address            What
[...]
0       step resume    dstp y   0x00000000004004d2  inf 1 thread 1
	stop only in thread 1

The breakpoint.c patch causes this to be removed as well.

Built and regtested on x86-64 Fedora 16.

Tom

2012-02-28  Tom Tromey  <tromey@redhat.com>

	PR breakpoints/13776:
	* target.c (generic_mourn_inferior): Call breakpoint_init_inferior
	earlier.
	* breakpoint.c (breakpoint_init_inferior): Delete step-resume
	breakpoints.

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index db05b97..048cc63 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3341,6 +3341,10 @@ breakpoint_init_inferior (enum inf_context context)
 	   (gdb) tar rem :9999     # remote Windows gdbserver.
 	*/
 
+      case bp_step_resume:
+
+	/* Also remove step-resume breakpoints.  */
+
 	delete_breakpoint (b);
 	break;
 
diff --git a/gdb/target.c b/gdb/target.c
index 1f408f6..65a6c23 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3583,13 +3583,14 @@ generic_mourn_inferior (void)
   ptid = inferior_ptid;
   inferior_ptid = null_ptid;
 
+  breakpoint_init_inferior (inf_exited);
+
   if (!ptid_equal (ptid, null_ptid))
     {
       int pid = ptid_get_pid (ptid);
       exit_inferior (pid);
     }
 
-  breakpoint_init_inferior (inf_exited);
   registers_changed ();
 
   reopen_exec_file ();


             reply	other threads:[~2012-02-28 17:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 17:51 Tom Tromey [this message]
2012-02-28 18:27 ` Tom Tromey
2012-02-28 20:35 ` Jan Kratochvil
2012-02-28 21:05 ` Doug Evans
2012-02-29 20:07 ` Pedro Alves
2012-03-02 17:39   ` Tom Tromey
2012-03-02 18:15     ` Doug Evans
2012-03-02 19:05     ` Pedro Alves

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=878vjmswbr.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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