From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com, insight@sources.redhat.com Subject: [rfa] Remove a silly looking symtab sort. Date: Wed, 24 Oct 2001 21:29:00 -0000 Message-id: <20011025002938.A13688@nevyn.them.org> X-SW-Source: 2001-q4/msg00182.html The function search_symbols () does not seem to be used anywhere where the order of the returned functions matters, and the algorithm it searches with does not rely on any sorting. The same thing seems to be true for gdb_listfuncs, but I haven't investigated as thoroughly. Both of these functions have a blurb like: if (!BLOCK_SHOULD_SORT (b)) sort_block_syms (b); Note that this isn't something like "! BLOCK_SORTED" - it's "! BLOCK_SHOULD_SORT". The condition for that currently is #define BLOCK_SHOULD_SORT(bl) ((bl)->nsyms >= 40 && BLOCK_FUNCTION (bl) == NULL) In that latter case, we certainly should not sort the symtab. I have never run across this in practice, but the symbol hashing patch wants this to be cleaned up first. Sorting a hash table's buckets is bad, mmkay? Is this patch OK to commit? If someone disagrees with my assessment on the need for the results of these functions to be sorted, I can add code to sort them after searching. -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer 2001-10-25 Daniel Jacobowitz * symtab.c (search_symbols): Do not attempt to sort a block if !BLOCK_SHOULD_SORT (b). 2001-10-25 Daniel Jacobowitz * generic/gdbtk-cmds (gdb_listfuncs): Do not attempt to sort a block if !BLOCK_SHOULD_SORT (b). Index: gdb/symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.44 diff -u -p -r1.44 symtab.c --- gdb/symtab.c 2001/10/12 23:51:29 1.44 +++ gdb/symtab.c 2001/10/25 04:23:05 @@ -2475,9 +2475,6 @@ search_symbols (char *regexp, namespace_ for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++) { b = BLOCKVECTOR_BLOCK (bv, i); - /* Skip the sort if this block is always sorted. */ - if (!BLOCK_SHOULD_SORT (b)) - sort_block_syms (b); for (j = 0; j < BLOCK_NSYMS (b); j++) { QUIT; Index: gdb/gdbtk/generic/gdbtk-cmds.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v retrieving revision 1.40 diff -u -p -r1.40 gdbtk-cmds.c --- gdb/gdbtk/generic/gdbtk-cmds.c 2001/10/12 23:51:29 1.40 +++ gdb/gdbtk/generic/gdbtk-cmds.c 2001/10/25 04:23:06 @@ -1495,9 +1495,6 @@ gdb_listfuncs (clientData, interp, objc, for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++) { b = BLOCKVECTOR_BLOCK (bv, i); - /* Skip the sort if this block is always sorted. */ - if (!BLOCK_SHOULD_SORT (b)) - sort_block_syms (b); ALL_BLOCK_SYMBOLS (b, j, sym) { if (SYMBOL_CLASS (sym) == LOC_BLOCK)