This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 1/6] Use std::vector in end_symtab_get_static_block
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Cc: tom at tromey dot com, simon dot marchi at ericsson dot com
- Date: Fri, 20 Oct 2017 17:33:18 +0200 (CEST)
- Subject: Re: [RFA 1/6] Use std::vector in end_symtab_get_static_block
- Authentication-results: sourceware.org; auth=none
[Re-sent since the original seems to have gotten lost somehow.]
> >>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:
>
> Simon> That made me doubt for a second, since we're more used to see "<"
> Simon> in these functions. I then saw that block_compar did sort them
> Simon> in descending order. Could you add a comment here to indicate that?
>
> Done, thanks.
This causes a number of regressions in the gdb.opt/inline-cmds.exp
test case for me. Not sure exactly why, but changing the std::sort
to a std::stable_sort like below fixes those regressions for me.
Maybe the logic for handling inline function blocks somehow relied
on some (undocumented) behavior of qsort for handling elements that
compare as equal?
Bye,
Ulrich
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index c556ac1..b6d4e67 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1249,7 +1249,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
for (pb = pending_blocks; pb != NULL; pb = pb->next)
barray.push_back (pb->block);
- std::sort (barray.begin (), barray.end (),
+ std::stable_sort (barray.begin (), barray.end (),
[] (const block *a, const block *b)
{
/* Sort blocks in descending order. */
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com