From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22499 invoked by alias); 18 Jul 2004 21:07:46 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 22490 invoked from network); 18 Jul 2004 21:07:45 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 18 Jul 2004 21:07:45 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i6IL7ie3015180 for ; Sun, 18 Jul 2004 17:07:45 -0400 Received: from localhost.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i6IL7ga27752; Sun, 18 Jul 2004 17:07:42 -0400 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id C3A402B9D; Sun, 18 Jul 2004 16:39:56 -0400 (EDT) Message-ID: <40FAE01C.2050407@gnu.org> Date: Sun, 18 Jul 2004 21:49:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Chris Zankel Cc: Daniel Jacobowitz , gdb@sources.redhat.com Subject: Re: Extract the return value in finish_command on Xtensa. References: <40F31BA9.2060101@tensilica.com> <40F58BBA.5060300@gnu.org> <20040714195925.GA20006@nevyn.them.org> <40F6C16C.7050200@tensilica.com> In-Reply-To: <40F6C16C.7050200@tensilica.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-07/txt/msg00237.txt.bz2 Can you point us at a published abi document? > Daniel Jacobowitz wrote: > >> On Wed, Jul 14, 2004 at 03:38:34PM -0400, Andrew Cagney wrote: >> >>>> I am working on a port of GDB to the Xtensa architecture. >>>> >>>> Unfortunately, it is impossible on Xtensa to extract the return value once the 'callee' has returned to the 'caller' without analyzing the call instruction (if there was one). Depending on the call instruction, the return value can be in register a6, a10, oder a14. >>> >>> >>> Puzzled expression. The ABI should specify which return-value convention will be used? >>> >>> I suspect you'll need to explain a little more about your architecture. > > > What Daniel said is basically correct. Xtensa uses register windows much like Sparc but with the difference that is doesn't always shift 8 registers but a variable number of registers (4, 8, or 12). That number is encoded in the call instruction (call4, call8, or call12). > The shift walue is also encoded in the return address, so the return instruction knows how many registers it has to shift backwards. That doesn't sound much like the sparc. I'm wondering more about ia64. Do the same feature work on that architecture. > The 'callee' always returns the return value in a2. For the caller the return value thus is in either a6 (call4), a10 (call8), or a14 (call12). > > The calling function obviously knows what call instruction it used to extract the return value. So the information can (with a bit of effort) be extracted from the calling function. Perhaphs using prolog analysis, CFI, other registers, or examining the instruction. > The easiest way for GDB to find the return register would be to look at the return address of the 'callee', but once that function has returned, the information is lost. Because this problem only arises for the finish command, GDB could save the return address (from the 'callee' frame) before it resumes the target and then use that value to extract the return value. Your original post didn't discuss "return ". That has the same problem as finish (except more extreem since GDB blows away the callee frame). Andrew