GNU Binutils with patches for OS216
Revisión | 5e9705017f5b257421136b8d7752b9c793335ace (tree) |
---|---|
Tiempo | 2015-05-14 03:47:32 |
Autor | Jan Kratochvil <jan.kratochvil@redh...> |
Commiter | Jan Kratochvil |
Call dummy_frame_dtor_ftype also from remove_dummy_frame
There was now a leak-like bug that if dummy_frame "disappeared" by
remove_dummy_frame then its destructor was not called. For example in the case
of 'compile code' dummy frames the injected objfile would never get freed after
some inferior longjmp out of the injected code.
gdb/ChangeLog
2015-05-13 Jan Kratochvil <jan.kratochvil@redhat.com>
* compile/compile-object-run.c (do_module_cleanup): Add parameter
registers_valid.
(compile_object_run): Update do_module_cleanup caller.
* dummy-frame.c: Include infcall.h.
(struct dummy_frame): Update dtor comment.
(remove_dummy_frame): Call dtor.
(pop_dummy_frame): Update dtor caller.
* dummy-frame.h (dummy_frame_dtor_ftype): Add parameter
registers_valid.
@@ -1,3 +1,15 @@ | ||
1 | +2015-05-13 Jan Kratochvil <jan.kratochvil@redhat.com> | |
2 | + | |
3 | + * compile/compile-object-run.c (do_module_cleanup): Add parameter | |
4 | + registers_valid. | |
5 | + (compile_object_run): Update do_module_cleanup caller. | |
6 | + * dummy-frame.c: Include infcall.h. | |
7 | + (struct dummy_frame): Update dtor comment. | |
8 | + (remove_dummy_frame): Call dtor. | |
9 | + (pop_dummy_frame): Update dtor caller. | |
10 | + * dummy-frame.h (dummy_frame_dtor_ftype): Add parameter | |
11 | + registers_valid. | |
12 | + | |
1 | 13 | 2015-05-13 Joel Brobecker <brobecker@adacore.com> |
2 | 14 | |
3 | 15 | GDB 7.9.1 released. |
@@ -45,7 +45,7 @@ struct do_module_cleanup | ||
45 | 45 | |
46 | 46 | static dummy_frame_dtor_ftype do_module_cleanup; |
47 | 47 | static void |
48 | -do_module_cleanup (void *arg) | |
48 | +do_module_cleanup (void *arg, int registers_valid) | |
49 | 49 | { |
50 | 50 | struct do_module_cleanup *data = arg; |
51 | 51 | struct objfile *objfile; |
@@ -129,7 +129,7 @@ compile_object_run (struct compile_module *module) | ||
129 | 129 | data->executedp = NULL; |
130 | 130 | gdb_assert (!(dtor_found && executed)); |
131 | 131 | if (!dtor_found && !executed) |
132 | - do_module_cleanup (data); | |
132 | + do_module_cleanup (data, 0); | |
133 | 133 | throw_exception (ex); |
134 | 134 | } |
135 | 135 | END_CATCH |
@@ -28,6 +28,7 @@ | ||
28 | 28 | #include "gdbcmd.h" |
29 | 29 | #include "observer.h" |
30 | 30 | #include "gdbthread.h" |
31 | +#include "infcall.h" | |
31 | 32 | |
32 | 33 | struct dummy_frame_id |
33 | 34 | { |
@@ -62,8 +63,7 @@ struct dummy_frame | ||
62 | 63 | /* The caller's state prior to the call. */ |
63 | 64 | struct infcall_suspend_state *caller_state; |
64 | 65 | |
65 | - /* If non-NULL, a destructor that is run when this dummy frame is | |
66 | - popped. */ | |
66 | + /* If non-NULL, a destructor that is run when this dummy frame is freed. */ | |
67 | 67 | dummy_frame_dtor_ftype *dtor; |
68 | 68 | |
69 | 69 | /* Arbitrary data that is passed to DTOR. */ |
@@ -96,6 +96,9 @@ remove_dummy_frame (struct dummy_frame **dummy_ptr) | ||
96 | 96 | { |
97 | 97 | struct dummy_frame *dummy = *dummy_ptr; |
98 | 98 | |
99 | + if (dummy->dtor != NULL) | |
100 | + dummy->dtor (dummy->dtor_data, 0); | |
101 | + | |
99 | 102 | *dummy_ptr = dummy->next; |
100 | 103 | discard_infcall_suspend_state (dummy->caller_state); |
101 | 104 | xfree (dummy); |
@@ -136,7 +139,7 @@ pop_dummy_frame (struct dummy_frame **dummy_ptr) | ||
136 | 139 | gdb_assert (ptid_equal (dummy->id.ptid, inferior_ptid)); |
137 | 140 | |
138 | 141 | if (dummy->dtor != NULL) |
139 | - dummy->dtor (dummy->dtor_data); | |
142 | + dummy->dtor (dummy->dtor_data, 1); | |
140 | 143 | |
141 | 144 | restore_infcall_suspend_state (dummy->caller_state); |
142 | 145 |
@@ -54,8 +54,9 @@ extern void dummy_frame_discard (struct frame_id dummy_id, ptid_t ptid); | ||
54 | 54 | |
55 | 55 | extern const struct frame_unwind dummy_frame_unwind; |
56 | 56 | |
57 | -/* Destructor for dummy_frame. DATA is supplied by registrant. */ | |
58 | -typedef void (dummy_frame_dtor_ftype) (void *data); | |
57 | +/* Destructor for dummy_frame. DATA is supplied by registrant. | |
58 | + REGISTERS_VALID is 1 for dummy_frame_pop, 0 for dummy_frame_discard. */ | |
59 | +typedef void (dummy_frame_dtor_ftype) (void *data, int registers_valid); | |
59 | 60 | |
60 | 61 | /* Call DTOR with DTOR_DATA when DUMMY_ID frame of thread PTID gets discarded. |
61 | 62 | Dummy frame with DUMMY_ID must exist. There must be no other call of |