From patchwork Thu Feb 25 13:25:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tremblay X-Patchwork-Id: 11080 Received: (qmail 128927 invoked by alias); 25 Feb 2016 13:25:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 128908 invoked by uid 89); 25 Feb 2016 13:25:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=0xffff, 3089, sk:native-, sk:native X-HELO: usplmg21.ericsson.net Received: from usplmg21.ericsson.net (HELO usplmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 25 Feb 2016 13:25:55 +0000 Received: from EUSAAHC008.ericsson.se (Unknown_Domain [147.117.188.96]) by usplmg21.ericsson.net (Symantec Mail Security) with SMTP id BA.16.32102.6C00FC65; Thu, 25 Feb 2016 14:25:26 +0100 (CET) Received: from elxa4wqvvz1.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.96) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 25 Feb 2016 08:25:52 -0500 From: Antoine Tremblay To: CC: Antoine Tremblay Subject: [PATCH] Map registers to remote numbers when encoding an ax_reg or ax_reg_mask operation Date: Thu, 25 Feb 2016 08:25:45 -0500 Message-ID: <1456406745-27854-1-git-send-email-antoine.tremblay@ericsson.com> MIME-Version: 1.0 X-IsSubscribed: yes When encoding the agent expression operation ax_reg or ax_reg_mask, the register number used is internal to GDB. However GDBServer expects a tdesc based number. This usually does not cause a problem since at the moment, for raw registers GDBServer R trace action ignores the register mask and just collects all registers. It can be a problem, however with pseudo registers on some platforms if the tdesc number doesn't match the GDB internal register number. This is the case with ARM, the upcoming ARM tracepoint support, fails these test cases without this patch: gdb.trace/collection.exp: collect register locals collectively:* GDBSever would exit with: unhandled register size Since the register number is not mapped. This patch fixes these issues by calling gdbarch_remote_register_number before encoding the register number in the ax_reg or ax_reg_mask operation. Tested on x86 native-gdbserver no regressions observed. --- gdb/ax-general.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gdb/ax-general.c b/gdb/ax-general.c index 30f90e8..eb0e6fc 100644 --- a/gdb/ax-general.c +++ b/gdb/ax-general.c @@ -308,6 +308,9 @@ ax_reg (struct agent_expr *x, int reg) } else { + /* Get the remote register number. */ + reg = gdbarch_remote_register_number (x->gdbarch, reg); + /* Make sure the register number is in range. */ if (reg < 0 || reg > 0xffff) error (_("GDB bug: ax-general.c (ax_reg): " @@ -456,7 +459,11 @@ ax_reg_mask (struct agent_expr *ax, int reg) } else { - int byte = reg / 8; + int byte = 0; + + /* Get the remote register number. */ + reg = gdbarch_remote_register_number (ax->gdbarch, reg); + byte = reg / 8; /* Grow the bit mask if necessary. */ if (byte >= ax->reg_mask_len)