This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix gdb.opt/inline-cmds.exp regressions
- From: Ulrich Weigand <uweigand at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 24 Oct 2017 14:36:43 -0000
- Subject: [binutils-gdb] Fix gdb.opt/inline-cmds.exp regressions
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5033013f17524964564dac5d422739ae5214729e
commit 5033013f17524964564dac5d422739ae5214729e
Author: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Date: Tue Oct 24 16:33:53 2017 +0200
Fix gdb.opt/inline-cmds.exp regressions
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.
Diff:
---
gdb/ChangeLog | 4 ++++
gdb/buildsym.c | 14 ++++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e13b0d8..b44349f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index c556ac1..07bfbd5 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -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)