aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2009-01-08 16:32:30 +0000
committerTom Tromey <tromey@redhat.com>2009-01-08 16:32:30 +0000
commitf75455520e7d4fa0f867d2f4a8f3dffd1a0595fc (patch)
tree67b7301ed29325c649f0f2da4745a855bf3ccb28
parente77b97d43359df06713529ec054ed1ed8afb3e37 (diff)
downloadfsf-binutils-gdb-f75455520e7d4fa0f867d2f4a8f3dffd1a0595fc.zip
fsf-binutils-gdb-f75455520e7d4fa0f867d2f4a8f3dffd1a0595fc.tar.gz
fsf-binutils-gdb-f75455520e7d4fa0f867d2f4a8f3dffd1a0595fc.tar.bz2
PR breakpoints/9350:
* varobj.c (varobj_invalidate): Unconditionally free all_rootvarobj. * symfile.c (syms_from_objfile): Free local_addr when returning normally. * exec.c (exec_file_attach): Do cleanups before returning. (exec_file_command): Likewise. * corefile.c (reopen_exec_file): Do cleanups before returning. * breakpoint.c (insert_breakpoint_locations): Do cleanups before returning. (do_vec_free): New function. (update_global_location_list): Make a cleanup for old_locations. Do cleanups before returning. Remove unused variable 'e'. (find_condition_and_thread): Free result of parsing the expression. (print_it_typical): Do cleanups before returning. (breakpoint_re_set_one): Always free sals.sals.
-rw-r--r--gdb/ChangeLog20
-rw-r--r--gdb/breakpoint.c78
-rw-r--r--gdb/corefile.c5
-rw-r--r--gdb/exec.c11
-rw-r--r--gdb/symfile.c1
-rw-r--r--gdb/varobj.c2
6 files changed, 85 insertions, 32 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 665ae66..8e4acbf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,23 @@
+2009-01-08 Tom Tromey <tromey@redhat.com>
+
+ PR breakpoints/9350:
+ * varobj.c (varobj_invalidate): Unconditionally free
+ all_rootvarobj.
+ * symfile.c (syms_from_objfile): Free local_addr when returning
+ normally.
+ * exec.c (exec_file_attach): Do cleanups before returning.
+ (exec_file_command): Likewise.
+ * corefile.c (reopen_exec_file): Do cleanups before returning.
+ * breakpoint.c (insert_breakpoint_locations): Do cleanups before
+ returning.
+ (do_vec_free): New function.
+ (update_global_location_list): Make a cleanup for old_locations.
+ Do cleanups before returning. Remove unused variable 'e'.
+ (find_condition_and_thread): Free result of parsing the
+ expression.
+ (print_it_typical): Do cleanups before returning.
+ (breakpoint_re_set_one): Always free sals.sals.
+
2009-01-08 Joel Brobecker <brobecker@adacore.com>
Emi Suzuki <emi-suzuki@tjsys.co.jp>
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 41fefe1..65bbca9 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1278,7 +1278,7 @@ insert_breakpoint_locations (void)
int hw_breakpoint_error = 0;
struct ui_file *tmp_error_stream = mem_fileopen ();
- make_cleanup_ui_file_delete (tmp_error_stream);
+ struct cleanup *cleanups = make_cleanup_ui_file_delete (tmp_error_stream);
/* Explicitly mark the warning -- this will only be printed if
there was an error. */
@@ -1351,6 +1351,8 @@ You may have requested too many hardware breakpoints/watchpoints.\n");
target_terminal_ours_for_output ();
error_stream (tmp_error_stream);
}
+
+ do_cleanups (cleanups);
}
int
@@ -2232,13 +2234,13 @@ watchpoint_value_print (struct value *val, struct ui_file *stream)
static enum print_stop_action
print_it_typical (bpstat bs)
{
- struct cleanup *old_chain, *ui_out_chain;
+ struct cleanup *old_chain;
struct breakpoint *b;
const struct bp_location *bl;
struct ui_stream *stb;
- int bp_temp = 0;
- stb = ui_out_stream_new (uiout);
- old_chain = make_cleanup_ui_out_stream_delete (stb);
+ int bp_temp = 0;
+ enum print_stop_action result;
+
/* bs->breakpoint_at can be NULL if it was a momentary breakpoint
which has since been deleted. */
if (bs->breakpoint_at == NULL)
@@ -2246,6 +2248,9 @@ print_it_typical (bpstat bs)
bl = bs->breakpoint_at;
b = bl->owner;
+ stb = ui_out_stream_new (uiout);
+ old_chain = make_cleanup_ui_out_stream_delete (stb);
+
switch (b->type)
{
case bp_breakpoint:
@@ -2268,7 +2273,7 @@ print_it_typical (bpstat bs)
}
ui_out_field_int (uiout, "bkptno", b->number);
ui_out_text (uiout, ", ");
- return PRINT_SRC_AND_LOC;
+ result = PRINT_SRC_AND_LOC;
break;
case bp_shlib_event:
@@ -2276,20 +2281,20 @@ print_it_typical (bpstat bs)
variable? (If so, we report this as a generic, "Stopped due
to shlib event" message.) */
printf_filtered (_("Stopped due to shared library event\n"));
- return PRINT_NOTHING;
+ result = PRINT_NOTHING;
break;
case bp_thread_event:
/* Not sure how we will get here.
GDB should not stop for these breakpoints. */
printf_filtered (_("Thread Event Breakpoint: gdb should not stop!\n"));
- return PRINT_NOTHING;
+ result = PRINT_NOTHING;
break;
case bp_overlay_event:
/* By analogy with the thread event, GDB should not stop for these. */
printf_filtered (_("Overlay Event Breakpoint: gdb should not stop!\n"));
- return PRINT_NOTHING;
+ result = PRINT_NOTHING;
break;
case bp_watchpoint:
@@ -2300,17 +2305,16 @@ print_it_typical (bpstat bs)
(uiout, "reason",
async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER));
mention (b);
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+ make_cleanup_ui_out_tuple_begin_end (uiout, "value");
ui_out_text (uiout, "\nOld value = ");
watchpoint_value_print (bs->old_val, stb->stream);
ui_out_field_stream (uiout, "old", stb);
ui_out_text (uiout, "\nNew value = ");
watchpoint_value_print (b->val, stb->stream);
ui_out_field_stream (uiout, "new", stb);
- do_cleanups (ui_out_chain);
ui_out_text (uiout, "\n");
/* More than one watchpoint may have been triggered. */
- return PRINT_UNKNOWN;
+ result = PRINT_UNKNOWN;
break;
case bp_read_watchpoint:
@@ -2319,13 +2323,12 @@ print_it_typical (bpstat bs)
(uiout, "reason",
async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER));
mention (b);
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+ make_cleanup_ui_out_tuple_begin_end (uiout, "value");
ui_out_text (uiout, "\nValue = ");
watchpoint_value_print (b->val, stb->stream);
ui_out_field_stream (uiout, "value", stb);
- do_cleanups (ui_out_chain);
ui_out_text (uiout, "\n");
- return PRINT_UNKNOWN;
+ result = PRINT_UNKNOWN;
break;
case bp_access_watchpoint:
@@ -2337,7 +2340,7 @@ print_it_typical (bpstat bs)
(uiout, "reason",
async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
mention (b);
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+ make_cleanup_ui_out_tuple_begin_end (uiout, "value");
ui_out_text (uiout, "\nOld value = ");
watchpoint_value_print (bs->old_val, stb->stream);
ui_out_field_stream (uiout, "old", stb);
@@ -2350,14 +2353,13 @@ print_it_typical (bpstat bs)
ui_out_field_string
(uiout, "reason",
async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
- ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+ make_cleanup_ui_out_tuple_begin_end (uiout, "value");
ui_out_text (uiout, "\nValue = ");
}
watchpoint_value_print (b->val, stb->stream);
ui_out_field_stream (uiout, "new", stb);
- do_cleanups (ui_out_chain);
ui_out_text (uiout, "\n");
- return PRINT_UNKNOWN;
+ result = PRINT_UNKNOWN;
break;
/* Fall through, we don't deal with these types of breakpoints
@@ -2368,7 +2370,7 @@ print_it_typical (bpstat bs)
ui_out_field_string
(uiout, "reason",
async_reason_lookup (EXEC_ASYNC_FUNCTION_FINISHED));
- return PRINT_UNKNOWN;
+ result = PRINT_UNKNOWN;
break;
case bp_until:
@@ -2376,7 +2378,7 @@ print_it_typical (bpstat bs)
ui_out_field_string
(uiout, "reason",
async_reason_lookup (EXEC_ASYNC_LOCATION_REACHED));
- return PRINT_UNKNOWN;
+ result = PRINT_UNKNOWN;
break;
case bp_none:
@@ -2386,8 +2388,12 @@ print_it_typical (bpstat bs)
case bp_watchpoint_scope:
case bp_call_dummy:
default:
- return PRINT_UNKNOWN;
+ result = PRINT_UNKNOWN;
+ break;
}
+
+ do_cleanups (old_chain);
+ return result;
}
/* Generic routine for printing messages indicating why we
@@ -5432,8 +5438,11 @@ find_condition_and_thread (char *tok, CORE_ADDR pc,
if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
{
+ struct expression *expr;
+
tok = cond_start = end_tok + 1;
- parse_exp_1 (&tok, block_for_pc (pc), 0);
+ expr = parse_exp_1 (&tok, block_for_pc (pc), 0);
+ xfree (expr);
cond_end = tok;
*cond_string = savestring (cond_start,
cond_end - cond_start);
@@ -6846,6 +6855,16 @@ breakpoint_auto_delete (bpstat bs)
}
}
+/* A cleanup function which destroys a vector. */
+
+static void
+do_vec_free (void *p)
+{
+ VEC(bp_location_p) **vec = p;
+ if (*vec)
+ VEC_free (bp_location_p, *vec);
+}
+
/* If SHOULD_INSERT is false, do not insert any breakpoint locations
into the inferior, only remove already-inserted locations that no
longer should be inserted. Functions that delete a breakpoint or
@@ -6868,11 +6887,12 @@ update_global_location_list (int should_insert)
struct bp_location **next = &bp_location_chain;
struct bp_location *loc;
struct bp_location *loc2;
- struct gdb_exception e;
VEC(bp_location_p) *old_locations = NULL;
int ret;
int ix;
-
+ struct cleanup *cleanups;
+
+ cleanups = make_cleanup (do_vec_free, &old_locations);
/* Store old locations for future reference. */
for (loc = bp_location_chain; loc; loc = loc->global_next)
VEC_safe_push (bp_location_p, old_locations, loc);
@@ -7001,6 +7021,8 @@ update_global_location_list (int should_insert)
|| (gdbarch_has_global_solist (target_gdbarch)
&& target_supports_multi_process ())))
insert_breakpoint_locations ();
+
+ do_cleanups (cleanups);
}
void
@@ -7360,7 +7382,7 @@ breakpoint_re_set_one (void *bint)
char *s;
enum enable_state save_enable;
struct gdb_exception e;
-
+ struct cleanup *cleanups;
switch (b->type)
{
@@ -7430,9 +7452,9 @@ breakpoint_re_set_one (void *bint)
b->condition_not_parsed = 0;
}
expanded = expand_line_sal_maybe (sals.sals[0]);
+ cleanups = make_cleanup (xfree, sals.sals);
update_breakpoint_locations (b, expanded);
-
- xfree (sals.sals);
+ do_cleanups (cleanups);
break;
case bp_watchpoint:
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 2566f9f..57a0cdf 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -153,6 +153,7 @@ reopen_exec_file (void)
int res;
struct stat st;
long mtime;
+ struct cleanup *cleanups;
/* Don't do anything if there isn't an exec file. */
if (exec_bfd == NULL)
@@ -160,7 +161,7 @@ reopen_exec_file (void)
/* If the timestamp of the exec file has changed, reopen it. */
filename = xstrdup (bfd_get_filename (exec_bfd));
- make_cleanup (xfree, filename);
+ cleanups = make_cleanup (xfree, filename);
res = stat (filename, &st);
if (exec_bfd_mtime && exec_bfd_mtime != st.st_mtime)
@@ -170,6 +171,8 @@ reopen_exec_file (void)
this stops GDB from holding the executable open after it
exits. */
bfd_cache_close_all ();
+
+ do_cleanups (cleanups);
#endif
}
diff --git a/gdb/exec.c b/gdb/exec.c
index 542af0e..8d8c1df 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -194,6 +194,7 @@ exec_file_attach (char *filename, int from_tty)
}
else
{
+ struct cleanup *cleanups;
char *scratch_pathname;
int scratch_chan;
@@ -228,7 +229,7 @@ exec_file_attach (char *filename, int from_tty)
via the exec_bfd->name pointer, so we need to make another copy and
leave exec_bfd as the new owner of the original copy. */
scratch_pathname = xstrdup (scratch_pathname);
- make_cleanup (xfree, scratch_pathname);
+ cleanups = make_cleanup (xfree, scratch_pathname);
if (!bfd_check_format (exec_bfd, bfd_object))
{
@@ -276,6 +277,8 @@ exec_file_attach (char *filename, int from_tty)
/* Tell display code (if any) about the changed file name. */
if (deprecated_exec_file_display_hook)
(*deprecated_exec_file_display_hook) (filename);
+
+ do_cleanups (cleanups);
}
bfd_cache_close_all ();
observer_notify_executable_changed ();
@@ -302,11 +305,13 @@ exec_file_command (char *args, int from_tty)
if (args)
{
+ struct cleanup *cleanups;
+
/* Scan through the args and pick up the first non option arg
as the filename. */
argv = gdb_buildargv (args);
- make_cleanup_freeargv (argv);
+ cleanups = make_cleanup_freeargv (argv);
for (; (*argv != NULL) && (**argv == '-'); argv++)
{;
@@ -317,6 +322,8 @@ exec_file_command (char *args, int from_tty)
filename = tilde_expand (*argv);
make_cleanup (xfree, filename);
exec_file_attach (filename, from_tty);
+
+ do_cleanups (cleanups);
}
else
exec_file_attach (NULL, from_tty);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 14cb7b8..21328b8 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -899,6 +899,7 @@ syms_from_objfile (struct objfile *objfile,
/* Discard cleanups as symbol reading was successful. */
discard_cleanups (old_chain);
+ xfree (local_addr);
}
/* Perform required actions after either reading in the initial
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 25cc207..5b2ed9c 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2780,7 +2780,7 @@ varobj_invalidate (void)
varp++;
}
- xfree (all_rootvarobj);
}
+ xfree (all_rootvarobj);
return;
}