From e385593eef98ac92be57159e141f4b805dadbbb3 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Mon, 30 May 2016 14:14:43 +0200 Subject: PR 15231: import bare DW_TAG_lexical_block 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): [...] 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 out of line functions nested inside inline functions. So I have removed that xfail. gdb/ChangeLog 2016-05-30 Jan Kratochvil PR c++/15231 * dwarf2read.c (enum pc_bounds_kind): Add PC_BOUNDS_INVALID. (process_psymtab_comp_unit_reader, read_func_scope): Adjust callers. (read_lexical_block_scope): Import DIEs from bare DW_TAG_lexical_block. (read_call_site_scope): Adjust callers. (dwarf2_get_pc_bounds): Implement pc_bounds_invalid. (dwarf2_get_subprogram_pc_bounds, get_scope_pc_bounds): Adjust callers. gdb/testsuite/ChangeLog 2016-05-30 Jan Kratochvil PR c++/15231 * gdb.ada/out_of_line_in_inlined.exp: Remove xfails. * gdb.dwarf2/dw2-lexical-block-bare.exp: New file. --- gdb/testsuite/ChangeLog | 6 ++ gdb/testsuite/gdb.ada/out_of_line_in_inlined.exp | 6 -- .../gdb.dwarf2/dw2-lexical-block-bare.exp | 70 ++++++++++++++++++++++ 3 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp (limited to 'gdb/testsuite') diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4819203..8397f67 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-05-30 Jan Kratochvil + + PR c++/15231 + * gdb.ada/out_of_line_in_inlined.exp: Remove xfails. + * gdb.dwarf2/dw2-lexical-block-bare.exp: New file. + 2016-05-27 Pedro Alves * gdb.threads/attach-many-short-lived-threads.exp (bad_dejagnu): 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 . +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]+} -- cgit v1.1