[Converted from Gnats 1262] Hello, Debugging an executable build with more than 3000 source files, it can take several seconds to GDB to output some source file information. A reproducer can be generated with the following script (It generated an Ada program): --- rm main.adb rm -rf many_files mkdir many_files for i in 0 1 2 3 ; do for j in 0 1 2 3 4 5 6 7 8 9 ; do for k in 0 1 2 3 4 5 6 7 8 9 ; do for l in 0 1 2 3 4 5 6 7 8 9 ; do echo "with Pack_${i}${j}${k}${l}_Test;" >> main.adb echo "package Pack_${i}$j${k}${l}_Test is" \ >> many_files/pack_${i}${j}${k}${l}_test.ads echo " pragma Pure;" \ >> many_files/pack_${i}${j}${k}${l}_test.ads echo " Var_${i}$j${k}${l}_Test : constant String := \"${i}${j}${k}${l}\";" \ >> many_files/pack_${i}${j}${k}${l}_test.ads echo "end Pack_${i}$j${k}${l}_Test;" \ >> many_files/pack_${i}${j}${k}${l}_test.ads done done done done echo "procedure Main is" >> main.adb echo "begin" >> main.adb echo " null;" >> main.adb echo "end Main;" >> main.adb --- Compiling with GNAT 3.16a, and debugging with gdb 5.3: (gdb) l /home/guitton/bug/C411-003/many_files/pack_0001_test.ads:2 [after several seconds:] 1 package Pack_0001_Test is 2 pragma Pure; 3 Var_0001_Test : constant String := "0001"; 4 end Pack_0001_Test; (gdb) The culprit is lookup_partial_symtab, that may do a call to source_full_path_of for every file referenced. I suggest trying to avoid as much as possible this function call by doing some preliminary testing: if the basenames are not equal, no need to fetch the fullname and make the fullname comparison. With this modification GDB reacts almost instantly. I have tested this patch against the testsuite on linux; no regression appeared. There seems to be no test using an absolute path, I can also propose one. Joel Brobecker volunteered to commit this path if/when it is approved. 2003-05-26 J. Guitton <guitton@gnat.com> * symtab.c (lookup_partial_symbol): To improve the performance, try to avoid as much as possible to call source_full_path_of, by doing some preliminary testing. Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.109 diff -c -r1.109 symtab.c *** symtab.c 20 May 2003 01:55:17 -0000 1.109 --- symtab.c 10 Jun 2003 13:22:43 -0000 *************** *** 273,280 **** } /* If the user gave us an absolute path, try to find the file in ! this symtab and use its absolute path. */ ! if (full_path != NULL) { if (pst->fullname == NULL) source_full_path_of (pst->filename, &pst->fullname); --- 273,283 ---- } /* If the user gave us an absolute path, try to find the file in ! this symtab and use its absolute path. However, if the ! base names are different, the two files are different and there ! is no need to do a full comparison. */ ! if (full_path != NULL && ! strcmp (lbasename (full_path), lbasename (pst->filename)) == 0) { if (pst->fullname == NULL) source_full_path_of (pst->filename, &pst->fullname); *************** *** 285,291 **** } } ! if (real_path != NULL) { char *rp = NULL; if (pst->fullname == NULL) --- 288,295 ---- } } ! if (real_path != NULL && ! strcmp (lbasename (real_path), lbasename (pst->filename)) == 0) { char *rp = NULL; if (pst->fullname == NULL) Release: unknown
*** Bug 9264 has been marked as a duplicate of this bug. ***
CVSROOT: /cvs/src Module name: src Changes by: devans@sourceware.org 2011-12-14 16:06:01 Modified files: gdb : ChangeLog Log message: Add PR gdb/8367 to basenames-may-differ patch. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13620&r2=1.13621
CVSROOT: /cvs/src Module name: src Branch: gdb_7_4-branch Changes by: devans@sourceware.org 2011-12-14 16:08:37 Modified files: gdb : ChangeLog Log message: Add PR gdb/8367 to basenames-may-differ patch. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&only_with_tag=gdb_7_4-branch&r1=1.13614.2.8&r2=1.13614.2.9
Note to self, to compile you must use: $ gnatmake -g main -aImany_files With git master this is very quick: (gdb) maint time 1 (gdb) list /home/tromey/gdb/PRs/pr8367-basenames/many_files/pack_0001_test.ads:22023-01-06 12:40:09.325 - command started 1 package Pack_0001_Test is 2 pragma Pure; 3 Var_0001_Test : constant String := "0001"; 4 end Pack_0001_Test; 2023-01-06 12:40:09.359 - command finished Command execution time: 0.034019 (cpu), 0.034398 (wall) So I think this is fixed.