mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-12 11:28:21 +08:00
gdb/
PR gdb/9988: * buildsym.c (block_compar): New function. (end_symtab): Replace the bubble sort by a qsort based code.
This commit is contained in:
@ -1,4 +1,10 @@
|
|||||||
2009-05-07 Sami Wagiaalla <swagiaal@redhat.com>
|
2009-06-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
PR gdb/9988:
|
||||||
|
* buildsym.c (block_compar): New function.
|
||||||
|
(end_symtab): Replace the bubble sort by a qsort based code.
|
||||||
|
|
||||||
|
2009-06-22 Sami Wagiaalla <swagiaal@redhat.com>
|
||||||
|
|
||||||
* MAINTAINERS (Write After Approval): Add self.
|
* MAINTAINERS (Write After Approval): Add self.
|
||||||
|
|
||||||
|
@ -899,6 +899,19 @@ watch_main_source_file_lossage (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Helper function for qsort. Parametes are `struct block *' pointers,
|
||||||
|
function sorts them in descending order by their BLOCK_START. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
block_compar (const void *ap, const void *bp)
|
||||||
|
{
|
||||||
|
const struct block *a = *(const struct block **) ap;
|
||||||
|
const struct block *b = *(const struct block **) bp;
|
||||||
|
|
||||||
|
return ((BLOCK_START (b) > BLOCK_START (a))
|
||||||
|
- (BLOCK_START (b) < BLOCK_START (a)));
|
||||||
|
}
|
||||||
|
|
||||||
/* Finish the symbol definitions for one main source file, close off
|
/* Finish the symbol definitions for one main source file, close off
|
||||||
all the lexical contexts for that file (creating struct block's for
|
all the lexical contexts for that file (creating struct block's for
|
||||||
them), then make the struct symtab for that file and put it in the
|
them), then make the struct symtab for that file and put it in the
|
||||||
@ -952,32 +965,28 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
|
|||||||
OBJF_REORDERED is true, then sort the pending blocks. */
|
OBJF_REORDERED is true, then sort the pending blocks. */
|
||||||
if ((objfile->flags & OBJF_REORDERED) && pending_blocks)
|
if ((objfile->flags & OBJF_REORDERED) && pending_blocks)
|
||||||
{
|
{
|
||||||
/* FIXME! Remove this horrid bubble sort and use merge sort!!! */
|
unsigned count = 0;
|
||||||
int swapped;
|
struct pending_block *pb;
|
||||||
do
|
struct block **barray, **bp;
|
||||||
{
|
struct cleanup *back_to;
|
||||||
struct pending_block *pb, *pbnext;
|
|
||||||
|
|
||||||
pb = pending_blocks;
|
for (pb = pending_blocks; pb != NULL; pb = pb->next)
|
||||||
pbnext = pb->next;
|
count++;
|
||||||
swapped = 0;
|
|
||||||
|
|
||||||
while (pbnext)
|
barray = xmalloc (sizeof (*barray) * count);
|
||||||
{
|
back_to = make_cleanup (xfree, barray);
|
||||||
/* swap blocks if unordered! */
|
|
||||||
|
|
||||||
if (BLOCK_START (pb->block) < BLOCK_START (pbnext->block))
|
bp = barray;
|
||||||
{
|
for (pb = pending_blocks; pb != NULL; pb = pb->next)
|
||||||
struct block *tmp = pb->block;
|
*bp++ = pb->block;
|
||||||
pb->block = pbnext->block;
|
|
||||||
pbnext->block = tmp;
|
qsort (barray, count, sizeof (*barray), block_compar);
|
||||||
swapped = 1;
|
|
||||||
}
|
bp = barray;
|
||||||
pb = pbnext;
|
for (pb = pending_blocks; pb != NULL; pb = pb->next)
|
||||||
pbnext = pbnext->next;
|
pb->block = *bp++;
|
||||||
}
|
|
||||||
}
|
do_cleanups (back_to);
|
||||||
while (swapped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup any undefined types that have been left hanging around
|
/* Cleanup any undefined types that have been left hanging around
|
||||||
|
Reference in New Issue
Block a user