using perl in gdbinit

Edward Peschko
2001-02-27T16:10:00Z

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