This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
User-defined macros and C string
- From: Daniel Chiaramello <dchiaramello at madwaves dot com>
- To: gdb at sources dot redhat dot com
- Date: Wed, 30 Jul 2003 13:47:41 +0200
- Subject: User-defined macros and C string
Hi gdb gurus.
Well, I'm a total gdb newbie, so sorry if the question sounds stupid...
I failed to find a forum on which I could post it, so... Here is it!
I try to define a user-defined macro, to display parameters used when a
specific function is called.
IE there a the following function:
void dosomething (long theValue, char *theString) {...}
I want to put a breakpoint on that function and display a line like
that:
"dosomething(10, "coucou");\n"
each time that function is called.
Of course, that function is not in my code, and the caller is not
either.
I tried the following:
define DisplayFunctionCall
echo dosomething(
output $r3
output , \"
output $r4
echo \");\n
end
I planned to put a breakpoint at the function entrance, and then
execute my macro:
b *<the function addr>
command $bpnum
> DisplayFunctionCall
> continue
> end
But the output I get is:
dosomething(0, "145ae0");
dosomething(1, "145be0");
dosomething(2, "145ce0");
dosomething(3, "145de0");
ie the content of the r4 register (I'm on a PowerPC machine) is not
dumped as a C string, but its value is displayed...
Is there a way to display the C string pointed to by r4, in its
simplest form, ie only the C string? x/s $r4 displays the C string, but
also its address as well as the estimated position in a function...
echo $r4 displays a "$r4" string...
I hope you understand what I am trying to do...
Thanks for your attention,
Daniel, aka Souricette