summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2011-06-30 18:48:18 +0000
committerTom Tromey <tromey@redhat.com>2011-06-30 18:48:18 +0000
commit9808f28cd4250a5a1736b92cee63973730c252cb (patch)
treee5db750b4b485b80af3934329db307d63c7e9734
parent73d1a0e39af77d0c90a7d1a8d9072eaace308032 (diff)
downloadgdb-9808f28cd4250a5a1736b92cee63973730c252cb.tar.gz
* symfile-mem.c (symbol_file_add_from_memory): Call do_cleanups.
* solib-svr4.c (open_symbol_file_object): Call do_cleanups on all return paths. Defer final do_cleanups until last return. * arm-tdep.c (arm_exidx_new_objfile): Make null cleanup after early return.
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/arm-tdep.c3
-rw-r--r--gdb/solib-svr4.c25
-rw-r--r--gdb/symfile-mem.c4
4 files changed, 31 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 39dd1443333..c625a006ff8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2011-06-30 Tom Tromey <tromey@redhat.com>
+ * symfile-mem.c (symbol_file_add_from_memory): Call do_cleanups.
+ * solib-svr4.c (open_symbol_file_object): Call do_cleanups on all
+ return paths. Defer final do_cleanups until last return.
+ * arm-tdep.c (arm_exidx_new_objfile): Make null cleanup after
+ early return.
+
+2011-06-30 Tom Tromey <tromey@redhat.com>
+
* Makefile.in (SUBDIR_MI_CFLAGS): Don't add -DMI_OUT=1.
2011-06-30 Andrew Burgess <aburgess@broadcom.com>
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 433ce2125e9..1a75af14bcd 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -2211,7 +2211,7 @@ arm_obj_section_from_vma (struct objfile *objfile, bfd_vma vma)
static void
arm_exidx_new_objfile (struct objfile *objfile)
{
- struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
+ struct cleanup *cleanups;
struct arm_exidx_data *data;
asection *exidx, *extab;
bfd_vma exidx_vma = 0, extab_vma = 0;
@@ -2222,6 +2222,7 @@ arm_exidx_new_objfile (struct objfile *objfile)
/* If we've already touched this file, do nothing. */
if (!objfile || objfile_data (objfile, arm_exidx_data_key) != NULL)
return;
+ cleanups = make_cleanup (null_cleanup, NULL);
/* Read contents of exception table and index. */
exidx = bfd_get_section_by_name (objfile->obfd, ".ARM.exidx");
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index f668f83b9df..d92a83cb201 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1021,17 +1021,26 @@ open_symbol_file_object (void *from_ttyp)
if (symfile_objfile)
if (!query (_("Attempt to reload symbols from process? ")))
- return 0;
+ {
+ do_cleanups (cleanups);
+ return 0;
+ }
/* Always locate the debug struct, in case it has moved. */
info->debug_base = 0;
if (locate_base (info) == 0)
- return 0; /* failed somehow... */
+ {
+ do_cleanups (cleanups);
+ return 0; /* failed somehow... */
+ }
/* First link map member should be the executable. */
lm = solib_svr4_r_map (info);
if (lm == 0)
- return 0; /* failed somehow... */
+ {
+ do_cleanups (cleanups);
+ return 0; /* failed somehow... */
+ }
/* Read address of name from target memory to GDB. */
read_memory (lm + lmo->l_name_offset, l_name_buf, l_name_size);
@@ -1039,11 +1048,11 @@ open_symbol_file_object (void *from_ttyp)
/* Convert the address to host format. */
l_name = extract_typed_address (l_name_buf, ptr_type);
- /* Free l_name_buf. */
- do_cleanups (cleanups);
-
if (l_name == 0)
- return 0; /* No filename. */
+ {
+ do_cleanups (cleanups);
+ return 0; /* No filename. */
+ }
/* Now fetch the filename from target memory. */
target_read_string (l_name, &filename, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
@@ -1053,12 +1062,14 @@ open_symbol_file_object (void *from_ttyp)
{
warning (_("failed to read exec filename from attached file: %s"),
safe_strerror (errcode));
+ do_cleanups (cleanups);
return 0;
}
/* Have a pathname: read the symbol file. */
symbol_file_add_main (filename, from_tty);
+ do_cleanups (cleanups);
return 1;
}
diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c
index 6da5a1c3d39..bef28c7ccfa 100644
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -72,6 +72,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
bfd_vma loadbase;
struct section_addr_info *sai;
unsigned int i;
+ struct cleanup *cleanup;
if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
error (_("add-symbol-file-from-memory not supported for this target"));
@@ -97,7 +98,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
}
sai = alloc_section_addr_info (bfd_count_sections (nbfd));
- make_cleanup (xfree, sai);
+ cleanup = make_cleanup (xfree, sai);
i = 0;
for (sec = nbfd->sections; sec != NULL; sec = sec->next)
if ((bfd_get_section_flags (nbfd, sec) & (SEC_ALLOC|SEC_LOAD)) != 0)
@@ -114,6 +115,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
/* This might change our ideas about frames already looked at. */
reinit_frame_cache ();
+ do_cleanups (cleanup);
return objf;
}