From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17632 invoked by alias); 17 Sep 2006 04:22:01 -0000 Received: (qmail 17624 invoked by uid 22791); 17 Sep 2006 04:22:00 -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; Sun, 17 Sep 2006 04:21:57 +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 947A2645E1 for ; Sun, 17 Sep 2006 04:21:54 +0000 (UTC) Received: (qmail 22687 invoked from network); 17 Sep 2006 00:20:07 -0400 Received: from unknown (HELO vapier) (192.168.0.2) by 192.168.0.1 with SMTP; 17 Sep 2006 00:20:07 -0400 From: Mike Frysinger To: Daniel Jacobowitz Subject: Re: [patch ping] change lookup order of $localvars to happen before symbol tables Date: Sun, 17 Sep 2006 04:22:00 -0000 User-Agent: KMail/1.9.4 Cc: gdb-patches@sourceware.org References: <200608200903.07185.vapier@gentoo.org> <200609140100.54614.vapier@gentoo.org> <20060916040222.GA7673@nevyn.them.org> In-Reply-To: <20060916040222.GA7673@nevyn.them.org> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_x1MDFZTirsQyYh2" Message-Id: <200609170022.09732.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/msg00088.txt.bz2 --Boundary-00=_x1MDFZTirsQyYh2 Content-Type: multipart/signed; boundary="nextPart1846928.DX2hJmoBcl"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart1846928.DX2hJmoBcl Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-length: 1191 On Saturday 16 September 2006 00:02, Daniel Jacobowitz wrote: > Sorry, I'm way behind on patches, and it seems others don't have > much time for review either. no problem ... i just wasnt sure if it was a "people are overloaded and hav= ent=20 gotten a chance to review" or "people have reviewed just havent posted an=20 opinion one way or the other" > Scanning the list of internal variables is linear. Let's not be > wasteful with it; please save the result the first time you do it. indeed ... that would go from 3 internal linear searches to 2 as the final= =20 case would be calling internal_lookup() ... if we break up the the lookup_internal() up completely, splitting the creat= ion=20 of the variable into say "create_internal()", we could kill off the last=20 linear search > Would you mind resubmitting with those changes? sure, ive attached two versions ... the first is just the previous patch wi= th=20 your requested changes while the second is that plus breaking up the=20 internal_lookup() function into lookup_only_internal() and=20 create_internal() ... doesnt matter to me which of these patches are accept= ed=20 as they both accomplish my original goal :) -mike --nextPart1846928.DX2hJmoBcl Content-Type: application/pgp-signature Content-length: 827 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iQIVAwUARQzNcUFjO5/oN/WBAQLoNhAA5d9LozdAXgFIjFCygi5oMFrR2EoGkPzS vOs9gwg8wzoBtuFdcSVLUwRdCppKM8JQVw7f/Amxe+EhI5mNcXLbvl9vMAPC2Xr9 +zQ6WBWCYeBZtoHwuMOD/bED666gdAH03TSiS2Z2zaLFQrhQwwQgZBU6VYlCcNbY QGGiLYFDVrMFJoOxIO/UyY8wo5rYuGw1+GGdDxZhkgiffpPXJvErpN1koYnvYNNH OpKCykyb0ua2Aw/3yq6+RMEcp62+Qy8Aw6EZZIZ8Dn0LbDcvppNgtQDSPicQk8MZ f3O87D4oBdUPMIyuU9WxnaeDwIG8vKaBJ/DDtW7EPIv+EF1yRQe4jK0KchKi42Cg d9Lvd5oj5ymMpNW11fRcl+3RPiuQQ7qRfIfL7bar+VoCjuD6/nSGPzDX4yuYo3nf uoDAMBr4UYcMA1hTQmtEluURe/SJWEeqyRhnFv9LsUsUqSXCxlzEyiG/d9sD4ga5 H0zLsXv3wR7FW9U7BV5Lac6PXHTFns4kTaGeuyzRw/1z/o13UsCy/DzW0g+RDm2R XBAOfcypjmQ9Px1qDu2VuF2I/WFRWpBPur/qrV4de6iSf3bpuuEl5pezXZa2TWMe LEfCBhTrlg1pxOGBvuEtZsOZiK8nT30RJ3zEmPXsqo6UULIJMteScJht64HtkiAy cgxPow/eJMk= =9zHI -----END PGP SIGNATURE----- --nextPart1846928.DX2hJmoBcl-- --Boundary-00=_x1MDFZTirsQyYh2 Content-Type: text/x-diff; charset="iso-8859-1"; name="gdb-lookup-internal-first-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdb-lookup-internal-first-2.patch" Content-length: 2992 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); +extern struct internalvar *lookup_only_internalvar (char *name); + extern struct internalvar *lookup_internalvar (char *name); 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. If the specified internal variable does not exist, - one is created, with a void value. */ + the return value is NULL. */ struct internalvar * -lookup_internalvar (char *name) +lookup_only_internalvar (char *name) { struct internalvar *var; @@ -752,6 +752,25 @@ lookup_internalvar (char *name) if (strcmp (var->name, name) == 0) return var; + 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 = lookup_only_internalvar (name); + if (var) + return var; + var = (struct internalvar *) xmalloc (sizeof (struct internalvar)); var->name = concat (name, (char *)NULL); var->value = allocate_value (builtin_type_void); --- gdb/parse.c +++ gdb/parse.c @@ -448,6 +448,7 @@ write_dollar_variable (struct stoken str { struct symbol *sym = NULL; struct minimal_symbol *msym = NULL; + struct internalvar *isym = NULL; /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) and $$digits (equivalent to $<-digits> if you could type that). */ @@ -486,6 +487,17 @@ write_dollar_variable (struct stoken str if (i >= 0) goto handle_register; + /* Any names starting with $ are probably debugger internal variables. */ + + isym = lookup_only_internalvar (copy_name (str) + 1); + if (isym) + { + write_exp_elt_opcode (OP_INTERNALVAR); + write_exp_elt_intern (isym); + write_exp_elt_opcode (OP_INTERNALVAR); + return; + } + /* On some systems, such as HP-UX and hppa-linux, certain system routines have names beginning with $ or $$. Check for those, first. */ @@ -508,7 +520,7 @@ write_dollar_variable (struct stoken str return; } - /* Any other names starting in $ are debugger internal variables. */ + /* Any other names are assumed to be debugger internal variables. */ write_exp_elt_opcode (OP_INTERNALVAR); write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1)); --Boundary-00=_x1MDFZTirsQyYh2 Content-Type: text/x-diff; charset="iso-8859-1"; name="gdb-lookup-internal-first-3.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdb-lookup-internal-first-3.patch" Content-length: 3695 2006-08-21 Mike Frysinger * value.h (lookup_only_internalvar): New prototype. (create_internalvar): Likewise. * value.c (lookup_only_internalvar): New function. (create_internalvar): Likewise. (lookup_internalvar): Use new lookup_only_internalvar and create_internalvar functions. * parse.c (write_dollar_variable): Look up $ symbols in internal table first rather than last. --- gdb/value.h +++ gdb/value.h @@ -419,6 +419,10 @@ extern void set_internalvar_component (s int bitpos, int bitsize, struct value *newvalue); +extern struct internalvar *lookup_only_internalvar (char *name); + +extern struct internalvar *create_internalvar (char *name); + extern struct internalvar *lookup_internalvar (char *name); 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. If the specified internal variable does not exist, - one is created, with a void value. */ + the return value is NULL. */ struct internalvar * -lookup_internalvar (char *name) +lookup_only_internalvar (char *name) { struct internalvar *var; @@ -752,6 +752,17 @@ lookup_internalvar (char *name) if (strcmp (var->name, name) == 0) return var; + return NULL; +} + + +/* Create an internal variable with name NAME and with a void value. + NAME should not normally include a dollar sign. */ + +struct internalvar * +create_internalvar (char *name) +{ + struct internalvar *var; var = (struct internalvar *) xmalloc (sizeof (struct internalvar)); var->name = concat (name, (char *)NULL); var->value = allocate_value (builtin_type_void); @@ -762,6 +773,25 @@ lookup_internalvar (char *name) return var; } + +/* 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 = lookup_only_internalvar (name); + if (var) + return var; + + return create_internalvar (name); +} + struct value * value_of_internalvar (struct internalvar *var) { --- gdb/parse.c +++ gdb/parse.c @@ -448,6 +448,7 @@ write_dollar_variable (struct stoken str { struct symbol *sym = NULL; struct minimal_symbol *msym = NULL; + struct internalvar *isym = NULL; /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) and $$digits (equivalent to $<-digits> if you could type that). */ @@ -486,6 +487,17 @@ write_dollar_variable (struct stoken str if (i >= 0) goto handle_register; + /* Any names starting with $ are probably debugger internal variables. */ + + isym = lookup_only_internalvar (copy_name (str) + 1); + if (isym) + { + write_exp_elt_opcode (OP_INTERNALVAR); + write_exp_elt_intern (isym); + write_exp_elt_opcode (OP_INTERNALVAR); + return; + } + /* On some systems, such as HP-UX and hppa-linux, certain system routines have names beginning with $ or $$. Check for those, first. */ @@ -508,10 +520,10 @@ write_dollar_variable (struct stoken str return; } - /* Any other names starting in $ are debugger internal variables. */ + /* Any other names are assumed to be debugger internal variables. */ write_exp_elt_opcode (OP_INTERNALVAR); - write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1)); + write_exp_elt_intern (create_internalvar (copy_name (str) + 1)); write_exp_elt_opcode (OP_INTERNALVAR); return; handle_last: --Boundary-00=_x1MDFZTirsQyYh2--