aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-02-25 11:11:59 -0700
committerTom Tromey <tom@tromey.com>2018-03-11 21:06:41 -0600
commit484cf504af0e9403e3437a5d2c5fb361c73daa90 (patch)
tree992472243526babe68d8b7eb862db071755e88aa /gdb
parentc20bca94fa17fa59bacd7702acbbbe87a64c0193 (diff)
downloadgdb-484cf504af0e9403e3437a5d2c5fb361c73daa90.zip
gdb-484cf504af0e9403e3437a5d2c5fb361c73daa90.tar.gz
gdb-484cf504af0e9403e3437a5d2c5fb361c73daa90.tar.bz2
Remove cleanup from build_type_psymtabs_1
This removes a cleanup from build_type_psymtabs_1, by using std::vector rather than manual memory management. gdb/ChangeLog 2018-03-11 Tom Tromey <tom@tromey.com> * dwarf2read.c (sort_tu_by_abbrev_offset): Change to be suitable for use by std::sort. (build_type_psymtabs_1): Use std::vector.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/dwarf2read.c29
2 files changed, 15 insertions, 20 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8234b6d..2842b7b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2018-03-11 Tom Tromey <tom@tromey.com>
+
+ * dwarf2read.c (sort_tu_by_abbrev_offset): Change to be suitable
+ for use by std::sort.
+ (build_type_psymtabs_1): Use std::vector.
+
2018-03-09 Eli Zaretskii <eliz@gnu.org>
* top.c (print_gdb_configuration): Reflect LIBIPT, LIBMEMCHECK,
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 5827ab4..bbeb76c 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8610,19 +8610,13 @@ struct tu_abbrev_offset
sect_offset abbrev_offset;
};
-/* Helper routine for build_type_psymtabs_1, passed to qsort. */
+/* Helper routine for build_type_psymtabs_1, passed to std::sort. */
-static int
-sort_tu_by_abbrev_offset (const void *ap, const void *bp)
+static bool
+sort_tu_by_abbrev_offset (const struct tu_abbrev_offset &a,
+ const struct tu_abbrev_offset &b)
{
- const struct tu_abbrev_offset * const *a
- = (const struct tu_abbrev_offset * const*) ap;
- const struct tu_abbrev_offset * const *b
- = (const struct tu_abbrev_offset * const*) bp;
- sect_offset aoff = (*a)->abbrev_offset;
- sect_offset boff = (*b)->abbrev_offset;
-
- return (aoff > boff) - (aoff < boff);
+ return a.abbrev_offset < b.abbrev_offset;
}
/* Efficiently read all the type units.
@@ -8647,10 +8641,8 @@ static void
build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats;
- struct cleanup *cleanups;
abbrev_table_up abbrev_table;
sect_offset abbrev_offset;
- struct tu_abbrev_offset *sorted_by_abbrev;
int i;
/* It's up to the caller to not call us multiple times. */
@@ -8683,8 +8675,8 @@ build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile)
/* Sort in a separate table to maintain the order of all_type_units
for .gdb_index: TU indices directly index all_type_units. */
- sorted_by_abbrev = XNEWVEC (struct tu_abbrev_offset,
- dwarf2_per_objfile->n_type_units);
+ std::vector<struct tu_abbrev_offset> sorted_by_abbrev
+ (dwarf2_per_objfile->n_type_units);
for (i = 0; i < dwarf2_per_objfile->n_type_units; ++i)
{
struct signatured_type *sig_type = dwarf2_per_objfile->all_type_units[i];
@@ -8695,9 +8687,8 @@ build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile)
sig_type->per_cu.section,
sig_type->per_cu.sect_off);
}
- cleanups = make_cleanup (xfree, sorted_by_abbrev);
- qsort (sorted_by_abbrev, dwarf2_per_objfile->n_type_units,
- sizeof (struct tu_abbrev_offset), sort_tu_by_abbrev_offset);
+ std::sort (sorted_by_abbrev.begin (), sorted_by_abbrev.end (),
+ sort_tu_by_abbrev_offset);
abbrev_offset = (sect_offset) ~(unsigned) 0;
@@ -8720,8 +8711,6 @@ build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile)
init_cutu_and_read_dies (&tu->sig_type->per_cu, abbrev_table.get (),
0, 0, build_type_psymtabs_reader, NULL);
}
-
- do_cleanups (cleanups);
}
/* Print collected type unit statistics. */