From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125576 invoked by alias); 22 Sep 2017 12:11:56 -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 125563 invoked by uid 89); 22 Sep 2017 12:11:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=stwu, H*MI:c776, H*M:c776 X-HELO: mail.rt-rk.com Received: from mx2.rt-rk.com (HELO mail.rt-rk.com) (89.216.37.149) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Sep 2017 12:11:53 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 8DC011A1FC7; Fri, 22 Sep 2017 14:11:50 +0200 (CEST) Received: from [10.10.13.98] (rtrkw512-lin.domain.local [10.10.13.98]) by mail.rt-rk.com (Postfix) with ESMTPSA id 726761A153E; Fri, 22 Sep 2017 14:11:50 +0200 (CEST) To: gdb-patches@sourceware.org Cc: "Ananthakrishna Sowda (asowda)" , "Ivan Baev (ibaev)" , 'Nemanja Popov' , Djordje Todorovic From: Nikola Prica Subject: Fix for prologue processing on PowerPC Message-ID: Date: Fri, 22 Sep 2017 12:11:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------7E023FC7BB82C07EBE97E971" X-SW-Source: 2017-09/txt/msg00672.txt.bz2 This is a multi-part message in MIME format. --------------7E023FC7BB82C07EBE97E971 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1538 After analyzing dump of ppc program, whose crash occurred after watchdog_force_here () function, GDB couldn't print full back trace because GDB couldn't unwind PC from the watchdog fucntion. The problem is introduced with the following patch: https://sourceware.org/ml/gdb-patches/2008-08/msg00245.html In function skip_prologue(), shifted lr_reg makes below condition always false because non-shifted lr_reg value is expected to be checked. else if (lr_reg >= 0 && /* std Rx, NUM(r1) || stdu Rx, NUM(r1) */ (((op & 0xffff0000) == (lr_reg | 0xf8010000)) || /* stw Rx, NUM(r1) */ ((op & 0xffff0000) == (lr_reg | 0x90010000)) || /* stwu Rx, NUM(r1) */ ((op & 0xffff0000) == (lr_reg | 0x94010000)))) Before this fix unwinding was able to work because it relied on unwind directives or on some of the next frames to find PC. Problem came with watchdog_force_here() function which didn't contain unwind directives. I wasn't able to produce test case that would show improvements for end user. I suppose that changes would be visible if watchdog event was called, but I don't have valid ppc board to try this. I have tried this code on simple test case with few functions in back trace. The back trace is printed correctly with and without this fix, but the difference between those two runs is that the body of the upper condition was visited with this patch. After visiting the body there was no need to look for PC counter in next frames nor to use unwind directives. --------------7E023FC7BB82C07EBE97E971 Content-Type: text/x-patch; name="PowerPC-fix-for-prologue-processing.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="PowerPC-fix-for-prologue-processing.patch" Content-length: 1734 >From 93a406efd79552eba7fc55ed3b7f293cdcf324ef Mon Sep 17 00:00:00 2001 From: Prica Date: Tue, 19 Sep 2017 17:52:35 +0200 Subject: [PATCH] PowerPC, fix for prologue processing One of conditions in skip_prologue() is never visited because it expects non shifted `lr_reg`. That condition is supposed to set PC offset. When body of this condition is visited PC offset is set and there will be no need to look for it in next frames nor to use frame unwind directives. gdb/ChangeLog: *rs6000-tdep.c (skip_prologue): Remove shifting for lr_reg and assign shifted lr_reg to fdata->lr_register when lr_reg is set. --- gdb/rs6000-tdep.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 95b2ca7..7f64901 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -1652,11 +1652,14 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc, remember just the first one, but skip over additional ones. */ - if (lr_reg == -1) - lr_reg = (op & 0x03e00000) >> 21; - if (lr_reg == 0) - r0_contains_arg = 0; - continue; + if (lr_reg == -1) + { + lr_reg = (op & 0x03e00000); + fdata->lr_register = lr_reg >> 21; + } + if (lr_reg == 0) + r0_contains_arg = 0; + continue; } else if ((op & 0xfc1fffff) == 0x7c000026) { /* mfcr Rx */ @@ -2178,9 +2181,6 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc, } #endif /* 0 */ - if (pc == lim_pc && lr_reg >= 0) - fdata->lr_register = lr_reg; - fdata->offset = -fdata->offset; return last_prologue_pc; } -- 2.7.4 --------------7E023FC7BB82C07EBE97E971--