diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2020-10-21 10:43:48 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-10-21 10:43:48 -0400 |
commit | c21f37a889dbf57077981970a1b6167a0dcb39af (patch) | |
tree | 9fb1572976cf1664ed89cb7749d7b706c5edf6d7 /gdb/gdbarch.c | |
parent | 4dbe16c8115cd9820cadba5300cbfe04f518269f (diff) | |
download | gdb-c21f37a889dbf57077981970a1b6167a0dcb39af.zip gdb-c21f37a889dbf57077981970a1b6167a0dcb39af.tar.gz 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.c')
-rw-r--r-- | gdb/gdbarch.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 3a55820..285d9f9 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -3700,7 +3700,7 @@ gdbarch_make_corefile_notes_p (struct gdbarch *gdbarch) return gdbarch->make_corefile_notes != NULL; } -char * +gdb::unique_xmalloc_ptr<char> gdbarch_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) { gdb_assert (gdbarch != NULL); |