diff options
author | Pedro Alves <palves@redhat.com> | 2016-01-19 12:18:14 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-01-19 12:18:14 +0000 |
commit | c2f4122d5cc2a21a441470336c8637b6a6965c6e (patch) | |
tree | e14f11987e3a0d6ced34db4a25b7cc6960045bd5 /gdb/breakpoint.h | |
parent | bd0a71fa16f668341a9361c695bc3ca44d27b322 (diff) | |
download | gdb-c2f4122d5cc2a21a441470336c8637b6a6965c6e.zip gdb-c2f4122d5cc2a21a441470336c8637b6a6965c6e.tar.gz gdb-c2f4122d5cc2a21a441470336c8637b6a6965c6e.tar.bz2 |
Limit breakpoint re-set to the current program space
Currently, we always re-set all locations of all breakpoints. This
commit makes us re-set only locations of the current program space.
If we loaded symbols to a program space (e.g., "file" command or some
shared library was loaded), GDB must run through all breakpoints and
determine if any new locations need to be added to the breakpoint.
However, there's no reason to recreate locations for _other_ program
spaces, as those haven't changed.
Similarly, when we create a new inferior, through e.g., a fork, GDB
must run through all breakpoints and determine if any new locations
need to be added to the breakpoint. There's no reason to destroy the
locations of the parent inferior and other inferiors. We know those
won't change.
In addition to being inneficient, resetting breakpoints of inferiors
that are currently running is problematic, because:
- some targets can't read memory while the inferior is running.
- the inferior might exit while we're re-setting its breakpoints,
which may confuse prologue skipping.
I went through all the places where we call breakpoint_re_set, and it
seems to me that all can be changed to only re-set locations of the
current program space.
The patch that reversed threads order in "info threads" etc. happened
to make gdb.threads/fork-plus-thread.exp expose this problem when
testing on x86/-m32. The problem was latent and masked out by chance
by the code-cache:
https://sourceware.org/ml/gdb-patches/2016-01/msg00213.html
Tested on x86-64 F20, native (-m64/-m32) and extended-remote
gdbserver.
Fixes the regression discussed in the url above with --target_board=unix/-m32:
-FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited
+PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited
-FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: no threads left (timeout)
-FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left (the program exited)
+PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: no threads left
+PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left
gdb/ChangeLog:
2016-01-19 Pedro Alves <palves@redhat.com>
* ax-gdb.c (agent_command_1): Adjust call to decode_line_full.
* break-catch-throw.c (re_set_exception_catchpoint): Pass the
current program space down to linespec decoding and breakpoint
location updating.
* breakpoint.c (parse_breakpoint_sals): Adjust calls to
decode_line_full.
(until_break_command): Adjust calls to decode_line_1.
(base_breakpoint_decode_location, bkpt_decode_location): Add
'search_pspace' parameter. Pass it along.
(bkpt_probe_create_sals_from_location): Adjust calls to
parse_probes.
(tracepoint_decode_location, tracepoint_probe_decode_location)
(strace_marker_decode_location): Add 'search_pspace' parameter.
Pass it along.
(all_locations_are_pending): Rewrite to take a breakpoint and
program space as arguments instead.
(hoist_existing_locations): New function.
(update_breakpoint_locations): Add 'filter_pspace' parameter. Use
hoist_existing_locations instead of always removing all locations,
and adjust to all_locations_are_pending change.
(location_to_sals): Add 'search_pspace' parameter. Pass it along.
Don't disable the breakpoint if there are other locations in
another program space.
(breakpoint_re_set_default): Adjust to pass down the current
program space as filter program space.
(decode_location_default): Add 'search_pspace' parameter and pass
it along.
(prepare_re_set_context): Don't switch program space here.
(breakpoint_re_set): Use save_current_space_and_thread instead of
save_current_program_space.
* breakpoint.h (struct breakpoint_ops) <decode_location>: Add
'search_pspace' parameter.
(update_breakpoint_locations): Add 'filter_pspace' parameter.
* cli/cli-cmds.c (edit_command, list_command): Adjust calls to
decode_line_1.
* elfread.c (elf_gnu_ifunc_resolver_return_stop): Pass the current
program space as filter program space.
* linespec.c (struct linespec_state) <search_pspace>: New field.
(create_sals_line_offset, convert_explicit_location_to_sals)
(parse_linespec): Pass the search program space down.
(linespec_state_constructor): Add 'search_pspace' parameter.
Store it.
(linespec_parser_new): Add 'search_pspace' parameter and pass it
along.
(linespec_lex_to_end): Adjust.
(decode_line_full, decode_line_1): Add 'search_pspace' parameter
and pass it along.
(decode_line_with_last_displayed): Adjust.
(collect_symtabs_from_filename, symtabs_from_filename): New
'search_pspace' parameter. Use it.
(find_function_symbols): Pass the search program space down.
* linespec.h (decode_line_1, decode_line_full): Add
'search_pspace' parameter.
* probe.c (parse_probes_in_pspace): New function, factored out
from ...
(parse_probes): ... this. Add 'search_pspace' parameter and use
it.
* probe.h (parse_probes): Add pspace' parameter.
* python/python.c (gdbpy_decode_line): Adjust.
* tracepoint.c (scope_info): Adjust.
Diffstat (limited to 'gdb/breakpoint.h')
-rw-r--r-- | gdb/breakpoint.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 68710e6..054eab4 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -599,13 +599,15 @@ struct breakpoint_ops int, const struct breakpoint_ops *, int, int, int, unsigned); - /* Given the location (second parameter), this method decodes it - and provides the SAL locations related to it. For ordinary breakpoints, - it calls `decode_line_full'. + /* Given the location (second parameter), this method decodes it and + provides the SAL locations related to it. For ordinary + breakpoints, it calls `decode_line_full'. If SEARCH_PSPACE is + not NULL, symbol search is restricted to just that program space. This function is called inside `location_to_sals'. */ void (*decode_location) (struct breakpoint *b, const struct event_location *location, + struct program_space *search_pspace, struct symtabs_and_lines *sals); /* Return true if this breakpoint explains a signal. See @@ -1200,6 +1202,7 @@ extern void init_bp_location (struct bp_location *loc, struct breakpoint *owner); extern void update_breakpoint_locations (struct breakpoint *b, + struct program_space *filter_pspace, struct symtabs_and_lines sals, struct symtabs_and_lines sals_end); |