From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15409 invoked by alias); 18 Mar 2007 17:10:50 -0000 Received: (qmail 15390 invoked from network); 18 Mar 2007 17:10:40 -0000 Received: from unknown (212.77.101.9) by sourceware.org with QMTP; 18 Mar 2007 17:10:40 -0000 Received: (wp-smtpd smtp.wp.pl 11813 invoked from network); 18 Mar 2007 18:10:39 +0100 Received: from host86-128-14-58.range86-128.btcentralplus.com (HELO BIGOS) (jagorak@[86.128.14.58]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with SMTP for ; 18 Mar 2007 18:10:39 +0100 Date: Sun, 18 Mar 2007 17:10:00 -0000 From: jagorak X-Mailer: Private Mailer 1.0 Reply-To: jagorak Message-ID: <5416595812.20070318171038@wp.pl> To: gdb@sourceware.org Subject: Re: Calling an Ada subprogram with complex parameters In-Reply-To: <1827236609.20070317231124@wp.pl> References: <1827236609.20070317231124@wp.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-WP-AV: skaner antywirusowy poczty Wirtualnej Polski S. A. X-WP-SPAM: NO 0000000 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-03/txt/msg00214.txt.bz2 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