Jan Kratochvil 6b46b9b
From e385593eef98ac92be57159e141f4b805dadbbb3 Mon Sep 17 00:00:00 2001
Jan Kratochvil 6b46b9b
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Jan Kratochvil 6b46b9b
Date: Mon, 30 May 2016 14:14:43 +0200
Jan Kratochvil 6b46b9b
Subject: [PATCH 2/2] PR 15231: import bare DW_TAG_lexical_block
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
Local variables in lambdas are not accessible
Jan Kratochvil 6b46b9b
https://sourceware.org/bugzilla/show_bug.cgi?id=15231
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
GDB: read_lexical_block_scope
Jan Kratochvil 6b46b9b
  /* Ignore blocks with missing or invalid low and high pc attributes.  */
Jan Kratochvil 6b46b9b
[...]
Jan Kratochvil 6b46b9b
  if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL))
Jan Kratochvil 6b46b9b
    return;
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
But sometimes there is:
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
FAIL: gcc-5.3.1-6.fc23.x86_64
Jan Kratochvil 6b46b9b
 <2><92>: Abbrev Number: 11 (DW_TAG_lexical_block)
Jan Kratochvil 6b46b9b
 <3><9c>: Abbrev Number: 13 (DW_TAG_structure_type)
Jan Kratochvil 6b46b9b
    <9d>   DW_AT_name        : (indirect string, offset: 0x3c): <lambda()>
Jan Kratochvil 6b46b9b
    [...]
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
Where DW_TAG_lexical_block has no attributes.  Such whole subtree is currently
Jan Kratochvil 6b46b9b
dropped by GDB while I think it should just import all its children DIEs.
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
It even XFAIL->XPASSes gdb.ada/out_of_line_in_inlined.exp:
Jan Kratochvil 6b46b9b
	commit 0fa7fe506c242b459c4c05d331e7c7d66fb52390
Jan Kratochvil 6b46b9b
	Author: Joel Brobecker <brobecker@adacore.com>
Jan Kratochvil 6b46b9b
	    out of line functions nested inside inline functions.
Jan Kratochvil 6b46b9b
So I have removed that xfail.
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
gdb/ChangeLog
Jan Kratochvil 6b46b9b
2016-05-30  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
	PR c++/15231
Jan Kratochvil 6b46b9b
	* dwarf2read.c (enum pc_bounds_kind): Add PC_BOUNDS_INVALID.
Jan Kratochvil 6b46b9b
	(process_psymtab_comp_unit_reader, read_func_scope): Adjust callers.
Jan Kratochvil 6b46b9b
	(read_lexical_block_scope): Import DIEs from bare DW_TAG_lexical_block.
Jan Kratochvil 6b46b9b
	(read_call_site_scope): Adjust callers.
Jan Kratochvil 6b46b9b
	(dwarf2_get_pc_bounds): Implement pc_bounds_invalid.
Jan Kratochvil 6b46b9b
	(dwarf2_get_subprogram_pc_bounds, get_scope_pc_bounds): Adjust callers.
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
gdb/testsuite/ChangeLog
Jan Kratochvil 6b46b9b
2016-05-30  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
	PR c++/15231
Jan Kratochvil 6b46b9b
	* gdb.ada/out_of_line_in_inlined.exp: Remove xfails.
Jan Kratochvil 6b46b9b
	* gdb.dwarf2/dw2-lexical-block-bare.exp: New file.
Jan Kratochvil 6b46b9b
---
Jan Kratochvil 6b46b9b
 gdb/ChangeLog                                      | 10 ++++
Jan Kratochvil 6b46b9b
 gdb/dwarf2read.c                                   | 53 ++++++++++------
Jan Kratochvil 6b46b9b
 gdb/testsuite/ChangeLog                            |  6 ++
Jan Kratochvil 6b46b9b
 gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp   |  6 --
Jan Kratochvil 6b46b9b
 .../gdb.dwarf2/dw2-lexical-block-bare.exp          | 70 ++++++++++++++++++++++
Jan Kratochvil 6b46b9b
 5 files changed, 120 insertions(+), 25 deletions(-)
