public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] PR 15231: import bare DW_TAG_lexical_block
@ 2016-05-14 19:30 Jan Kratochvil
  2016-05-27 15:35 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2016-05-14 19:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker

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

Hi,

Local variables in lambdas are not accessible
https://sourceware.org/bugzilla/show_bug.cgi?id=15231

GDB: read_lexical_block_scope
  /* Ignore blocks with missing or invalid low and high pc attributes.  */
[...]
  if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL))
    return;

But sometimes there is:

FAIL: gcc-5.3.1-6.fc23.x86_64
 <2><92>: Abbrev Number: 11 (DW_TAG_lexical_block)
 <3><9c>: Abbrev Number: 13 (DW_TAG_structure_type)
    <9d>   DW_AT_name        : (indirect string, offset: 0x3c): <lambda()>
    [...]

Where DW_TAG_lexical_block has no attributes.  Such whole subtree is currently
dropped by GDB while I think it should just import all its children DIEs.

It even XFAIL->XPASSes gdb.ada/out_of_line_in_inlined.exp:
	commit 0fa7fe506c242b459c4c05d331e7c7d66fb52390
	Author: Joel Brobecker <brobecker@adacore.com>
	    out of line functions nested inside inline functions.
So I have removed that xfail.

I agree that my dwarf2_get_pc_bounds() extension is ugly.

No regression on Fedora Rawhide.

OK for check-in?


Thanks,
Jan

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

gdb/ChangeLog
2016-05-14  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR c++/15231
	* dwarf2read.c (read_lexical_block_scope): Import DIEs from bare
	DW_TAG_lexical_block.
	(dwarf2_get_pc_bounds): Return more info in *LOWPC.

gdb/testsuite/ChangeLog
2016-05-14  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR c++/15231
	* gdb.ada/out_of_line_in_inlined.exp: Remove xfails.
	* gdb.dwarf2/dw2-lexical-block-bare.exp: New file.

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index f526619..9ec595a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -11534,7 +11534,18 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
      be nasty.  Might be easier to properly extend generic blocks to
      describe ranges.  */
   if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL))
-    return;
+    {
+      if (lowpc == 1)
+	{
+	  /* DW_TAG_lexical_block has no attributes, process its child as if
+	     there was no wrapping by that DW_TAG_lexical_block.
+	     GCC does no longer produces such DWARF since GCC r224161.  */
+	  for (child_die = die->child; child_die && child_die->tag;
+	       child_die = sibling_die (child_die))
+	    process_die (child_die, cu);
+	}
+      return;
+    }
   lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr);
   highpc = gdbarch_adjust_dwarf2_addr (gdbarch, highpc + baseaddr);
 
@@ -12020,7 +12031,10 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
 
 /* Get low and high pc attributes from a die.  Return 1 if the attributes
    are present and valid, otherwise, return 0.  Return -1 if the range is
-   discontinuous, i.e. derived from DW_AT_ranges information.  */
+   discontinuous, i.e. derived from DW_AT_ranges information.
+   If the function returns 0 then *LOWPC is set to 1 if none of the
+   range specifying attribute was present; otherwise *LOW is set to 0 as
+   the attribute values were not valid.  */
 
 static int
 dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
@@ -12033,6 +12047,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
   CORE_ADDR high = 0;
   int ret = 0;
 
+  *lowpc = 0;
   attr_high = dwarf2_attr (die, DW_AT_high_pc, cu);
   if (attr_high)
     {
@@ -12072,6 +12087,12 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
 	  /* Found discontinuous range of addresses.  */
 	  ret = -1;
 	}
+      else
+	{
+	  /* None of the attributes is present.  */
+	  *lowpc = 1;
+	  return 0;
+	}
     }
 
   /* read_partial_die has also the strict LOW < HIGH requirement.  */
diff --git a/gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp b/gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp
index 1ebd89f..8a3a4b1 100644
--- a/gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp
+++ b/gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp
@@ -23,20 +23,14 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug optimize=-O2}]
 
 clean_restart ${testfile}
 
-# GCC currently is missing a DW_AT_origin attribute in one of the
-# lexical blocks, preventing GDB from creating a symbol for the
-# subprogram we want to break on.
-setup_xfail "*-*-*"
 gdb_test "break foo_o224_021.child1.child2" \
          "Breakpoint \[0-9\]+ at.*: file .*foo_o224_021.adb, line \[0-9\]+."
 
 gdb_run_cmd
