From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126921 invoked by alias); 26 Jan 2016 14:58:59 -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 126905 invoked by uid 89); 26 Jan 2016 14:58:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=nit, xxx X-HELO: e06smtp06.uk.ibm.com Received: from e06smtp06.uk.ibm.com (HELO e06smtp06.uk.ibm.com) (195.75.94.102) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 26 Jan 2016 14:58:56 +0000 Received: from localhost by e06smtp06.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 26 Jan 2016 14:58:53 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp06.uk.ibm.com (192.168.101.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 26 Jan 2016 14:58:51 -0000 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: arnez@linux.vnet.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4F1E117D8062 for ; Tue, 26 Jan 2016 14:58:59 +0000 (GMT) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0QEwpOt22151336 for ; Tue, 26 Jan 2016 14:58:51 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u0QEwoRv020294 for ; Tue, 26 Jan 2016 07:58:50 -0700 Received: from oc1027705133.ibm.com (dyn-9-152-212-180.boeblingen.de.ibm.com [9.152.212.180]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u0QEwohO020244 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 26 Jan 2016 07:58:50 -0700 From: Andreas Arnez To: Marcin =?utf-8?Q?Ko=C5=9Bcielnicki?= Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/8] gdb: Add write_guessed_tracepoint_pc hook to gdbarch. References: <1453637529-26972-1-git-send-email-koriakin@0x04.net> <1453637529-26972-2-git-send-email-koriakin@0x04.net> Date: Tue, 26 Jan 2016 14:58:00 -0000 In-Reply-To: <1453637529-26972-2-git-send-email-koriakin@0x04.net> ("Marcin \=\?utf-8\?Q\?Ko\=C5\=9Bcielnicki\=22's\?\= message of "Sun, 24 Jan 2016 13:12:02 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16012614-0025-0000-0000-000005A6A6E1 X-IsSubscribed: yes X-SW-Source: 2016-01/txt/msg00657.txt.bz2 On Sun, Jan 24 2016, Marcin Ko=C5=9Bcielnicki wrote: > When we're looking at a tracefile trace frame where registers are not > available, and the tracepoint has only one location, we supply > the location's address as the PC register. However, this only works > if PC is not a pseudo register. Add a gdbarch hook that will handle > that for pseudo registers. > diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh > index 4ac6b90..b67ea72 100755 > --- a/gdb/gdbarch.sh > +++ b/gdb/gdbarch.sh > @@ -417,6 +417,7 @@ v:int:char_signed:::1:-1:1 > # > F:CORE_ADDR:read_pc:struct regcache *regcache:regcache > F:void:write_pc:struct regcache *regcache, CORE_ADDR val:regcache, val > +F:void:write_guessed_tracepoint_pc:struct regcache *regcache, CORE_ADDR = val:regcache, val Rather than write_guessed_tracepoint_pc, maybe the method could be named more generically, like "supply_pc"? Also, a comment describing the method's purpose and interface would be nice, particularly how it differs from the "write_pc" method or from regcache_write_pc(). > # Function for getting target's idea of a frame pointer. FIXME: GDB's > # whole scheme for dealing with "frames" and "frame pointers" needs a > # serious shakedown. > diff --git a/gdb/tracefile.c b/gdb/tracefile.c > index fef4ed9..7c2649d 100644 > --- a/gdb/tracefile.c > +++ b/gdb/tracefile.c > @@ -396,16 +396,18 @@ tracefile_fetch_registers (struct regcache *regcach= e, int regno) > as the address of the tracepoint. */ > pc_regno =3D gdbarch_pc_regnum (gdbarch); >=20=20 > - /* XXX This guessing code below only works if the PC register isn't > - a pseudo-register. The value of a pseudo-register isn't stored > - in the (non-readonly) regcache -- instead it's recomputed > - (probably from some other cached raw register) whenever the > - register is read. This guesswork should probably move to some > - higher layer. */ I wonder whether the last statement in this comment still applies? > - if (pc_regno < 0 || pc_regno >=3D gdbarch_num_regs (gdbarch)) > + if (pc_regno < 0) > return; >=20=20 > - if (regno =3D=3D -1 || regno =3D=3D pc_regno) > + /* We try to guess PC if: > + > + 1) We want all registers, or > + 2) PC is a real register, and we want exactly it, or > + 3) PC is a pseudo register (we don't know which real register it > + corresponds to, so let's try to play safe). */ > + > + if (regno =3D=3D -1 || regno =3D=3D pc_regno || > + pc_regno >=3D gdbarch_num_regs (gdbarch)) > { > struct tracepoint *tp =3D get_tracepoint (get_tracepoint_number ()= ); > gdb_byte *regs; > @@ -429,11 +431,23 @@ tracefile_fetch_registers (struct regcache *regcach= e, int regno) > return; > } >=20=20 > - regs =3D (gdb_byte *) alloca (register_size (gdbarch, pc_regno)); > - store_unsigned_integer (regs, register_size (gdbarch, pc_regno), > - gdbarch_byte_order (gdbarch), > - tp->base.loc->address); > - regcache_raw_supply (regcache, pc_regno, regs); > + if (pc_regno >=3D gdbarch_num_regs (gdbarch)) > + { > + /* PC is a pseudo, let gdbarch deal with that. If it doesn't > + know how, just bail. */ Nit: The indentation space of this line and the second one below contains 8 consecutive spaces where a tab could be used instead. This occurs several times in the patch series. > + if (gdbarch_write_guessed_tracepoint_pc_p (gdbarch)) > + gdbarch_write_guessed_tracepoint_pc (gdbarch, regcache, > + tp->base.loc->address); > + } > + else > + { > + /* PC is a real register. */ > + regs =3D (gdb_byte *) alloca (register_size (gdbarch, pc_regno)); > + store_unsigned_integer (regs, register_size (gdbarch, pc_regno), > + gdbarch_byte_order (gdbarch), > + tp->base.loc->address); > + regcache_raw_supply (regcache, pc_regno, regs); > + } > } > } > }