This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: using perl in gdbinit
- To: Edward Peschko <edwardp at excitehome dot net>
- Subject: Re: using perl in gdbinit
- From: Keith Seitz <keiths at cygnus dot com>
- Date: Wed, 28 Feb 2001 07:49:35 -0800 (PST)
- cc: gdb at sourceware dot cygnus dot com
On Tue, 27 Feb 2001, Edward Peschko wrote:
> I'd like to use perl in gdbinit to make gdb commands and bind them to a key.
> So I could say stuff like:
>
> local($/) = undef;
> my $functions = `info functions`;
[snip]
I would guess that you should be able to add a perl interpreter to gdb. I
don't know a whole lot about how perl was written, but if there is a way
to create your own perl interpreter like this:
init_perl ()
{
g_interp = Perl_New_Interpreter ();
}
You should be able to do what you want (albeit in a hacky kind of way).
For insight, we added a tcl interpreter and bound tcl's command parser to
the gdb command "tk". We also have a tcl command, "gdb_cmd", which can be
used to execute gdb commands in the tcl interpreter.
I could do things like what you want above (although I never have):
(gdb) tk set help [gdb_cmd help]; puts stdout $help
(gdb) tk set functions [gdb_cmd "info func main"]; puts stdout $functions
Of course, you are still leaving yourself at the mercy of gdb's human
readable output, so you'll need to parse gdb's output to do some things
well.
Keith