Jan Kratochvil 6b46b9b
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp
Jan Kratochvil 6b46b9b
Jan Kratochvil 6b46b9b
### a/gdb/ChangeLog
Jan Kratochvil 6b46b9b
### b/gdb/ChangeLog
Jan Kratochvil 6b46b9b
## -1,5 +1,15 @@
Jan Kratochvil 6b46b9b
 2016-05-30  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
+	PR c++/15231
Jan Kratochvil 6b46b9b
+	* dwarf2read.c (enum pc_bounds_kind): Add PC_BOUNDS_INVALID.
Jan Kratochvil 6b46b9b
+	(process_psymtab_comp_unit_reader, read_func_scope): Adjust callers.
Jan Kratochvil 6b46b9b
+	(read_lexical_block_scope): Import DIEs from bare DW_TAG_lexical_block.
Jan Kratochvil 6b46b9b
+	(read_call_site_scope): Adjust callers.
Jan Kratochvil 6b46b9b
+	(dwarf2_get_pc_bounds): Implement pc_bounds_invalid.
Jan Kratochvil 6b46b9b
+	(dwarf2_get_subprogram_pc_bounds, get_scope_pc_bounds): Adjust callers.
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+2016-05-30  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
 	Code cleanup: dwarf2_get_pc_bounds: -1/0/+1 -> enum
Jan Kratochvil 6b46b9b
 	* dwarf2read.c (enum pc_bounds_kind) New.
Jan Kratochvil 6b46b9b
 	(dwarf2_get_pc_bounds): Use it in the declaration.
Jan Kratochvil 6b46b9b
--- a/gdb/dwarf2read.c
Jan Kratochvil 6b46b9b
+++ b/gdb/dwarf2read.c
Jan Kratochvil 6b46b9b
@@ -1607,13 +1607,16 @@ static int dwarf2_ranges_read (unsigned, CORE_ADDR *, CORE_ADDR *,
Jan Kratochvil 6b46b9b
 			       struct dwarf2_cu *, struct partial_symtab *);
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
 /* How dwarf2_get_pc_bounds constructed its *LOWPC and *HIGHPC return
Jan Kratochvil 6b46b9b
-   values.  */
Jan Kratochvil 6b46b9b
+   values.  Keep the items ordered with increasing constraints compliance.  */
Jan Kratochvil 6b46b9b
 enum pc_bounds_kind
Jan Kratochvil 6b46b9b
 {
Jan Kratochvil 6b46b9b
-  /* No valid combination of DW_AT_low_pc, DW_AT_high_pc or DW_AT_ranges
Jan Kratochvil 6b46b9b
-     was found.  */
Jan Kratochvil 6b46b9b
+  /* No attribute DW_AT_low_pc, DW_AT_high_pc or DW_AT_ranges was found.  */
Jan Kratochvil 6b46b9b
   PC_BOUNDS_NOT_PRESENT,
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
+  /* Some of the attributes DW_AT_low_pc, DW_AT_high_pc or DW_AT_ranges
Jan Kratochvil 6b46b9b
+     were present but they do not form a valid range of PC addresses.  */
Jan Kratochvil 6b46b9b
+  PC_BOUNDS_INVALID,
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
   /* Discontiguous range was found - that is DW_AT_ranges was found.  */
Jan Kratochvil 6b46b9b
   PC_BOUNDS_RANGES,
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
@@ -6019,7 +6022,7 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
Jan Kratochvil 6b46b9b
       first_die = load_partial_dies (reader, info_ptr, 1);
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
       scan_partial_symbols (first_die, &lowpc, &highpc,
Jan Kratochvil 6b46b9b
-			    cu_bounds_kind == PC_BOUNDS_NOT_PRESENT, cu);
Jan Kratochvil 6b46b9b
+			    cu_bounds_kind <= PC_BOUNDS_INVALID, cu);
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
       /* If we didn't find a lowpc, set it to highpc to avoid
Jan Kratochvil 6b46b9b
 	 complaints from `maint check'.	 */
Jan Kratochvil 6b46b9b
@@ -6028,7 +6031,7 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
       /* If the compilation unit didn't have an explicit address range,
Jan Kratochvil 6b46b9b
 	 then use the information extracted from its child dies.  */
