• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision484cf504af0e9403e3437a5d2c5fb361c73daa90 (tree)
Time2018-03-12 12:06:41
AuthorTom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

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.

Change Summary

Incremental Difference

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
1+2018-03-11 Tom Tromey <tom@tromey.com>
2+
3+ * dwarf2read.c (sort_tu_by_abbrev_offset): Change to be suitable
4+ for use by std::sort.
5+ (build_type_psymtabs_1): Use std::vector.
6+
17 2018-03-09 Eli Zaretskii <eliz@gnu.org>
28
39 * top.c (print_gdb_configuration): Reflect LIBIPT, LIBMEMCHECK,
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8610,19 +8610,13 @@ struct tu_abbrev_offset
86108610 sect_offset abbrev_offset;
86118611 };
86128612
8613-/* Helper routine for build_type_psymtabs_1, passed to qsort. */
8613+/* Helper routine for build_type_psymtabs_1, passed to std::sort. */
86148614
8615-static int
8616-sort_tu_by_abbrev_offset (const void *ap, const void *bp)
8615+static bool
8616+sort_tu_by_abbrev_offset (const struct tu_abbrev_offset &a,
8617+ const struct tu_abbrev_offset &b)
86178618 {
8618- const struct tu_abbrev_offset * const *a
8619- = (const struct tu_abbrev_offset * const*) ap;
8620- const struct tu_abbrev_offset * const *b
8621- = (const struct tu_abbrev_offset * const*) bp;
8622- sect_offset aoff = (*a)->abbrev_offset;
8623- sect_offset boff = (*b)->abbrev_offset;
8624-
8625- return (aoff > boff) - (aoff < boff);
8619+ return a.abbrev_offset < b.abbrev_offset;
86268620 }
86278621
86288622 /* Efficiently read all the type units.
@@ -8647,10 +8641,8 @@ static void
86478641 build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile)
86488642 {
86498643 struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats;
8650- struct cleanup *cleanups;
86518644 abbrev_table_up abbrev_table;
86528645 sect_offset abbrev_offset;
8653- struct tu_abbrev_offset *sorted_by_abbrev;
86548646 int i;
86558647
86568648 /* 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)
86838675
86848676 /* Sort in a separate table to maintain the order of all_type_units
86858677 for .gdb_index: TU indices directly index all_type_units. */
8686- sorted_by_abbrev = XNEWVEC (struct tu_abbrev_offset,
8687- dwarf2_per_objfile->n_type_units);
8678+ std::vector<struct tu_abbrev_offset> sorted_by_abbrev
8679+ (dwarf2_per_objfile->n_type_units);
86888680 for (i = 0; i < dwarf2_per_objfile->n_type_units; ++i)
86898681 {
86908682 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)
86958687 sig_type->per_cu.section,
86968688 sig_type->per_cu.sect_off);
86978689 }
8698- cleanups = make_cleanup (xfree, sorted_by_abbrev);
8699- qsort (sorted_by_abbrev, dwarf2_per_objfile->n_type_units,
8700- sizeof (struct tu_abbrev_offset), sort_tu_by_abbrev_offset);
8690+ std::sort (sorted_by_abbrev.begin (), sorted_by_abbrev.end (),
8691+ sort_tu_by_abbrev_offset);
87018692
87028693 abbrev_offset = (sect_offset) ~(unsigned) 0;
87038694
@@ -8720,8 +8711,6 @@ build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile)
87208711 init_cutu_and_read_dies (&tu->sig_type->per_cu, abbrev_table.get (),
87218712 0, 0, build_type_psymtabs_reader, NULL);
87228713 }
8723-
8724- do_cleanups (cleanups);
87258714 }
87268715
87278716 /* Print collected type unit statistics. */