Message ID | 1456406745-27854-1-git-send-email-antoine.tremblay@ericsson.com |
---|---|
State | New, archived |
Headers |
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: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> 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 <antoine.tremblay@ericsson.com> To: <gdb-patches@sourceware.org> CC: Antoine Tremblay <antoine.tremblay@ericsson.com> 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 Content-Type: text/plain X-IsSubscribed: yes |
Commit Message
Antoine Tremblay
Feb. 25, 2016, 1:25 p.m. UTC
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(-)
Comments
On 02/25/2016 01:25 PM, Antoine Tremblay wrote: > 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. > else > { > - int byte = reg / 8; > + int byte = 0; No need to zero initialize. > + > + /* 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) > OK with ChangeLog entry. Thanks, Pedro Alves
Pedro Alves writes: > On 02/25/2016 01:25 PM, Antoine Tremblay wrote: >> 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. > >> else >> { >> - int byte = reg / 8; >> + int byte = 0; > > No need to zero initialize. OK. > >> + >> + /* 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) >> > > OK with ChangeLog entry. Oops, yes I'll add a ChangeLog sorry about that. Thanks, Antoine
Antoine Tremblay writes: > Pedro Alves writes: > >> On 02/25/2016 01:25 PM, Antoine Tremblay wrote: >>> 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. >> >>> else >>> { >>> - int byte = reg / 8; >>> + int byte = 0; >> >> No need to zero initialize. > > OK. > >> >>> + >>> + /* 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) >>> >> >> OK with ChangeLog entry. > > Oops, yes I'll add a ChangeLog sorry about that. > Pushed.
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)