Jan Kratochvil 6b46b9b
-      if (cu_bounds_kind == PC_BOUNDS_NOT_PRESENT)
Jan Kratochvil 6b46b9b
+      if (cu_bounds_kind <= PC_BOUNDS_INVALID)
Jan Kratochvil 6b46b9b
 	{
Jan Kratochvil 6b46b9b
 	  best_lowpc = lowpc;
Jan Kratochvil 6b46b9b
 	  best_highpc = highpc;
Jan Kratochvil 6b46b9b
@@ -11390,7 +11393,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
   /* Ignore functions with missing or invalid low and high pc attributes.  */
Jan Kratochvil 6b46b9b
   if (dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL)
Jan Kratochvil 6b46b9b
-      == PC_BOUNDS_NOT_PRESENT)
Jan Kratochvil 6b46b9b
+      <= PC_BOUNDS_INVALID)
Jan Kratochvil 6b46b9b
     {
Jan Kratochvil 6b46b9b
       attr = dwarf2_attr (die, DW_AT_external, cu);
Jan Kratochvil 6b46b9b
       if (!attr || !DW_UNSND (attr))
Jan Kratochvil 6b46b9b
@@ -11552,9 +11555,20 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
Jan Kratochvil 6b46b9b
      as multiple lexical blocks?  Handling children in a sane way would
Jan Kratochvil 6b46b9b
      be nasty.  Might be easier to properly extend generic blocks to
Jan Kratochvil 6b46b9b
      describe ranges.  */
Jan Kratochvil 6b46b9b
-  if (dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL)
Jan Kratochvil 6b46b9b
-      == PC_BOUNDS_NOT_PRESENT)
Jan Kratochvil 6b46b9b
-    return;
Jan Kratochvil 6b46b9b
+  switch (dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL))
Jan Kratochvil 6b46b9b
+    {
Jan Kratochvil 6b46b9b
+    case PC_BOUNDS_NOT_PRESENT:
Jan Kratochvil 6b46b9b
+      /* DW_TAG_lexical_block has no attributes, process its children as if
Jan Kratochvil 6b46b9b
+	 there was no wrapping by that DW_TAG_lexical_block.
Jan Kratochvil 6b46b9b
+	 GCC does no longer produces such DWARF since GCC r224161.  */
Jan Kratochvil 6b46b9b
+      for (child_die = die->child;
Jan Kratochvil 6b46b9b
+	   child_die != NULL && child_die->tag;
Jan Kratochvil 6b46b9b
+	   child_die = sibling_die (child_die))
Jan Kratochvil 6b46b9b
+	process_die (child_die, cu);
Jan Kratochvil 6b46b9b
+      return;
Jan Kratochvil 6b46b9b
+    case PC_BOUNDS_INVALID:
Jan Kratochvil 6b46b9b
+      return;
Jan Kratochvil 6b46b9b
+    }
Jan Kratochvil 6b46b9b
   lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr);
Jan Kratochvil 6b46b9b
   highpc = gdbarch_adjust_dwarf2_addr (gdbarch, highpc + baseaddr);
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
@@ -11764,7 +11778,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
 	  /* DW_AT_entry_pc should be preferred.  */
