From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: Re: RFC add "convenience functions" to gdb
Date: Sat, 08 Mar 2008 20:24:00 -0000 [thread overview]
Message-ID: <m38x0t107r.fsf@fleche.redhat.com> (raw)
In-Reply-To: <m3od9zhwe5.fsf@fleche.redhat.com> (Tom Tromey's message of "Fri\, 29 Feb 2008 21\:59\:46 -0700")
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> So, this evening I spent some time adding a new "convenience
Tom> function" facility to gdb.
I added a new convenience function, "show". This lets you get at any
gdb "set/show" value in an expression. Mostly, I think, this kind of
thing is useful for conditions in commands.
I've appended the new function, so folks can see it. I could prepare
a new patch if anybody cares.
After writing this I started thinking that it sure would be nice to
have a host-side string type, plus a regex-matching operator. Then
$(caller-matches ...) could be rewritten like:
break func if $(caller-name) =~ $"callerfunction"
I use $"..." to denote a host string.
After this it would be pretty simple to start allowing scripting
access to all kinds of interesting state: string-valued set/show
variables, the exe name, the names of functions up and down the stack,
types, syscalls (whatever happened to that "catch syscall" patch?) --
anything we can think of.
So, I started implementing host strings... but I dunno. Is it worth
doing? Maybe python will solve all the problems -- since what I
really want is a nice, normal, complete programming language with
access to gdb state.
In fact maybe we only need *one* convenience function, $(python ...).
Tom
/* Return the value of a 'set/show' variable. Integer-ish variables
are returned as integers, others as strings. */
static struct value *
show_fn (char *arg)
{
struct cmd_list_element *alias, *prefix, *cmd;
char *newarg;
newarg = concat ("show ", arg, (char *) NULL);
make_cleanup (free, newarg);
if (! lookup_cmd_composition (newarg, &alias, &prefix, &cmd))
error ("could not find variable `%s'", arg);
if (! cmd->var)
error ("`%s' is not a variable", arg);
switch (cmd->var_type)
{
case var_string:
case var_string_noescape:
case var_optional_filename:
case var_filename:
case var_enum:
error ("gdb-internal string type not yet implemented");
case var_boolean:
return value_from_longest (builtin_type_bool, * (int *) cmd->var);
case var_auto_boolean:
{
enum auto_boolean ab = * (enum auto_boolean *) cmd->var;
return value_from_longest (builtin_type_int,
(ab == AUTO_BOOLEAN_TRUE ? 1
: (ab == AUTO_BOOLEAN_FALSE ? 0
: -1)));
}
case var_integer:
case var_uinteger:
case var_zinteger:
return value_from_longest (builtin_type_int, * (int *) cmd->var);
}
error ("programmer error: unhandled type");
}
next prev parent reply other threads:[~2008-03-08 20:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-01 5:50 Tom Tromey
2008-03-01 7:05 ` Tom Tromey
2008-03-08 20:24 ` Tom Tromey [this message]
2008-03-08 20:30 ` Daniel Jacobowitz
2008-03-08 20:35 ` Tom Tromey
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=m38x0t107r.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/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