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/probe.c | |
parent | bd0a71fa16f668341a9361c695bc3ca44d27b322 (diff) | |
download | binutils-gdb-c2f4122d5cc2a21a441470336c8637b6a6965c6e.tar.gz |
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/probe.c')
-rw-r--r-- | gdb/probe.c | 120 |
1 files changed, 73 insertions, 47 deletions
diff --git a/gdb/probe.c b/gdb/probe.c index 374e7a77eb6..56f93dad9b3 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -41,18 +41,77 @@ DEF_VEC_O (bound_probe_s); +/* A helper for parse_probes that decodes a probe specification in + SEARCH_PSPACE. It appends matching SALs to RESULT. */ + +static void +parse_probes_in_pspace (const struct probe_ops *probe_ops, + struct program_space *search_pspace, + const char *objfile_namestr, + const char *provider, + const char *name, + struct symtabs_and_lines *result) +{ + struct objfile *objfile; + + ALL_PSPACE_OBJFILES (search_pspace, objfile) + { + VEC (probe_p) *probes; + struct probe *probe; + int ix; + + if (!objfile->sf || !objfile->sf->sym_probe_fns) + continue; + + if (objfile_namestr + && FILENAME_CMP (objfile_name (objfile), objfile_namestr) != 0 + && FILENAME_CMP (lbasename (objfile_name (objfile)), + objfile_namestr) != 0) + continue; + + probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile); + + for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++) + { + struct symtab_and_line *sal; + + if (probe_ops != &probe_ops_any && probe->pops != probe_ops) + continue; + + if (provider && strcmp (probe->provider, provider) != 0) + continue; + + if (strcmp (probe->name, name) != 0) + continue; + + ++result->nelts; + result->sals = XRESIZEVEC (struct symtab_and_line, result->sals, + result->nelts); + sal = &result->sals[result->nelts - 1]; + + init_sal (sal); + + sal->pc = get_probe_address (probe, objfile); + sal->explicit_pc = 1; + sal->section = find_pc_overlay (sal->pc); + sal->pspace = search_pspace; + sal->probe = probe; + sal->objfile = objfile; + } + } +} + /* See definition in probe.h. */ struct symtabs_and_lines parse_probes (const struct event_location *location, + struct program_space *search_pspace, struct linespec_result *canonical) { char *arg_end, *arg; char *objfile_namestr = NULL, *provider = NULL, *name, *p; struct cleanup *cleanup; struct symtabs_and_lines result; - struct objfile *objfile; - struct program_space *pspace; const struct probe_ops *probe_ops; const char *arg_start, *cs; @@ -114,52 +173,19 @@ parse_probes (const struct event_location *location, if (objfile_namestr && *objfile_namestr == '\0') error (_("invalid objfile name")); - ALL_PSPACES (pspace) - ALL_PSPACE_OBJFILES (pspace, objfile) - { - VEC (probe_p) *probes; - struct probe *probe; - int ix; - - if (!objfile->sf || !objfile->sf->sym_probe_fns) - continue; - - if (objfile_namestr - && FILENAME_CMP (objfile_name (objfile), objfile_namestr) != 0 - && FILENAME_CMP (lbasename (objfile_name (objfile)), - objfile_namestr) != 0) - continue; - - probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile); - - for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++) - { - struct symtab_and_line *sal; - - if (probe_ops != &probe_ops_any && probe->pops != probe_ops) - continue; - - if (provider && strcmp (probe->provider, provider) != 0) - continue; - - if (strcmp (probe->name, name) != 0) - continue; - - ++result.nelts; - result.sals = XRESIZEVEC (struct symtab_and_line, result.sals, - result.nelts); - sal = &result.sals[result.nelts - 1]; - - init_sal (sal); + if (search_pspace != NULL) + { + parse_probes_in_pspace (probe_ops, search_pspace, objfile_namestr, + provider, name, &result); + } + else + { + struct program_space *pspace; - sal->pc = get_probe_address (probe, objfile); - sal->explicit_pc = 1; - sal->section = find_pc_overlay (sal->pc); - sal->pspace = pspace; - sal->probe = probe; - sal->objfile = objfile; - } - } + ALL_PSPACES (pspace) + parse_probes_in_pspace (probe_ops, pspace, objfile_namestr, + provider, name, &result); + } if (result.nelts == 0) { |