Jan Kratochvil 6b46b9b
 	  if (dwarf2_get_pc_bounds (target_die, &lowpc, NULL, target_cu, NULL)
Jan Kratochvil 6b46b9b
-	      == PC_BOUNDS_NOT_PRESENT)
Jan Kratochvil 6b46b9b
+	      <= PC_BOUNDS_INVALID)
Jan Kratochvil 6b46b9b
 	    complaint (&symfile_complaints,
Jan Kratochvil 6b46b9b
 		       _("DW_AT_GNU_call_site_target target DIE has invalid "
Jan Kratochvil 6b46b9b
 		         "low pc, for referencing DIE 0x%x [in module %s]"),
Jan Kratochvil 6b46b9b
@@ -12041,7 +12055,7 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
 /* Get low and high pc attributes from a die.  See enum pc_bounds_kind
Jan Kratochvil 6b46b9b
    definition for the return value.  *LOWPC and *HIGHPC are set iff
Jan Kratochvil 6b46b9b
-   PC_BOUNDS_NOT_PRESENT is not returned.  */
Jan Kratochvil 6b46b9b
+   neither PC_BOUNDS_NOT_PRESENT nor PC_BOUNDS_INVALID are returned.  */
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
 static enum pc_bounds_kind
Jan Kratochvil 6b46b9b
 dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
Jan Kratochvil 6b46b9b
@@ -12052,7 +12066,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
Jan Kratochvil 6b46b9b
   struct attribute *attr_high;
Jan Kratochvil 6b46b9b
   CORE_ADDR low = 0;
Jan Kratochvil 6b46b9b
   CORE_ADDR high = 0;
Jan Kratochvil 6b46b9b
-  enum pc_bounds_kind ret = PC_BOUNDS_NOT_PRESENT;
Jan Kratochvil 6b46b9b
+  enum pc_bounds_kind ret;
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
   attr_high = dwarf2_attr (die, DW_AT_high_pc, cu);
Jan Kratochvil 6b46b9b
   if (attr_high)
Jan Kratochvil 6b46b9b
@@ -12067,7 +12081,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
Jan Kratochvil 6b46b9b
 	}
Jan Kratochvil 6b46b9b
       else
Jan Kratochvil 6b46b9b
 	/* Found high w/o low attribute.  */
Jan Kratochvil 6b46b9b
-	return PC_BOUNDS_NOT_PRESENT;
Jan Kratochvil 6b46b9b
+	return PC_BOUNDS_INVALID;
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
       /* Found consecutive range of addresses.  */
Jan Kratochvil 6b46b9b
       ret = PC_BOUNDS_HIGH_LOW;
Jan Kratochvil 6b46b9b
@@ -12089,15 +12103,17 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
Jan Kratochvil 6b46b9b
 	  /* Value of the DW_AT_ranges attribute is the offset in the
Jan Kratochvil 6b46b9b
 	     .debug_ranges section.  */
Jan Kratochvil 6b46b9b
 	  if (!dwarf2_ranges_read (ranges_offset, &low, &high, cu, pst))
Jan Kratochvil 6b46b9b
-	    return PC_BOUNDS_NOT_PRESENT;
Jan Kratochvil 6b46b9b
+	    return PC_BOUNDS_INVALID;
Jan Kratochvil 6b46b9b
 	  /* Found discontinuous range of addresses.  */
Jan Kratochvil 6b46b9b
 	  ret = PC_BOUNDS_RANGES;
Jan Kratochvil 6b46b9b
 	}
Jan Kratochvil 6b46b9b
+      else
Jan Kratochvil 6b46b9b
+	return PC_BOUNDS_NOT_PRESENT;
Jan Kratochvil 6b46b9b
     }
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
   /* read_partial_die has also the strict LOW < HIGH requirement.  */
Jan Kratochvil 6b46b9b
   if (high <= low)
Jan Kratochvil 6b46b9b
-    return PC_BOUNDS_NOT_PRESENT;
Jan Kratochvil 6b46b9b
+    return PC_BOUNDS_INVALID;
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
   /* When using the GNU linker, .gnu.linkonce. sections are used to
Jan Kratochvil 6b46b9b
      eliminate duplicate copies of functions and vtables and such.
Jan Kratochvil 6b46b9b
@@ -12108,7 +12124,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
Jan Kratochvil 6b46b9b
      If this is a discarded function, mark the pc bounds as invalid,
Jan Kratochvil 6b46b9b
      so that GDB will ignore it.  */
Jan Kratochvil 6b46b9b
   if (low == 0 && !dwarf2_per_objfile->has_section_at_zero)
Jan Kratochvil 6b46b9b
-    return PC_BOUNDS_NOT_PRESENT;
Jan Kratochvil 6b46b9b
+    return PC_BOUNDS_INVALID;
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
   *lowpc = low;
Jan Kratochvil 6b46b9b
   if (highpc)
Jan Kratochvil 6b46b9b
@@ -12129,8 +12145,7 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *die,
Jan Kratochvil 6b46b9b
   CORE_ADDR low, high;
