Message ID | 1405520243-17282-4-git-send-email-gbenson@redhat.com |
---|---|
State | Changes Requested, archived |
Headers |
Received: (qmail 11637 invoked by alias); 16 Jul 2014 16:48:20 -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 11628 invoked by uid 89); 16 Jul 2014 16:48:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 16 Jul 2014 16:48:18 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6GGJadh006104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Jul 2014 12:19:36 -0400 Received: from blade.nx (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6GGJZ3V003254; Wed, 16 Jul 2014 12:19:35 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id C4B2E2640C9; Wed, 16 Jul 2014 15:17:30 +0100 (BST) From: Gary Benson <gbenson@redhat.com> To: gdb-patches@sourceware.org Cc: Tom Tromey <tromey@redhat.com>, Doug Evans <dje@google.com> Subject: [PATCH 03/15 v2] Make gdbserver CORE_ADDR unsigned Date: Wed, 16 Jul 2014 15:17:11 +0100 Message-Id: <1405520243-17282-4-git-send-email-gbenson@redhat.com> In-Reply-To: <1405520243-17282-1-git-send-email-gbenson@redhat.com> References: <1405520243-17282-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes |
Commit Message
Gary Benson
July 16, 2014, 2:17 p.m. UTC
gdbserver defines CORE_ADDR to be signed. This seems erroneous to me; and furthermore likely to cause problems in common/, as it is different from gdb's definition. gdb/gdbserver/ 2014-07-16 Tom Tromey <tromey@redhat.com> Gary Benson <gbenson@redhat.com> * server.h (CORE_ADDR): Now unsigned. --- gdb/gdbserver/ChangeLog | 5 +++++ gdb/gdbserver/server.h | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-)
Comments
On Wed, Jul 16, 2014 at 7:17 AM, Gary Benson <gbenson@redhat.com> wrote: > gdbserver defines CORE_ADDR to be signed. This seems erroneous to > me; and furthermore likely to cause problems in common/, as it is > different from gdb's definition. > > gdb/gdbserver/ > 2014-07-16 Tom Tromey <tromey@redhat.com> > Gary Benson <gbenson@redhat.com> > > * server.h (CORE_ADDR): Now unsigned. LGTM
The only issue that I think might come out of this is that on MIPS, addresses are signed, so pointers are sign extended. But we can definitely handle whatever fallout this may cause, if any, when we see it. Clearly if GDB's native targets can handle that, so should gdbserver's, and in any case the issue should be pretty localized. Just pointing it out FYI, to keep an eye out for it.
On Thu, 17 Jul 2014, Pedro Alves wrote: > The only issue that I think might come out of this is > that on MIPS, addresses are signed, so pointers are sign > extended. But we can definitely handle whatever fallout this > may cause, if any, when we see it. Clearly if GDB's native > targets can handle that, so should gdbserver's, and in any > case the issue should be pretty localized. Just pointing it > out FYI, to keep an eye out for it. Also SH64 AFAICT, it defines `elf_backend_sign_extend_vma' to true in bfd/elf32-sh64.c. We have the following comment in gdb/mips-tdep.c: /* MIPS believes that the PC has a sign extended value. Perhaps the all registers should be sign extended for simplicity? */ which is of course true in that we need to sign-extend all integer registers (that includes GPRs and CP0 registers; maybe some control registers as well); where applicable that is, i.e. debugging a strict 32-bit ABI on 64-bit hardware. Then on the other hand the values in these registers should already have been truncated to 32 bits and then sign-extended before they have been written in the first place. Overall it's tricky, hardware does not always enforce proper sign-extension required by the ABI, e.g. an o32 kernel-mode program is free to set GPRs or the PC to a value outside the range supported by the ABI (the Linux kernel sometimes takes advantage of this possibility), and we have no way I believe to make the user aware of this happening, while that might be The Bug they're after. Maciej
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index 6eb1a16..2d55513 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -87,7 +87,7 @@ typedef unsigned char gdb_byte; /* FIXME: This should probably be autoconf'd for. It's an integer type at least the size of a (void *). */ -typedef long long CORE_ADDR; +typedef unsigned long long CORE_ADDR; typedef long long LONGEST; typedef unsigned long long ULONGEST;