This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re[2]: Calling an Ada subprogram with complex parameters


>> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]