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 | 68b888fff3164b5e8e347d9c1ca351c366f0aac4 (patch) | |
tree | 407df662edc349c3ec33bf23379f33d3bce06cd4 /gdb/symfile.h | |
parent | 62982abdee45cb20a7cfadb2b1bcc358655d4ad3 (diff) | |
download | gdb-68b888fff3164b5e8e347d9c1ca351c366f0aac4.zip gdb-68b888fff3164b5e8e347d9c1ca351c366f0aac4.tar.gz gdb-68b888fff3164b5e8e347d9c1ca351c366f0aac4.tar.bz2 |
gdb: use std::vector to store segments in symfile_segment_data
Instead of maintaining two vectors, I added a small `segment` class
which holds both the base address and size of one segment and replaced
the two `segment_bases` and `segment_sizes` arrays with a single vector.
The rest of the changes are straightforward, no behavior changes are
expected.
gdb/ChangeLog:
* symfile.h (struct symfile_segment_data) <struct segment>: New.
<segments>: New.
<segment_bases, segment_sizes>: Remove.
* symfile.c (default_symfile_segments): Update.
* elfread.c (elf_symfile_segments): Update.
* remote.c (remote_target::get_offsets): Update.
* solib-target.c (solib_target_relocate_section_addresses):
Update.
Diffstat (limited to 'gdb/symfile.h')
-rw-r--r-- | gdb/symfile.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/gdb/symfile.h b/gdb/symfile.h index 2dfa655..1f23951 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -80,29 +80,31 @@ typedef std::vector<other_sections> section_addr_info; each BFD section belongs to. */ struct symfile_segment_data { + struct segment + { + segment (CORE_ADDR base, CORE_ADDR size) + : base (base), size (size) + {} + + /* The original base address the segment. */ + CORE_ADDR base; + + /* The memory size of the segment. */ + CORE_ADDR size; + }; + ~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 + /* The segments 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 = 0; - - /* If NUM_SEGMENTS is greater than zero, the original base address - of each segment. */ - CORE_ADDR *segment_bases = nullptr; - - /* If NUM_SEGMENTS is greater than zero, the memory size of each - segment. */ - CORE_ADDR *segment_sizes = nullptr; + std::vector<segment> segments; - /* 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 + /* 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 = nullptr; }; |