aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-05-19 12:18:04 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-19 12:18:36 -0400
commit62982abdee45cb20a7cfadb2b1bcc358655d4ad3 (patch)
treee4b4bc04a83dfc55cecc865b20ad561f8ec13939 /gdb/symfile.h
parent8ac10c5bfca0602398b38cc69976db213a7d9917 (diff)
downloadgdb-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/symfile.h')
-rw-r--r--gdb/symfile.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 5ada6c3..2dfa655 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -80,26 +80,35 @@ typedef std::vector<other_sections> section_addr_info;
each BFD section belongs to. */
struct symfile_segment_data
{
+ ~symfile_segment_data ()
+ {
+ xfree (this->segment_bases);
+ xfree (this->segment_sizes);
+ xfree (this->segment_info);
+ }
+
/* How many segments are present in this file. If there are
two, the text segment is the first one and the data segment
is the second one. */
- int num_segments;
+ int num_segments = 0;
/* If NUM_SEGMENTS is greater than zero, the original base address
of each segment. */
- CORE_ADDR *segment_bases;
+ CORE_ADDR *segment_bases = nullptr;
/* If NUM_SEGMENTS is greater than zero, the memory size of each
segment. */
- CORE_ADDR *segment_sizes;
+ CORE_ADDR *segment_sizes = nullptr;
/* If NUM_SEGMENTS is greater than zero, this is an array of entries
recording which segment contains each BFD section.
SEGMENT_INFO[I] is S+1 if the I'th BFD section belongs to segment
S, or zero if it is not in any segment. */
- int *segment_info;
+ int *segment_info = nullptr;
};
+using symfile_segment_data_up = std::unique_ptr<symfile_segment_data>;
+
/* Callback for quick_symbol_functions->map_symbol_filenames. */
typedef void (symbol_filename_ftype) (const char *filename,
@@ -360,7 +369,7 @@ struct sym_fns
the segments of ABFD. Each segment is a unit of the file
which may be relocated independently. */
- struct symfile_segment_data *(*sym_segments) (bfd *abfd);
+ symfile_segment_data_up (*sym_segments) (bfd *abfd);
/* This function should read the linetable from the objfile when
the line table cannot be read while processing the debugging
@@ -401,7 +410,7 @@ extern void default_symfile_offsets (struct objfile *objfile,
/* The default version of sym_fns.sym_segments for readers that don't
do anything special. */
-extern struct symfile_segment_data *default_symfile_segments (bfd *abfd);
+extern symfile_segment_data_up default_symfile_segments (bfd *abfd);
/* The default version of sym_fns.sym_relocate for readers that don't
do anything special. */
@@ -530,8 +539,7 @@ extern int symfile_map_offsets_to_segments (bfd *,
const struct symfile_segment_data *,
section_offsets &,
int, const CORE_ADDR *);
-struct symfile_segment_data *get_symfile_segment_data (bfd *abfd);
-void free_symfile_segment_data (struct symfile_segment_data *data);
+symfile_segment_data_up get_symfile_segment_data (bfd *abfd);
extern scoped_restore_tmpl<int> increment_reading_symtab (void);