From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17087 invoked by alias); 22 Aug 2002 16:35:18 -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 17079 invoked from network); 22 Aug 2002 16:35:17 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 22 Aug 2002 16:35:17 -0000 Received: by localhost.redhat.com (Postfix, from userid 469) id 004BB10DCC; Thu, 22 Aug 2002 12:33:23 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15717.4691.829881.98118@localhost.redhat.com> Date: Thu, 22 Aug 2002 10:08:00 -0000 To: Andrew Cagney Cc: Michael Snyder , gdb-patches@sources.redhat.com, kevinb@redhat.com, cagney@redhat.com, Elena Zannoni Subject: Re: [RFC] fixing extract_struct_value_address In-Reply-To: <3D65001C.70609@ges.redhat.com> References: <3D6418C5.FBF117D@redhat.com> <3D65001C.70609@ges.redhat.com> X-SW-Source: 2002-08/txt/msg00692.txt.bz2 Discussed before in: http://sources.redhat.com/ml/gdb-patches/2001-11/msg00571.html and http://sources.redhat.com/ml/gdb-patches/2001-12/msg00325.html never resolved. Elena Andrew Cagney writes: > > Problem: Find a function's return value when it is a struct > > returned by reference (thru a pointer). > > Hmm, > > > As far as I know, there are two cases: > > 1. a normal function forced to return: > (gdb) break foo > (gdb) finish > > 2. an inferior function call: > (gdb) print foo() > > > I don't think the first case has a solution (unless the debug info steps > forward with the answer we need). > > > For the latter case, the inferior function code contains: > > /* Figure out the value returned by the function. */ > /* elz: I defined this new macro for the hppa architecture only. > this gives us a way to get the value returned by the function from > the stack, > at the same address we told the function to put it. > We cannot assume on the pa that r28 still contains the address of > the returned > structure. Usually this will be overwritten by the callee. > I don't know about other architectures, so I defined this macro > */ > > #ifdef VALUE_RETURNED_FROM_STACK > if (struct_return) > { > do_cleanups (retbuf_cleanup); > return VALUE_RETURNED_FROM_STACK (value_type, struct_addr); > } > #endif > > { > struct value *retval = value_being_returned (value_type, retbuf, > struct_return); > do_cleanups (retbuf_cleanup); > return retval; > } > } > > I get the feeling that all that is needed is for the above to be enabled > for all targets. > > enjoy, > Andrew > > > > 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? > > >