From: jagorak <jagorak@wp.pl>
To: gdb@sourceware.org
Subject: Re: Calling an Ada subprogram with complex parameters
Date: Sun, 18 Mar 2007 17:10:00 -0000 [thread overview]
Message-ID: <5416595812.20070318171038@wp.pl> (raw)
In-Reply-To: <1827236609.20070317231124@wp.pl>
I've managed to work out how to make GDB treat an address as if
data there was of specific type and make a call accordingly.
(gdb) set ({Rec} 0xABCDEF00).a := false
(gdb) set ({Rec} 0xABCDEF00).b := 55
(gdb) call myProc({Rec} *0xABCDEF00))
Cheers
Jan
j> Hi,
j> I'm trying to invoke from the GDB an Ada subprogram (say a procedure) which takes a
j> complex-type as a parameter. I'm struggling to work out how this can
j> be done.
j> Say I have a type
j> type Rec is record
j> a : Boolean;
j> b : Integer;
j> end record;
j> and a procedure, which takes a variable of this type as a parameter:
j> procedure myProc( data : in Rec );
j> .
j> ----
j> Now, from the GDB I'd like to make a call like this:
j> (gdb) call myProc( data => Rec'(a => true, b => 55) );
j> but this doesn't work since GDB does not seem to fully support accessing
j> attributes (section 12.4.6.2 of the GDB manual). (means = aposthrophe
j> notation does not always work).
j> ----
j> Therefore I wanted to try something else. For example:
j> (gdb) call myProc($myRec);
j> where $myRec is a convenience variable of type "Rec", but this
j> wouldn't work either since convenience variable resides in
j> gdb-specific memory space, complex types seem to be passed by reference and myProc
j> cannot access memory address of $myRec.
j> Besides, even if that worked, here is another problem: I was able
j> to 'force' $myRec to be of type 'Rec' only by assigning it to
j> another variable of type Rec
j> (e.g. (gdb) set $myRec := otherVariableOfTypeRec)
j> which is not ideal since otherVariableOfTypeRec is not always
j> available. (In fact, in most cases it won't be.)
j> ----
j> Another solution would be to have a specific memory address (since I
j> don't have any local variables available - the call to the procedure
j> is made almost without any context) set to a value of type Rec using type casting.
j> Which would be something like this:
j> (gdb) p *0xABCDEF00 := something_here;
j> (gdb) call myProc(Rec(*0xABCDEF00))
j> But the problem here is that the bytes occupied by "something_here"
j> have to be correctly set to what would variable of type Rec normally
j> occupy. Also "something_here" has to be a single expression. It cannot
j> be a record aggregate like for instance "(True, 55)" since obviously there is no
j> type associated with the 0xABCDEF00 memory address and GDB probably
j> doesn't know what to do with an aggregate notation. (BTW: Is there a
j> way to tell GDB to treat a memory address as if it was of a specific
j> type?)
j> When I try to run
j> (gdb) call myProc(Rec(*0xABCDEF00))
j> just to see what happens... (*0xABCDEF00 set to whatever resides at
j> that address) I'm getting:
j> Program received signal SIGILL, Illegal instruction.
j> I must mention here that I'm quite new to Ada so the solution to my
j> problem may be not by using a gdb feature, but by using and Ada
j> language feature... (e.g. appropriate casting).
j> Does anyone have any idea how I can solve this problem?
j> Many thanks,
j> Jan
next prev parent reply other threads:[~2007-03-18 17:10 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 [this message]
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=5416595812.20070318171038@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