From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24646 invoked by alias); 6 Dec 2013 13:50:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 24637 invoked by uid 89); 6 Dec 2013 13:50:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Dec 2013 13:50:34 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB6DoO7F004161 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 6 Dec 2013 08:50:27 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB6DoNgJ008695; Fri, 6 Dec 2013 08:50:23 -0500 Message-ID: <52A1D61E.1050707@redhat.com> Date: Fri, 06 Dec 2013 13:50:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Sergio Durigan Junior CC: GDB Patches , Tom Tromey Subject: Re: [PATCH] Sanitize gdbarch access on probe/SDT API References: <1386225226-18549-1-git-send-email-sergiodj@redhat.com> <52A079DD.5050101@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-12/txt/msg00245.txt.bz2 > I tried to use get_selected_frame whenever I could, and when I couldn't, > I used get_current_regcache. But what does "couldn't" mean? Looking at the function that uses get_current_regcache: 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. 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?) 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? It sounds like you just managed to use it becauese get_current_regcache doesn't error out when inferior_ptid is pointing nowhere. 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? With that out of the way, would it work to pass the frame pointer down instead of the gdbarch? > if (objfile->separate_debug_objfile_backlink != NULL) > { > @@ -1486,7 +1493,7 @@ stap_get_probes (VEC (probe_p) **probesp, struct objfile *objfile) > { > /* We first have to handle all the information about the > probe which is present in the section. */ > - handle_stap_probe (objfile, iter, probesp, base); > + handle_stap_probe (objfile, iter, probesp, base, gdbarch); > } -- Pedro Alves