diff options
author | Tom Tromey <tom@tromey.com> | 2020-10-12 15:53:16 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-10-12 20:18:47 -0600 |
commit | 91840ee38a1114bc02120935bf73dd5acda3b062 (patch) | |
tree | 0acea37944e6c869c22e8eca007bbb256f4f032b | |
parent | 2d128614d4101354d8125449539dc3255c37d345 (diff) | |
download | gdb-91840ee38a1114bc02120935bf73dd5acda3b062.zip gdb-91840ee38a1114bc02120935bf73dd5acda3b062.tar.gz gdb-91840ee38a1114bc02120935bf73dd5acda3b062.tar.bz2 |
Simplify add_target_sections_of_objfile
Now that target_section_table uses std::vector,
add_target_sections_of_objfile does not need to loop twice. This
patch simplifies this code to have just a single loop. Also, the
passed-in objfile can never be NULL, so this changes this function to
assert that.
gdb/ChangeLog
2020-10-12 Tom Tromey <tom@tromey.com>
* exec.c (add_target_sections_of_objfile): Simplify.
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/exec.c | 14 |
2 files changed, 5 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7a66a4d..6cf0b26 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2020-10-12 Tom Tromey <tom@tromey.com> + * exec.c (add_target_sections_of_objfile): Simplify. + +2020-10-12 Tom Tromey <tom@tromey.com> + * solib.c (solib_map_sections): Update. * record-full.c (record_full_core_open_1): Update. * exec.h (build_section_table): Return a target_section_table. @@ -661,26 +661,14 @@ add_target_sections_of_objfile (struct objfile *objfile) { struct target_section_table *table = current_target_sections; struct obj_section *osect; - unsigned count = 0; - if (objfile == NULL) - return; + gdb_assert (objfile != nullptr); /* Compute the number of sections to add. */ ALL_OBJFILE_OSECTIONS (objfile, osect) { if (bfd_section_size (osect->the_bfd_section) == 0) continue; - count++; - } - - if (count == 0) - return; - - ALL_OBJFILE_OSECTIONS (objfile, osect) - { - if (bfd_section_size (osect->the_bfd_section) == 0) - continue; table->sections.emplace_back (); target_section &ts = table->sections.back (); |