Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: jagorak <jagorak@wp.pl>
To: Daniel Jacobowitz <drow@false.org>,
	Joel Brobecker <brobecker@adacore.com>
Cc: gdb@sourceware.org
Subject: Re[2]: Calling an Ada subprogram with complex parameters
Date: Mon, 19 Mar 2007 20:08:00 -0000	[thread overview]
Message-ID: <1905422578.20070319200802@wp.pl> (raw)
In-Reply-To: <20070319021557.GA26173@caradoc.them.org>

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


  reply	other threads:[~2007-03-19 20:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-17 23:11 jagorak
2007-03-18 17:10 ` jagorak
2007-03-19 16:35   ` Joel Brobecker
2007-03-19 18:46     ` Re[2]: " jagorak
2007-03-19  2:16 ` Daniel Jacobowitz
2007-03-19 20:08   ` jagorak [this message]
2007-03-19 20:17     ` Daniel Jacobowitz
2007-03-19 20:40       ` Re[2]: " jagorak

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=1905422578.20070319200802@wp.pl \
    --to=jagorak@wp.pl \
    --cc=brobecker@adacore.com \
    --cc=drow@false.org \
    --cc=gdb@sourceware.org \
    /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