From 08a6411c715c2d8bf31d5a5c8a477fa4651639aa Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Tue, 10 Dec 2013 23:53:25 -0200 Subject: Sanitize access to gdbarch on the SDT probe API (and fix ARM bug) This patch sanitizes the access to gdbarch made by various functions of the SDT probe API. Before this patch, gdbarch was being accessed via the probe's objfile; however, this proved to cause a bug on 32-bit ARM targets because during the parsing of the probe's arguments the code needed to access some pseudo-registers of the architecture, and this information is not fully correct on the objfile's gdbarch. Basically, the approach taken was to instead pass the current/selected frame to the parsing and evaluation functions, so that they can extract the gdbarch directly from the frame. It solved the ARM bug reported above, and also contributed to make the API cleaner. Tested on x86_64 and 32-bit ARM. 2013-12-11 Sergio Durigan Junior * break-catch-throw.c (fetch_probe_arguments): Pass selected frame to get_probe_argument_count and evaluate_probe_argument. * probe.c (get_probe_argument_count): Adjust declaration to accept frame. Pass frame to probe_ops's get_probe_argument_count. (evaluate_probe_argument): Likewise, for evaluate_probe_argument. (probe_safe_evaluate_at_pc): Pass frame to get_probe_argument_count and evaluate_probe_argument. * probe.h (struct probe_ops) : Adjust declarations to accept frame. (get_probe_argument_count, evaluate_probe_argument): Likewise. * solib-svr4.c (solib_event_probe_action): Get current frame. Pass it to get_probe_argument_count. (svr4_handle_solib_event): Get current frame. Pass it to get_probe_argument_count and evaluate_probe_argument. * stap-probe.c (stap_parse_probe_arguments): Adjust declaration to accept gdbarch. Do not obtain it from the probe's objfile. (stap_get_probe_argument_count): Adjust declaration to accept frame. Obtain gdbarch from the frame. Call generic can_evaluate_probe_arguments. Pass gdbarch to stap_parse_probe_arguments. (stap_get_arg): Adjust declaration to accept gdbarch. Pass it to stap_parse_probe_arguments. (stap_evaluate_probe_argument): Adjust declaration to accept frame. Obtain gdbarch from the frame. Pass gdbarch to stap_get_arg. (stap_compile_to_ax): Pass agent_expr's gdbarch to stap_get_arg. (compute_probe_arg): Obtain gdbarch from frame. Pass frame to get_probe_argument_count and evaluate_probe_argument. --- gdb/probe.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'gdb/probe.c') diff --git a/gdb/probe.c b/gdb/probe.c index c1e0111..8dad364 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -614,9 +614,9 @@ info_probes_command (char *arg, int from_tty) /* See comments in probe.h. */ unsigned -get_probe_argument_count (struct probe *probe) +get_probe_argument_count (struct probe *probe, struct frame_info *frame) { - return probe->pops->get_probe_argument_count (probe); + return probe->pops->get_probe_argument_count (probe, frame); } /* See comments in probe.h. */ @@ -630,9 +630,10 @@ can_evaluate_probe_arguments (struct probe *probe) /* See comments in probe.h. */ struct value * -evaluate_probe_argument (struct probe *probe, unsigned n) +evaluate_probe_argument (struct probe *probe, unsigned n, + struct frame_info *frame) { - return probe->pops->evaluate_probe_argument (probe, n); + return probe->pops->evaluate_probe_argument (probe, n, frame); } /* See comments in probe.h. */ @@ -647,11 +648,11 @@ probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n) if (!probe) return NULL; - n_args = get_probe_argument_count (probe); + n_args = get_probe_argument_count (probe, frame); if (n >= n_args) return NULL; - return evaluate_probe_argument (probe, n); + return evaluate_probe_argument (probe, n, frame); } /* See comment in probe.h. */ -- cgit v1.1