From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79404 invoked by alias); 11 Mar 2016 12:26:12 -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 79391 invoked by uid 89); 11 Mar 2016 12:26:12 -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=determines, dark, our, 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 12:26:10 +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 1A3773FF2B; Fri, 11 Mar 2016 13:27:07 +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 B7F545800F9; Fri, 11 Mar 2016 13:26:07 +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> <56E2AD82.3060101@0x04.net> Cc: gdb-patches@sourceware.org From: =?UTF-8?Q?Marcin_Ko=c5=9bcielnicki?= Message-ID: <56E2B95F.7050701@0x04.net> Date: Fri, 11 Mar 2016 12:26: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/msg00187.txt.bz2 On 11/03/16 13:18, Andreas Arnez wrote: > On Fri, Mar 11 2016, Marcin Kościelnicki wrote: > >> 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). > > Nah, that doesn't help either, since most functions don't use r11 as a > frame pointer. There is just no way to locate the return address unless > we have call frame information or perform code analysis. > >> 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. > > The point I was trying to make is that r14 is fairly *unlikely* to > contain the return address, unless we're near function entry. If we > just called a function, then r14 contains an address within our own > function. Otherwise r14 can also contain something else entirely. Well, it works for leaf functions... not much, but not totally useless either. > > Is there a way to admit that we don't know the return address? What if > we always return garbage? E.g., maybe it's better to always return 0? > We can always error() in there (and KFAIL the testcase in gdb.trace that exercises it). However, returning garbage here doesn't result in garbage backtrace - this only collects data, if the unwinder actually doing the work later determines it should look for the return address on the stack, it'll just ignore our collected $r14 and consider the return address unavailable (unless another collect rule happened to match it).