Jan Kratochvil 6b46b9b
   struct die_info *child = die->child;
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
-  if (dwarf2_get_pc_bounds (die, &low, &high, cu, NULL)
Jan Kratochvil 6b46b9b
-      != PC_BOUNDS_NOT_PRESENT)
Jan Kratochvil 6b46b9b
+  if (dwarf2_get_pc_bounds (die, &low, &high, cu, NULL) >= PC_BOUNDS_RANGES)
Jan Kratochvil 6b46b9b
     {
Jan Kratochvil 6b46b9b
       *lowpc = min (*lowpc, low);
Jan Kratochvil 6b46b9b
       *highpc = max (*highpc, high);
Jan Kratochvil 6b46b9b
@@ -12168,7 +12183,7 @@ get_scope_pc_bounds (struct die_info *die,
Jan Kratochvil 6b46b9b
   CORE_ADDR current_low, current_high;
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
   if (dwarf2_get_pc_bounds (die, &current_low, &current_high, cu, NULL)
Jan Kratochvil 6b46b9b
-      != PC_BOUNDS_NOT_PRESENT)
Jan Kratochvil 6b46b9b
+      >= PC_BOUNDS_RANGES)
Jan Kratochvil 6b46b9b
     {
Jan Kratochvil 6b46b9b
       best_low = current_low;
Jan Kratochvil 6b46b9b
       best_high = current_high;
Jan Kratochvil 6b46b9b
### a/gdb/testsuite/ChangeLog
Jan Kratochvil 6b46b9b
### b/gdb/testsuite/ChangeLog
Jan Kratochvil 6b46b9b
## -1,3 +1,9 @@
Jan Kratochvil 6b46b9b
+2016-05-30  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+	PR c++/15231
Jan Kratochvil 6b46b9b
+	* gdb.ada/out_of_line_in_inlined.exp: Remove xfails.
Jan Kratochvil 6b46b9b
+	* gdb.dwarf2/dw2-lexical-block-bare.exp: New file.
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
 2016-05-27  Pedro Alves  <palves@redhat.com>
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
 	* gdb.threads/attach-many-short-lived-threads.exp (bad_dejagnu):
Jan Kratochvil 6b46b9b
--- a/gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp
Jan Kratochvil 6b46b9b
+++ b/gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp
Jan Kratochvil 6b46b9b
@@ -23,20 +23,14 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug optimize=-O2}]
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
 clean_restart ${testfile}
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
-# GCC currently is missing a DW_AT_origin attribute in one of the
Jan Kratochvil 6b46b9b
-# lexical blocks, preventing GDB from creating a symbol for the
Jan Kratochvil 6b46b9b
-# subprogram we want to break on.
Jan Kratochvil 6b46b9b
-setup_xfail "*-*-*"
Jan Kratochvil 6b46b9b
 gdb_test "break foo_o224_021.child1.child2" \
Jan Kratochvil 6b46b9b
          "Breakpoint \[0-9\]+ at.*: file .*foo_o224_021.adb, line \[0-9\]+."
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
 gdb_run_cmd
Jan Kratochvil 6b46b9b
-setup_xfail "*-*-*"
Jan Kratochvil 6b46b9b
 gdb_test "" \
Jan Kratochvil 6b46b9b
          "Breakpoint $decimal, foo_o224_021\\.child1\\.child2 \\(s=\\.\\.\\.\\).*"
Jan Kratochvil 6b46b9b
 
Jan Kratochvil 6b46b9b
 set opt_addr_in "($hex in)?"
Jan Kratochvil 6b46b9b
-setup_xfail "*-*-*"
Jan Kratochvil 6b46b9b
 gdb_test "bt" \
