This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 1/6] Use std::vector in end_symtab_get_static_block


[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]