]>
Commit | Line | Data |
---|---|---|
f412e1b4 PS |
1 | http://sourceware.org/ml/gdb-patches/2012-02/msg00664.html |
2 | Subject: RFA: fix PR breakpoints/13776 | |
3 | ||
4 | I'd appreciate comments on this patch. | |
5 | I have no idea whether it is the best way to fix the problem. | |
6 | ||
7 | Bug 13776 concerns 'next'ing over an exit. For the trivial: | |
8 | ||
9 | #include <stdlib.h> | |
10 | int | |
11 | main (void) | |
12 | { | |
13 | exit (0); | |
14 | } | |
15 | ||
16 | We get this behavior: | |
17 | ||
18 | (gdb) start | |
19 | Temporary breakpoint 1, main () at exit0.c:5 | |
20 | 5 exit (0); | |
21 | (gdb) next | |
22 | [Inferior 1 (process 2428) exited normally] | |
23 | warning: Error removing breakpoint 0 | |
24 | warning: Error removing breakpoint 0 | |
25 | warning: Error removing breakpoint 0 | |
26 | ||
27 | The bug is that exit_inferior ends up calling delete_longjmp_breakpoint, | |
28 | which tries to delete the longjmp breakpoints -- but as the inferior is | |
29 | dead, this fails. | |
30 | ||
31 | This patch fixes this problem by moving the breakpoint_init_inferior | |
32 | call earlier in generic_mourn_inferior. This causes the breakpoints to | |
33 | be marked as uninserted before they are deleted. | |
34 | ||
35 | While doing this I noticed that after the inferior exits, we are left | |
36 | with a step-resume breakpoint: | |
37 | ||
38 | (gdb) maint info b | |
39 | Num Type Disp Enb Address What | |
40 | [...] | |
41 | 0 step resume dstp y 0x00000000004004d2 inf 1 thread 1 | |
42 | stop only in thread 1 | |
43 | ||
44 | The breakpoint.c patch causes this to be removed as well. | |
45 | ||
46 | Built and regtested on x86-64 Fedora 16. | |
47 | ||
48 | Tom | |
49 | ||
50 | 2012-02-28 Tom Tromey <tromey@redhat.com> | |
51 | ||
52 | PR breakpoints/13776: | |
53 | * target.c (generic_mourn_inferior): Call breakpoint_init_inferior | |
54 | earlier. | |
55 | * breakpoint.c (breakpoint_init_inferior): Delete step-resume | |
56 | breakpoints. | |
57 | ||
58 | diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c | |
59 | index db05b97..048cc63 100644 | |
60 | --- a/gdb/breakpoint.c | |
61 | +++ b/gdb/breakpoint.c | |
62 | @@ -3341,6 +3341,10 @@ breakpoint_init_inferior (enum inf_context context) | |
63 | (gdb) tar rem :9999 # remote Windows gdbserver. | |
64 | */ | |
65 | ||
66 | + case bp_step_resume: | |
67 | + | |
68 | + /* Also remove step-resume breakpoints. */ | |
69 | + | |
70 | delete_breakpoint (b); | |
71 | break; | |
72 | ||
73 | diff --git a/gdb/target.c b/gdb/target.c | |
74 | index 1f408f6..65a6c23 100644 | |
75 | --- a/gdb/target.c | |
76 | +++ b/gdb/target.c | |
77 | @@ -3583,13 +3583,14 @@ generic_mourn_inferior (void) | |
78 | ptid = inferior_ptid; | |
79 | inferior_ptid = null_ptid; | |
80 | ||
81 | + breakpoint_init_inferior (inf_exited); | |
82 | + | |
83 | if (!ptid_equal (ptid, null_ptid)) | |
84 | { | |
85 | int pid = ptid_get_pid (ptid); | |
86 | exit_inferior (pid); | |
87 | } | |
88 | ||
89 | - breakpoint_init_inferior (inf_exited); | |
90 | registers_changed (); | |
91 | ||
92 | reopen_exec_file (); | |
93 |