public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Fix for prologue processing on PowerPC
@ 2017-09-22 12:11 Nikola Prica
  2017-10-05  2:01 ` Kevin Buettner
  2017-10-26 10:02 ` [PING]Fix " Nikola Prica
  0 siblings, 2 replies; 19+ messages in thread
From: Nikola Prica @ 2017-09-22 12:11 UTC (permalink / raw)
  To: gdb-patches
  Cc: Ananthakrishna Sowda (asowda), Ivan Baev (ibaev),
	'Nemanja Popov',
	Djordje Todorovic

[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]

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.

[-- Attachment #2: PowerPC-fix-for-prologue-processing.patch --]
[-- Type: text/x-patch, Size: 1733 bytes --]

From 93a406efd79552eba7fc55ed3b7f293cdcf324ef Mon Sep 17 00:00:00 2001
From: Prica <nprica@rt-rk.com>
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


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-02-01 13:09 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-22 12:11 Fix for prologue processing on PowerPC Nikola Prica
2017-10-05  2:01 ` Kevin Buettner
2017-10-26 10:02 ` [PING]Fix " Nikola Prica
2017-11-08 16:58   ` Kevin Buettner
2017-11-09 18:15     ` [PING][PATCH] Fix " Nikola Prica
2017-12-01 19:37       ` pedromfc
2017-12-19 15:57         ` Nikola Prica
2017-12-29 18:05           ` Pedro Franco de Carvalho
2018-01-09 11:22             ` Nikola Prica
2018-01-10 17:26               ` Pedro Franco de Carvalho
2018-01-11 15:12                 ` Nikola Prica
2018-01-19  7:49                   ` Nikola Prica
2018-01-19 19:01                     ` Pedro Franco de Carvalho
2018-01-19 19:08                     ` Pedro Franco de Carvalho
2018-01-27 14:32                       ` Nikola Prica
2018-01-31 18:04                         ` Pedro Franco de Carvalho
2018-01-31 18:28                           ` Ulrich Weigand
2018-02-01 13:09                             ` Nikola Prica
2018-01-02 10:29           ` Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).