This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: GDB Scripting
- To: Robert Graulich <graulich at synopsys dot COM>
- Subject: Re: GDB Scripting
- From: Fernando Nasser <fnasser at redhat dot com>
- Date: Sun, 21 Oct 2001 13:48:18 -0400
- CC: GDB Mailing List <gdb at sources dot redhat dot com>
- Organization: Red Hat Canada
- References: <3BD16CD3.CCF7FB47@synopsys.com>
Robert Graulich wrote:
>
> Hi all,
>
> is it possible, to store the result of a gdb command like 'frame' in a variable?
> I like to write someting like
>
> define hook-stop
> set $FRAME=frame
> if $FRAME=="main"
> ...
> else
> ...
> end
> end
>
> How to do that?
>
Unfortunately the "frame" command does not set any convenience variable
automatically (which is the only way to obtain data from a GDB command
execution). So, the way to do this is:
Set a breakpoint at main.
Use the "commands" command and add
print $main_fp=$<reg>
continue
where <reg> is the FP register in your architecture.
Then just make your if compare the $<reg> at the
point you've stopped with $main_fp
I hope this helps.
Regards,
Fernando
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9