From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4763 invoked by alias); 17 Mar 2007 23:11:42 -0000 Received: (qmail 4735 invoked from network); 17 Mar 2007 23:11:26 -0000 Received: from unknown (212.77.101.9) by sourceware.org with QMTP; 17 Mar 2007 23:11:26 -0000 Received: (wp-smtpd smtp.wp.pl 3152 invoked from network); 18 Mar 2007 00:11:25 +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 00:11:25 +0100 Date: Sat, 17 Mar 2007 23:11:00 -0000 From: jagorak X-Mailer: Private Mailer 1.0 Reply-To: jagorak Message-ID: <1827236609.20070317231124@wp.pl> To: gdb@sourceware.org Subject: Calling an Ada subprogram with complex parameters 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/msg00212.txt.bz2 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