gdb: Ensure that !(a < a) is true in sort_cmp on obj_section objects
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 21 Oct 2019 15:39:51 +0000 (16:39 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 21 Oct 2019 20:10:02 +0000 (21:10 +0100)
commit45f47c3a25d7574d21b9f451efce38c06256f591
treef47a79abfe8ae237dfbcd9624d51724f37c4d271
parente5f3c0e3b83239b4b73fa76f28513a4a56fe50ce
gdb: Ensure that !(a < a) is true in sort_cmp on obj_section objects

After the switch to use std::sort, if GDB is compiled with the
-D_GLIBCXX_DEBUG=1 flag then we see an error when using sort_cmp (in
objfiles.c) to sort obj_section objects.

The problem is that std::sort checks that the condition !(a < a)
holds, and currently this is not true.  GDB's sort_cmp is really
designed to sort lists in which no obj_section repeats, however, there
is some code in place to try and ensure we get a stable sort order if
there is a bug in GDB, unfortunately this code fails the above check.

By reordering some of the checks inside sort_cmp, it is pretty easy to
ensure that the !(a < a) condition holds.

I've not bothered to make this condition check optimal, like I said
this code is only in place to ensure that we get stable results if GDB
goes wrong, so I've made the smallest change needed to get the correct
behaviour.

After this commit I see no regressions when running GDB compiled with
-D_GLIBCXX_DEBUG=1.

gdb/ChangeLog:

* objfiles.c (sort_cmp): Ensure that !(a < a) holds true.

Change-Id: I4b1e3e1640865104c0896cbb6c3fdbbc04d9645b
gdb/ChangeLog
gdb/objfiles.c
This page took 0.025625 seconds and 4 git commands to generate.