1 diff --git a/gdb/infrun.c b/gdb/infrun.c
2 index 91e0fc2..1d7c808 100644
5 @@ -3111,6 +3111,56 @@ fill_in_stop_func (struct gdbarch *gdbarch,
9 +/* Argument for at_solib_event_breakpoint_helper. */
11 +struct solib_event_breakpoint_helper_arg
18 +/* Helper for at_solib_event_breakpoint. */
21 +at_solib_event_breakpoint_helper (struct breakpoint *b, void *argp)
23 + struct solib_event_breakpoint_helper_arg *arg
24 + = (struct solib_event_breakpoint_helper_arg *) argp;
25 + struct bp_location *loc;
27 + for (loc = b->loc; loc; loc = loc->next)
29 + if (loc->pspace == current_program_space
30 + && (loc->address == stop_pc || loc->address == arg->prev_pc))
32 + if (b->type == bp_shlib_event)
33 + arg->shlib_bp_count++;
36 + arg->other_bp_count++;
37 + return 1; /* quick exit */
42 + return 0; /* carry on looking */
45 +/* Nonzero if the location stopoed at is the shlib event breakpoint. */
48 +at_solib_event_breakpoint (struct execution_control_state *ecs)
50 + struct solib_event_breakpoint_helper_arg arg;
51 + arg.prev_pc = ecs->event_thread->prev_pc;
52 + arg.shlib_bp_count = arg.other_bp_count = 0;
54 + iterate_over_breakpoints (at_solib_event_breakpoint_helper, &arg);
56 + return arg.shlib_bp_count && !arg.other_bp_count;
59 /* Given an execution control state that has been freshly filled in
60 by an event from the inferior, figure out what it means and take
61 appropriate action. */
62 @@ -3964,11 +4014,23 @@ handle_inferior_event (struct execution_control_state *ecs)
63 ecs->random_signal = 0;
64 stopped_by_random_signal = 0;
66 - /* Hide inlined functions starting here, unless we just performed stepi or
67 - nexti. After stepi and nexti, always show the innermost frame (not any
68 - inline function call sites). */
69 - if (ecs->event_thread->control.step_range_end != 1)
70 - skip_inline_frames (ecs->ptid);
71 + /* If we have stopped at the solib event breakpoint and
72 + stop_on_solib_events is not set then we can avoid calling
73 + anything that calls find_pc_section. This saves a lot
74 + of time when the inferior loads a lot of shared libraries,
75 + because otherwise the section map gets regenerated every
77 + if (stop_on_solib_events
78 + || ecs->event_thread->suspend.stop_signal != TARGET_SIGNAL_TRAP
80 + || !at_solib_event_breakpoint (ecs))
82 + /* Hide inlined functions starting here, unless we just
83 + performed stepi or nexti. After stepi and nexti, always show
84 + the innermost frame (not any inline function call sites). */
85 + if (ecs->event_thread->control.step_range_end != 1)
86 + skip_inline_frames (ecs->ptid);
89 if (ecs->event_thread->suspend.stop_signal == TARGET_SIGNAL_TRAP
90 && ecs->event_thread->control.trap_expected