This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
Re: gdb/1799: $fp is not a left value, would be useful to be
- From: Samuel Thibault <samuel dot thibault at ens-lyon dot org>
- To: nobody at sources dot redhat dot com
- Cc: gdb-prs at sources dot redhat dot com,
- Date: 28 Nov 2004 00:58:00 -0000
- Subject: Re: gdb/1799: $fp is not a left value, would be useful to be
- Reply-to: Samuel Thibault <samuel dot thibault at ens-lyon dot org>
The following reply was made to PR gdb/1799; it has been noted by GNATS.
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-gnats@sources.redhat.com
Subject: Re: gdb/1799: $fp is not a left value, would be useful to be
Date: Sun, 28 Nov 2004 01:55:50 +0100
Le sam 27 nov 2004 à 18:31:20 -0500, Daniel Jacobowitz a tapoté sur son clavier :
> On Sat, Nov 27, 2004 at 06:22:28PM +0100, Samuel Thibault wrote:
> > Le ven 29 oct 2004 à 22:12:14 -0400, Daniel Jacobowitz a tapoté sur son clavier :
> > > On Wed, Oct 27, 2004 at 12:16:40PM -0000, samuel.thibault@ens-lyon.org wrote:
> > > $fp doesn't have an architecture-independant meaning; in many cases it
> > > is computed, not a register at all.
> >
> > Hum, indeed.
> > Could there be any architecture-independant way of achieving context
> > switches by hand ? (sort of longjmp, but without actually continuing the
> > program)
>
> The layout of the jmp_buf is already architecture dependent. Why not
> just ship an appropriate .gdbinit file for each architecture, defining
> a macro which sets the registers?
I precisely did that:
define set-ctx-x86
set $esp=((marcel_t)$arg0)->ctx_yield[0].jbuf[4]
set $ebp=((marcel_t)$arg0)->ctx_yield[0].jbuf[3]
set $eip=((marcel_t)$arg0)->ctx_yield[0].jbuf[5]
end
and then couldn't find any way to define a set-ctx macro according
to the current architecture (I couldn't find any variable holding
its name). Having several .gdbinit files, one per architecture,
and choose it before launching gdb would work indeed.
Now the trouble is that it doesn't really work nicely: I also defined
save-ctx/rest-ctx to be able to get back to the current thread:
define save-ctx
set $marcel_saved_pc=$eip
set $marcel_saved_sp=$esp
set $marcel_saved_bp=$ebp
set $marcel_saved=1
end
define rest-ctx
if $marcel_saved==0
echo no context saved !\n
else
set $eip=$marcel_saved_pc
set $esp=$marcel_saved_sp
set $ebp=$marcel_saved_bp
set $marcel_saved=0
end
end
but
(gdb) printf "%p %p %p\n", $eip, $esp, $ebp
0x805afd2 0x3ffff7d0 0xbffefb18
(gdb) save-ctx
(gdb) set-ctx __main_thread
(gdb) printf "%p %p %p\n", $eip, $esp, $ebp
0x805bf85 0xbffef9a0 0xbffefbb8
(gdb) rest-ctx
Cannot access memory at address 0x40000000
(gdb) printf "%p %p %p\n", $eip, $esp, $ebp
0x805afd2 0x3ffff7d0 0xbffefbb8
(gdb) rest-ctx
(gdb) printf "%p %p %p\n", $eip, $esp, $ebp
0x805afd2 0x3ffff7d0 0xbffefb18
gdb has difficulties with setting back all three registers to previous
value. Putting instructions twice in rest-ctx doesn't help (although
calling it twice seems to !) Neither does putting instructions in
another order help. Would there be any cleaner way to do it ?
Regards,
Samuel Thibault