mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 18:08:24 +08:00
make_corefile_notes: have caller free returned memory
The various make_corefile_notes implementations for gdbarch as well as target currently make an xfree cleanup on the data they return. This causes problems when trying to put a TRY_CATCH around the make_corefile_notes call. Specifically, we get a stale cleanup error in restore_my_cleanups. Omit the make_cleanup and have the caller free the memory. gdb/ * fbsd-nat.c (fbsd_make_corefile_notes): Remove make_cleanup call. * gcore.c (write_gcore_file): Free memory returned from make_corefile_notes. * linux-tdep.c (linux_make_corefile_notes): Remove make_cleanup call. * procfs.c (procfs_make_note_section): Remove make_cleanup call.
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2014-06-25 Markus Metzger <markus.t.metzger@intel.com>
|
||||||
|
|
||||||
|
* fbsd-nat.c (fbsd_make_corefile_notes): Remove make_cleanup call.
|
||||||
|
* gcore.c (write_gcore_file): Free memory returned from
|
||||||
|
make_corefile_notes.
|
||||||
|
* linux-tdep.c (linux_make_corefile_notes): Remove make_cleanup call.
|
||||||
|
* procfs.c (procfs_make_note_section): Remove make_cleanup call.
|
||||||
|
|
||||||
2014-06-24 Yao Qi <yao@codesourcery.com>
|
2014-06-24 Yao Qi <yao@codesourcery.com>
|
||||||
|
|
||||||
* arm-linux-tdep.c (arm_linux_skip_trampoline_code): New.
|
* arm-linux-tdep.c (arm_linux_skip_trampoline_code): New.
|
||||||
|
@ -214,6 +214,5 @@ fbsd_make_corefile_notes (struct target_ops *self, bfd *obfd, int *note_size)
|
|||||||
fname, psargs);
|
fname, psargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
make_cleanup (xfree, note_data);
|
|
||||||
return note_data;
|
return note_data;
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ create_gcore_bfd (const char *filename)
|
|||||||
void
|
void
|
||||||
write_gcore_file (bfd *obfd)
|
write_gcore_file (bfd *obfd)
|
||||||
{
|
{
|
||||||
|
struct cleanup *cleanup;
|
||||||
void *note_data = NULL;
|
void *note_data = NULL;
|
||||||
int note_size = 0;
|
int note_size = 0;
|
||||||
asection *note_sec = NULL;
|
asection *note_sec = NULL;
|
||||||
@ -81,6 +82,8 @@ write_gcore_file (bfd *obfd)
|
|||||||
else
|
else
|
||||||
note_data = gdbarch_make_corefile_notes (target_gdbarch (), obfd, ¬e_size);
|
note_data = gdbarch_make_corefile_notes (target_gdbarch (), obfd, ¬e_size);
|
||||||
|
|
||||||
|
cleanup = make_cleanup (xfree, note_data);
|
||||||
|
|
||||||
if (note_data == NULL || note_size == 0)
|
if (note_data == NULL || note_size == 0)
|
||||||
error (_("Target does not support core file generation."));
|
error (_("Target does not support core file generation."));
|
||||||
|
|
||||||
@ -104,6 +107,8 @@ write_gcore_file (bfd *obfd)
|
|||||||
/* Write out the contents of the note section. */
|
/* Write out the contents of the note section. */
|
||||||
if (!bfd_set_section_contents (obfd, note_sec, note_data, 0, note_size))
|
if (!bfd_set_section_contents (obfd, note_sec, note_data, 0, note_size))
|
||||||
warning (_("writing note section (%s)"), bfd_errmsg (bfd_get_error ()));
|
warning (_("writing note section (%s)"), bfd_errmsg (bfd_get_error ()));
|
||||||
|
|
||||||
|
do_cleanups (cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1502,7 +1502,6 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size,
|
|||||||
note_data = linux_make_mappings_corefile_notes (gdbarch, obfd,
|
note_data = linux_make_mappings_corefile_notes (gdbarch, obfd,
|
||||||
note_data, note_size);
|
note_data, note_size);
|
||||||
|
|
||||||
make_cleanup (xfree, note_data);
|
|
||||||
return note_data;
|
return note_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5522,7 +5522,6 @@ procfs_make_note_section (struct target_ops *self, bfd *obfd, int *note_size)
|
|||||||
xfree (auxv);
|
xfree (auxv);
|
||||||
}
|
}
|
||||||
|
|
||||||
make_cleanup (xfree, note_data);
|
|
||||||
return note_data;
|
return note_data;
|
||||||
}
|
}
|
||||||
#else /* !Solaris */
|
#else /* !Solaris */
|
||||||
|
Reference in New Issue
Block a user