Blame SOURCES/gdb-gnat-dwarf-crash-1of3.patch

8c62a9
commit adde2bff0757e89175ede493f03b86953d0d9352
8c62a9
Author: Doug Evans <xdje42@gmail.com>
8c62a9
Date:   Thu Feb 20 09:13:53 2014 -0800
8c62a9
8c62a9
    Fix PR symtab/16581
8c62a9
    
8c62a9
    	* dwarf2read.c (struct die_info): New member in_process.
8c62a9
    	(reset_die_in_process): New function.
8c62a9
    	(process_die): Set it at the start, reset when returning.
8c62a9
    	(inherit_abstract_dies): Only call process_die if origin_child_die
8c62a9
    	not already being processed.
8c62a9
    
8c62a9
    	testsuite/
8c62a9
    	* gdb.dwarf2/dw2-icycle.S: New file.
8c62a9
    	* gdb.dwarf2/dw2-icycle.c: New file.
8c62a9
    	* gdb.dwarf2/dw2-icycle.exp: New file.
8c62a9
8c62a9
### a/gdb/ChangeLog
8c62a9
### b/gdb/ChangeLog
8c62a9
## -1,3 +1,14 @@
8c62a9
+2014-02-20  lin zuojian  <manjian2006@gmail.com>
8c62a9
+	    Joel Brobecker  <brobecker@adacore.com>
8c62a9
+	    Doug Evans  <xdje42@gmail.com>
8c62a9
+
8c62a9
+	PR symtab/16581
8c62a9
+	* dwarf2read.c (struct die_info): New member in_process.
8c62a9
+	(reset_die_in_process): New function.
8c62a9
+	(process_die): Set it at the start, reset when returning.
8c62a9
+	(inherit_abstract_dies): Only call process_die if origin_child_die
8c62a9
+	not already being processed.
8c62a9
+
8c62a9
 2014-02-20  Joel Brobecker  <brobecker@adacore.com>
8c62a9
 
8c62a9
 	* windows-nat.c (handle_unload_dll): Add function documentation.
8c62a9
--- a/gdb/dwarf2read.c
8c62a9
+++ b/gdb/dwarf2read.c
8c62a9
@@ -1225,6 +1225,9 @@ struct die_info
8c62a9
        type derived from this DIE.  */
8c62a9
     unsigned char building_fullname : 1;
8c62a9
 
8c62a9
+    /* True if this die is in process.  PR 16581.  */
8c62a9
+    unsigned char in_process : 1;
8c62a9
+
8c62a9
     /* Abbrev number */
8c62a9
     unsigned int abbrev;
8c62a9
 
8c62a9
@@ -8008,11 +8011,28 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu)
8c62a9
     }
8c62a9
 }
8c62a9
 
8c62a9
+/* Reset the in_process bit of a die.  */
8c62a9
+
8c62a9
+static void
8c62a9
+reset_die_in_process (void *arg)
8c62a9
+{
8c62a9
+  struct die_info *die = arg;
8c62a9
+  die->in_process = 0;
8c62a9
+}
8c62a9
+
8c62a9
 /* Process a die and its children.  */
8c62a9
 
8c62a9
 static void
8c62a9
 process_die (struct die_info *die, struct dwarf2_cu *cu)
8c62a9
 {
8c62a9
+  struct cleanup *in_process;
8c62a9
+
8c62a9
+  /* We should only be processing those not already in process.  */
8c62a9
+  gdb_assert (!die->in_process);
8c62a9
+
8c62a9
+  die->in_process = 1;
8c62a9
+  in_process = make_cleanup (reset_die_in_process,die);
8c62a9
+
8c62a9
   switch (die->tag)
8c62a9
     {
8c62a9
     case DW_TAG_padding:
8c62a9
@@ -7278,6 +7298,8 @@ process_die (struct die_info *die, struc
8c62a9
       new_symbol (die, NULL, cu);
8c62a9
       break;
8c62a9
     }
8c62a9
+
8c62a9
+  do_cleanups (in_process);
8c62a9
 }
8c62a9
 
8c62a9
 /* A helper function for dwarf2_compute_name which determines whether DIE
8c62a9
@@ -10967,8 +10989,12 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
8c62a9
       if (offsetp >= offsets_end
8c62a9
 	  || offsetp->sect_off > origin_child_die->offset.sect_off)
8c62a9
 	{
8c62a9
-	  /* Found that ORIGIN_CHILD_DIE is really not referenced.  */
8c62a9
-	  process_die (origin_child_die, origin_cu);
8c62a9
+	  /* Found that ORIGIN_CHILD_DIE is really not referenced.
8c62a9
+	     Check whether we're already processing ORIGIN_CHILD_DIE.
8c62a9
+	     This can happen with mutually referenced abstract_origins.
8c62a9
+	     PR 16581.  */
8c62a9
+	  if (!origin_child_die->in_process)
8c62a9
+	    process_die (origin_child_die, origin_cu);
8c62a9
 	}
