gdb/gdb-exit-warning.patch

94 lines
2.4 KiB
Diff
Raw Normal View History

http://sourceware.org/ml/gdb-patches/2012-02/msg00664.html
Subject: RFA: fix PR breakpoints/13776
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 ();