Re: [rfc][patch] Eliminate quadratic slow-down on number of solibs.

Paul Pluzhnikov
2009-06-23T01:33:17Z

[-- Attachment #1: Type: text/plain, Size: 1276 bytes --]

On Mon, Jun 22, 2009 at 5:43 PM, Ulrich Weigand<uweigand@de.ibm.com> wrote:

> This is OK.  (Any reason why we can't inline create_overlay_event_breakpoint_1
> into its sole caller?)

No particular reason (it was that way before my 2009-05-14 change).

I've inlined it in the patch below, and that saves a bunch of calls to
update_global_location_list as well :-)

Tested on Linux/x86_64.

>> I also verified that create_overlay_event_breakpoint is not called for
>> each solib (though it is called 7 times, which seems like 6 too many).
>
> Hmm, do you understand where the other calls come from?

I've attached a log (to avoid GMail line wrapping): 4 calls at startup,
3 more when all the solibs are loaded. I haven't debugged the exact reason;
in my reading of the code it should only fire once after all solibs.

Thanks,
--
Paul Pluzhnikov

2009-06-22 Paul Pluzhnikov <ppluzhnikov@google.com>

Revert 2009-05-14 breakpoint commit (no longer needed).
* breakpoint.h (breakpoint_re_set_objfile): Remove
* breakpoint.c (breakpoint_re_set_objfile): Likewise
(create_overlay_event_breakpoint): Remove objfile parameter,
iterate over all objfiles.
* objfiles.c (objfile_relocate): Update.
* symfile.c (new_symfile_objfile): Likewise.

[-- Attachment #2: gdb-overlay-bp-20090622-3.txt --]
[-- Type: text/plain, Size: 5106 bytes --]

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.407
diff -u -p -u -r1.407 breakpoint.c
--- breakpoint.c 19 Jun 2009 15:14:11 -0000 1.407
+++ breakpoint.c 23 Jun 2009 01:22:08 -0000
@@ -1476,28 +1476,33 @@ create_internal_breakpoint (CORE_ADDR ad
}

static void
-create_overlay_event_breakpoint (char *func_name, struct objfile *objfile)
+create_overlay_event_breakpoint (char *func_name)
{
- struct breakpoint *b;
- struct minimal_symbol *m;
+ struct objfile *objfile;

- m = lookup_minimal_symbol_text (func_name, objfile);
- if (m == NULL)
- return;
+ ALL_OBJFILES (objfile)
+ {
+ struct breakpoint *b;
+ struct minimal_symbol *m;
+
+ m = lookup_minimal_symbol_text (func_name, objfile);
+ if (m == NULL)
+ continue;

- b = create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m),
- bp_overlay_event);
- b->addr_string = xstrdup (func_name);
+ b = create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m),
+ bp_overlay_event);
+ b->addr_string = xstrdup (func_name);

- if (overlay_debugging == ovly_auto)
- {
- b->enable_state = bp_enabled;
- overlay_events_enabled = 1;
- }
- else
- {
- b->enable_state = bp_disabled;
- overlay_events_enabled = 0;
+ if (overlay_debugging == ovly_auto)
+ {
+ b->enable_state = bp_enabled;
+ overlay_events_enabled = 1;
+ }
+ else
+ {
+ b->enable_state = bp_disabled;
+ overlay_events_enabled = 0;
+ }
}
update_global_location_list (1);
}
@@ -1508,7 +1513,6 @@ update_breakpoints_after_exec (void)
struct breakpoint *b;
struct breakpoint *temp;
struct bp_location *bploc;
- struct objfile *objfile;

/* We're about to delete breakpoints from GDB's lists. If the
INSERTED flag is true, GDB will try to lift the breakpoints by
@@ -1603,8 +1607,7 @@ update_breakpoints_after_exec (void)
}
}
/* FIXME what about longjmp breakpoints? Re-create them here? */
- ALL_OBJFILES (objfile)
- create_overlay_event_breakpoint ("_ovly_debug_event", objfile);
+ create_overlay_event_breakpoint ("_ovly_debug_event");
}

