diff options
author | Sergio Durigan Junior <sergiodj@redhat.com> | 2017-11-13 00:28:24 -0500 |
---|---|---|
committer | Sergio Durigan Junior <sergiodj@redhat.com> | 2017-11-22 19:13:44 -0500 |
commit | 935676c92feb5f35e4634ef58c20ffdfd0979b07 (patch) | |
tree | 5458a6eb5bda71faf22e90550640a1dd2981fab0 /gdb/solib-svr4.c | |
parent | 88108bf28c4a726af84dfec2f85b8404cc2ac0bd (diff) | |
download | gdb-935676c92feb5f35e4634ef58c20ffdfd0979b07.zip gdb-935676c92feb5f35e4634ef58c20ffdfd0979b07.tar.gz gdb-935676c92feb5f35e4634ef58c20ffdfd0979b07.tar.bz2 |
Convert generic probe interface to C++ (and perform some cleanups)
This patch converts the generic probe interface (gdb/probe.[ch]) to
C++, and also performs some cleanups that were on my TODO list for a
while.
The main changes were the conversion of 'struct probe' to 'class
probe', and 'struct probe_ops' to 'class static_probe_ops'. The
former now contains all the "dynamic", generic methods that act on a
probe + the generic data related to it; the latter encapsulates a
bunch of "static" methods that relate to the probe type, but not to a
specific probe itself.
I've had to do a few renamings (e.g., on 'struct bound_probe' the
field is called 'probe *prob' now, instead of 'struct probe *probe')
because GCC was complaining about naming the field using the same name
as the class. Nothing major, though. Generally speaking, the logic
behind and the design behind the code are the same.
Even though I'm sending a series of patches, they need to be tested
and committed as a single unit, because of inter-dependencies. But it
should be easier to review in separate logical units.
I've regtested this patch on BuildBot, no regressions found.
gdb/ChangeLog:
2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com>
* break-catch-throw.c (fetch_probe_arguments): Use
'probe.prob' instead of 'probe.probe'.
* breakpoint.c (create_longjmp_master_breakpoint): Call
'can_evaluate_arguments' and 'get_relocated_address' methods
from probe.
(create_exception_master_breakpoint): Likewise.
(add_location_to_breakpoint): Use 'sal->prob' instead of
'sal->probe'.
(bkpt_probe_insert_location): Call 'set_semaphore' method from
probe.
(bkpt_probe_remove_location): Likewise, for 'clear_semaphore'.
* elfread.c (elf_get_probes): Use 'static_probe_ops' instead
of 'probe_ops'.
(probe_key_free): Call 'delete' on probe.
(check_exception_resume): Use 'probe.prob' instead of
'probe.probe'.
* location.c (string_to_event_location_basic): Call
'probe_linespec_to_static_ops'.
* probe.c (class any_static_probe_ops): New class.
(any_static_probe_ops any_static_probe_ops): New variable.
(parse_probes_in_pspace): Receive 'static_probe_ops' as
argument. Adjust code to reflect change.
(parse_probes): Use 'static_probe_ops' instead of
'probe_ops'. Adjust code to reflect change.
(find_probes_in_objfile): Call methods to get name and
provider from probe.
(find_probe_by_pc): Use 'result.prob' instead of
'result.probe'. Call 'get_relocated_address' method from
probe.
(collect_probes): Adjust comment and argument list to receive
'static_probe_ops' instead of 'probe_ops'. Adjust code to
reflect change. Call necessary methods from probe.
(compare_probes): Call methods to get name and provider from
probes.
(gen_ui_out_table_header_info): Receive 'static_probe_ops'
instead of 'probe_ops'. Use 'std::vector' instead of VEC,
adjust code accordingly.
(print_ui_out_not_applicables): Likewise.
(info_probes_for_ops): Rename to...
(info_probes_for_spops): ...this. Receive 'static_probe_ops'
as argument instead of 'probe_ops'. Adjust code. Call
necessary methods from probe.
(info_probes_command): Use 'info_probes_for_spops'.
(enable_probes_command): Pass correct argument to
'collect_probes'. Call methods from probe.
(disable_probes_command): Likewise.
(get_probe_address): Move to 'any_static_probe_ops::get_address'.
(get_probe_argument_count): Move to
'any_static_probe_ops::get_argument_count'.
(can_evaluate_probe_arguments): Move to
'any_static_probe_ops::can_evaluate_arguments'.
(evaluate_probe_argument): Move to
'any_static_probe_ops::evaluate_argument'.
(probe_safe_evaluate_at_pc): Use 'probe.prob' instead of
'probe.probe'.
(probe_linespec_to_ops): Rename to...
(probe_linespec_to_static_ops): ...this. Adjust code.
(probe_any_is_linespec): Rename to...
(any_static_probe_ops::is_linespec): ...this.
(probe_any_get_probes): Rename to...
(any_static_probe_ops::get_probes): ...this.
(any_static_probe_ops::type_name): New method.
(any_static_probe_ops::gen_info_probes_table_header): New
method.
(compute_probe_arg): Use 'pc_probe.prob' instead of
'pc_probe.probe'. Call methods from probe.
(compile_probe_arg): Likewise.
(std::vector<const probe_ops *> all_probe_ops): Delete.
(std::vector<const static_probe_ops *> all_static_probe_ops):
New variable.
(_initialize_probe): Use 'all_static_probe_ops' instead of
'all_probe_ops'.
* probe.h (struct info_probe_column) <field_name>: Delete
extraneous newline
(info_probe_column_s): Delete type and VEC.
(struct probe_ops): Delete. Replace with...
(class static_probe_ops): ...this and...
(clas probe): ...this.
(struct bound_probe) <bound_probe>: Delete extraneous
newline. Adjust constructor to receive 'probe' instead of
'struct probe'.
<probe>: Rename to...
<prob>: ...this. Delete extraneous newline.
<objfile>: Delete extraneous newline.
(register_probe_ops): Delete unused prototype.
(info_probes_for_ops): Rename to...
(info_probes_for_spops): ...this. Adjust comment.
(get_probe_address): Move to 'probe::get_address'.
(get_probe_argument_count): Move to
'probe::get_argument_count'.
(can_evaluate_probe_arguments): Move to
'probe::can_evaluate_arguments'.
(evaluate_probe_argument): Move to 'probe::evaluate_argument'.
* solib-svr4.c (struct svr4_info): Adjust comment.
(struct probe_and_action) <probe>: Rename to...
<prob>: ...this.
(register_solib_event_probe): Receive 'probe' instead of
'struct probe' as argument. Use 'prob' instead of 'probe'
when applicable.
(solib_event_probe_action): Call 'get_argument_count' method
from probe. Adjust comment.
(svr4_handle_solib_event): Adjust comment. Call
'evaluate_argument' method from probe.
(svr4_create_probe_breakpoints): Call 'get_relocated_address'
from probe.
(svr4_create_solib_event_breakpoints): Use 'probe' instead of
'struct probe'. Call 'can_evaluate_arguments' from probe.
* symfile.h: Forward declare 'class probe' instead of 'struct
probe'.
* symtab.h: Likewise.
(struct symtab_and_line) <probe>: Rename to...
<prob>: ...this.
* tracepoint.c (start_tracing): Use 'prob' when applicable.
Call probe methods.
(stop_tracing): Likewise.
Diffstat (limited to 'gdb/solib-svr4.c')
-rw-r--r-- | gdb/solib-svr4.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 5ec606d..6e834fb 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -351,7 +351,7 @@ struct svr4_info /* Table of struct probe_and_action instances, used by the probes-based interface to map breakpoint addresses to probes and their associated actions. Lookup is performed using - probe_and_action->probe->address. */ + probe_and_action->prob->address. */ htab_t probes_table; /* List of objects loaded into the inferior, used by the probes- @@ -1664,7 +1664,7 @@ exec_entry_point (struct bfd *abfd, struct target_ops *targ) struct probe_and_action { /* The probe. */ - struct probe *probe; + probe *prob; /* The relocated address of the probe. */ CORE_ADDR address; @@ -1699,7 +1699,7 @@ equal_probe_and_action (const void *p1, const void *p2) probes table. */ static void -register_solib_event_probe (struct probe *probe, CORE_ADDR address, +register_solib_event_probe (probe *prob, CORE_ADDR address, enum probe_action action) { struct svr4_info *info = get_svr4_info (); @@ -1712,13 +1712,13 @@ register_solib_event_probe (struct probe *probe, CORE_ADDR address, equal_probe_and_action, xfree, xcalloc, xfree); - lookup.probe = probe; + lookup.prob = prob; lookup.address = address; slot = htab_find_slot (info->probes_table, &lookup, INSERT); gdb_assert (*slot == HTAB_EMPTY_ENTRY); pa = XCNEW (struct probe_and_action); - pa->probe = probe; + pa->prob = prob; pa->address = address; pa->action = action; @@ -1767,7 +1767,7 @@ solib_event_probe_action (struct probe_and_action *pa) arg2: struct link_map *new (optional, for incremental updates) */ TRY { - probe_argc = get_probe_argument_count (pa->probe, frame); + probe_argc = pa->prob->get_argument_count (frame); } CATCH (ex, RETURN_MASK_ERROR) { @@ -1776,11 +1776,11 @@ solib_event_probe_action (struct probe_and_action *pa) } END_CATCH - /* If get_probe_argument_count throws an exception, probe_argc will - be set to zero. However, if pa->probe does not have arguments, - then get_probe_argument_count will succeed but probe_argc will - also be zero. Both cases happen because of different things, but - they are treated equally here: action will be set to + /* If get_argument_count throws an exception, probe_argc will be set + to zero. However, if pa->prob does not have arguments, then + get_argument_count will succeed but probe_argc will also be zero. + Both cases happen because of different things, but they are + treated equally here: action will be set to PROBES_INTERFACE_FAILED. */ if (probe_argc == 2) action = FULL_RELOAD; @@ -1922,7 +1922,7 @@ svr4_handle_solib_event (void) return; } - /* evaluate_probe_argument looks up symbols in the dynamic linker + /* evaluate_argument looks up symbols in the dynamic linker using find_pc_section. find_pc_section is accelerated by a cache called the section map. The section map is invalidated every time a shared library is loaded or unloaded, and if the inferior @@ -1931,14 +1931,14 @@ svr4_handle_solib_event (void) We called find_pc_section in svr4_create_solib_event_breakpoints, so we can guarantee that the dynamic linker's sections are in the section map. We can therefore inhibit section map updates across - these calls to evaluate_probe_argument and save a lot of time. */ + these calls to evaluate_argument and save a lot of time. */ inhibit_section_map_updates (current_program_space); usm_chain = make_cleanup (resume_section_map_updates_cleanup, current_program_space); TRY { - val = evaluate_probe_argument (pa->probe, 1, frame); + val = pa->prob->evaluate_argument (1, frame); } CATCH (ex, RETURN_MASK_ERROR) { @@ -1979,7 +1979,7 @@ svr4_handle_solib_event (void) { TRY { - val = evaluate_probe_argument (pa->probe, 2, frame); + val = pa->prob->evaluate_argument (2, frame); } CATCH (ex, RETURN_MASK_ERROR) { @@ -2084,7 +2084,7 @@ svr4_create_probe_breakpoints (struct gdbarch *gdbarch, for (probe *p : probes[i]) { - CORE_ADDR address = get_probe_address (p, objfile); + CORE_ADDR address = p->get_relocated_address (objfile); create_solib_event_breakpoint (gdbarch, address); register_solib_event_probe (p, address, action); @@ -2126,7 +2126,7 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch, for (int i = 0; i < NUM_PROBES; i++) { const char *name = probe_info[i].name; - struct probe *p; + probe *p; char buf[32]; /* Fedora 17 and Red Hat Enterprise Linux 6.2-6.4 @@ -2160,7 +2160,7 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch, if (!checked_can_use_probe_arguments) { p = probes[i][0]; - if (!can_evaluate_probe_arguments (p)) + if (!p->can_evaluate_arguments ()) { all_probes_found = 0; break; |