Jan Kratochvil 6b46b9b
     [multi_line "#0 +$opt_addr_in +foo_o224_021\\.child1\\.child2 \\(s=\\.\\.\\.\\).*" \
Jan Kratochvil 6b46b9b
                 "#1 +$opt_addr_in +foo_o224_021\\.child1 \\(\\).*" \
Jan Kratochvil 6b46b9b
--- /dev/null
Jan Kratochvil 6b46b9b
+++ b/gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp
Jan Kratochvil 6b46b9b
@@ -0,0 +1,70 @@
Jan Kratochvil 6b46b9b
+# Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil 6b46b9b
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil 6b46b9b
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 6b46b9b
+# (at your option) any later version.
Jan Kratochvil 6b46b9b
+#
Jan Kratochvil 6b46b9b
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil 6b46b9b
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 6b46b9b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 6b46b9b
+# GNU General Public License for more details.
Jan Kratochvil 6b46b9b
+#
Jan Kratochvil 6b46b9b
+# You should have received a copy of the GNU General Public License
Jan Kratochvil 6b46b9b
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil 6b46b9b
+load_lib dwarf.exp
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+# This test can only be run on targets which support DWARF-2 and use gas.
Jan Kratochvil 6b46b9b
+if {![dwarf2_support]} {
Jan Kratochvil 6b46b9b
+    return 0
Jan Kratochvil 6b46b9b
+}
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+standard_testfile .S main.c
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+# Make some DWARF for the test.
Jan Kratochvil 6b46b9b
+set asm_file [standard_output_file $srcfile]
Jan Kratochvil 6b46b9b
+Dwarf::assemble $asm_file {
Jan Kratochvil 6b46b9b
+    cu {} {
Jan Kratochvil 6b46b9b
+	compile_unit {
Jan Kratochvil 6b46b9b
+	    {low_pc [gdb_target_symbol main] DW_FORM_addr}
Jan Kratochvil 6b46b9b
+	    {high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
Jan Kratochvil 6b46b9b
+	} {
Jan Kratochvil 6b46b9b
+	    declare_labels integer_label
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+	    integer_label: DW_TAG_base_type {
Jan Kratochvil 6b46b9b
+		{DW_AT_byte_size 4 DW_FORM_sdata}
Jan Kratochvil 6b46b9b
+		{DW_AT_encoding  @DW_ATE_signed}
Jan Kratochvil 6b46b9b
+		{DW_AT_name      integer}
Jan Kratochvil 6b46b9b
+	    }
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+	    DW_TAG_subprogram {
Jan Kratochvil 6b46b9b
+		{name main}
Jan Kratochvil 6b46b9b
+		{DW_AT_external 1 flag}
Jan Kratochvil 6b46b9b
+		{low_pc [gdb_target_symbol main] DW_FORM_addr}
Jan Kratochvil 6b46b9b
+		{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
Jan Kratochvil 6b46b9b
+	    } {
Jan Kratochvil 6b46b9b
+		DW_TAG_lexical_block {
Jan Kratochvil 6b46b9b
+		} {
Jan Kratochvil 6b46b9b
+		    DW_TAG_variable {
Jan Kratochvil 6b46b9b
+			{DW_AT_name testvar}
Jan Kratochvil 6b46b9b
+			    {DW_AT_type :$integer_label}
Jan Kratochvil 6b46b9b
+			    {DW_AT_external 1 flag}
Jan Kratochvil 6b46b9b
+			{DW_AT_location {
Jan Kratochvil 6b46b9b
+			    DW_OP_addr [gdb_target_symbol main]
Jan Kratochvil 6b46b9b
+			} SPECIAL_expr}
Jan Kratochvil 6b46b9b
+		    }
Jan Kratochvil 6b46b9b
+		}
Jan Kratochvil 6b46b9b
+	    }
Jan Kratochvil 6b46b9b
+	}
Jan Kratochvil 6b46b9b
+    }
Jan Kratochvil 6b46b9b
+}
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+if { [prepare_for_testing ${testfile}.exp ${testfile} \
Jan Kratochvil 6b46b9b
+			  [list $srcfile2 $asm_file] {nodebug}] } {
Jan Kratochvil 6b46b9b
+    return -1
Jan Kratochvil 6b46b9b
+}
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+runto_main
Jan Kratochvil 6b46b9b
+
Jan Kratochvil 6b46b9b
+# FAILing GDB did print: No symbol "testvar" in current context.
Jan Kratochvil 6b46b9b
+gdb_test "p testvar" { = -?[0-9]+}
Jan Kratochvil 6b46b9b
-- 
Jan Kratochvil 6b46b9b
2.5.5
Jan Kratochvil 6b46b9b