From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 503 invoked by alias); 21 Aug 2002 23:05:11 -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 496 invoked from network); 21 Aug 2002 23:05:10 -0000 Received: from unknown (HELO cygnus.com) (205.180.83.203) by sources.redhat.com with SMTP; 21 Aug 2002 23:05:10 -0000 Received: from redhat.com (reddwarf.sfbay.redhat.com [172.16.24.50]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id PAA19701; Wed, 21 Aug 2002 15:59:33 -0700 (PDT) Message-ID: <3D6418C5.FBF117D@redhat.com> Date: Wed, 21 Aug 2002 16:05:00 -0000 From: Michael Snyder Organization: Red Hat, Inc. X-Accept-Language: en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com CC: kevinb@redhat.com, cagney@redhat.com Subject: [RFC] fixing extract_struct_value_address Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-08/txt/msg00674.txt.bz2 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?