This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

using perl in gdbinit


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]