-setup_xfail "*-*-*"
 gdb_test "" \
          "Breakpoint $decimal, foo_o224_021\\.child1\\.child2 \\(s=\\.\\.\\.\\).*"
 
 set opt_addr_in "($hex in)?"
-setup_xfail "*-*-*"
 gdb_test "bt" \
     [multi_line "#0 +$opt_addr_in +foo_o224_021\\.child1\\.child2 \\(s=\\.\\.\\.\\).*" \
                 "#1 +$opt_addr_in +foo_o224_021\\.child1 \\(\\).*" \
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp b/gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp
new file mode 100644
index 0000000..3f9411e
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp
@@ -0,0 +1,70 @@
+# Copyright 2016 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+    return 0
+}
+
+standard_testfile .S main.c
+
+# Make some DWARF for the test.
+set asm_file [standard_output_file $srcfile]
+Dwarf::assemble $asm_file {
+    cu {} {
+	compile_unit {
+	    {low_pc [gdb_target_symbol main] DW_FORM_addr}
+	    {high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
+	} {
+	    declare_labels integer_label
+
+	    integer_label: DW_TAG_base_type {
+		{DW_AT_byte_size 4 DW_FORM_sdata}
+		{DW_AT_encoding  @DW_ATE_signed}
+		{DW_AT_name      integer}
+	    }
+
+	    DW_TAG_subprogram {
+		{name main}
+		{DW_AT_external 1 flag}
+		{low_pc [gdb_target_symbol main] DW_FORM_addr}
+		{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
+	    } {
+		DW_TAG_lexical_block {
+		} {
+		    DW_TAG_variable {
+			{DW_AT_name testvar}
+			    {DW_AT_type :$integer_label}
+			    {DW_AT_external 1 flag}
+			{DW_AT_location {
+			    DW_OP_addr [gdb_target_symbol main]
+			} SPECIAL_expr}
+		    }
+		}
+	    }
+	}
+    }
+}
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} \
+			  [list $srcfile2 $asm_file] {nodebug}] } {
+    return -1
+}
+
+runto_main
+
+# FAILing GDB did print: No symbol "testvar" in current context.
+gdb_test "p testvar" { = -?[0-9]+}

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

* Re: [patch] PR 15231: import bare DW_TAG_lexical_block
  2016-05-14 19:30 [patch] PR 15231: import bare DW_TAG_lexical_block Jan Kratochvil
@ 2016-05-27 15:35 ` Pedro Alves
  2016-05-29 14:12   ` obsolete: " Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2016-05-27 15:35 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches; +Cc: Joel Brobecker

On 05/14/2016 08:30 PM, Jan Kratochvil wrote:

> I agree that my dwarf2_get_pc_bounds() extension is ugly.

Can you make it not ugly?

Thanks,
Pedro Alves

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

* obsolete: [patch] PR 15231: import bare DW_TAG_lexical_block
  2016-05-27 15:35 ` Pedro Alves
@ 2016-05-29 14:12   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2016-05-29 14:12 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Joel Brobecker

On Fri, 27 May 2016 17:35:22 +0200, Pedro Alves wrote:
> On 05/14/2016 08:30 PM, Jan Kratochvil wrote:
> 
> > I agree that my dwarf2_get_pc_bounds() extension is ugly.
> 
> Can you make it not ugly?

Done, newly posted as:
	[patch 1/2] Code cleanup: dwarf2_get_pc_bounds: -1/0/+1 -> enum
	https://sourceware.org/ml/gdb-patches/2016-05/msg00519.html
	Message-ID: <20160529141035.GA13685@host1.jankratochvil.net>
	+
	[patchv2 2/2] PR 15231: import bare DW_TAG_lexical_block
	https://sourceware.org/ml/gdb-patches/2016-05/msg00520.html
	Message-ID: <20160529141043.GB13685@host1.jankratochvil.net>


Jan

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

end of thread, other threads:[~2016-05-29 14:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-14 19:30 [patch] PR 15231: import bare DW_TAG_lexical_block Jan Kratochvil
2016-05-27 15:35 ` Pedro Alves
2016-05-29 14:12   ` obsolete: " Jan Kratochvil

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).