GNU Binutils with patches for OS216
Revision | 484cf504af0e9403e3437a5d2c5fb361c73daa90 (tree) |
---|---|
Time | 2018-03-12 12:06:41 |
Author | Tom Tromey <tom@trom...> |
Commiter | Tom Tromey |
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.
@@ -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 | + | |
1 | 7 | 2018-03-09 Eli Zaretskii <eliz@gnu.org> |
2 | 8 | |
3 | 9 | * top.c (print_gdb_configuration): Reflect LIBIPT, LIBMEMCHECK, |
@@ -8610,19 +8610,13 @@ struct tu_abbrev_offset | ||
8610 | 8610 | sect_offset abbrev_offset; |
8611 | 8611 | }; |
8612 | 8612 | |
8613 | -/* Helper routine for build_type_psymtabs_1, passed to qsort. */ | |
8613 | +/* Helper routine for build_type_psymtabs_1, passed to std::sort. */ | |
8614 | 8614 | |
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) | |
8617 | 8618 | { |
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; | |
8626 | 8620 | } |
8627 | 8621 | |
8628 | 8622 | /* Efficiently read all the type units. |
@@ -8647,10 +8641,8 @@ static void | ||
8647 | 8641 | build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile) |
8648 | 8642 | { |
8649 | 8643 | struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats; |
8650 | - struct cleanup *cleanups; | |
8651 | 8644 | abbrev_table_up abbrev_table; |
8652 | 8645 | sect_offset abbrev_offset; |
8653 | - struct tu_abbrev_offset *sorted_by_abbrev; | |
8654 | 8646 | int i; |
8655 | 8647 | |
8656 | 8648 | /* 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) | ||
8683 | 8675 | |
8684 | 8676 | /* Sort in a separate table to maintain the order of all_type_units |
8685 | 8677 | 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); | |
8688 | 8680 | for (i = 0; i < dwarf2_per_objfile->n_type_units; ++i) |
8689 | 8681 | { |
8690 | 8682 | 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) | ||
8695 | 8687 | sig_type->per_cu.section, |
8696 | 8688 | sig_type->per_cu.sect_off); |
8697 | 8689 | } |
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); | |
8701 | 8692 | |
8702 | 8693 | abbrev_offset = (sect_offset) ~(unsigned) 0; |
8703 | 8694 |
@@ -8720,8 +8711,6 @@ build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile) | ||
8720 | 8711 | init_cutu_and_read_dies (&tu->sig_type->per_cu, abbrev_table.get (), |
8721 | 8712 | 0, 0, build_type_psymtabs_reader, NULL); |
8722 | 8713 | } |
8723 | - | |
8724 | - do_cleanups (cleanups); | |
8725 | 8714 | } |
8726 | 8715 | |
8727 | 8716 | /* Print collected type unit statistics. */ |