[PATCH] Sanitize gdbarch access on probe/SDT API

Pedro Alves palves@redhat.com
Fri Dec 6 16:00:00 GMT 2013


On 12/06/2013 03:49 PM, Sergio Durigan Junior wrote:
>> > With that out of the way, would it work to pass the frame pointer down
>> >instead of the gdbarch?
> You mean that the callers should pass the frame pointers, instead of the
> relying on the callees to get it by themselves?

Something like that.  I meant, the patch added a gdbarch parameter to
a few functions, and then passes get_frame_arch (frame) down.

 fetch_probe_arguments (struct value **arg0, struct value **arg1)
 {
   struct frame_info *frame = get_selected_frame (_("No frame selected"));
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   CORE_ADDR pc = get_frame_pc (frame);
   struct probe *pc_probe;
   const struct sym_probe_fns *pc_probe_fns;
...
+    *arg0 = pc_probe_fns->sym_evaluate_probe_argument (pc_probe, 0, gdbarch);
+  *arg1 = pc_probe_fns->sym_evaluate_probe_argument (pc_probe, 1, gdbarch);

etc. etc.  I'm wondering whether after making that spot discussed
use the probe's obfile's arch, which I think already it has handy
through the probe pointer, we can pass down the frame pointer instead
of the gdbarch pointer:

 fetch_probe_arguments (struct value **arg0, struct value **arg1)
 {
   struct frame_info *frame = get_selected_frame (_("No frame selected"));
   CORE_ADDR pc = get_frame_pc (frame);
   struct probe *pc_probe;
   const struct sym_probe_fns *pc_probe_fns;
...
+    *arg0 = pc_probe_fns->sym_evaluate_probe_argument (pc_probe, 0, frame);
+  *arg1 = pc_probe_fns->sym_evaluate_probe_argument (pc_probe, 1, frame);

etc.  That would make the intention of the code clearer, I think, as
that way we don't need to explain that much what the gdbarch is for,
and where it must come from.

-- 
Pedro Alves



More information about the Gdb-patches mailing list