From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27782 invoked by alias); 22 Aug 2002 01:32:13 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 27775 invoked from network); 22 Aug 2002 01:32:13 -0000 Received: from unknown (HELO crack.them.org) (65.125.64.184) by sources.redhat.com with SMTP; 22 Aug 2002 01:32:13 -0000 Received: from nevyn.them.org ([66.93.61.169] ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 17hgpc-0007b7-00; Wed, 21 Aug 2002 20:32:16 -0500 Received: from drow by nevyn.them.org with local (Exim 3.35 #1 (Debian)) id 17hgqF-0004jR-00; Wed, 21 Aug 2002 21:32:55 -0400 Date: Wed, 21 Aug 2002 18:32:00 -0000 From: Daniel Jacobowitz To: Michael Snyder Cc: gdb-patches@sources.redhat.com, kevinb@redhat.com, cagney@redhat.com Subject: Re: [RFC] fixing extract_struct_value_address Message-ID: <20020822013255.GA18169@nevyn.them.org> Mail-Followup-To: Michael Snyder , gdb-patches@sources.redhat.com, kevinb@redhat.com, cagney@redhat.com References: <3D6418C5.FBF117D@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3D6418C5.FBF117D@redhat.com> User-Agent: Mutt/1.5.1i X-SW-Source: 2002-08/txt/msg00677.txt.bz2 On Wed, Aug 21, 2002 at 03:48:37PM -0700, Michael Snyder wrote: > Problem: Find a function's return value when it is a struct > returned by reference (thru a pointer). > > Solution level one: Take the value of the register that was > used by the caller to pass the struct return address. > > Shortcoming: that register isn't preserved, so may be clobbered. > > Solution level two: Save the struct_return address when it > is passed to store_struct_return (or push_arguments), and > recover it when it is needed by extract_struct_value_address. > > Shortcoming: Not reentrant. Nested function calls will clobber it. > > Proposed solution: create a stack structure, and "push" the > struct_return address in store_struct_return, popping it in > extract_return_address. If you can't find it on the stack, > then use the value of the appropriate arg0 register. > > I think this should work for most targets, so the code for > managing the stack can be shared. > > What do you think? Sharing the solution to this across targets would be a good step forward - I just had to use the same hack for another port. You want to be careful of functions which don't return (either GDB is activated inside the called function and the expression is never finished, or we longjmp out, or something...) but I believe there's somewhere that already tries to figure these things out... -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer