diff options
author | Tom Tromey <tromey@redhat.com> | 2013-12-02 13:58:59 -0700 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2014-03-03 12:47:20 -0700 |
commit | 729662a5221eaee2b3cd71d79afb3f612c4df904 (patch) | |
tree | 929c58f2c94334b9a645ba7cf167b54b6a9349be /gdb/stap-probe.c | |
parent | ff8879201af6e734741c2be0c26b71b1745667ad (diff) | |
download | gdb-729662a5221eaee2b3cd71d79afb3f612c4df904.zip gdb-729662a5221eaee2b3cd71d79afb3f612c4df904.tar.gz gdb-729662a5221eaee2b3cd71d79afb3f612c4df904.tar.bz2 |
change probes to be program-space-independent
This changes the probes to be independent of the program space.
After this, when a probe's address is needed, it is determined by
applying offsets at the point of use.
This introduces a bound_probe object, similar to bound minimal
symbols. Objects of this type are used when it's necessary to pass a
probe and its corresponding objfile.
This removes the backlink from probe to objfile, which was primarily
used to fetch the architecture to use.
This adds a get_probe_address function which calls a probe method to
compute the probe's relocated address. Similarly, it adds an objfile
parameter to the semaphore methods so they can do the relocation
properly as well.
2014-03-03 Tom Tromey <tromey@redhat.com>
* break-catch-throw.c (fetch_probe_arguments): Use bound probes.
* breakpoint.c (create_longjmp_master_breakpoint): Use
get_probe_address.
(add_location_to_breakpoint, bkpt_probe_insert_location)
(bkpt_probe_remove_location): Update.
* breakpoint.h (struct bp_location) <probe>: Now a bound_probe.
* elfread.c (elf_symfile_relocate_probe): Remove.
(elf_probe_fns): Update.
(insert_exception_resume_breakpoint): Change type of "probe"
parameter to bound_probe.
(check_exception_resume): Update.
* objfiles.c (objfile_relocate1): Don't relocate probes.
* probe.c (bound_probe_s): New typedef.
(parse_probes): Use get_probe_address. Set sal's objfile.
(find_probe_by_pc): Return a bound_probe.
(collect_probes): Return a VEC(bound_probe_s).
(compare_probes): Update.
(gen_ui_out_table_header_info): Change type of "probes"
parameter. Update.
(info_probes_for_ops): Update.
(get_probe_address): New function.
(probe_safe_evaluate_at_pc): Update.
* probe.h (struct probe_ops) <get_probe_address>: New field.
<set_semaphore, clear_semaphore>: Add objfile parameter.
(struct probe) <objfile>: Remove field.
<arch>: New field.
<address>: Update comment.
(struct bound_probe): New.
(find_probe_by_pc): Return a bound_probe.
(get_probe_address): Declare.
* solib-svr4.c (struct probe_and_action) <address>: New field.
(hash_probe_and_action, equal_probe_and_action): Update.
(register_solib_event_probe): Add address parameter.
(solib_event_probe_at): Update.
(svr4_create_probe_breakpoints): Add objfile parameter. Use
get_probe_address.
* stap-probe.c (struct stap_probe) <sem_addr>: Update comment.
(stap_get_probe_address): New function.
(stap_can_evaluate_probe_arguments, compute_probe_arg)
(compile_probe_arg): Update.
(stap_set_semaphore, stap_clear_semaphore): Compute semaphore's
address.
(handle_stap_probe): Don't relocate the probe.
(stap_relocate): Remove.
(stap_gen_info_probes_table_values): Update.
(stap_probe_ops): Remove stap_relocate.
* symfile-debug.c (debug_sym_relocate_probe): Remove.
(debug_sym_probe_fns): Update.
* symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove.
* symtab.c (init_sal): Use memset.
* symtab.h (struct symtab_and_line) <objfile>: New field.
* tracepoint.c (start_tracing, stop_tracing): Update.
Diffstat (limited to 'gdb/stap-probe.c')
-rw-r--r-- | gdb/stap-probe.c | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index 3064614..6bb7323 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -99,7 +99,7 @@ struct stap_probe struct probe p; /* If the probe has a semaphore associated, then this is the value of - it. */ + it, relative to SECT_OFF_DATA. */ CORE_ADDR sem_addr; /* One if the arguments have been parsed. */ @@ -1151,6 +1151,15 @@ stap_parse_probe_arguments (struct stap_probe *probe, struct gdbarch *gdbarch) } } +/* Implementation of the get_probe_address method. */ + +static CORE_ADDR +stap_get_probe_address (struct probe *probe, struct objfile *objfile) +{ + return probe->address + ANOFFSET (objfile->section_offsets, + SECT_OFF_DATA (objfile)); +} + /* Given PROBE, returns the number of arguments present in that probe's argument string. */ @@ -1241,7 +1250,7 @@ static int stap_can_evaluate_probe_arguments (struct probe *probe_generic) { struct stap_probe *stap_probe = (struct stap_probe *) probe_generic; - struct gdbarch *gdbarch = get_objfile_arch (stap_probe->p.objfile); + struct gdbarch *gdbarch = stap_probe->p.arch; /* For SystemTap probes, we have to guarantee that the method stap_is_single_operand is defined on gdbarch. If it is not, then it @@ -1323,7 +1332,7 @@ compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar, struct frame_info *frame = get_selected_frame (_("No frame selected")); CORE_ADDR pc = get_frame_pc (frame); int sel = (int) (uintptr_t) data; - struct probe *pc_probe; + struct bound_probe pc_probe; const struct sym_probe_fns *pc_probe_fns; unsigned n_args; @@ -1331,10 +1340,10 @@ compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar, gdb_assert (sel >= -1); pc_probe = find_probe_by_pc (pc); - if (pc_probe == NULL) + if (pc_probe.probe == NULL) error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc)); - n_args = get_probe_argument_count (pc_probe, frame); + n_args = get_probe_argument_count (pc_probe.probe, frame); if (sel == -1) return value_from_longest (builtin_type (arch)->builtin_int, n_args); @@ -1342,7 +1351,7 @@ compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar, error (_("Invalid probe argument %d -- probe has %u arguments available"), sel, n_args); - return evaluate_probe_argument (pc_probe, sel, frame); + return evaluate_probe_argument (pc_probe.probe, sel, frame); } /* This is called to compile one of the $_probe_arg* convenience @@ -1354,7 +1363,7 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr, { CORE_ADDR pc = expr->scope; int sel = (int) (uintptr_t) data; - struct probe *pc_probe; + struct bound_probe pc_probe; const struct sym_probe_fns *pc_probe_fns; int n_args; struct frame_info *frame = get_selected_frame (NULL); @@ -1363,10 +1372,10 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr, gdb_assert (sel >= -1); pc_probe = find_probe_by_pc (pc); - if (pc_probe == NULL) + if (pc_probe.probe == NULL) error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc)); - n_args = get_probe_argument_count (pc_probe, frame); + n_args = get_probe_argument_count (pc_probe.probe, frame); if (sel == -1) { @@ -1381,7 +1390,7 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr, error (_("Invalid probe argument %d -- probe has %d arguments available"), sel, n_args); - pc_probe->pops->compile_to_ax (pc_probe, expr, value, sel); + pc_probe.probe->pops->compile_to_ax (pc_probe.probe, expr, value, sel); } @@ -1433,25 +1442,33 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch) the probes, but that is too rare to care. */ static void -stap_set_semaphore (struct probe *probe_generic, struct gdbarch *gdbarch) +stap_set_semaphore (struct probe *probe_generic, struct objfile *objfile, + struct gdbarch *gdbarch) { struct stap_probe *probe = (struct stap_probe *) probe_generic; + CORE_ADDR addr; gdb_assert (probe_generic->pops == &stap_probe_ops); - stap_modify_semaphore (probe->sem_addr, 1, gdbarch); + addr = (probe->sem_addr + + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile))); + stap_modify_semaphore (addr, 1, gdbarch); } /* Clear a SystemTap semaphore. SEM is the semaphore's address. */ static void -stap_clear_semaphore (struct probe *probe_generic, struct gdbarch *gdbarch) +stap_clear_semaphore (struct probe *probe_generic, struct objfile *objfile, + struct gdbarch *gdbarch) { struct stap_probe *probe = (struct stap_probe *) probe_generic; + CORE_ADDR addr; gdb_assert (probe_generic->pops == &stap_probe_ops); - stap_modify_semaphore (probe->sem_addr, 0, gdbarch); + addr = (probe->sem_addr + + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile))); + stap_modify_semaphore (addr, 0, gdbarch); } /* Implementation of `$_probe_arg*' set of variables. */ @@ -1491,7 +1508,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el, ret = obstack_alloc (&objfile->objfile_obstack, sizeof (*ret)); ret->p.pops = &stap_probe_ops; - ret->p.objfile = objfile; + ret->p.arch = gdbarch; /* Provider and the name of the probe. */ ret->p.provider = (char *) &el->data[3 * size]; @@ -1520,13 +1537,9 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el, /* Semaphore address. */ ret->sem_addr = extract_typed_address (&el->data[2 * size], ptr_type); - ret->p.address += (ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)) - + base - base_ref); + ret->p.address += base - base_ref; if (ret->sem_addr != 0) - ret->sem_addr += (ANOFFSET (objfile->section_offsets, - SECT_OFF_DATA (objfile)) - + base - base_ref); + ret->sem_addr += base - base_ref; /* Arguments. We can only extract the argument format if there is a valid name for this probe. */ @@ -1647,18 +1660,6 @@ stap_get_probes (VEC (probe_p) **probesp, struct objfile *objfile) } } -static void -stap_relocate (struct probe *probe_generic, CORE_ADDR delta) -{ - struct stap_probe *probe = (struct stap_probe *) probe_generic; - - gdb_assert (probe_generic->pops == &stap_probe_ops); - - probe->p.address += delta; - if (probe->sem_addr != 0) - probe->sem_addr += delta; -} - static int stap_probe_is_linespec (const char **linespecp) { @@ -1688,7 +1689,7 @@ stap_gen_info_probes_table_values (struct probe *probe_generic, gdb_assert (probe_generic->pops == &stap_probe_ops); - gdbarch = get_objfile_arch (probe->p.objfile); + gdbarch = probe->p.arch; if (probe->sem_addr != 0) val = print_core_address (gdbarch, probe->sem_addr); @@ -1702,7 +1703,7 @@ static const struct probe_ops stap_probe_ops = { stap_probe_is_linespec, stap_get_probes, - stap_relocate, + stap_get_probe_address, stap_get_probe_argument_count, stap_can_evaluate_probe_arguments, stap_evaluate_probe_argument, |