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

7b26da
commit 33f8fe58b9a55a0075a90cc9080a1716221a3f81
7b26da
Author: Pedro Alves <palves@redhat.com>
7b26da
Date:   Fri Nov 22 11:51:59 2013 +0000
7b26da
7b26da
    Don't let two frames with the same id end up in the frame chain.
7b26da
    
7b26da
    The UNWIND_SAME_ID check is done between THIS_FRAME and the next frame
7b26da
    when we go try to unwind the previous frame.  But at this point, it's
7b26da
    already too late -- we ended up with two frames with the same ID in
7b26da
    the frame chain.  Each frame having its own ID is an invariant assumed
7b26da
    throughout GDB.  This patch applies the UNWIND_SAME_ID detection
7b26da
    earlier, right after the previous frame is unwound, discarding the dup
7b26da
    frame if a cycle is detected.
7b26da
    
7b26da
    The patch includes a new test that fails before the change.  Before
7b26da
    the patch, the test causes an infinite loop in GDB, after the patch,
7b26da
    the UNWIND_SAME_ID logic kicks in and makes the backtrace stop with:
7b26da
    
7b26da
      Backtrace stopped: previous frame identical to this frame (corrupt stack?)
7b26da
    
7b26da
    The test uses dwarf CFI to emulate a corrupted stack with a cycle.  It
7b26da
    has a function with registers marked DW_CFA_same_value (most
7b26da
    importantly RSP/RIP), so that GDB computes the same ID for that frame
7b26da
    and its caller.  IOW, something like this:
7b26da
    
7b26da
     #0 - frame_id_1
7b26da
     #1 - frame_id_2
7b26da
     #2 - frame_id_3
7b26da
     #3 - frame_id_4
7b26da
     #4 - frame_id_4  <<<< outermost (UNWIND_SAME_ID).
7b26da
    
7b26da
    (The test's code is just a copy of dw2-reg-undefined.S /
7b26da
    dw2-reg-undefined.c, adjusted to use DW_CFA_same_value instead of
7b26da
    DW_CFA_undefined, and to mark a different set of registers.)
7b26da
    
7b26da
    The infinite loop is here, in value_fetch_lazy:
7b26da
    
7b26da
          while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
7b26da
    	{
7b26da
    	  frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
7b26da
    ...
7b26da
    	  new_val = get_frame_register_value (frame, regnum);
7b26da
    	}
7b26da
    
7b26da
    get_frame_register_value can return a lazy register value pointing to
7b26da
    the next frame.  This means that the register wasn't clobbered by
7b26da
    FRAME; the debugger should therefore retrieve its value from the next
7b26da
    frame.
7b26da
    
7b26da
    To be clear, get_frame_register_value unwinds the value in question
7b26da
    from the next frame:
7b26da
    
7b26da
     struct value *
7b26da
     get_frame_register_value (struct frame_info *frame, int regnum)
7b26da
     {
7b26da
       return frame_unwind_register_value (frame->next, regnum);
7b26da
                                           ^^^^^^^^^^^
7b26da
     }
7b26da
    
7b26da
    In other words, if we get a lazy lval_register, it should have the
7b26da
    frame ID of the _next_ frame, never of FRAME.
7b26da
    
7b26da
    At this point in value_fetch_lazy, the whole relevant chunk of the
7b26da
    stack up to frame #4 has already been unwound.  The loop always
7b26da
    "unlazies" lval_registers in the "next/innermost" direction, not in
7b26da
    the "prev/unwind further/outermost" direction.
7b26da
    
7b26da
    So say we're looking at frame #4.  get_frame_register_value in frame
7b26da
    #4 can return a lazy register value of frame #3.  So the next
7b26da
    iteration, frame_find_by_id tries to read the register from frame #3.
7b26da
    But, since frame #4 happens to have same id as frame #3,
7b26da
    frame_find_by_id returns frame #4 instead.  Rinse, repeat, and we have
7b26da
    an infinite loop.
7b26da
    
7b26da
    This is an old latent problem, exposed by the recent addition of the
7b26da
    frame stash.  Before we had a stash, frame_find_by_id(frame_id_4)
7b26da
    would walk over all frames starting at the current frame, and would
7b26da
    always find #3 first.  The stash happens to return #4 instead:
