From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123244 invoked by alias); 23 Nov 2016 12:02:16 -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 123184 invoked by uid 89); 23 Nov 2016 12:02:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Richards, richards, Henderson, henderson 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 ESMTP; Wed, 23 Nov 2016 12:02:04 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 177CE6AD0; Wed, 23 Nov 2016 12:02:03 +0000 (UTC) Received: from [127.0.0.1] (ovpn03.gateway.prod.ext.phx2.redhat.com [10.5.9.3]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uANC1xrU001655; Wed, 23 Nov 2016 07:01:59 -0500 Subject: Re: [PATCH 2/2] amd64-linux: expose system register FS_BASE and GS_BASE for Linux. To: Walfred Tedeschi , eliz@gnu.org, brobecker@adacore.com References: <1478166445-21370-1-git-send-email-walfred.tedeschi@intel.com> <1478166445-21370-3-git-send-email-walfred.tedeschi@intel.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <4278085b-7272-47b5-047a-fd9f08a843dd@redhat.com> Date: Wed, 23 Nov 2016 12:02:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1478166445-21370-3-git-send-email-walfred.tedeschi@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-11/txt/msg00664.txt.bz2 On 11/03/2016 09:47 AM, Walfred Tedeschi wrote: > This patch allows examination of the registers FS_BASE and GS_BASE > for Linux Systems running on 64bit. Tests for simple read and write > of the new registers is also added with this patch. > > Tests were performed on: > x86_64 RHEL 5.3 - For the older ptrace calls. > x86_64 Ubuntu 16.10 - For the new ptrace calls. > > 2016-04-26 Walfred Tedeschi > Richard Henderson What changed compared to Richard's original version? > > diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c > index 3f2a92b..a8a0b79 100644 > --- a/gdb/amd64-linux-tdep.c > +++ b/gdb/amd64-linux-tdep.c > @@ -103,7 +103,14 @@ int amd64_linux_gregset_reg_offset[] = > -1, -1, -1, -1, -1, -1, -1, -1, > -1, -1, -1, -1, -1, -1, -1, -1, > -1, -1, -1, -1, -1, -1, -1, -1, > + /* System register added at the end. */ > +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE > + 21 * 8, 22 * 8, /* fs_base and gs_base. */ > +#else > + -1, -1, /* fs_base and gs_base. */ > +#endif > 15 * 8 /* "orig_rax" */ > + Spurious new line? How's this meant to work for cross debugging, and core debugging? I don't think it makes sense to put a host-specific "#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE" check in a tdep file. > diff --git a/gdb/features/Makefile b/gdb/features/Makefile > index 30eed5d..c87f29f 100644 > --- a/gdb/features/Makefile > +++ b/gdb/features/Makefile > @@ -259,7 +259,7 @@ $(outdir)/i386/i386-linux.dat: i386/32bit-core.xml i386/32bit-sse.xml \ > i386/32bit-linux.xml > $(outdir)/i386/amd64.dat: i386/64bit-core.xml i386/64bit-sse.xml > $(outdir)/i386/amd64-linux.dat: i386/64bit-core.xml i386/64bit-sse.xml \ > - i386/64bit-linux.xml > + i386/64bit-linux.xml i386/64bit-segments.xml > $(outdir)/i386/i386-avx.dat: i386/32bit-core.xml i386/32bit-avx.xml > $(outdir)/i386/i386-avx-linux.dat: i386/32bit-core.xml i386/32bit-avx.xml \ > i386/32bit-linux.xml > @@ -279,11 +279,11 @@ $(outdir)/i386/i386-mmx.dat: i386/32bit-core.xml > $(outdir)/i386/i386-mmx-linux.dat: i386/32bit-core.xml i386/32bit-linux.xml > $(outdir)/i386/amd64-avx.dat: i386/64bit-core.xml i386/64bit-avx.xml > $(outdir)/i386/amd64-avx-linux.dat: i386/64bit-core.xml i386/64bit-avx.xml \ > - i386/64bit-linux.xml > + i386/64bit-linux.xml i386/64bit-segments.xml Is indentation on these two changes above correct? Can't tell from the mail client. > +++ b/gdb/features/i386/64bit-segments.xml > @@ -0,0 +1,12 @@ > + > + > + > + > + > + > + #1 - Why is "regnum" hard coded? #2 - Is bitsize 64 and type "int" really correct? > --- a/gdb/gdbserver/linux-x86-low.c > +++ b/gdb/gdbserver/linux-x86-low.c > @@ -133,6 +133,11 @@ static const int x86_64_regmap[] = > -1, > -1, -1, -1, -1, -1, -1, -1, -1, > ORIG_RAX * 8, > +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE > + 21 * 8, 22 * 8, > +#else > + -1, -1, > +#endif > -1, -1, -1, -1, /* MPX registers BND0 ... BND3. */ It's curious that above this was put after orig_rax, while here: --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -103,7 +103,14 @@ int amd64_linux_gregset_reg_offset[] = -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + /* System register added at the end. */ +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE + 21 * 8, 22 * 8, /* fs_base and gs_base. */ +#else + -1, -1, /* fs_base and gs_base. */ +#endif 15 * 8 /* "orig_rax" */ + It was put before. > +++ b/gdb/testsuite/gdb.arch/amd64-gs_base.c > @@ -0,0 +1,33 @@ > +/* Unwinder test program for fs_base and gs_base. What aspect of the unwinder is being tested? > + > +int > +func (int a) > +{ > + return a * a; > +} > + > +int > +main (void) > +{ > + volatile int a; > + a = 10; > + a = func (a); Is any of this relevant for the test? > + return a; > +} > diff --git a/gdb/testsuite/gdb.arch/amd64-gs_base.exp b/gdb/testsuite/gdb.arch/amd64-gs_base.exp > new file mode 100644 > index 0000000..ccd6b87 > --- /dev/null > +++ b/gdb/testsuite/gdb.arch/amd64-gs_base.exp > @@ -0,0 +1,57 @@ > +# Copyright 2016 Free Software Foundation, Inc. > + > +# This file is part of the GDB testsuite. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +if { ![istarget "x86_64-*linux*"] } then { > + verbose "Skipping x86_64 fs_base and gs_base tests." > + return > +} > + > +standard_testfile > + > +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ > + executable { debug }] != "" } { > + untested ${testfile}.exp > + return -1 > +} > + > + > + > +gdb_exit > +gdb_start > +gdb_reinitialize_dir $srcdir/$subdir > +gdb_load ${binfile} > + > +runto func > + Use prepare_for_testing and handle runto failure. > +gdb_test "info register sys" $info_reg_out\ > + "info registers fs_base and gs_base with value " Spurious space after "value". Thanks, Pedro Alves