From: Jan Vrany Date: Thu, 23 Oct 2025 11:01:34 +0000 (+0100) Subject: gdb: update mdebugread.c to use blockvector::block_less_than X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e162de19f9b98279b48081eca88beb080a656b2f;p=thirdparty%2Fbinutils-gdb.git gdb: update mdebugread.c to use blockvector::block_less_than 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 --- diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 4927d44eb26..10c4133e6c2 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -3700,20 +3700,6 @@ add_line (struct linetable *lt, int lineno, CORE_ADDR adr, int last) /* 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 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); } {