From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45256 invoked by alias); 11 Mar 2016 11:35:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 45240 invoked by uid 89); 11 Mar 2016 11:35:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Under, IMO, dark, HContent-Transfer-Encoding:8bit X-HELO: xyzzy.0x04.net Received: from xyzzy.0x04.net (HELO xyzzy.0x04.net) (109.74.193.254) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Mar 2016 11:35:33 +0000 Received: from hogfather.0x04.net (89-65-66-135.dynamic.chello.pl [89.65.66.135]) by xyzzy.0x04.net (Postfix) with ESMTPS id 983C93FF2B; Fri, 11 Mar 2016 12:36:30 +0100 (CET) Received: from [192.168.1.62] (84-10-2-59.static.chello.pl [84.10.2.59]) by hogfather.0x04.net (Postfix) with ESMTPSA id 4742F5800F9; Fri, 11 Mar 2016 12:35:31 +0100 (CET) Subject: Re: [PATCH 4/8] gdb/s390: Fill gen_return_address hook. To: Andreas Arnez References: <1453637529-26972-5-git-send-email-koriakin@0x04.net> <1454853751-18455-1-git-send-email-koriakin@0x04.net> Cc: gdb-patches@sourceware.org From: =?UTF-8?Q?Marcin_Ko=c5=9bcielnicki?= Message-ID: <56E2AD82.3060101@0x04.net> Date: Fri, 11 Mar 2016 11:35:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg00181.txt.bz2 On 11/03/16 12:20, Andreas Arnez wrote: > On Sun, Feb 07 2016, Marcin Kościelnicki wrote: > >> diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c >> index 97bd564..0b91ed1 100644 >> --- a/gdb/s390-linux-tdep.c >> +++ b/gdb/s390-linux-tdep.c >> @@ -627,6 +627,18 @@ s390_ax_pseudo_register_push_stack (struct gdbarch *gdbarch, >> return 0; >> } >> >> +/* The "gen_return_address" gdbarch method. */ >> + >> +static void >> +s390_gen_return_address (struct gdbarch *gdbarch, >> + struct agent_expr *ax, struct axs_value *value, >> + CORE_ADDR scope) >> +{ >> + value->type = register_type (gdbarch, S390_R14_REGNUM); >> + value->kind = axs_lvalue_register; >> + value->u.reg = S390_R14_REGNUM; >> +} > > Under which circumstances is this supposed to work? And how reliable > does it need to be? The ABI only guarantees that r14 holds the return > address at function entry. Anywhere else it likely doesn't. > > -- > Andreas > Quoting gdbarch.sh: # Generate bytecodes to collect the return address in a frame. # Since the bytecodes run on the target, possibly with GDB not even # connected, the full unwinding machinery is not available, and # typically this function will issue bytecodes for one or more likely # places that the return address may be found. m:void:gen_return_address:struct agent_expr *ax, struct axs_value *value, CORE_ADDR scope:ax, value, scope::default_gen_return_address::0 ie. it's supposed to collect some value that will likely help the unwinder - if it collects the wrong thing, the unwinder (knowing the right place for sure) will simply consider the previous frame PC to be unavailable. We could also try to collect 14*(%r11), hoping that's the save slot for %r14, but the interface unfortunately doesn't support collecting multiple values (no matter what the comment above says). Unfortunately, this interface is just not very well-designed - both x86 and aarch64 just take a shot in the dark like this patch. A better way would be to reuse the existing unwinders and remove this hook altogether, or (for while-stepping, where we can't predict the PC) actually allow multiple values and aim at a few likely locations. But IMO that's not in scope for this patchset.