From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28909 invoked by alias); 18 Jan 2004 22:13:11 -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 28888 invoked from network); 18 Jan 2004 22:13:09 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (213.93.115.144) by sources.redhat.com with SMTP; 18 Jan 2004 22:13:09 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id i0IMD2ce000466; Sun, 18 Jan 2004 23:13:02 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: from elgar.kettenis.dyndns.org (localhost [127.0.0.1]) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6) with ESMTP id i0IMD2Wt026713; Sun, 18 Jan 2004 23:13:02 +0100 (CET) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.12.6p3/8.12.6/Submit) id i0IMD2oO026710; Sun, 18 Jan 2004 23:13:02 +0100 (CET) Date: Sun, 18 Jan 2004 22:13:00 -0000 Message-Id: <200401182213.i0IMD2oO026710@elgar.kettenis.dyndns.org> From: Mark Kettenis To: cagney@gnu.org CC: gdb@sources.redhat.com In-reply-to: <400AB4BE.5000300@gnu.org> (message from Andrew Cagney on Sun, 18 Jan 2004 11:30:54 -0500) Subject: Re: [RFC] Struct return values References: <200401091622.i09GMRVn000591@elgar.kettenis.dyndns.org> <4009883D.8050809@gnu.org> <200401181519.i0IFJrvC053668@elgar.kettenis.dyndns.org> <400AB4BE.5000300@gnu.org> X-SW-Source: 2004-01/txt/msg00221.txt.bz2 Date: Sun, 18 Jan 2004 11:30:54 -0500 From: Andrew Cagney When looking at the code I found two cases: "return VALUE": GDB first pops the callers frame, and second stores the return VALUE. This means that the method will see caller's frame just after the callee has been forceably "returned". "finish" GDB first finishes the function, and second extracts the return VALUE. This again means that the method will see the caller's frame just after the callee has returned. So perhaphs something like: The target should only define this method if it has a reliable way of extracting the struct-convention return-value address using only information obtained from the caller's frame just after the callee has returned. [insert something about how this is impossible on most ABIs :-)] Hmm, OK, but this means that there are really three classes of ABIs here: a) The return value address is passed to the callee, and the callee may clobber the location where the address is stored (i.e. it's stored in the callee's stack frame, or in a scratch register). b) The return value address is passed to the callee, and the callee may clobber the location where the address is stored (i.e. it's stored in the callee's stack frame, or in a scratch register). We can't "return VALUE" or display the return value with "finish". c) The return value address is passed to the callee in a location that isn't clobbered by the callee (i.e. in the caller's stack frame, or in a preserved register). This means that a) We cannot "return VALUE" or display the return value with "finish". b) We cannot "return VALUE" but we can display the return values with "finish". c) We can both "return VALUE" and display the return value with "finish". Examples are: a) The PPC System V psABI: The return value address is passed in r3, which is "volatile". b) The AMD64 System V psABI: The return values address is passed in %rdi. On return %rax will contain the address that has been passed in by the caller in %rdi. c) The (32-bit) SPARC System V psABI: The return address is stored in a reserved slot in the caller's frame. Personally I find it very usefull that GDB prints the return value when I say "finish", so I'd like to make that work too. Mark