This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
using perl in gdbinit
- To: gdb at sourceware dot cygnus dot com
- Subject: using perl in gdbinit
- From: Edward Peschko <edwardp at excitehome dot net>
- Date: Tue, 27 Feb 2001 16:09:52 -0800
hey all -
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`;
while ($functions =~ m"File\s*(\S+):\n(.*?)(?=File)"sg)
{
my ($filename, $functions) = ($1, $2);
$functionhash{$filename} = _getfilefunctions($functions);
}
foreach $file (keys(%functionhash))
{
my $filename = $file;
$filename =~ s".*/(.*?)(?:\..*|$)"$1";
my $define = "define b$filename\n" . join("\n",
map("b $_", @{$functionhash{$file}} )) .
"end\n";
`$define`;
}
to define bmod_so to mean 'set breakpoints on all of the functions in mod_so.c',
balloc to mean 'set breakpoints on all of the functions in alloc.c', etc. above,
I'm using `` to communicate with gdb, it could be -just as easily - a
function call.
So, is there any way people know of doing this automatically? (it doesn't have
to be as fancy, maybe being able to say:
info functions >> f
to pipe the output of info functions into the file f would do it...
Ed