int
@@ -7771,13 +7774,9 @@ breakpoint_re_set_one (void *bint)
return 0;
}

-/* Re-set all breakpoints after symbols have been re-loaded.
-
- If OBJFILE is non-null, create overlay break point only in OBJFILE
- (speed optimization). Otherwise rescan all loaded objfiles. */
-
+/* Re-set all breakpoints after symbols have been re-loaded. */
void
-breakpoint_re_set_objfile (struct objfile *objfile)
+breakpoint_re_set (void)
{
struct breakpoint *b, *temp;
enum language save_language;
@@ -7797,19 +7796,7 @@ breakpoint_re_set_objfile (struct objfil
set_language (save_language);
input_radix = save_input_radix;

- if (objfile == NULL)
- ALL_OBJFILES (objfile)
- create_overlay_event_breakpoint ("_ovly_debug_event", objfile);
- else
- create_overlay_event_breakpoint ("_ovly_debug_event", objfile);
-}
-
-/* Re-set all breakpoints after symbols have been re-loaded. */
-
-void
-breakpoint_re_set (void)
-{
- breakpoint_re_set_objfile (NULL);
+ create_overlay_event_breakpoint ("_ovly_debug_event");
}
\f
/* Reset the thread number of this breakpoint:
Index: breakpoint.h
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.h,v
retrieving revision 1.92
diff -u -p -u -r1.92 breakpoint.h
--- breakpoint.h 24 May 2009 18:00:08 -0000 1.92
+++ breakpoint.h 23 Jun 2009 01:22:08 -0000
@@ -687,7 +687,7 @@ extern int breakpoint_thread_match (CORE
extern void until_break_command (char *, int, int);

extern void breakpoint_re_set (void);
-extern void breakpoint_re_set_objfile (struct objfile *);
+
extern void breakpoint_re_set_thread (struct breakpoint *);

extern struct breakpoint *set_momentary_breakpoint
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.83
diff -u -p -u -r1.83 objfiles.c
--- objfiles.c 14 May 2009 23:33:08 -0000 1.83
+++ objfiles.c 23 Jun 2009 01:22:08 -0000
@@ -674,7 +674,7 @@ objfile_relocate (struct objfile *objfil
}

/* Relocate breakpoints as necessary, after things are relocated. */
- breakpoint_re_set_objfile (objfile);
+ breakpoint_re_set ();
}
\f
/* Many places in gdb want to test just to see if we have any partial
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.232
diff -u -p -u -r1.232 symfile.c
--- symfile.c 17 Jun 2009 18:34:34 -0000 1.232
+++ symfile.c 23 Jun 2009 01:22:08 -0000
@@ -919,7 +919,7 @@ new_symfile_objfile (struct objfile *obj
}
else if ((add_flags & SYMFILE_DEFER_BP_RESET) == 0)
{
- breakpoint_re_set_objfile (objfile);
+ breakpoint_re_set ();
}

/* We're done reading the symbol file; finish off complaints. */