8c62a9
       origin_child_die = sibling_die (origin_child_die);
8c62a9
     }
8c62a9
### a/gdb/testsuite/ChangeLog
8c62a9
### b/gdb/testsuite/ChangeLog
8c62a9
## -1,3 +1,12 @@
8c62a9
+2014-02-20  lin zuojian  <manjian2006@gmail.com>
8c62a9
+	    Joel Brobecker  <brobecker@adacore.com>
8c62a9
+	    Doug Evans  <xdje42@gmail.com>
8c62a9
+
8c62a9
+	PR symtab/16581
8c62a9
+	* gdb.dwarf2/dw2-icycle.S: New file.
8c62a9
+	* gdb.dwarf2/dw2-icycle.c: New file.
8c62a9
+	* gdb.dwarf2/dw2-icycle.exp: New file.
8c62a9
+
8c62a9
 2014-02-19  Siva Chandra Reddy  <sivachandra@google.com>
8c62a9
 
8c62a9
 	* gdb.python/py-value-cc.cc: Improve test case to enable testing
8c62a9
--- /dev/null
8c62a9
+++ b/gdb/testsuite/gdb.dwarf2/dw2-icycle.S
8c62a9
@@ -0,0 +1,258 @@
8c62a9
+/* This testcase is part of GDB, the GNU debugger.
8c62a9
+
8c62a9
+   Copyright 2014 Free Software Foundation, Inc.
8c62a9
+
8c62a9
+   This program is free software; you can redistribute it and/or modify
8c62a9
+   it under the terms of the GNU General Public License as published by
8c62a9
+   the Free Software Foundation; either version 3 of the License, or
8c62a9
+   (at your option) any later version.
8c62a9
+
8c62a9
+   This program is distributed in the hope that it will be useful,
8c62a9
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
8c62a9
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8c62a9
+   GNU General Public License for more details.
8c62a9
+
8c62a9
+   You should have received a copy of the GNU General Public License
8c62a9
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
8c62a9
+
8c62a9
+	.text
8c62a9
+
8c62a9
+.Ltext0:
8c62a9
+	.type	p__top__middle__inside.3062, @function
8c62a9
+p__top__middle__inside.3062:
8c62a9
+.LFB4:
8c62a9
+	.file 1 "p.adb"
8c62a9
+        .4byte 0
8c62a9
+.LBE6:
8c62a9
+
8c62a9
+	.globl	p__top
8c62a9
+	.type	p__top, @function
8c62a9
+p__top:
8c62a9
+.LFB2:
8c62a9
+        .4byte 0
8c62a9
+.LFE2:
8c62a9
+.Letext0:
8c62a9
+
8c62a9
+	.section	.debug_info,"",@progbits
8c62a9
+.Ldebug_info0:
8c62a9
+	.4byte	.Ledebug_info0 - .Lsdebug_info0  /* Length of CU Info */
8c62a9
+.Lsdebug_info0:
8c62a9
+	.2byte	0x4	/* DWARF version number */
8c62a9
+	.4byte	.Ldebug_abbrev0	/* Offset Into Abbrev. Section */
8c62a9
+	.byte	0x4	/* Pointer Size (in bytes) */
8c62a9
+	.uleb128 0x1	/* (DIE (0xb) DW_TAG_compile_unit) */
8c62a9
+	.ascii	"GNU Ada 4.9.0 20140126\0" /* DW_AT_producer */
8c62a9
+	.byte	0xd	/* DW_AT_language */
8c62a9
+	.ascii	"p.adb\0" /* DW_AT_name */
8c62a9
+	.ascii	"/tmp\0"  /* DW_AT_comp_dir */
8c62a9
+	.4byte	.Ltext0	/* DW_AT_low_pc */
8c62a9
+	.4byte	.Letext0-.Ltext0	/* DW_AT_high_pc */
8c62a9
+.S0x142:
8c62a9
+	.uleb128 0x8	/* (DIE (0x142) DW_TAG_base_type) */
8c62a9
+	.byte	0x4	/* DW_AT_byte_size */
8c62a9
+	.byte	0x5	/* DW_AT_encoding */
8c62a9
+	.ascii	"integer\0" /* DW_AT_name */
8c62a9
+
8c62a9
+	.uleb128 0x13	/* (DIE (0x1b4) DW_TAG_subprogram) */
8c62a9
+			/* DW_AT_external */
8c62a9
+	.ascii	"p__top\0" /* DW_AT_name */
8c62a9
+	.byte	0x1	/* DW_AT_decl_file (p.adb) */
8c62a9
+	.byte	0x3	/* DW_AT_decl_line */
8c62a9
+	.4byte	.LFB2	/* DW_AT_low_pc */
8c62a9
+	.4byte	.LFE2-.LFB2	/* DW_AT_high_pc */
8c62a9
+	.uleb128 0x1	/* DW_AT_frame_base */
8c62a9
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
8c62a9
+			/* DW_AT_GNU_all_call_sites */
8c62a9
+	.4byte	.S0x4fc - .Ldebug_info0	/* DW_AT_sibling */
8c62a9
+.S0x1e0:
8c62a9
+	.uleb128 0x15	/* (DIE (0x1e0) DW_TAG_subprogram) */
8c62a9
+	.ascii	"p__top__middle\0" /* DW_AT_name */
8c62a9
+	.byte	0x1	/* DW_AT_decl_file (p.adb) */
8c62a9
+	.byte	0x4	/* DW_AT_decl_line */
8c62a9
+	.byte	0x1	/* DW_AT_inline */
8c62a9
+	.4byte	.S0x374 - .Ldebug_info0	/* DW_AT_sibling */
8c62a9
+.S0x202:
8c62a9
+	.uleb128 0x15	/* (DIE (0x202) DW_TAG_subprogram) */
8c62a9
+	.ascii	"p__top__middle__inside\0" /* DW_AT_name */
8c62a9
+	.byte	0x1	/* DW_AT_decl_file (p.adb) */
8c62a9
+	.byte	0x5	/* DW_AT_decl_line */
8c62a9
+	.byte	0x1	/* DW_AT_inline */
8c62a9
+	.4byte	.S0x225	- .Ldebug_info0 /* DW_AT_sibling */
8c62a9
+	.byte	0	/* end of children of DIE 0x202 */
8c62a9
+.S0x225:
8c62a9
+	.uleb128 0x18	/* (DIE (0x225) DW_TAG_subprogram) */
8c62a9
+	.4byte	.S0x202 - .Ldebug_info0	/* DW_AT_abstract_origin */
8c62a9
+	.4byte	.LFB4	/* DW_AT_low_pc */
8c62a9
+	.4byte	.LBE6-.LFB4	/* DW_AT_high_pc */
8c62a9
+	.uleb128 0x1	/* DW_AT_frame_base */
8c62a9
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
8c62a9
+	.uleb128 0x1	/* DW_AT_static_link */
8c62a9
+	.byte	0x56	/* DW_OP_reg6 */
8c62a9
+			/* DW_AT_GNU_all_call_sites */
8c62a9
+	.uleb128 0x1a	/* (DIE (0x247) DW_TAG_inlined_subroutine) */
8c62a9
+	.4byte	.S0x1e0 - .Ldebug_info0	/* DW_AT_abstract_origin */
8c62a9
+	.4byte	.LFB4	/* DW_AT_low_pc */
8c62a9
+	.4byte	.LBE6-.LFB4	/* DW_AT_high_pc */
8c62a9
+	.byte	0x1	/* DW_AT_call_file (p.adb) */
8c62a9
+	.byte	0x14	/* DW_AT_call_line */
8c62a9
+	.4byte	.S0x374	- .Ldebug_info0 /* DW_AT_sibling */
8c62a9
+	.byte	0	/* end of children of DIE 0x247 */
8c62a9
+	.byte	0	/* end of children of DIE 0x225 */
8c62a9
+	.byte	0	/* end of children of DIE 0x1e0 */
8c62a9
+.S0x374:
8c62a9
+	.uleb128 0x23	/* (DIE (0x382) DW_TAG_inlined_subroutine) */
8c62a9
+	.4byte	.S0x1e0 - .Ldebug_info0 /* DW_AT_abstract_origin */
8c62a9
+	.4byte	.LFB4	/* DW_AT_low_pc */
8c62a9
+	.4byte	.LBE6-.LFB4	/* DW_AT_high_pc */
8c62a9
+	.byte	0x1	/* DW_AT_call_file (p.adb) */
8c62a9
+	.byte	0x1d	/* DW_AT_call_line */
8c62a9
+	.byte	0	/* end of children of DIE 0x382 */
8c62a9
+	.byte	0	/* end of children of DIE 0x1b4 */
8c62a9
+.S0x4fc:
8c62a9
+	.uleb128 0x28	/* (DIE (0x52e) DW_TAG_subprogram) */
8c62a9
+			/* DW_AT_external */
8c62a9
+	.ascii	"__gnat_rcheck_PE_Explicit_Raise\0" /* DW_AT_name */
8c62a9
+			/* DW_AT_artificial */
8c62a9
+			/* DW_AT_declaration */
8c62a9
+	.byte	0	/* end of children of DIE 0x52e */
8c62a9
+	.byte	0	/* end of children of DIE 0xb */
8c62a9
+.Ledebug_info0:
8c62a9
+
8c62a9
+	.section	.debug_abbrev,"",@progbits
8c62a9
+.Ldebug_abbrev0:
8c62a9
+	.uleb128 0x1	/* (abbrev code) */
8c62a9
+	.uleb128 0x11	/* (TAG: DW_TAG_compile_unit) */
8c62a9
+	.byte	0x1	/* DW_children_yes */
8c62a9
+	.uleb128 0x25	/* (DW_AT_producer) */
8c62a9
+	.uleb128 0x8	/* (DW_FORM_string) */
8c62a9
+	.uleb128 0x13	/* (DW_AT_language) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x3	/* (DW_AT_name) */
8c62a9
+	.uleb128 0x8	/* (DW_FORM_string) */
8c62a9
+	.uleb128 0x1b	/* (DW_AT_comp_dir) */
8c62a9
+	.uleb128 0x8	/* (DW_FORM_string) */
8c62a9
+	.uleb128 0x11	/* (DW_AT_low_pc) */
8c62a9
+	.uleb128 0x1	/* (DW_FORM_addr) */
8c62a9
+	.uleb128 0x12	/* (DW_AT_high_pc) */
8c62a9
+	.uleb128 0x6	/* (DW_FORM_data4) */
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+	.uleb128 0x8	/* (abbrev code) */
8c62a9
+	.uleb128 0x24	/* (TAG: DW_TAG_base_type) */
8c62a9
+	.byte	0	/* DW_children_no */
8c62a9
+	.uleb128 0xb	/* (DW_AT_byte_size) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x3e	/* (DW_AT_encoding) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x3	/* (DW_AT_name) */
8c62a9
+	.uleb128 0x8	/* (DW_FORM_string) */
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+	.uleb128 0x13	/* (abbrev code) */
8c62a9
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
8c62a9
+	.byte	0x1	/* DW_children_yes */
8c62a9
+	.uleb128 0x3f	/* (DW_AT_external) */
8c62a9
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
8c62a9
+	.uleb128 0x3	/* (DW_AT_name) */
8c62a9
+	.uleb128 0x8	/* (DW_FORM_string) */
8c62a9
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x11	/* (DW_AT_low_pc) */
8c62a9
+	.uleb128 0x1	/* (DW_FORM_addr) */
8c62a9
+	.uleb128 0x12	/* (DW_AT_high_pc) */
8c62a9
+	.uleb128 0x6	/* (DW_FORM_data4) */
8c62a9
+	.uleb128 0x40	/* (DW_AT_frame_base) */
8c62a9
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
8c62a9
+	.uleb128 0x2117	/* (DW_AT_GNU_all_call_sites) */
8c62a9
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
8c62a9
+	.uleb128 0x1	/* (DW_AT_sibling) */
8c62a9
+	.uleb128 0x13	/* (DW_FORM_ref4) */
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+	.uleb128 0x15	/* (abbrev code) */
8c62a9
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
8c62a9
+	.byte	0x1	/* DW_children_yes */
8c62a9
+	.uleb128 0x3	/* (DW_AT_name) */
8c62a9
+	.uleb128 0x8	/* (DW_FORM_string) */
8c62a9
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x20	/* (DW_AT_inline) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x1	/* (DW_AT_sibling) */
8c62a9
+	.uleb128 0x13	/* (DW_FORM_ref4) */
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+	.uleb128 0x18	/* (abbrev code) */
8c62a9
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
8c62a9
+	.byte	0x1	/* DW_children_yes */
8c62a9
+	.uleb128 0x31	/* (DW_AT_abstract_origin) */
8c62a9
+	.uleb128 0x13	/* (DW_FORM_ref4) */
8c62a9
+	.uleb128 0x11	/* (DW_AT_low_pc) */
8c62a9
+	.uleb128 0x1	/* (DW_FORM_addr) */
8c62a9
+	.uleb128 0x12	/* (DW_AT_high_pc) */
8c62a9
+	.uleb128 0x6	/* (DW_FORM_data4) */
8c62a9
+	.uleb128 0x40	/* (DW_AT_frame_base) */
8c62a9
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
8c62a9
+	.uleb128 0x48	/* (DW_AT_static_link) */
8c62a9
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
8c62a9
+	.uleb128 0x2117	/* (DW_AT_GNU_all_call_sites) */
8c62a9
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+	.uleb128 0x1a	/* (abbrev code) */
8c62a9
+	.uleb128 0x1d	/* (TAG: DW_TAG_inlined_subroutine) */
8c62a9
+	.byte	0x1	/* DW_children_yes */
8c62a9
+	.uleb128 0x31	/* (DW_AT_abstract_origin) */
8c62a9
+	.uleb128 0x13	/* (DW_FORM_ref4) */
8c62a9
+	.uleb128 0x11	/* (DW_AT_low_pc) */
8c62a9
+	.uleb128 0x1	/* (DW_FORM_addr) */
8c62a9
+	.uleb128 0x12	/* (DW_AT_high_pc) */
8c62a9
+	.uleb128 0x6	/* (DW_FORM_data4) */
8c62a9
+	.uleb128 0x58	/* (DW_AT_call_file) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x59	/* (DW_AT_call_line) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x1	/* (DW_AT_sibling) */
8c62a9
+	.uleb128 0x13	/* (DW_FORM_ref4) */
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+	.uleb128 0x23	/* (abbrev code) */
8c62a9
+	.uleb128 0x1d	/* (TAG: DW_TAG_inlined_subroutine) */
8c62a9
+	.byte	0x1	/* DW_children_yes */
8c62a9
+	.uleb128 0x31	/* (DW_AT_abstract_origin) */
8c62a9
+	.uleb128 0x13	/* (DW_FORM_ref4) */
8c62a9
+	.uleb128 0x11	/* (DW_AT_low_pc) */
8c62a9
+	.uleb128 0x1	/* (DW_FORM_addr) */
8c62a9
+	.uleb128 0x12	/* (DW_AT_high_pc) */
8c62a9
+	.uleb128 0x6	/* (DW_FORM_data4) */
8c62a9
+	.uleb128 0x58	/* (DW_AT_call_file) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.uleb128 0x59	/* (DW_AT_call_line) */
8c62a9
+	.uleb128 0xb	/* (DW_FORM_data1) */
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+	.uleb128 0x28	/* (abbrev code) */
8c62a9
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
8c62a9
+	.byte	0x1	/* DW_children_yes */
8c62a9
+	.uleb128 0x3f	/* (DW_AT_external) */
8c62a9
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
8c62a9
+	.uleb128 0x3	/* (DW_AT_name) */
8c62a9
+	.uleb128 0x8	/* (DW_FORM_string) */
8c62a9
+	.uleb128 0x34	/* (DW_AT_artificial) */
8c62a9
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
8c62a9
+	.uleb128 0x3c	/* (DW_AT_declaration) */
8c62a9
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+	.byte	0
8c62a9
+
8c62a9
+        .section .debug_line
8c62a9
+.Lline1_begin:
8c62a9
+        .byte   0
8c62a9
+
8c62a9
--- /dev/null
8c62a9
+++ b/gdb/testsuite/gdb.dwarf2/dw2-icycle.c
8c62a9
@@ -0,0 +1,24 @@
8c62a9
+/* This testcase is part of GDB, the GNU debugger.
8c62a9
+
8c62a9
+   Copyright 2004-2014 Free Software Foundation, Inc.
8c62a9
+
8c62a9
+   This program is free software; you can redistribute it and/or modify
8c62a9
+   it under the terms of the GNU General Public License as published by
8c62a9
+   the Free Software Foundation; either version 3 of the License, or
8c62a9
+   (at your option) any later version.
8c62a9
+
8c62a9
+   This program is distributed in the hope that it will be useful,
8c62a9
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
8c62a9
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8c62a9
+   GNU General Public License for more details.
8c62a9
+
8c62a9
+   You should have received a copy of the GNU General Public License
8c62a9
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
8c62a9
+
8c62a9
+/* Dummy main function.  */
8c62a9
+
8c62a9
+int
8c62a9
+main()
8c62a9
+{
8c62a9
+  return 0;
8c62a9
+}
8c62a9
--- /dev/null
8c62a9
+++ b/gdb/testsuite/gdb.dwarf2/dw2-icycle.exp
8c62a9
@@ -0,0 +1,46 @@
8c62a9
+# Copyright 2014 Free Software Foundation, Inc.
8c62a9
+
8c62a9
+# This program is free software; you can redistribute it and/or modify
8c62a9
+# it under the terms of the GNU General Public License as published by
8c62a9
+# the Free Software Foundation; either version 3 of the License, or
8c62a9
+# (at your option) any later version.
8c62a9
+#
8c62a9
+# This program is distributed in the hope that it will be useful,
8c62a9
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
8c62a9
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8c62a9
+# GNU General Public License for more details.
8c62a9
+#
8c62a9
+# You should have received a copy of the GNU General Public License
8c62a9
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
8c62a9
+
8c62a9
+# This test exercises PR 16581.
8c62a9
+
8c62a9
+load_lib dwarf.exp
8c62a9
+
8c62a9
+# This test can only be run on targets which support DWARF-2 and use gas.
8c62a9
+if {![dwarf2_support]} {
8c62a9
+    return 0
8c62a9
+}
8c62a9
+
8c62a9
+standard_testfile .S .c
8c62a9
+
8c62a9
+if { [prepare_for_testing ${testfile}.exp ${testfile} \
8c62a9
+	  [list $srcfile $srcfile2] {nodebug}] } {
8c62a9
+    return -1
8c62a9
+}
8c62a9
+
8c62a9
+# We are trying to verify that the partial symtab to symtab expansion
8c62a9
+# for the debugging info hand-coded in our assembly file does not cause
8c62a9
+# the debugger to crash (infinite recursion).  To facilitate the test,
8c62a9
+# start the debugger with -readnow.  This force expansion as soon as
8c62a9
+# the objfile is loaded.
8c62a9
+
8c62a9
+set saved_gdbflags $GDBFLAGS
8c62a9
+set GDBFLAGS "$GDBFLAGS -readnow"
8c62a9
+clean_restart ${testfile}
8c62a9
+set GDBFLAGS $saved_gdbflags
8c62a9
+
8c62a9
+# And just to be sure that the debugger did not crash after having
8c62a9
+# expanded our symbols, do a life-check.
8c62a9
+
8c62a9
+gdb_test "echo life check\\n" "life check"