This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

symtab/2159: lookup_partial_symtab() inefficient


>Number:         2159
>Category:       symtab
>Synopsis:       lookup_partial_symtab() inefficient
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 18 21:58:01 UTC 2006
>Closed-Date:
>Last-Modified:
>Originator:     larue@cadence.com
>Release:        unknown-1.0
>Organization:
>Environment:
Solaris 8
>Description:
The gdb function lookup_partial_symtab is incredibly SLOW. GDB iterates through every psymbol in the program being debugged and searches for the file associated with the psymbol. GDB checks full and relative paths for 
each of the psymbols. In one of our tests GDB took an hour to go through and check all the 
symbols in ncsim. GDB ends up doing multiple system calls for every psymbol.

A simple fix might be to check the base filename of the symbol against the name argument of lookup_partial_symtab. If they don't match it isn't necessary to do the very time consuming stat() and open() calls.

We only have seen this problem on Solaris. 

Here is the call stack showing where the performance bottle neck is:

#0  0xff11f208 in stat () from /usr/lib/libc.so.1
#1  0x000abfc8 in is_regular_file (name=0x2 <Error reading address 0x2: N
ot owner>) at ../../../gdb-6.3/gdb/source.c:623
#2  0x000ac110 in openp (path=0x2bac00 "", opts=23, string=0x6142968 
"../../libs/curly/cu.h", mode=0, prot=0, filename_opened=0x6142920) at 
../../../gdb-6.3/gdb/source.c:752
#3  0x000ac474 in find_and_open_source (objfile=0x308fb8, filename=0x6142968 
"../../libs/curly/cu.h", dirname=0x0, fullname=0x6142920) at 
../../../gdb-6.3/gdb/source.c:877
#4  0x000ac634 in psymtab_to_fullname (ps=0x6142918) at 
../../../gdb-6.3/gdb/source.c:957
#5  0x000c0598 in lookup_partial_symtab (name=0xffbece58 
"/home/mikef/systemc-tba/./src/cpp/transactor.cpp") at 
../../../gdb-6.3/gdb/symtab.c:276
#6  0x000c0424 in lookup_symtab (name=0xffbece58 
"/home/mikef/systemc-tba/./src/cpp/transactor.cpp") at 
../../../gdb-6.3/gdb/symtab.c:219
#7  0x000ceb18 in symtab_from_filename (argptr=0xffbecf8c, p=0xffbed43d ":1", 
is_quote_enclosed=0, not_found_ptr=0x0) at ../../../gdb-6.3/gdb/linespec.c:1523
#8  0x000cda44 in decode_line_1 (argptr=0xffbecf8c, funfirstline=0, 
default_symtab=0xbc091d0, default_line=9, canonical=0x0, not_found_ptr=0x0) at 
../../../gdb-6.3/gdb/linespec.c:744
#9  0x00080270 in list_command (arg=0xffbed40d 
"/home/mikef/systemc-tba/./src/cpp/transactor.cpp:1", from_tty=1) at 
../../../gdb-6.3/gdb/cli/cli-cmds.c:703
#10 0x0007bb84 in do_cfunc (c=0x2f2138, args=0xffbed40d 
"/home/mikef/systemc-tba/./src/cpp/transactor.cpp:1", from_tty=1) at 
../../../gdb-6.3/gdb/cli/cli-decode.c:57
#11 0x0007da98 in cmd_func (cmd=0x2f2138, args=0xffbed40d 
"/home/mikef/systemc-tba/./src/cpp/transactor.cpp:1", from_tty=1) at 
../../../gdb-6.3/gdb/cli/cli-decode.c:1601
#12 0x0004c658 in execute_command (p=0xffbed43e "1", from_tty=1) at 
../../../gdb-6.3/gdb/top.c:733
#13 0x0008291c in do_captured_execute_command (uiout=0x2, data=0xffbed390) at 
../../../gdb-6.3/gdb/cli/cli-interp.c:122
#14 0x0004c104 in catcher (func=0x82908 <do_captured_execute_command
> , func_uiout=0x2ea708, func_args=0xffbed390, func_val=0xffbed31c, 
func_caught=0xffbed318, errstring=0x0, gdberrmsg=0x0, mask=6) at 
../../../gdb-6.3/gdb/top.c:431
#15 0x0004c148 in catch_exceptions (uiout=0x2ea708, func=0, 
func_args=0xffbed390, errstring=0x0, mask=6) at ../../../gdb-6.3/gdb/top.c:488
#16 0x00082950 in safe_execute_command (uiout=0x2ea708, command=0xffbed408 
"list /home/mikef/systemc-tba/./src/cpp/transactor.cpp:1", from_tty=1) at 
../../../gdb-6.3/gdb/cli/cli-interp.c:132
#17 0x000828ec in cli_interpreter_exec (data=0x0, command_str=0x8756038 "list 
/home/mikef/systemc-tba/./src/cpp/transactor.cpp:1") at 
../../../gdb-6.3/gdb/cli/cli-interp.c:112
#18 0x000dffe4 in interp_exec (interp=0x2ea778, command_str=0x8756038 "list 
/home/mikef/systemc-tba/./src/cpp/transactor.cpp:1") at 
../../../gdb-6.3/gdb/interps.c:312
#19 0x00085858 in mi_cmd_interpreter_exec (command=0x0, argv=0x3e2fe8, argc=2) 
at ../../../gdb-6.3/gdb/mi/mi-interp.c:239
#20 0x000875a0 in mi_cmd_execute (parse=0xaf34ba0) at 
../../../gdb-6.3/gdb/mi/mi-main.c:1288
#21 0x00087248 in captured_mi_execute_command (uiout=0x2eb170, data=0xffbed7c8) 
at ../../../gdb-6.3/gdb/mi/mi-main.c:1113
#22 0x0004c104 in catcher (func=0x87124 <captured_mi_execute_command
> , func_uiout=0x2eb170, func_args=0xffbed7c8, func_val=0xffbed754, 
func_caught=0xffbed750, errstring=0x218ed8 "", gdberrmsg=0x0, mask=6) at 
../../../gdb-6.3/gdb/top.c:431
#23 0x0004c148 in catch_exceptions (uiout=0x2eb170, func=0, 
func_args=0xffbed7c8, errstring=0x218ed8 "", mask=6) at 
../../../gdb-6.3/gdb/top.c:488
#24 0x00087400 in mi_execute_command (cmd=0xaf34ba0 "", from_tty=553252) at 
../../../gdb-6.3/gdb/mi/mi-main.c:1217
#25 0x000e42f4 in gdb_readline2 (client_data=0x0) at 
../../../gdb-6.3/gdb/event-top.c:873
#26 0x000e387c in stdin_event_handler (error=934340, client_data=0x0) at 
../../../gdb-6.3/gdb/event-top.c:416
#27 0x000e284c in handle_file_event (event_file_desc=1) at 
../../../gdb-6.3/gdb/event-loop.c:721
#28 0x000e21b4 in process_event () at ../../../gdb-6.3/gdb/event-loop.c:334
#29 0x000e220c in gdb_do_one_event (data=0x1) at 
../../../gdb-6.3/gdb/event-loop.c:371
#30 0x0004c290 in do_catch_errors (uiout=0x2eb170, data=0xffbedbd0) at 
../../../gdb-6.3/gdb/top.c:524
#31 0x0004c104 in catcher (func=0x4c280 <do_catch_errors>, func_uiout=0x2e
b170, func_args=0xffbedbd0, func_val=0xffbedbcc, func_caught=0xffbedbc8, 
errstring=0x236d38 "", gdberrmsg=0x0, mask=6) at ../../../gdb-6.3/gdb/top.c:431
#32 0x0004c2cc in catch_errors (func=0xe21d0 <gdb_do_one_event>, func_args
=0x0, errstring=0x236d38 "", mask=6) at ../../../gdb-6.3/gdb/top.c:536
#33 0x000e223c in start_event_loop () at ../../../gdb-6.3/gdb/event-loop.c:397
#34 0x000dff68 in current_interp_command_loop () at 
../../../gdb-6.3/gdb/interps.c:274
#35 0x00042814 in captured_command_loop (data=0x1) at 
../../../gdb-6.3/gdb/main.c:95
#36 0x0004c290 in do_catch_errors (uiout=0x2eb170, data=0xffbedef0) at 
../../../gdb-6.3/gdb/top.c:524
#37 0x0004c104 in catcher (func=0x4c280 <do_catch_errors>, func_uiout=0x2e
b170, func_args=0xffbedef0, func_val=0xffbedeec, func_caught=0xffbedee8, 
errstring=0x200c50 "", gdberrmsg=0x0, mask=6) at ../../../gdb-6.3/gdb/top.c:431
#38 0x0004c2cc in catch_errors (func=0x42808 <captured_command_loop
> , func_args=0x0, errstring=0x200c50 "", mask=6) at 
../../../gdb-6.3/gdb/top.c:536
#39 0x00043338 in captured_main (data=0x0) at ../../../gdb-6.3/gdb/main.c:807 
#40 0x0004c290 in do_catch_errors (uiout=0x29ef94, data=0xffbee278) at 
../../../gdb-6.3/gdb/top.c:524
#41 0x0004c104 in catcher (func=0x4c280 <do_catch_errors>, func_uiout=0x29
ef94, func_args=0xffbee278, func_val=0xffbee274, func_caught=0xffbee270, 
errstring=0x200c50 "", gdberrmsg=0x0, mask=6) at ../../../gdb-6.3/gdb/top.c:431
#42 0x0004c2cc in catch_errors (func=0x4284c <captured_main
> , func_args=0xffbee360, errstring=0x200c50 "", mask=6) at 
../../../gdb-6.3/gdb/top.c:536
#43 0x0004367c in gdb_main (args=0xffbee360) at ../../../gdb-6.3/gdb/main.c:816
#44 0x00042800 in main (argc=5, argv=0xffbee3e4) at 
../../../gdb-6.3/gdb/gdb.c:35
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]