Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: jagorak <jagorak@wp.pl>
To: gdb@sourceware.org
Subject: Calling an Ada subprogram with complex parameters
Date: Sat, 17 Mar 2007 23:11:00 -0000	[thread overview]
Message-ID: <1827236609.20070317231124@wp.pl> (raw)

Hi,

I'm trying to invoke from the GDB an Ada subprogram (say a procedure) which takes a
complex-type as a parameter. I'm struggling to work out how this can
be done.



Say I have a type

     type Rec is record
          a : Boolean;
          b : Integer;
     end record;

and a procedure, which takes a variable of this type as a parameter:

    procedure myProc( data : in Rec );

.
----
Now, from the GDB I'd like to make a call like this:
     (gdb) call myProc( data => Rec'(a => true, b => 55) );

but  this  doesn't  work  since GDB does not seem to fully support accessing
attributes (section 12.4.6.2 of the GDB manual). (means = aposthrophe
notation does not always work).



----
Therefore I wanted to try something else. For example:

          (gdb) call myProc($myRec);

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.

Besides,  even if that worked, here is another problem: I  was  able
to  'force' $myRec to be of type 'Rec' only by assigning   it   to
another   variable  of type Rec
          (e.g.  (gdb) set  $myRec  := otherVariableOfTypeRec)
which is not ideal since otherVariableOfTypeRec is not always
available. (In fact, in most cases it won't be.)
----

Another solution would be to have a specific memory address (since I
don't have any local variables available - the call to the procedure
is made almost without any context) set to a value of type Rec using type casting.
Which would be something like this:

      (gdb) p *0xABCDEF00 := something_here;
      (gdb) call myProc(Rec(*0xABCDEF00))

But the problem here is that the bytes occupied by "something_here"
have to be correctly set to what would variable of type Rec normally
occupy. Also "something_here" has to be a single expression. It cannot
be a record aggregate like for instance "(True, 55)" since obviously there is no
type associated with the 0xABCDEF00 memory address and GDB probably
doesn't know what to do with an aggregate notation. (BTW: Is there a
way to tell GDB to treat a memory address as if it was of a specific
type?)

When I try to run
     (gdb) call myProc(Rec(*0xABCDEF00))
just to see what happens... (*0xABCDEF00 set to whatever resides at
that address) I'm getting:
     Program received signal SIGILL, Illegal instruction.



I must mention here that I'm quite new to Ada so the solution to my
problem may be not by using a gdb feature, but by using and Ada
language feature... (e.g. appropriate casting).



Does anyone have any idea how I can solve this problem?



Many thanks,
Jan


             reply	other threads:[~2007-03-17 23:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-17 23:11 jagorak [this message]
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   ` Re[2]: " jagorak
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=1827236609.20070317231124@wp.pl \
    --to=jagorak@wp.pl \
    --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