Fix gdb.opt/inline-cmds.exp regressions
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 24 Oct 2017 14:33:53 +0000 (16:33 +0200)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 24 Oct 2017 14:33:53 +0000 (16:33 +0200)
When sorting pending blocks in end_symtab_get_static_block, blocks
with the same starting address must remain in the original order
to preserve inline function caller/callee relationships.

The original code seems to have implicitly relied on the fact that the
glibc qsort implemention actually (in the common case) provides a stable
sort, although this is not guaranteed by the standard.  But the GNU
libstdc++ std::sort implementation is *not* stable.

gdb/ChangeLog:
2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>

* buildsym.c (end_symtab_get_static_block): Use std::stable_sort.

gdb/ChangeLog
gdb/buildsym.c

index e13b0d8f3022af8cb034375736469b828d547ce8..b44349ff2abb3febac02fcb825e65053c72100fa 100644 (file)
@@ -1,3 +1,7 @@
+2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * buildsym.c (end_symtab_get_static_block): Use std::stable_sort.
+
 2017-10-21  Simon Marchi  <simon.marchi@ericsson.com>
 
        * memattr.h: Don't include vec.h.
index c556ac1339a65ee78e25e0ee69e26aba494cfa6e..07bfbd5038946bbe09c4d689efda850300493574 100644 (file)
@@ -1249,12 +1249,14 @@ 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 (),
-                [] (const block *a, const block *b)
-                {
-                  /* Sort blocks in descending order.  */
-                  return BLOCK_START (a) > BLOCK_START (b);
-                });
+      /* Sort blocks by start address in descending order.  Blocks with the
+        same start address must remain in the original order to preserve
+        inline function caller/callee relationships.  */
+      std::stable_sort (barray.begin (), barray.end (),
+                       [] (const block *a, const block *b)
+                       {
+                         return BLOCK_START (a) > BLOCK_START (b);
+                       });
 
       int i = 0;
       for (pb = pending_blocks; pb != NULL; pb = pb->next)
This page took 0.038811 seconds and 4 git commands to generate.