[-- Attachment #3: gdblog.txt --]
[-- Type: text/plain, Size: 11447 bytes --]

Breakpoint 1, create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
1480 {
#0 create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
#1 0x00000000004e1a23 in clear_symtab_users () at ../../src/gdb/symfile.c:2800
#2 0x00000000004e2104 in new_symfile_objfile (objfile=0x676609, add_flags=4) at ../../src/gdb/symfile.c:918
#3 0x00000000004e3c6a in symbol_file_add_with_addrs_or_offsets (abfd=0x0, add_flags=4, addrs=0x0, offsets=0x0, num_offsets=0, flags=0) at ../../src/gdb/symfile.c:1083
#4 0x00000000004e45a8 in symbol_file_add_main_1 (args=0x676609 "_ovly_debug_event", from_tty=<value optimized out>, flags=99) at ../../src/gdb/symfile.c:1137
#5 0x00000000004fe626 in catch_command_errors (command=0x4e45c0 <symbol_file_add_main>, arg=0x7fffffffdea7 "blaze-google3/blaze-out/gcc-4.3.1-glibc-2.3.6-grte-k8-dbg/bin/gws/output/pages/custom_test", from_tty=0,
mask=<value optimized out>) at ../../src/gdb/exceptions.c:525
#6 0x0000000000446574 in captured_main (data=<value optimized out>) at ../../src/gdb/main.c:811
#7 0x00000000004fe6ab in catch_errors (func=0x445d20 <captured_main>, func_args=0x7fffffffd960, errstring=0x660050 "", mask=<value optimized out>) at ../../src/gdb/exceptions.c:510
#8 0x0000000000445ac4 in gdb_main (args=0x6635f1) at ../../src/gdb/main.c:911
#9 0x0000000000445a96 in main (argc=<value optimized out>, argv=0x6635f1) at ../../src/gdb/gdb.c:33
Breakpoint 1 at 0x406b3d: file gws/output/pages/custom_test.cc, line 793.

Breakpoint 1, create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
1480 {
#0 create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
#1 0x0000000000462a67 in solib_add (pattern=0x0, from_tty=0, target=<value optimized out>, readsyms=1) at ../../src/gdb/solib.c:763
#2 0x0000000000464283 in enable_break (info=0xa8fd60) at ../../src/gdb/solib-svr4.c:1393
#3 0x00000000004eea63 in post_create_inferior (target=0x9e0bc0, from_tty=0) at ../../src/gdb/infcmd.c:419
#4 0x00000000004ef3f3 in run_command_1 (args=0x0, from_tty=0, tbreak_at_main=<value optimized out>) at ../../src/gdb/infcmd.c:572
#5 0x000000000044d434 in execute_command (p=0x7fffffffde94 "", from_tty=0) at ../../src/gdb/top.c:442
#6 0x00000000004fe626 in catch_command_errors (command=0x44d1c0 <execute_command>, arg=0x7fffffffde91 "run", from_tty=1, mask=<value optimized out>) at ../../src/gdb/exceptions.c:525
#7 0x00000000004463dd in captured_main (data=<value optimized out>) at ../../src/gdb/main.c:861
#8 0x00000000004fe6ab in catch_errors (func=0x445d20 <captured_main>, func_args=0x7fffffffd960, errstring=0x660050 "", mask=<value optimized out>) at ../../src/gdb/exceptions.c:510
#9 0x0000000000445ac4 in gdb_main (args=0x6837c3) at ../../src/gdb/main.c:911
#10 0x0000000000445a96 in main (argc=<value optimized out>, argv=0x6837c3) at ../../src/gdb/gdb.c:33

Breakpoint 1, create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
1480 {
#0 create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
#1 0x00000000004eea68 in post_create_inferior (target=0x9e0bc0, from_tty=0) at ../../src/gdb/infcmd.c:433
#2 0x00000000004ef3f3 in run_command_1 (args=0x0, from_tty=0, tbreak_at_main=<value optimized out>) at ../../src/gdb/infcmd.c:572
#3 0x000000000044d434 in execute_command (p=0x7fffffffde94 "", from_tty=0) at ../../src/gdb/top.c:442
#4 0x00000000004fe626 in catch_command_errors (command=0x44d1c0 <execute_command>, arg=0x7fffffffde91 "run", from_tty=1, mask=<value optimized out>) at ../../src/gdb/exceptions.c:525
#5 0x00000000004463dd in captured_main (data=<value optimized out>) at ../../src/gdb/main.c:861
#6 0x00000000004fe6ab in catch_errors (func=0x445d20 <captured_main>, func_args=0x7fffffffd960, errstring=0x660050 "", mask=<value optimized out>) at ../../src/gdb/exceptions.c:510
#7 0x0000000000445ac4 in gdb_main (args=0x6837c3) at ../../src/gdb/main.c:911
#8 0x0000000000445a96 in main (argc=<value optimized out>, argv=0x6837c3) at ../../src/gdb/gdb.c:33

Breakpoint 1, create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
1480 {
#0 create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
#1 0x00000000004e20f6 in new_symfile_objfile (objfile=0x676609, add_flags=<value optimized out>) at ../../src/gdb/symfile.c:922
#2 0x00000000004e3c6a in symbol_file_add_with_addrs_or_offsets (abfd=0x0, add_flags=0, addrs=0x14bcd90, offsets=0x0, num_offsets=0, flags=2) at ../../src/gdb/symfile.c:1083
#3 0x00000000004661b6 in symbol_file_add_from_memory (templ=<value optimized out>, addr=<value optimized out>, name=<value optimized out>, from_tty=0) at ../../src/gdb/symfile-mem.c:110
#4 0x000000000046625a in symbol_file_add_from_memory_wrapper (uiout=<value optimized out>, data=0x3) at ../../src/gdb/symfile-mem.c:161
#5 0x00000000004fe750 in catch_exceptions_with_msg (uiout=0xa4f400, func=0x466240 <symbol_file_add_from_memory_wrapper>, func_args=0x7fffffffd690, gdberrmsg=0x0, mask=<value optimized out>) at ../../src/gdb/exceptions.c:478
#6 0x00000000004660b0 in add_vsyscall_page (target=<value optimized out>, from_tty=<value optimized out>) at ../../src/gdb/symfile-mem.c:205
#7 0x0000000000448f4e in generic_observer_notify (subject=<value optimized out>, args=0x7fffffffd6f0) at ../../src/gdb/observer.c:166
#8 0x00000000004496ea in observer_notify_inferior_created (objfile=<value optimized out>, from_tty=<value optimized out>) at ./observer.inc:174
#9 0x00000000004ef3f3 in run_command_1 (args=0x0, from_tty=0, tbreak_at_main=<value optimized out>) at ../../src/gdb/infcmd.c:572
#10 0x000000000044d434 in execute_command (p=0x7fffffffde94 "", from_tty=0) at ../../src/gdb/top.c:442
#11 0x00000000004fe626 in catch_command_errors (command=0x44d1c0 <execute_command>, arg=0x7fffffffde91 "run", from_tty=1, mask=<value optimized out>) at ../../src/gdb/exceptions.c:525
#12 0x00000000004463dd in captured_main (data=<value optimized out>) at ../../src/gdb/main.c:861
#13 0x00000000004fe6ab in catch_errors (func=0x445d20 <captured_main>, func_args=0x7fffffffd960, errstring=0x660050 "", mask=<value optimized out>) at ../../src/gdb/exceptions.c:510
#14 0x0000000000445ac4 in gdb_main (args=0x6837c3) at ../../src/gdb/main.c:911
#15 0x0000000000445a96 in main (argc=<value optimized out>, argv=0x6837c3) at ../../src/gdb/gdb.c:33
[Thread debugging using libthread_db enabled]

Breakpoint 1, create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
1480 {
#0 create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
#1 0x0000000000462a67 in solib_add (pattern=0x0, from_tty=0, target=<value optimized out>, readsyms=1) at ../../src/gdb/solib.c:763
#2 0x00000000004f4c2f in handle_inferior_event (ecs=0x7fffffffd580) at ../../src/gdb/infrun.c:3473
#3 0x00000000004f6f00 in wait_for_inferior (treat_exec_as_sigtrap=0) at ../../src/gdb/infrun.c:2023
#4 0x00000000004f7481 in proceed (addr=0, siggnal=TARGET_SIGNAL_0, step=<value optimized out>) at ../../src/gdb/infrun.c:1631
#5 0x00000000004ef403 in run_command_1 (args=0x0, from_tty=0, tbreak_at_main=<value optimized out>) at ../../src/gdb/infcmd.c:575
#6 0x000000000044d434 in execute_command (p=0x7fffffffde94 "", from_tty=0) at ../../src/gdb/top.c:442
#7 0x00000000004fe626 in catch_command_errors (command=0x44d1c0 <execute_command>, arg=0x7fffffffde91 "run", from_tty=1, mask=<value optimized out>) at ../../src/gdb/exceptions.c:525
#8 0x00000000004463dd in captured_main (data=<value optimized out>) at ../../src/gdb/main.c:861
#9 0x00000000004fe6ab in catch_errors (func=0x445d20 <captured_main>, func_args=0x7fffffffd960, errstring=0x660050 "", mask=<value optimized out>) at ../../src/gdb/exceptions.c:510
#10 0x0000000000445ac4 in gdb_main (args=0x6837c3) at ../../src/gdb/main.c:911
#11 0x0000000000445a96 in main (argc=<value optimized out>, argv=0x6837c3) at ../../src/gdb/gdb.c:33

Breakpoint 1, create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
1480 {
#0 create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
#1 0x0000000000462a67 in solib_add (pattern=0x0, from_tty=0, target=<value optimized out>, readsyms=1) at ../../src/gdb/solib.c:763
#2 0x00000000004f4c2f in handle_inferior_event (ecs=0x7fffffffd580) at ../../src/gdb/infrun.c:3473
#3 0x00000000004f6f00 in wait_for_inferior (treat_exec_as_sigtrap=0) at ../../src/gdb/infrun.c:2023
#4 0x00000000004f7481 in proceed (addr=0, siggnal=TARGET_SIGNAL_0, step=<value optimized out>) at ../../src/gdb/infrun.c:1631
#5 0x00000000004ef403 in run_command_1 (args=0x0, from_tty=0, tbreak_at_main=<value optimized out>) at ../../src/gdb/infcmd.c:575
#6 0x000000000044d434 in execute_command (p=0x7fffffffde94 "", from_tty=0) at ../../src/gdb/top.c:442
#7 0x00000000004fe626 in catch_command_errors (command=0x44d1c0 <execute_command>, arg=0x7fffffffde91 "run", from_tty=1, mask=<value optimized out>) at ../../src/gdb/exceptions.c:525
#8 0x00000000004463dd in captured_main (data=<value optimized out>) at ../../src/gdb/main.c:861
#9 0x00000000004fe6ab in catch_errors (func=0x445d20 <captured_main>, func_args=0x7fffffffd960, errstring=0x660050 "", mask=<value optimized out>) at ../../src/gdb/exceptions.c:510
#10 0x0000000000445ac4 in gdb_main (args=0x6837c3) at ../../src/gdb/main.c:911
#11 0x0000000000445a96 in main (argc=<value optimized out>, argv=0x6837c3) at ../../src/gdb/gdb.c:33

Breakpoint 1, create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
1480 {
#0 create_overlay_event_breakpoint (func_name=0x676609 "_ovly_debug_event") at ../../src/gdb/breakpoint.c:1480
#1 0x0000000000462a67 in solib_add (pattern=0x0, from_tty=0, target=<value optimized out>, readsyms=1) at ../../src/gdb/solib.c:763
#2 0x00000000004f4c2f in handle_inferior_event (ecs=0x7fffffffd580) at ../../src/gdb/infrun.c:3473
#3 0x00000000004f6f00 in wait_for_inferior (treat_exec_as_sigtrap=0) at ../../src/gdb/infrun.c:2023
#4 0x00000000004f7481 in proceed (addr=0, siggnal=TARGET_SIGNAL_0, step=<value optimized out>) at ../../src/gdb/infrun.c:1631
#5 0x00000000004ef403 in run_command_1 (args=0x0, from_tty=0, tbreak_at_main=<value optimized out>) at ../../src/gdb/infcmd.c:575
#6 0x000000000044d434 in execute_command (p=0x7fffffffde94 "", from_tty=0) at ../../src/gdb/top.c:442
#7 0x00000000004fe626 in catch_command_errors (command=0x44d1c0 <execute_command>, arg=0x7fffffffde91 "run", from_tty=1, mask=<value optimized out>) at ../../src/gdb/exceptions.c:525
#8 0x00000000004463dd in captured_main (data=<value optimized out>) at ../../src/gdb/main.c:861
#9 0x00000000004fe6ab in catch_errors (func=0x445d20 <captured_main>, func_args=0x7fffffffd960, errstring=0x660050 "", mask=<value optimized out>) at ../../src/gdb/exceptions.c:510
#10 0x0000000000445ac4 in gdb_main (args=0x6837c3) at ../../src/gdb/main.c:911
#11 0x0000000000445a96 in main (argc=<value optimized out>, argv=0x6837c3) at ../../src/gdb/gdb.c:33