7b26da
    
7b26da
    struct frame_info *
7b26da
    frame_find_by_id (struct frame_id id)
7b26da
    {
7b26da
      struct frame_info *frame, *prev_frame;
7b26da
    
7b26da
    ...
7b26da
      /* Try using the frame stash first.  Finding it there removes the need
7b26da
         to perform the search by looping over all frames, which can be very
7b26da
         CPU-intensive if the number of frames is very high (the loop is O(n)
7b26da
         and get_prev_frame performs a series of checks that are relatively
7b26da
         expensive).  This optimization is particularly useful when this function
7b26da
         is called from another function (such as value_fetch_lazy, case
7b26da
         VALUE_LVAL (val) == lval_register) which already loops over all frames,
7b26da
         making the overall behavior O(n^2).  */
7b26da
      frame = frame_stash_find (id);
7b26da
      if (frame)
7b26da
        return frame;
7b26da
    
7b26da
      for (frame = get_current_frame (); ; frame = prev_frame)
7b26da
        {
7b26da
    
7b26da
    gdb/
7b26da
    2013-11-22  Pedro Alves  <palves@redhat.com>
7b26da
    
7b26da
    	PR 16155
7b26da
    	* frame.c (get_prev_frame_1): Do the UNWIND_SAME_ID check between
7b26da
    	this frame and the new previous frame, not between this frame and
7b26da
    	the next frame.
7b26da
    
7b26da
    gdb/testsuite/
7b26da
    2013-11-22  Pedro Alves  <palves@redhat.com>
7b26da
    
7b26da
    	PR 16155
7b26da
    	* gdb.dwarf2/dw2-dup-frame.S: New file.
7b26da
    	* gdb.dwarf2/dw2-dup-frame.c: New file.
7b26da
    	* gdb.dwarf2/dw2-dup-frame.exp: New file.
7b26da
7b26da
Index: gdb-7.6.1/gdb/frame.c
7b26da
===================================================================
7b26da
--- gdb-7.6.1.orig/gdb/frame.c
7b26da
+++ gdb-7.6.1/gdb/frame.c
7b26da
@@ -1689,6 +1689,7 @@ get_prev_frame_1 (struct frame_info *thi
7b26da
 {
7b26da
   struct frame_id this_id;
7b26da
   struct gdbarch *gdbarch;
7b26da
+  struct frame_info *prev_frame;
7b26da
 
7b26da
   gdb_assert (this_frame != NULL);
7b26da
   gdbarch = get_frame_arch (this_frame);
7b26da
@@ -1790,22 +1791,6 @@ get_prev_frame_1 (struct frame_info *thi
7b26da
 	}
7b26da
     }
7b26da
 
7b26da
-  /* Check that this and the next frame are not identical.  If they
7b26da
-     are, there is most likely a stack cycle.  As with the inner-than
7b26da
-     test above, avoid comparing the inner-most and sentinel frames.  */
7b26da
-  if (this_frame->level > 0
7b26da
-      && frame_id_eq (this_id, get_frame_id (this_frame->next)))
7b26da
-    {
7b26da
-      if (frame_debug)
7b26da
-	{
7b26da
-	  fprintf_unfiltered (gdb_stdlog, "-> ");
7b26da
-	  fprint_frame (gdb_stdlog, NULL);
7b26da
-	  fprintf_unfiltered (gdb_stdlog, " // this frame has same ID }\n");
7b26da
-	}
7b26da
-      this_frame->stop_reason = UNWIND_SAME_ID;
7b26da
-      return NULL;
7b26da
-    }
7b26da
-
7b26da
   /* Check that this and the next frame do not unwind the PC register
7b26da
      to the same memory location.  If they do, then even though they
7b26da
      have different frame IDs, the new frame will be bogus; two
7b26da
@@ -1853,7 +1838,31 @@ get_prev_frame_1 (struct frame_info *thi
7b26da
 	}
7b26da
     }
7b26da
 
7b26da
-  return get_prev_frame_raw (this_frame);
7b26da
+  prev_frame = get_prev_frame_raw (this_frame);
7b26da
+
7b26da
+  /* Check that this and the prev frame are not identical.  If they
7b26da
+     are, there is most likely a stack cycle.  Unlike the tests above,
7b26da
+     we do this right after creating the prev frame, to avoid ever
7b26da
+     ending up with two frames with the same id in the frame
7b26da
+     chain.  */
7b26da
+  if (prev_frame != NULL
7b26da
+      && frame_id_eq (get_frame_id (prev_frame),
7b26da
+		      get_frame_id (this_frame)))
7b26da
+    {
7b26da
+      if (frame_debug)
7b26da
+	{
7b26da
+	  fprintf_unfiltered (gdb_stdlog, "-> ");
7b26da
+	  fprint_frame (gdb_stdlog, NULL);
7b26da
+	  fprintf_unfiltered (gdb_stdlog, " // this frame has same ID }\n");
7b26da
+	}
7b26da
+      this_frame->stop_reason = UNWIND_SAME_ID;
7b26da
+      /* Unlink.  */
7b26da
+      prev_frame->next = NULL;
7b26da
+      this_frame->prev = NULL;
7b26da
+      return NULL;
7b26da
+    }
7b26da
+
7b26da
+  return prev_frame;
7b26da
 }
7b26da
 
7b26da
 /* Construct a new "struct frame_info" and link it previous to
7b26da
Index: gdb-7.6.1/gdb/testsuite/gdb.dwarf2/dw2-dup-frame.S
7b26da
===================================================================
7b26da
--- /dev/null
7b26da
+++ gdb-7.6.1/gdb/testsuite/gdb.dwarf2/dw2-dup-frame.S
7b26da
@@ -0,0 +1,540 @@
7b26da
+/*
7b26da
+   Copyright 2013 Free Software Foundation, Inc.
7b26da
+
7b26da
+   This program is free software; you can redistribute it and/or modify
7b26da
+   it under the terms of the GNU General Public License as published by
7b26da
+   the Free Software Foundation; either version 3 of the License, or
7b26da
+   (at your option) any later version.
7b26da
+
7b26da
+   This program is distributed in the hope that it will be useful,
7b26da
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
7b26da
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7b26da
+   GNU General Public License for more details.
7b26da
+
7b26da
+   You should have received a copy of the GNU General Public License
7b26da
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7b26da
+
7b26da
+	/* The FDE entry for "stop_frame" in the .debug_frame section has
7b26da
+	been hand modified to mark a set of registers as DW_CFA_same_value.
7b26da
+	Otherwise this file is as generated by gcc 4.7.2 for x86_64.  */
7b26da
+	.file	"dw2-dup-frame.c"
7b26da
+	.text
7b26da
+.Ltext0:
7b26da
+	.globl	stop_frame
7b26da
+	.type	stop_frame, @function
7b26da
+stop_frame:
7b26da
+.LFB0:
7b26da
+	.file 1 "dw2-dup-frame.c"
7b26da
+	.loc 1 19 0
7b26da
+	pushq	%rbp
7b26da
+.LCFI0:
7b26da
+	movq	%rsp, %rbp
7b26da
+.LCFI1:
7b26da
+	.loc 1 22 0
7b26da
+	popq	%rbp
7b26da
+.LCFI2:
7b26da
+	ret
7b26da
+.LFE0:
7b26da
+	.size	stop_frame, .-stop_frame
7b26da
+	.globl	first_frame
7b26da
+	.type	first_frame, @function
7b26da
+first_frame:
7b26da
+.LFB1:
7b26da
+	.loc 1 26 0
7b26da
+	pushq	%rbp
7b26da
+.LCFI3:
7b26da
+	movq	%rsp, %rbp
7b26da
+.LCFI4:
7b26da
+	.loc 1 27 0
7b26da
+	movl	$0, %eax
7b26da
+	call	stop_frame
7b26da
+	.loc 1 28 0
7b26da
+	popq	%rbp
7b26da
+.LCFI5:
7b26da
+	ret
7b26da
+.LFE1:
7b26da
+	.size	first_frame, .-first_frame
7b26da
+	.globl	main
7b26da
+	.type	main, @function
7b26da
+main:
7b26da
+.LFB2:
7b26da
+	.loc 1 32 0
7b26da
+	pushq	%rbp
7b26da
+.LCFI6:
7b26da
+	movq	%rsp, %rbp
7b26da
+.LCFI7:
7b26da
+	.loc 1 33 0
7b26da
+	movl	$0, %eax
7b26da
+	call	first_frame
7b26da
+	.loc 1 35 0
7b26da
+	movl	$0, %eax
7b26da
+	.loc 1 36 0
7b26da
+	popq	%rbp
7b26da
+.LCFI8:
7b26da
+	ret
7b26da
+.LFE2:
7b26da
+	.size	main, .-main
7b26da
+	.section	.debug_frame,"",@progbits
7b26da
+.Lframe0:
7b26da
+	.long	.LECIE0-.LSCIE0
7b26da
+.LSCIE0:
7b26da
+	.long	0xffffffff
7b26da
+	.byte	0x1
7b26da
+	.string	""
7b26da
+	.uleb128 0x1
7b26da
+	.sleb128 -8
7b26da
+	.byte	0x10
7b26da
+	.byte	0xc
7b26da
+	.uleb128 0x7
7b26da
+	.uleb128 0x8
7b26da
+	.byte	0x90
7b26da
+	.uleb128 0x1
7b26da
+	.align 8
7b26da
+.LECIE0:
7b26da
+	/* This FDE entry, for stop_frame was modified to mark
7b26da
+	   registers 0 -> 16 (rax..ra/rip) as being DW_CFA_same_value.  */
7b26da
+.LSFDE0:
7b26da
+	.long	.LEFDE0-.LASFDE0
7b26da
+.LASFDE0:
7b26da
+	.long	.Lframe0
7b26da
+	.quad	.LFB0
7b26da
+	.quad	.LFE0-.LFB0
7b26da
+
7b26da
+		/* START OF NEW CONTENT.  */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x0			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x1			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x2			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x3			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x4			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x5			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x6			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x7			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x8			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x9			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0xa			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0xb			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0xc			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0xd			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0xe			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0xf			/*   ULEB128 register */
7b26da
+	.byte	0x8			/* DW_CFA_same_value */
7b26da
+	.uleb128 0x10			 /*   ULEB128 register */
7b26da
+		/* END OF NEW CONTENT.  */
7b26da
+
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI0-.LFB0
7b26da
+	.byte	0xe
7b26da
+	.uleb128 0x10
7b26da
+	.byte	0x86
7b26da
+	.uleb128 0x2
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI1-.LCFI0
7b26da
+	.byte	0xd
7b26da
+	.uleb128 0x6
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI2-.LCFI1
7b26da
+	.byte	0xc
7b26da
+	.uleb128 0x7
7b26da
+	.uleb128 0x8
7b26da
+	.align 8
7b26da
+.LEFDE0:
7b26da
+.LSFDE2:
7b26da
+	.long	.LEFDE2-.LASFDE2
7b26da
+.LASFDE2:
7b26da
+	.long	.Lframe0
7b26da
+	.quad	.LFB1
7b26da
+	.quad	.LFE1-.LFB1
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI3-.LFB1
7b26da
+	.byte	0xe
7b26da
+	.uleb128 0x10
7b26da
+	.byte	0x86
7b26da
+	.uleb128 0x2
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI4-.LCFI3
7b26da
+	.byte	0xd
7b26da
+	.uleb128 0x6
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI5-.LCFI4
7b26da
+	.byte	0xc
7b26da
+	.uleb128 0x7
7b26da
+	.uleb128 0x8
7b26da
+	.align 8
7b26da
+.LEFDE2:
7b26da
+.LSFDE4:
7b26da
+	.long	.LEFDE4-.LASFDE4
7b26da
+.LASFDE4:
7b26da
+	.long	.Lframe0
7b26da
+	.quad	.LFB2
7b26da
+	.quad	.LFE2-.LFB2
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI6-.LFB2
7b26da
+	.byte	0xe
7b26da
+	.uleb128 0x10
7b26da
+	.byte	0x86
7b26da
+	.uleb128 0x2
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI7-.LCFI6
7b26da
+	.byte	0xd
7b26da
+	.uleb128 0x6
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI8-.LCFI7
7b26da
+	.byte	0xc
7b26da
+	.uleb128 0x7
7b26da
+	.uleb128 0x8
7b26da
+	.align 8
7b26da
+.LEFDE4:
7b26da
+	.section	.eh_frame,"a",@progbits
7b26da
+.Lframe1:
7b26da
+	.long	.LECIE1-.LSCIE1
7b26da
+.LSCIE1:
7b26da
+	.long	0
7b26da
+	.byte	0x1
7b26da
+	.string	"zR"
7b26da
+	.uleb128 0x1
7b26da
+	.sleb128 -8
7b26da
+	.byte	0x10
7b26da
+	.uleb128 0x1
7b26da
+	.byte	0x3
7b26da
+	.byte	0xc
7b26da
+	.uleb128 0x7
7b26da
+	.uleb128 0x8
7b26da
+	.byte	0x90
7b26da
+	.uleb128 0x1
7b26da
+	.align 8
7b26da
+.LECIE1:
7b26da
+.LSFDE7:
7b26da
+	.long	.LEFDE7-.LASFDE7
7b26da
+.LASFDE7:
7b26da
+	.long	.LASFDE7-.Lframe1
7b26da
+	.long	.LFB0
7b26da
+	.long	.LFE0-.LFB0
7b26da
+	.uleb128 0
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI0-.LFB0
7b26da
+	.byte	0xe
7b26da
+	.uleb128 0x10
7b26da
+	.byte	0x86
7b26da
+	.uleb128 0x2
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI1-.LCFI0
7b26da
+	.byte	0xd
7b26da
+	.uleb128 0x6
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI2-.LCFI1
7b26da
+	.byte	0xc
7b26da
+	.uleb128 0x7
7b26da
+	.uleb128 0x8
7b26da
+	.align 8
7b26da
+.LEFDE7:
7b26da
+.LSFDE9:
7b26da
+	.long	.LEFDE9-.LASFDE9
7b26da
+.LASFDE9:
7b26da
+	.long	.LASFDE9-.Lframe1
7b26da
+	.long	.LFB1
7b26da
+	.long	.LFE1-.LFB1
7b26da
+	.uleb128 0
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI3-.LFB1
7b26da
+	.byte	0xe
7b26da
+	.uleb128 0x10
7b26da
+	.byte	0x86
7b26da
+	.uleb128 0x2
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI4-.LCFI3
7b26da
+	.byte	0xd
7b26da
+	.uleb128 0x6
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI5-.LCFI4
7b26da
+	.byte	0xc
7b26da
+	.uleb128 0x7
7b26da
+	.uleb128 0x8
7b26da
+	.align 8
7b26da
+.LEFDE9:
7b26da
+.LSFDE11:
7b26da
+	.long	.LEFDE11-.LASFDE11
7b26da
+.LASFDE11:
7b26da
+	.long	.LASFDE11-.Lframe1
7b26da
+	.long	.LFB2
7b26da
+	.long	.LFE2-.LFB2
7b26da
+	.uleb128 0
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI6-.LFB2
7b26da
+	.byte	0xe
7b26da
+	.uleb128 0x10
7b26da
+	.byte	0x86
7b26da
+	.uleb128 0x2
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI7-.LCFI6
7b26da
+	.byte	0xd
7b26da
+	.uleb128 0x6
7b26da
+	.byte	0x4
7b26da
+	.long	.LCFI8-.LCFI7
7b26da
+	.byte	0xc
7b26da
+	.uleb128 0x7
7b26da
+	.uleb128 0x8
7b26da
+	.align 8
7b26da
+.LEFDE11:
7b26da
+	.text
7b26da
+.Letext0:
7b26da
+	.section	.debug_info,"",@progbits
7b26da
+.Ldebug_info0:
7b26da
+	.long	0x8c
7b26da
+	.value	0x2
7b26da
+	.long	.Ldebug_abbrev0
7b26da
+	.byte	0x8
7b26da
+	.uleb128 0x1
7b26da
+	.long	.LASF2
7b26da
+	.byte	0x1
7b26da
+	.long	.LASF3
7b26da
+	.long	.LASF4
7b26da
+	.quad	.Ltext0
7b26da
+	.quad	.Letext0
7b26da
+	.long	.Ldebug_line0
7b26da
+	.uleb128 0x2
7b26da
+	.byte	0x1
7b26da
+	.long	.LASF0
7b26da
+	.byte	0x1
7b26da
+	.byte	0x12
7b26da
+	.quad	.LFB0
7b26da
+	.quad	.LFE0
7b26da
+	.long	.LLST0
7b26da
+	.byte	0x1
7b26da
+	.uleb128 0x3
7b26da
+	.byte	0x1
7b26da
+	.long	.LASF1
7b26da
+	.byte	0x1
7b26da
+	.byte	0x19
7b26da
+	.quad	.LFB1
7b26da
+	.quad	.LFE1
7b26da
+	.long	.LLST1
7b26da
+	.byte	0x1
7b26da
+	.uleb128 0x4
7b26da
+	.byte	0x1
7b26da
+	.long	.LASF5
7b26da
+	.byte	0x1
7b26da
+	.byte	0x1f
7b26da
+	.long	0x88
7b26da
+	.quad	.LFB2
7b26da
+	.quad	.LFE2
7b26da
+	.long	.LLST2
7b26da
+	.byte	0x1
7b26da
+	.uleb128 0x5
7b26da
+	.byte	0x4
7b26da
+	.byte	0x5
7b26da
+	.string	"int"
7b26da
+	.byte	0
7b26da
+	.section	.debug_abbrev,"",@progbits
7b26da
+.Ldebug_abbrev0:
7b26da
+	.uleb128 0x1
7b26da
+	.uleb128 0x11
7b26da
+	.byte	0x1
7b26da
+	.uleb128 0x25
7b26da
+	.uleb128 0xe
7b26da
+	.uleb128 0x13
7b26da
+	.uleb128 0xb
7b26da
+	.uleb128 0x3
7b26da
+	.uleb128 0xe
7b26da
+	.uleb128 0x1b
7b26da
+	.uleb128 0xe
7b26da
+	.uleb128 0x11
7b26da
+	.uleb128 0x1
7b26da
+	.uleb128 0x12
7b26da
+	.uleb128 0x1
7b26da
+	.uleb128 0x10
7b26da
+	.uleb128 0x6
7b26da
+	.byte	0
7b26da
+	.byte	0
7b26da
+	.uleb128 0x2
7b26da
+	.uleb128 0x2e
7b26da
+	.byte	0
7b26da
+	.uleb128 0x3f
7b26da
+	.uleb128 0xc
7b26da
+	.uleb128 0x3
7b26da
+	.uleb128 0xe
7b26da
+	.uleb128 0x3a
7b26da
+	.uleb128 0xb
7b26da
+	.uleb128 0x3b
7b26da
+	.uleb128 0xb
7b26da
+	.uleb128 0x11
7b26da
+	.uleb128 0x1
7b26da
+	.uleb128 0x12
7b26da
+	.uleb128 0x1
7b26da
+	.uleb128 0x40
7b26da
+	.uleb128 0x6
7b26da
+	.uleb128 0x2117
7b26da
+	.uleb128 0xc
7b26da
+	.byte	0
7b26da
+	.byte	0
7b26da
+	.uleb128 0x3
7b26da
+	.uleb128 0x2e
7b26da
+	.byte	0
7b26da
+	.uleb128 0x3f
7b26da
+	.uleb128 0xc
7b26da
+	.uleb128 0x3
7b26da
+	.uleb128 0xe
7b26da
+	.uleb128 0x3a
7b26da
+	.uleb128 0xb
7b26da
+	.uleb128 0x3b
7b26da
+	.uleb128 0xb
7b26da
+	.uleb128 0x11
7b26da
+	.uleb128 0x1
7b26da
+	.uleb128 0x12
7b26da
+	.uleb128 0x1
7b26da
+	.uleb128 0x40
7b26da
+	.uleb128 0x6
7b26da
+	.uleb128 0x2116
7b26da
+	.uleb128 0xc
7b26da
+	.byte	0
7b26da
+	.byte	0
7b26da
+	.uleb128 0x4
7b26da
+	.uleb128 0x2e
7b26da
+	.byte	0
7b26da
+	.uleb128 0x3f
7b26da
+	.uleb128 0xc
7b26da
+	.uleb128 0x3
7b26da
+	.uleb128 0xe
7b26da
+	.uleb128 0x3a
7b26da
+	.uleb128 0xb
7b26da
+	.uleb128 0x3b
7b26da
+	.uleb128 0xb
7b26da
+	.uleb128 0x49
7b26da
+	.uleb128 0x13
7b26da
+	.uleb128 0x11
7b26da
+	.uleb128 0x1
7b26da
+	.uleb128 0x12
7b26da
+	.uleb128 0x1
7b26da
+	.uleb128 0x40
7b26da
+	.uleb128 0x6
7b26da
+	.uleb128 0x2116
7b26da
+	.uleb128 0xc
7b26da
+	.byte	0
7b26da
+	.byte	0
7b26da
+	.uleb128 0x5
7b26da
+	.uleb128 0x24
7b26da
+	.byte	0
7b26da
+	.uleb128 0xb
7b26da
+	.uleb128 0xb
7b26da
+	.uleb128 0x3e
7b26da
+	.uleb128 0xb
7b26da
+	.uleb128 0x3
7b26da
+	.uleb128 0x8
7b26da
+	.byte	0
7b26da
+	.byte	0
7b26da
+	.byte	0
7b26da
+	.section	.debug_loc,"",@progbits
7b26da
+.Ldebug_loc0:
7b26da
+.LLST0:
7b26da
+	.quad	.LFB0-.Ltext0
7b26da
+	.quad	.LCFI0-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x77
7b26da
+	.sleb128 8
7b26da
+	.quad	.LCFI0-.Ltext0
7b26da
+	.quad	.LCFI1-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x77
7b26da
+	.sleb128 16
7b26da
+	.quad	.LCFI1-.Ltext0
7b26da
+	.quad	.LCFI2-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x76
7b26da
+	.sleb128 16
7b26da
+	.quad	.LCFI2-.Ltext0
7b26da
+	.quad	.LFE0-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x77
7b26da
+	.sleb128 8
7b26da
+	.quad	0
7b26da
+	.quad	0
7b26da
+.LLST1:
7b26da
+	.quad	.LFB1-.Ltext0
7b26da
+	.quad	.LCFI3-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x77
7b26da
+	.sleb128 8
7b26da
+	.quad	.LCFI3-.Ltext0
7b26da
+	.quad	.LCFI4-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x77
7b26da
+	.sleb128 16
7b26da
+	.quad	.LCFI4-.Ltext0
7b26da
+	.quad	.LCFI5-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x76
7b26da
+	.sleb128 16
7b26da
+	.quad	.LCFI5-.Ltext0
7b26da
+	.quad	.LFE1-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x77
7b26da
+	.sleb128 8
7b26da
+	.quad	0
7b26da
+	.quad	0
7b26da
+.LLST2:
7b26da
+	.quad	.LFB2-.Ltext0
7b26da
+	.quad	.LCFI6-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x77
7b26da
+	.sleb128 8
7b26da
+	.quad	.LCFI6-.Ltext0
7b26da
+	.quad	.LCFI7-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x77
7b26da
+	.sleb128 16
7b26da
+	.quad	.LCFI7-.Ltext0
7b26da
+	.quad	.LCFI8-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x76
7b26da
+	.sleb128 16
7b26da
+	.quad	.LCFI8-.Ltext0
7b26da
+	.quad	.LFE2-.Ltext0
7b26da
+	.value	0x2
7b26da
+	.byte	0x77
7b26da
+	.sleb128 8
7b26da
+	.quad	0
7b26da
+	.quad	0
7b26da
+	.section	.debug_aranges,"",@progbits
7b26da
+	.long	0x2c
7b26da
+	.value	0x2
7b26da
+	.long	.Ldebug_info0
7b26da
+	.byte	0x8
7b26da
+	.byte	0
7b26da
+	.value	0
7b26da
+	.value	0
7b26da
+	.quad	.Ltext0
7b26da
+	.quad	.Letext0-.Ltext0
7b26da
+	.quad	0
7b26da
+	.quad	0
7b26da
+	.section	.debug_line,"",@progbits
7b26da
+.Ldebug_line0:
7b26da
+	.section	.debug_str,"MS",@progbits,1
7b26da
+.LASF0:
7b26da
+	.string	"stop_frame"
7b26da
+.LASF3:
7b26da
+	.string	"dw2-reg-undefined.c"
7b26da
+.LASF2:
7b26da
+	.string	"GNU C 4.7.2"
7b26da
+.LASF1:
7b26da
+	.string	"first_frame"
7b26da
+.LASF5:
7b26da
+	.string	"main"
7b26da
+.LASF4:
7b26da
+	.string	"/home/username/src/gdb/testsuite/gdb.dwarf2"
7b26da
+	.ident	"GCC: (GNU) 4.7.2"
7b26da
+	.section	.note.GNU-stack,"",@progbits
7b26da
Index: gdb-7.6.1/gdb/testsuite/gdb.dwarf2/dw2-dup-frame.c
7b26da
===================================================================
7b26da
--- /dev/null
7b26da
+++ gdb-7.6.1/gdb/testsuite/gdb.dwarf2/dw2-dup-frame.c
7b26da
@@ -0,0 +1,36 @@
7b26da
+/*
7b26da
+   Copyright 2013 Free Software Foundation, Inc.
7b26da
+
7b26da
+   This program is free software; you can redistribute it and/or modify
7b26da
+   it under the terms of the GNU General Public License as published by
7b26da
+   the Free Software Foundation; either version 3 of the License, or
7b26da
+   (at your option) any later version.
7b26da
+
7b26da
+   This program is distributed in the hope that it will be useful,
7b26da
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
7b26da
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7b26da
+   GNU General Public License for more details.
7b26da
+
7b26da
+   You should have received a copy of the GNU General Public License
7b26da
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7b26da
+
7b26da
+void
7b26da
+stop_frame ()
7b26da
+{
7b26da
+  /* The debug information for this frame is modified in the accompanying
7b26da
+     .S file, to mark a set of registers as being DW_CFA_same_value.  */
7b26da
+}
7b26da
+
7b26da
+void
7b26da
+first_frame ()
7b26da
+{
7b26da
+  stop_frame ();
7b26da
+}
7b26da
+
7b26da
+int
7b26da
+main ()
7b26da
+{
7b26da
+  first_frame ();
7b26da
+
7b26da
+  return 0;
7b26da
+}
7b26da
Index: gdb-7.6.1/gdb/testsuite/gdb.dwarf2/dw2-dup-frame.exp
7b26da
===================================================================
7b26da
--- /dev/null
7b26da
+++ gdb-7.6.1/gdb/testsuite/gdb.dwarf2/dw2-dup-frame.exp
7b26da
@@ -0,0 +1,44 @@
7b26da
+# Copyright 2013 Free Software Foundation, Inc.
7b26da
+
7b26da
+# This program is free software; you can redistribute it and/or modify
7b26da
+# it under the terms of the GNU General Public License as published by
7b26da
+# the Free Software Foundation; either version 3 of the License, or
7b26da
+# (at your option) any later version.
7b26da
+#
7b26da
+# This program is distributed in the hope that it will be useful,
7b26da
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
7b26da
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7b26da
+# GNU General Public License for more details.
7b26da
+#
7b26da
+# You should have received a copy of the GNU General Public License
7b26da
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7b26da
+load_lib dwarf.exp
7b26da
+
7b26da
+# This test can only be run on targets which support DWARF-2 and use gas.
7b26da
+if {![dwarf2_support]} {
7b26da
+    return 0
7b26da
+}
7b26da
+
7b26da
+# This test can only be run on x86_64 targets.
7b26da
+if {![istarget "x86_64-*-*"] || ![is_lp64_target]} {
7b26da
+    return 0
7b26da
+}
7b26da
+
7b26da
+standard_testfile .S
7b26da
+
7b26da
+if { [prepare_for_testing $testfile.exp $testfile $srcfile {nodebug}] } {
7b26da
+    return -1
7b26da
+}
7b26da
+
7b26da
+if ![runto stop_frame] {
7b26da
+    perror "Failed to stop in stop_frame"
7b26da
+    return -1
7b26da
+}
7b26da
+
7b26da
+gdb_test "bt" \
7b26da
+    "#0  stop_frame \[^\r\n\]*\r\nBacktrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)" \
7b26da
+    "backtrace from stop_frame"
7b26da
+
7b26da
+gdb_test "up" \
7b26da
+    "Initial frame selected; you cannot go up\\\." \
7b26da
+    "up from stop_frame"