From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6212 invoked by alias); 5 Dec 2013 06:34:09 -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 6203 invoked by uid 89); 5 Dec 2013 06:34:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_50,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; Thu, 05 Dec 2013 06:34:08 +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 rB56Y0jo027852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 5 Dec 2013 01:34:01 -0500 Received: from psique.redhat.com (ovpn-113-192.phx2.redhat.com [10.3.113.192]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB56XxGq010146; Thu, 5 Dec 2013 01:34:00 -0500 From: Sergio Durigan Junior To: GDB Patches Cc: Sergio Durigan Junior Subject: [PATCH] Use "get_current_arch" instead of "get_objfile_arch" on SystemTap SDT code (and fix ARM bug) Date: Thu, 05 Dec 2013 06:34:00 -0000 Message-Id: <1386225226-18549-1-git-send-email-sergiodj@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00173.txt.bz2 While implementing another patch and testing things on ARM, I found a strange bug (at least initially). There was an expression on some probe's argument that did a displacement of the "fp" register (i.e., "[fp, #-8]"). However, during the evaluation of the parsed expression GDB got confused and could not access the "fp" register due to an invalid address being returned. After a good deal of time spent on the investigation of this, I found that the culprit was the gdbarch being used; it did not provide the correct number of pseudo-registers for the architecture, and thus the internal number of the "fp" register ended up being completely wrong. Then, I began to read the code, and found this on gdb/objfiles.h:struct objfile_per_bfd_storage: /* The gdbarch associated with the BFD. Note that this gdbarch is determined solely from BFD information, without looking at target information. The gdbarch determined from a running target may differ from this e.g. with respect to register types and names. */ struct gdbarch *gdbarch; Well, then the fix became obvious. I replaced all the occurrences of "get_objfile_arch" on gdb/stap-probe.c to "get_current_arch", and voilà. This patch has been tested on both x86_64 Fedora 17 and ARM Fedora 19. 2013-12-05 Sergio Durigan Junior * stap-probe.c (stap_parse_probe_arguments): Use "get_current_arch" instead of "get_objfile_arch". (stap_can_evaluate_probe_arguments): Likewise. (handle_stap_probe): Likewise. (stap_gen_info_probes_table_values): Likewise. --- gdb/ChangeLog | 8 ++++++++ gdb/stap-probe.c | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f5ba7d3..ec56b57 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2013-12-05 Sergio Durigan Junior + + * stap-probe.c (stap_parse_probe_arguments): Use "get_current_arch" + instead of "get_objfile_arch". + (stap_can_evaluate_probe_arguments): Likewise. + (handle_stap_probe): Likewise. + (stap_gen_info_probes_table_values): Likewise. + 2013-12-05 Joel Brobecker Tristan Gingold diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index a734793..3ab54b0 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -917,7 +917,7 @@ static void stap_parse_probe_arguments (struct stap_probe *probe) { const char *cur; - struct gdbarch *gdbarch = get_objfile_arch (probe->p.objfile); + struct gdbarch *gdbarch = get_current_arch (); gdb_assert (!probe->args_parsed); cur = probe->args_u.text; @@ -1086,7 +1086,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 = get_current_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 @@ -1337,7 +1337,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el, { bfd *abfd = objfile->obfd; int size = bfd_get_arch_size (abfd) / 8; - struct gdbarch *gdbarch = get_objfile_arch (objfile); + struct gdbarch *gdbarch = get_current_arch (); struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; CORE_ADDR base_ref; const char *probe_args = NULL; @@ -1540,7 +1540,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 = get_current_arch (); if (probe->sem_addr) val = print_core_address (gdbarch, probe->sem_addr); -- 1.7.11.7