This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Sanitize gdbarch access on probe/SDT API
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>, Tom Tromey <tromey at redhat dot com>
- Date: Fri, 06 Dec 2013 13:49:19 -0200
- Subject: Re: [PATCH] Sanitize gdbarch access on probe/SDT API
- Authentication-results: sourceware.org; auth=none
- References: <1386225226-18549-1-git-send-email-sergiodj at redhat dot com> <52A079DD dot 5050101 at redhat dot com> <m361r3hrrf dot fsf_-_ at redhat dot com> <52A1D61E dot 1050707 at redhat dot com>
On Friday, December 06 2013, Pedro Alves wrote:
> On 12/05/2013 10:12 PM, Sergio Durigan Junior wrote:
>> @@ -1461,6 +1466,8 @@ stap_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
>> bfd_vma base;
>> struct sdt_note *iter;
>> unsigned save_probesp_len = VEC_length (probe_p, *probesp);
>> + struct regcache *regcache = get_current_regcache ();
>> + struct gdbarch *gdbarch = get_regcache_arch (regcache);
>
> AFAICS, stap_get_probes isn't called when evaluating a probe,
> but instead when getting the list of probes out of an objfile.
Right.
> Seems to me like this function is reachable even if the inferior
> is not running yet. Is that why you couldn't use
> get_selected_frame here? (because there's no frame?)
Right.
> If so, using get_current_regcache is wrong. If there's no thread at
> all, then what does the regcache of the current thread mean?
Indeed. Now that you put it that way, it makes total sense.
> It sounds like you just managed to use it becauese
> get_current_regcache doesn't error out when inferior_ptid is pointing
> nowhere.
OK, interesting.
> As this is listing the probes in the objfile, and not using the
>target's registers (afaics), can you use the objfile's arch here?
Yes, I guess that's the best solution indeed.
> 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?
--
Sergio