diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2020-05-19 12:18:04 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-05-19 12:18:36 -0400 |
commit | 62982abdee45cb20a7cfadb2b1bcc358655d4ad3 (patch) | |
tree | e4b4bc04a83dfc55cecc865b20ad561f8ec13939 /gdb/remote.c | |
parent | 8ac10c5bfca0602398b38cc69976db213a7d9917 (diff) | |
download | gdb-62982abdee45cb20a7cfadb2b1bcc358655d4ad3.zip gdb-62982abdee45cb20a7cfadb2b1bcc358655d4ad3.tar.gz gdb-62982abdee45cb20a7cfadb2b1bcc358655d4ad3.tar.bz2 |
gdb: allocate symfile_segment_data with new
- Allocate this structure with new instead of XNEW, use a unique pointer
to manage its lifetime.
- Change a few functions to return a unique pointer instead of a
plain pointer.
- Change free_symfile_segment_data to be symfile_segment_data's
destructor.
gdb/ChangeLog:
* symfile.h (struct symfile_segment_data): Initialize fields.
<~symfile_segment_data>: Add.
(symfile_segment_data_up): New.
(struct sym_fns) <sym_segments>: Return a
symfile_segment_data_up.
(default_symfile_segments): Return a symfile_segment_data_up.
(free_symfile_segment_data): Remove.
(get_symfile_segment_data): Return a symfile_segment_data_up.
* symfile.c (default_symfile_segments): Likewise.
(get_symfile_segment_data): Likewise.
(free_symfile_segment_data): Remove.
(symfile_find_segment_sections): Update.
* elfread.c (elf_symfile_segments): Return a
symfile_segment_data_up.
* remote.c (remote_target::get_offsets): Update.
* solib-target.c (solib_target_relocate_section_addresses):
Update.
* symfile-debug.c (debug_sym_segments): Return a
symfile_segment_data_up.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r-- | gdb/remote.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/gdb/remote.c b/gdb/remote.c index 812ab8b..a28f34d 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4105,7 +4105,6 @@ remote_target::get_offsets () char *ptr; int lose, num_segments = 0, do_sections, do_segments; CORE_ADDR text_addr, data_addr, bss_addr, segments[2]; - struct symfile_segment_data *data; if (symfile_objfile == NULL) return; @@ -4185,7 +4184,8 @@ remote_target::get_offsets () section_offsets offs = symfile_objfile->section_offsets; - data = get_symfile_segment_data (symfile_objfile->obfd); + symfile_segment_data_up data + = get_symfile_segment_data (symfile_objfile->obfd); do_segments = (data != NULL); do_sections = num_segments == 0; @@ -4220,8 +4220,9 @@ remote_target::get_offsets () if (do_segments) { - int ret = symfile_map_offsets_to_segments (symfile_objfile->obfd, data, - offs, num_segments, segments); + int ret = symfile_map_offsets_to_segments (symfile_objfile->obfd, + data.get (), offs, + num_segments, segments); if (ret == 0 && !do_sections) error (_("Can not handle qOffsets TextSeg " @@ -4231,9 +4232,6 @@ remote_target::get_offsets () do_sections = 0; } - if (data) - free_symfile_segment_data (data); - if (do_sections) { offs[SECT_OFF_TEXT (symfile_objfile)] = text_addr; |