This is the mail archive of the 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]

Calling an Ada subprogram with complex parameters


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

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,

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