aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-10-28 22:40:58 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-10-28 22:40:58 +0000
commit4dfb23656276c3b25104355c6673c1c6a9c59163 (patch)
treec194cd48ff71b210bb0335a42ceaba77f4e1000d /gdb
parent4323feccfd124151f6c9409ea2970b1d981bc1e4 (diff)
downloadgdb-4dfb23656276c3b25104355c6673c1c6a9c59163.zip
gdb-4dfb23656276c3b25104355c6673c1c6a9c59163.tar.gz
gdb-4dfb23656276c3b25104355c6673c1c6a9c59163.tar.bz2
gdb/
PR symtab/13208 * jit.c (jit_register_code): Remove unused variable my_cleanups. Check for NULL from bfd_open_from_target_memory. Fix ownership of NBFD and SAI.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/jit.c16
2 files changed, 17 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2e3f06a..d47a3b0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ PR symtab/13208
+ * jit.c (jit_register_code): Remove unused variable my_cleanups. Check
+ for NULL from bfd_open_from_target_memory. Fix ownership of NBFD and
+ SAI.
+
2011-10-28 Pedro Alves <pedro@codesourcery.com>
* linux-nat.c (linux_nat_filter_event): Remove `options'
diff --git a/gdb/jit.c b/gdb/jit.c
index 283ccdb..954d297 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -253,7 +253,7 @@ jit_register_code (struct gdbarch *gdbarch,
struct section_addr_info *sai;
struct bfd_section *sec;
struct objfile *objfile;
- struct cleanup *old_cleanups, *my_cleanups;
+ struct cleanup *old_cleanups;
int i;
const struct bfd_arch_info *b;
CORE_ADDR *entry_addr_ptr;
@@ -267,7 +267,11 @@ jit_register_code (struct gdbarch *gdbarch,
nbfd = bfd_open_from_target_memory (code_entry->symfile_addr,
code_entry->symfile_size, gnutarget);
- old_cleanups = make_cleanup_bfd_close (nbfd);
+ if (nbfd == NULL)
+ {
+ puts_unfiltered (_("Error opening JITed symbol file, ignoring it.\n"));
+ return;
+ }
/* Check the format. NOTE: This initializes important data that GDB uses!
We would segfault later without this line. */
@@ -275,7 +279,7 @@ jit_register_code (struct gdbarch *gdbarch,
{
printf_unfiltered (_("\
JITed symbol file is not an object file, ignoring it.\n"));
- do_cleanups (old_cleanups);
+ bfd_close (nbfd);
return;
}
@@ -290,7 +294,7 @@ JITed symbol file is not an object file, ignoring it.\n"));
file is generated by the JIT at runtime, it should all of the absolute
addresses that we care about. */
sai = alloc_section_addr_info (bfd_count_sections (nbfd));
- make_cleanup_free_section_addr_info (sai);
+ old_cleanups = make_cleanup_free_section_addr_info (sai);
i = 0;
for (sec = nbfd->sections; sec != NULL; sec = sec->next)
if ((bfd_get_section_flags (nbfd, sec) & (SEC_ALLOC|SEC_LOAD)) != 0)
@@ -303,7 +307,7 @@ JITed symbol file is not an object file, ignoring it.\n"));
++i;
}
- /* This call takes ownership of sai. */
+ /* This call takes ownership of NBFD. It does not take ownership of SAI. */
objfile = symbol_file_add_from_bfd (nbfd, 0, sai, OBJF_SHARED, NULL);
/* Remember a mapping from entry_addr to objfile. */
@@ -311,7 +315,7 @@ JITed symbol file is not an object file, ignoring it.\n"));
*entry_addr_ptr = entry_addr;
set_objfile_data (objfile, jit_objfile_data, entry_addr_ptr);
- discard_cleanups (old_cleanups);
+ do_cleanups (old_cleanups);
}
/* This function unregisters JITed code and frees the corresponding