From: Mike Frysinger <vapier@gentoo.org>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch ping] change lookup order of $localvars to happen before symbol tables
Date: Sun, 17 Sep 2006 04:22:00 -0000 [thread overview]
Message-ID: <200609170022.09732.vapier@gentoo.org> (raw)
In-Reply-To: <20060916040222.GA7673@nevyn.them.org>
[-- Attachment #1.1: Type: text/plain, Size: 1189 bytes --]
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 havent
gotten a chance to review" or "people have reviewed just havent posted an
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
case would be calling internal_lookup() ...
if we break up the the lookup_internal() up completely, splitting the creation
of the variable into say "create_internal()", we could kill off the last
linear search
> Would you mind resubmitting with those changes?
sure, ive attached two versions ... the first is just the previous patch with
your requested changes while the second is that plus breaking up the
internal_lookup() function into lookup_only_internal() and
create_internal() ... doesnt matter to me which of these patches are accepted
as they both accomplish my original goal :)
-mike
[-- Attachment #1.2: Type: application/pgp-signature, Size: 827 bytes --]
[-- Attachment #2: gdb-lookup-internal-first-2.patch --]
[-- Type: text/x-diff, Size: 2992 bytes --]
2006-08-21 Mike Frysinger <vapier@gentoo.org>
* 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));
[-- Attachment #3: gdb-lookup-internal-first-3.patch --]
[-- Type: text/x-diff, Size: 3695 bytes --]
2006-08-21 Mike Frysinger <vapier@gentoo.org>
* 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:
next prev parent reply other threads:[~2006-09-17 4:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-20 14:28 only force symbol lookups with local variables on hppa Mike Frysinger
2006-08-20 14:33 ` Mark Kettenis
2006-08-20 14:38 ` Daniel Jacobowitz
2006-08-22 1:35 ` Mark Kettenis
2006-08-22 2:06 ` Daniel Jacobowitz
2006-08-22 18:01 ` Mike Frysinger
2006-08-22 18:21 ` Daniel Jacobowitz
2006-08-22 18:34 ` Mike Frysinger
2006-09-14 5:01 ` [patch ping] change lookup order of $localvars to happen before symbol tables Mike Frysinger
2006-09-16 4:02 ` Daniel Jacobowitz
2006-09-17 4:22 ` Mike Frysinger [this message]
2006-09-17 15:10 ` Daniel Jacobowitz
2006-09-17 20:22 ` Mike Frysinger
2006-09-17 20:28 ` Daniel Jacobowitz
2006-09-27 5:51 ` Mike Frysinger
2007-09-26 19:50 ` Mike Frysinger
2007-10-01 0:37 ` Daniel Jacobowitz
2007-10-01 1:41 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200609170022.09732.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=drow@false.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox