This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re[2]: Calling an Ada subprogram with complex parameters
- From: jagorak <jagorak at wp dot pl>
- To: Daniel Jacobowitz <drow at false dot org>, Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb at sourceware dot org
- Date: Mon, 19 Mar 2007 20:08:02 +0000
- Subject: Re[2]: Calling an Ada subprogram with complex parameters
- References: <1827236609.20070317231124@wp.pl> <20070319021557.GA26173@caradoc.them.org>
- Reply-to: jagorak <jagorak at wp dot pl>
>> where $myRec is a convenience variable of type "Rec", but this
>> wouldn't work either since convenience variable resides in
>> gdb-specific memory space, complex types seem to be passed by
>> reference and myProc cannot access memory address of $myRec.
DJ> Actually, that's not true - convenience variables which have a
DJ> memory location are put into the target's memory. Sometimes GDB
DJ> uses the stack, other times malloc is called under the hood.
That is very good news to me, as using absolute addressess is much
less convenient than using convenience variables.
HOWEVER, GDB is complaining when I try to use convenience variable in
a subprogram call, whereas it is not complaining when I give it an
absolute address. (This is why I thought convenience variables were
not stored in target memory).
Let me explain.
Assuming Rec is a type as defined in my previous posts, using absolute
address I can set data & make a call as follows (this is actually the
solution to my problem I described in my original post).
(gdb) set ({Rec} 0xABCDEF00).a := false
(gdb) set ({Rec} 0xABCDEF00).b := 55
(gdb) call myProc({Rec} *0xABCDEF00))
ABOVE WORKS FINE.
Now, when I use a convenience variable (still using absolute address
but only as 'read-only-trick' to get the convenience variable to be set to
the appropriate type), GDB is complaining.
Here is the process:
// The 'read-only-trick' to set $conVar to appropriate type (I'm
// not bothered with the value of $conVar at that stage)
// Address can be random and doesn't really matter here.
(gdb) set $conVar := ({Rec} 0xABCDEF00)
// set $conVar to what I want
(gdb) set $conVar.a := false
(gdb) set $conVar.b := 55
// ---> NOW - here is the problem: <----
(gdb) call myProc($conVar)
gdb says: Attempt to take address of value not located in memory.
I tried to work out what is the address of $conVar, as I would do with
'normal' variable, but it doesn't work:
(gdb) p &$conVar
gdb says: Attempt to take address of non-lval
Which is curious - previously I was able to set the value of $conVar,
but now it is complaining $conVar is not a non-lval.
It seems that as if gdb treats each instance of a convenience variable
in a command as the actual value which the variable holds.
I think I need to have a better understanding of convenience
variables. I'm not even sure whether I understand correctly what gdb
says to me - your help is greatly appreciated! (coudn't work this out
with the help of the gdb manual)
Many, many thanks,
Jan