aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-10-21 10:43:48 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-10-21 10:43:48 -0400
commitc21f37a889dbf57077981970a1b6167a0dcb39af (patch)
tree9fb1572976cf1664ed89cb7749d7b706c5edf6d7 /gdb/gdbarch.h
parent4dbe16c8115cd9820cadba5300cbfe04f518269f (diff)
downloadfsf-binutils-gdb-c21f37a889dbf57077981970a1b6167a0dcb39af.zip
fsf-binutils-gdb-c21f37a889dbf57077981970a1b6167a0dcb39af.tar.gz
fsf-binutils-gdb-c21f37a889dbf57077981970a1b6167a0dcb39af.tar.bz2
gdb: make gdbarch_make_corefile_notes return a unique ptr
This patch starts by making the gdbarch_make_corefile_notes function return a gdb::unique_xmalloc_ptr<char> and takes care of the fallouts, mostly in linux-tdep.c and fbsd-tdep.c. The difficulty in these files is that they use the BFD API for writing core files, where you pass in a pointer to a malloc-ed buffer (or NULL in the beginning), it re-allocs it if needed, and returns you the possibly updated pointer. I therefore used this pattern everywhere: note_data.reset (elfcore_write_note (obfd, note_data.release (), ...) This hands over the ownership of note_data to the BFD function for the duration of the call, and then puts its back in note_data right after the call. gdb/ChangeLog: * gdbarch.sh (make_corefile_notes): Return unique pointer. * gdbarch.c: Re-generate. * gdbarch.h: Re-generate. * gcore.c (write_gcore_file_1): Adjust. * fbsd-tdep.c (struct fbsd_collect_regset_section_cb_data): Add constructor. <note_data>: Change type to unique pointer. <abort_iteration>: Change type to bool. (fbsd_collect_regset_section_cb): Adjust to unique pointer. (fbsd_collect_thread_registers): Return void, adjust. (struct fbsd_corefile_thread_data): Add construtor. <note_data>: Change type to unique pointer. (fbsd_corefile_thread): Adjust. (fbsd_make_corefile_notes): Return unique pointer, adjust. * linux-tdep.c (linux_make_mappings_corefile_notes): Change type to unique pointer, adjust. (struct linux_collect_regset_section_cb_data): Add constructor. <note_data>: Change type to unique pointer. <abort_iteration>: Change type to bool. (linux_collect_thread_registers): Return void, adjust. (struct linux_corefile_thread_data): Add constructor. <note_data>: Change type to unique pointer. (linux_corefile_thread): Adjust. (linux_make_corefile_notes): Return unique pointer, adjust. Change-Id: I1e03476bb47b87c6acb3e12204d193f38cc4e02b
Diffstat (limited to 'gdb/gdbarch.h')
-rw-r--r--gdb/gdbarch.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index d126dfc..ae65f29 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -912,8 +912,8 @@ extern void set_gdbarch_iterate_over_regset_sections (struct gdbarch *gdbarch, g
extern bool gdbarch_make_corefile_notes_p (struct gdbarch *gdbarch);
-typedef char * (gdbarch_make_corefile_notes_ftype) (struct gdbarch *gdbarch, bfd *obfd, int *note_size);
-extern char * gdbarch_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size);
+typedef gdb::unique_xmalloc_ptr<char> (gdbarch_make_corefile_notes_ftype) (struct gdbarch *gdbarch, bfd *obfd, int *note_size);
+extern gdb::unique_xmalloc_ptr<char> gdbarch_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size);
extern void set_gdbarch_make_corefile_notes (struct gdbarch *gdbarch, gdbarch_make_corefile_notes_ftype *make_corefile_notes);
/* Find core file memory regions */