From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12008 invoked by alias); 14 Sep 2006 05:01:00 -0000 Received: (qmail 12000 invoked by uid 22791); 14 Sep 2006 05:00:59 -0000 X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 14 Sep 2006 05:00:55 +0000 Received: from home.wh0rd.org (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id DD9B5646B7 for ; Thu, 14 Sep 2006 05:00:52 +0000 (UTC) Received: (qmail 22334 invoked from network); 14 Sep 2006 01:00:03 -0400 Received: from unknown (HELO vapier) (192.168.0.2) by 192.168.0.1 with SMTP; 14 Sep 2006 01:00:03 -0400 From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [patch ping] change lookup order of $localvars to happen before symbol tables User-Agent: KMail/1.9.4 References: <200608200903.07185.vapier@gentoo.org> <200608212132.30241.vapier@gentoo.org> <20060822013517.GA4935@nevyn.them.org> In-Reply-To: <20060822013517.GA4935@nevyn.them.org> MIME-Version: 1.0 Date: Thu, 14 Sep 2006 05:01:00 -0000 Content-Type: multipart/signed; boundary="nextPart3705156.fURNRquiMS"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200609140100.54614.vapier@gentoo.org> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-09/txt/msg00076.txt.bz2 --nextPart3705156.fURNRquiMS Content-Type: multipart/mixed; boundary="Boundary-01=_GIOCFjU1n+ZFH/7" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_GIOCFjU1n+ZFH/7 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 648 On Monday 21 August 2006 21:35, Daniel Jacobowitz wrote: > On Mon, Aug 21, 2006 at 09:32:29PM -0400, Mike Frysinger wrote: > > hmm, is there a spec somewhere that says what order symbols need to be > > resolved ? how about an alternative option: > > - in write_dollar_variable(), if the symbol starts with a '$', we first > > try to look it up via lookup_internalvar() ... if that fails, we fall > > back to lookup_symbol() and lookup_minimal_symbol() and then jump back to > > the lookup_internalvar() ... > > Hmm... that's also an interesting option. I have no opinion. here's a stab at it then ... i'm sure others have better ideas :) -mike --Boundary-01=_GIOCFjU1n+ZFH/7 Content-Type: text/x-diff; charset="iso-8859-1"; name="gdb-lookup-internal-first.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="gdb-lookup-internal-first.patch" Content-length: 2943 2006-08-21 Mike Frysinger * value.h (lookup_only_internalvar): New prototype. * value.c (lookup_only_internalvar): New function. (lookup_internalvar): Use lookup_only_internalvar. * parse.c (write_dollar_variable): Look up $ symbols in internal table first rather than last. --- gdb/value.h +++ gdb/value.h @@ -419,6 +419,8 @@ extern void set_internalvar_component (s int bitpos, int bitsize, struct value *newvalue); =20 +extern struct internalvar *lookup_only_internalvar (char *name); + extern struct internalvar *lookup_internalvar (char *name); =20 extern int value_equal (struct value *arg1, struct value *arg2); --- gdb/value.c +++ gdb/value.c @@ -741,10 +741,10 @@ init_if_undefined_command (char* args, i normally include a dollar sign. =20 If the specified internal variable does not exist, - one is created, with a void value. */ + the return value is NULL. */ =20 struct internalvar * -lookup_internalvar (char *name) +lookup_only_internalvar (char *name) { struct internalvar *var; =20 @@ -752,6 +752,25 @@ lookup_internalvar (char *name) if (strcmp (var->name, name) =3D=3D 0) return var; =20 + return NULL; +} + + +/* Look up an internal variable with name NAME. NAME should not + normally include a dollar sign. + + If the specified internal variable does not exist, + one is created, with a void value. */ + +struct internalvar * +lookup_internalvar (char *name) +{ + struct internalvar *var; + + var =3D lookup_only_internalvar (name); + if (var) + return var; + var =3D (struct internalvar *) xmalloc (sizeof (struct internalvar)); var->name =3D concat (name, (char *)NULL); var->value =3D allocate_value (builtin_type_void); --- gdb/parse.c +++ gdb/parse.c @@ -486,6 +486,17 @@ write_dollar_variable (struct stoken str if (i >=3D 0) goto handle_register; =20 + /* Any names starting with $ are probably debugger internal variables. = */ + + if (str.ptr[0] =3D=3D '$' && lookup_only_internalvar (copy_name (str) + = 1)) + { +internal_lookup: + write_exp_elt_opcode (OP_INTERNALVAR); + write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1)); + write_exp_elt_opcode (OP_INTERNALVAR); + return; + } + /* On some systems, such as HP-UX and hppa-linux, certain system routine= s=20 have names beginning with $ or $$. Check for those, first. */ =20 @@ -508,12 +519,9 @@ write_dollar_variable (struct stoken str return; } =20 - /* Any other names starting in $ are debugger internal variables. */ - - write_exp_elt_opcode (OP_INTERNALVAR); - write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1)); - write_exp_elt_opcode (OP_INTERNALVAR); - return; + /* Any other names are assumed to be debugger internal variables. */ + + goto internal_lookup; handle_last: write_exp_elt_opcode (OP_LAST); write_exp_elt_longcst ((LONGEST) i); --Boundary-01=_GIOCFjU1n+ZFH/7-- --nextPart3705156.fURNRquiMS Content-Type: application/pgp-signature Content-length: 827 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iQIVAwUARQjiBkFjO5/oN/WBAQLpuRAArm5rlM2Kb70fHtq6xZPfI6RyTYIQahH4 cB3in/e109ACkp4DBD/IEjgUiAVB64/oKw3s/2S51DTL+SrUEIcOXhCq2mMto1Ll EpyWHLh32rojVKviEz7fgw6jJfYh6sqAZoJcI6fjlHqCMm7Maiq8EGdLjqqs7R/v uva26iWX2jfsu5fG6snNtJob6OuR0KVv0Q0XHZs1keHKXSotxaQiv8427xfZ3ays igNgFi2nYA+Hw3ktFiRUPAlthC56OxZ9KZBD54NRFaSvOLDBZaqoiayy1HAAE1cr Tujk3I6QoxUnf50tt+3cbdpWnxTs2RZHbDPNX+TTKKr1PbepBweSqFaZjRZXOjGm 9+9GT3yQ+YeVPWhxDDXpghU/Cy3jX96yURBu5fCQz0AR+KPszj0X3irO7qzCglkz N7DpG7YPN5G0de9KWLv3F+IdAnytMH/ORF325DGPG6rqYmKmxC1NkbkqQCJaa67s 3PWjRFGGGwtimKJEnlODjBftEMkhOYPn7VQrwjzPlvShtcoNirKORxpfHiw3Xufb BsdyOwZDhlbbbOxunx2XGL7rpV4WHxEsu09/oqgdj0rqgC1P9w8J5kEMtHDgqKKq PHE7k+ZZxL5q0cg3LC7FlEPMNS3U9WjH894IQJvqfUEjBK4oTAPyNQX4xUbc8zJp E6HuiMNbAuM= =xPmA -----END PGP SIGNATURE----- --nextPart3705156.fURNRquiMS--