Blame SOURCES/gdb-rhbz1225569-oom-killer-aarch64-frame-same-id-6of8.patch

7b26da
commit 62261490a36c6911c5eb61be7cddcfb1bd19ba18
7b26da
Author: Pedro Alves <palves@redhat.com>
7b26da
Date:   Thu Jan 16 17:43:26 2014 +0000
7b26da
7b26da
    Fix gdb.trace/mi-traceframe-changed.exp on s390.
7b26da
    
7b26da
    The test fails on s390 with:
7b26da
    
7b26da
      -trace-find frame-number 0^M
7b26da
      &"PC not available\n"^M
7b26da
      ^done,found="1",tracepoint="1",traceframe="0",frame={level="-1",addr="<unavailable>",func="??",args=[]}^M
7b26da
      (gdb) ^M
7b26da
      FAIL: gdb.trace/mi-traceframe-changed.exp: tfile: -trace-find frame-number 0
7b26da
    
7b26da
    tfile knows to infer the PC from the tracepoint's address if the PC
7b26da
    wasn't collected (tfile_fetch_registers) but, that only works on
7b26da
    targets whose PC register is a raw register, and on s390, the PC
7b26da
    register is a pseudo register.
7b26da
    
7b26da
    But even if GDB doesn't know how to infer the value of PC, saying the
7b26da
    current frame is level -1 is a bug:
7b26da
    
7b26da
      ^done,found="1",tracepoint="1",traceframe="0",frame={level="-1",addr="<unavailable>",func="??",args=[]}^M
7b26da
                                                           ^^^^^^^^^
7b26da
    
7b26da
    '-1' is the level of the sentinel frame, which should never be visible.
7b26da
    
7b26da
    This is caused by the s390's heuristic unwinder accepting the frame
7b26da
    (the fallback heuristic unwinders _always_ accept the frame), but then
7b26da
    the unwind->this_id method throws that "PC not available\n" error.
7b26da
    
7b26da
    IOW, the s390's heuristic unwinder was never adjusted to handle
7b26da
    unavailable register values gracefully, which can happen with e.g., a
7b26da
    trimmed core file too.
7b26da
    
7b26da
    This is just the minimal necessary for
7b26da
    <unavailable> frames, which at least gets us:
7b26da
    
7b26da
      (gdb) tfind
7b26da
      Found trace frame 0, tracepoint 1
7b26da
      #0  <unavailable> in ?? ()
7b26da
    
7b26da
    That is, frame #0 instead of -1.
7b26da
    
7b26da
    We could get better info out of "info frame" (this patch makes us show
7b26da
    "outermost"), but this change would still be necessary.
7b26da
    
7b26da
    gdb/
7b26da
    2014-01-16  Pedro Alves  <palves@redhat.com>
7b26da
    
7b26da
    	* s390-linux-tdep.c (s390_frame_unwind_cache): Swallow
7b26da
    	NOT_AVAILABLE_ERROR errors while parsing the prologue or reading
7b26da
    	the backchain.
7b26da
7b26da
Index: gdb-7.6.1/gdb/s390-tdep.c
7b26da
===================================================================
7b26da
--- gdb-7.6.1.orig/gdb/s390-tdep.c
7b26da
+++ gdb-7.6.1/gdb/s390-tdep.c
7b26da
@@ -1995,7 +1995,9 @@ static struct s390_unwind_cache *
7b26da
 s390_frame_unwind_cache (struct frame_info *this_frame,
7b26da
 			 void **this_prologue_cache)
7b26da
 {
7b26da
+  volatile struct gdb_exception ex;
7b26da
   struct s390_unwind_cache *info;
7b26da
+
7b26da
   if (*this_prologue_cache)
7b26da
     return *this_prologue_cache;
7b26da
 
7b26da
@@ -2006,10 +2008,15 @@ s390_frame_unwind_cache (struct frame_in
7b26da
   info->frame_base = -1;
7b26da
   info->local_base = -1;
7b26da
 
7b26da
-  /* Try to use prologue analysis to fill the unwind cache.
7b26da
-     If this fails, fall back to reading the stack backchain.  */
7b26da
-  if (!s390_prologue_frame_unwind_cache (this_frame, info))
7b26da
-    s390_backchain_frame_unwind_cache (this_frame, info);
7b26da
+  TRY_CATCH (ex, RETURN_MASK_ERROR)
7b26da
+    {
7b26da
+      /* Try to use prologue analysis to fill the unwind cache.
7b26da
+	 If this fails, fall back to reading the stack backchain.  */
7b26da
+      if (!s390_prologue_frame_unwind_cache (this_frame, info))
7b26da
+	s390_backchain_frame_unwind_cache (this_frame, info);
7b26da
+    }
7b26da
+  if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
7b26da
+    throw_exception (ex);
7b26da
 
7b26da
   return info;
7b26da
 }