Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* User-defined macros and C string
@ 2003-07-30 11:47 Daniel Chiaramello
  2003-07-30 12:56 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Chiaramello @ 2003-07-30 11:47 UTC (permalink / raw)
  To: gdb

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-07-30 13:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-30 11:47 User-defined macros and C string Daniel Chiaramello
2003-07-30 12:56 ` Daniel Jacobowitz
2003-07-30 13:14   ` Daniel Chiaramello

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox