Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Daniel Chiaramello <dchiaramello@madwaves.com>
To: gdb@sources.redhat.com
Subject: User-defined macros and C string
Date: Wed, 30 Jul 2003 11:47:00 -0000	[thread overview]
Message-ID: <A07C7042-C283-11D7-B1DD-0003936CB86C@madwaves.com> (raw)

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


             reply	other threads:[~2003-07-30 11:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-30 11:47 Daniel Chiaramello [this message]
2003-07-30 12:56 ` Daniel Jacobowitz
2003-07-30 13:14   ` Daniel Chiaramello

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A07C7042-C283-11D7-B1DD-0003936CB86C@madwaves.com \
    --to=dchiaramello@madwaves.com \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox