]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: update mdebugread.c to use blockvector::block_less_than
authorJan Vrany <jan.vrany@labware.com>
Thu, 23 Oct 2025 11:01:34 +0000 (12:01 +0100)
committerJan Vrany <jan.vrany@labware.com>
Thu, 23 Oct 2025 11:01:34 +0000 (12:01 +0100)
This commit updates mdebugread.c to use common blockvector ordering
predicate. It also changes the code to use std::stable_sort as in
buildsym.c. This is probably not necessary but should not hurt and makes
block sorting code more consistent.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/mdebugread.c

index 4927d44eb2653228a247b95e9e61c419fbf2dc99..10c4133e6c2378f7f4b6f0ef27450c6620f9eb5f 100644 (file)
@@ -3700,20 +3700,6 @@ add_line (struct linetable *lt, int lineno, CORE_ADDR adr, int last)
 \f
 /* Sorting and reordering procedures.  */
 
-/* Blocks with a smaller low bound should come first.  */
-
-static bool
-block_is_less_than (const struct block *b1, const struct block *b2)
-{
-  CORE_ADDR start1 = b1->start ();
-  CORE_ADDR start2 = b2->start ();
-
-  if (start1 != start2)
-    return start1 < start2;
-
-  return (b2->end ()) < (b1->end ());
-}
-
 /* Sort the blocks of a symtab S.
    Reorder the blocks in the blockvector by code-address,
    as required by some MI search routines.  */
@@ -3745,8 +3731,8 @@ sort_blocks (struct symtab *s)
     {
       gdb::array_view<block *> blocks_view = bv->blocks ();
 
-      std::sort (blocks_view.begin () + FIRST_LOCAL_BLOCK,
-                blocks_view.end (), block_is_less_than);
+      std::stable_sort (blocks_view.begin () + FIRST_LOCAL_BLOCK,
+                       blocks_view.end (), blockvector::block_less_than);
     }
 
   {