public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] "info locals" for clang-compiled inlined functions
@ 2021-04-14  8:14 Tankut Baris Aktemur
  2021-04-14  8:14 ` [PATCH v2 1/2] testsuite, gdb: recognize DW_OP_fbreg in lib/dwarf.exp Tankut Baris Aktemur
  2021-04-14  8:14 ` [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions Tankut Baris Aktemur
  0 siblings, 2 replies; 9+ messages in thread
From: Tankut Baris Aktemur @ 2021-04-14  8:14 UTC (permalink / raw)
  To: gdb-patches

Hi,

This is the v2 of

  https://sourceware.org/pipermail/gdb-patches/2021-February/176203.html

The revision includes:

  * an additional patch to recognize DW_OP_fbreg as a location op in the
  testsuite's Dwarf assembler.

  * a new test that uses the Dwarf assembler.

  * minor fixes that Simon Marchi commented on for v1.

Regards
Baris

Tankut Baris Aktemur (2):
  testsuite, gdb: recognize DW_OP_fbreg in lib/dwarf.exp
  gdb/dwarf2: fix "info locals" for clang-compiled inlined functions

 gdb/dwarf2/read.c                             |  49 ++++++-
 .../dw2-inline-with-lexical-scope.c           |  47 ++++++
 .../dw2-inline-with-lexical-scope.exp         | 137 ++++++++++++++++++
 gdb/testsuite/gdb.opt/inline-locals.c         |  20 +++
 gdb/testsuite/gdb.opt/inline-locals.exp       |  30 ++++
 gdb/testsuite/lib/dwarf.exp                   |   5 +
 6 files changed, 287 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp

-- 
2.17.1


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

* [PATCH v2 1/2] testsuite, gdb: recognize DW_OP_fbreg in lib/dwarf.exp
  2021-04-14  8:14 [PATCH v2 0/2] "info locals" for clang-compiled inlined functions Tankut Baris Aktemur
@ 2021-04-14  8:14 ` Tankut Baris Aktemur
  2021-04-14  9:50   ` Andrew Burgess
  2021-04-14  8:14 ` [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions Tankut Baris Aktemur
  1 sibling, 1 reply; 9+ messages in thread
From: Tankut Baris Aktemur @ 2021-04-14  8:14 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2021-04-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* lib/dwarf.exp (_location): Recognize DW_OP_fbreg as an op.
---
 gdb/testsuite/lib/dwarf.exp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index f6a35749cab..e4dc284f4ee 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -1211,6 +1211,11 @@ namespace eval Dwarf {
 		    _op .sleb128 $argvec(offset)
 		}
 
+		DW_OP_fbreg {
+		    _get_args $line $opcode offset
+		    _op .sleb128 $argvec(offset)
+		}
+
 		default {
 		    if {[llength $line] > 1} {
 			error "Unimplemented: operands in location for $opcode"
-- 
2.17.1


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

* [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions
  2021-04-14  8:14 [PATCH v2 0/2] "info locals" for clang-compiled inlined functions Tankut Baris Aktemur
  2021-04-14  8:14 ` [PATCH v2 1/2] testsuite, gdb: recognize DW_OP_fbreg in lib/dwarf.exp Tankut Baris Aktemur
@ 2021-04-14  8:14 ` Tankut Baris Aktemur
  2021-04-14 12:18   ` Aktemur, Tankut Baris
  2021-04-14 13:30   ` Simon Marchi
  1 sibling, 2 replies; 9+ messages in thread
From: Tankut Baris Aktemur @ 2021-04-14  8:14 UTC (permalink / raw)
  To: gdb-patches

GDB reports duplicate local vars with "<optimized out>" values for
inlined functions that are compiled with Clang.

Suppose we have

  __attribute__((always_inline))
  static void aFunction() {
    int a = 42;
    if(a > 2) {
      int value = a;
      value += 10; /* break here */
    }
  }

The "info locals" command at the "break here" line gives the following
output:

  ...
  Breakpoint 1, aFunction () at test.c:6
  6           value += 10; /* break here */
  (gdb) info locals
  value = 42
  a = 42
  value = <optimized out>
  (gdb)

The reason is, inlined functions that are compiled by Clang do not
contain DW_AT_abstract_origin attributes in the DW_TAG_lexical_block
entries.  See

  https://bugs.llvm.org/show_bug.cgi?id=49953

E.g. the DIE of the inlined function above is

0x00000087:     DW_TAG_inlined_subroutine
                  DW_AT_abstract_origin (0x0000002a "aFunction")
                  DW_AT_low_pc  (0x00000000004004b2)
                  DW_AT_high_pc (0x00000000004004d2)
                  DW_AT_call_file       ("/tmp/test.c")
                  DW_AT_call_line       (11)
                  DW_AT_call_column     (0x03)

0x0000009b:       DW_TAG_variable
                    DW_AT_location      (DW_OP_fbreg -4)
                    DW_AT_abstract_origin       (0x00000032 "a")

0x000000a3:       DW_TAG_lexical_block
                    DW_AT_low_pc        (0x00000000004004c3)
                    DW_AT_high_pc       (0x00000000004004d2)

0x000000b0:         DW_TAG_variable
                      DW_AT_location    (DW_OP_fbreg -8)
                      DW_AT_abstract_origin     (0x0000003e "value")

This causes GDB to fail matching the concrete lexical scope with the
corresponding abstract entry.  Hence, the local vars of the abstract
function that are contained in the lexical scope are read separately
(and thus, in addition to) the local vars of the concrete scope.
Because the abstract definitions of the vars do not contain location
information, we see the extra 'value = <optimized out>' above.

This bug is highly related to PR gdb/25695, but the root cause is not
exactly the same.  In PR gdb/25695, GCC emits an extra
DW_TAG_lexical_block without an DW_AT_abstract_origin that wraps the
body of the inlined function.  That is, the trees of the abstract DIE
for the function and its concrete instance are structurally not the
same.  In the case of using Clang, the trees have the same structure.

To tackle the Clang case, when traversing the children of the concrete
instance root, keep a reference to the child of the abstract DIE that
corresponds to the concrete child, so that we can match the two DIEs
heuristically in case of missing DW_AT_abstract_origin attributes.

The updated gdb.opt/inline-locals.exp test has been checked with GCC
5-10 and Clang 5-11.

gdb/ChangeLog:
2021-04-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* dwarf2/read.c (inherit_abstract_dies): Keep a reference to the
	corresponding child of the abstract DIE when iterating the
	children of the concrete DIE.

gdb/testsuite/ChangeLog:
2021-04-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* gdb.opt/inline-locals.c (scoped): New function.
	(main): Call 'scoped'.
	* gdb.opt/inline-locals.exp: Update with "info locals" tests
	for scoped variables.
	* gdb.dwarf2/dw2-inline-with-lexical-scope.c: New file.
	* gdb.dwarf2/dw2-inline-with-lexical-scope.exp: New file.
---
 gdb/dwarf2/read.c                             |  49 ++++++-
 .../dw2-inline-with-lexical-scope.c           |  47 ++++++
 .../dw2-inline-with-lexical-scope.exp         | 137 ++++++++++++++++++
 gdb/testsuite/gdb.opt/inline-locals.c         |  20 +++
 gdb/testsuite/gdb.opt/inline-locals.exp       |  30 ++++
 5 files changed, 282 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
 create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index ed0d1c6cc7f..32c0ed73cbd 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -13492,6 +13492,37 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
 	       sect_offset_str (die->sect_off),
 	       sect_offset_str (origin_die->sect_off));
 
+  /* Find if the concrete and abstract trees are structurally the
+     same.  This is a shallow traversal and it is not bullet-proof;
+     the compiler can trick the debugger into believing that the trees
+     are isomorphic, whereas they actually are not.  However, the
+     likelyhood of this happening is pretty low, and a full-fledged
+     check would be an overkill.  */
+  bool are_isomorphic = true;
+  die_info *concrete_child = die->child;
+  die_info *abstract_child = origin_die->child;
+  while (concrete_child != nullptr || abstract_child != nullptr)
+    {
+      if (concrete_child == nullptr
+	  || abstract_child == nullptr
+	  || concrete_child->tag != abstract_child->tag)
+	{
+	  are_isomorphic = false;
+	  break;
+	}
+
+      concrete_child = concrete_child->sibling;
+      abstract_child = abstract_child->sibling;
+    }
+
+  /* Walk the origin's children in parallel to the concrete children.
+     This helps match an origin child in case the debug info misses
+     DW_AT_abstract_origin attributes.  Keep in mind that the abstract
+     origin tree may not have the same tree structure as the concrete
+     DIE, though.  */
+  die_info *corresponding_abstract_child
+    = are_isomorphic ? origin_die->child : nullptr;
+
   std::vector<sect_offset> offsets;
 
   for (child_die = die->child;
@@ -13508,7 +13539,12 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
 	 one.  */
       if (child_die->tag == DW_TAG_call_site
 	  || child_die->tag == DW_TAG_GNU_call_site)
-	continue;
+	{
+	  if (are_isomorphic)
+	    corresponding_abstract_child
+	      = corresponding_abstract_child->sibling;
+	  continue;
+	}
 
       /* For each CHILD_DIE, find the corresponding child of
 	 ORIGIN_DIE.  If there is more than one layer of
@@ -13527,6 +13563,14 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
 					     &child_origin_cu);
 	}
 
+      /* If missing DW_AT_abstract_origin, try the corresponding child
+	 of the origin.  Clang emits such lexical scopes.  */
+      if (child_origin_die == child_die
+	  && dwarf2_attr (child_die, DW_AT_abstract_origin, cu) == nullptr
+	  && are_isomorphic
+	  && child_die->tag == DW_TAG_lexical_block)
+	child_origin_die = corresponding_abstract_child;
+
       /* According to DWARF3 3.3.8.2 #3 new entries without their abstract
 	 counterpart may exist.  */
       if (child_origin_die != child_die)
@@ -13546,6 +13590,9 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
 	  else
 	    offsets.push_back (child_origin_die->sect_off);
 	}
+
+      if (are_isomorphic)
+	corresponding_abstract_child = corresponding_abstract_child->sibling;
     }
   std::sort (offsets.begin (), offsets.end ());
   sect_offset *offsets_end = offsets.data () + offsets.size ();
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
new file mode 100644
index 00000000000..0fd909459ba
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
@@ -0,0 +1,47 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2021 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/>.  */
+
+#ifdef __GNUC__
+#define ATTR __attribute__((always_inline))
+#else
+#define ATTR
+#endif
+
+inline ATTR
+static void
+func ()
+{ /* func prologue */
+  int num= 42;
+  if (num > 2)
+    {
+      asm ("scope_label1: .globl scope_label1");
+      int value = num;
+      asm ("breakpoint_label: .globl breakpoint_label");
+      value += 10; /* break here */
+      asm ("scope_label2: .globl scope_label2");
+    }
+} /* func end */
+
+int
+main ()
+{ /* main prologue */
+  asm ("main_label: .globl main_label");
+  func (); /* func call */
+  asm ("main_label2: .globl main_label2");
+  return 0; /* main return */
+} /* main end */
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
new file mode 100644
index 00000000000..e815c859639
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
@@ -0,0 +1,137 @@
+# Copyright 2021 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/>.
+
+# Test that scoped local variables in an inlined function are printed
+# properly.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets that support DWARF-2 and use
+# gas.
+if {![dwarf2_support]} {
+    return 0
+}
+
+standard_testfile .c .S
+
+# Make some DWARF for the test.  The concrete inlined instance
+# (i.e. the DW_TAG_inlined_subroutine) has a DW_TAG_lexical_block that
+# does not contain a DW_AT_abstract_origin attribute.  This is
+# deliberate.  Bad GDB printed duplicate local variables with
+# "optimized out" values in this case.
+
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+    global srcfile srcdir subdir
+    declare_labels int_label func_label num_label value_label lines_label
+
+    get_func_info main
+    set func_call [gdb_get_line_number "func call"]
+
+    cu {} {
+	compile_unit {
+	    {language @DW_LANG_C99}
+	    {name $srcfile}
+	    {low_pc $main_start addr}
+	    {high_pc "$main_start + $main_len" addr}
+	    {stmt_list ${lines_label} DW_FORM_sec_offset}
+	} {
+	    int_label: base_type {
+                {name "int"}
+                {byte_size 4 sdata}
+		{encoding @DW_ATE_signed}
+            }
+
+	    func_label: subprogram {
+		{name func}
+		{inline 3 data1}
+	    } {
+		num_label: DW_TAG_variable {
+		    {name num}
+		    {type :$int_label}
+		}
+		lexical_block {
+		} {
+		    value_label: DW_TAG_variable {
+			{name value}
+			{type :$int_label}
+		    }
+		}
+	    }
+
+	    subprogram {
+		{name main}
+		{frame_base {DW_OP_reg6} SPECIAL_expr}
+		{external 1 flag}
+		{low_pc $main_start addr}
+		{high_pc "$main_start + $main_len" addr}
+	    } {
+		inlined_subroutine {
+		    {abstract_origin %$func_label}
+		    {low_pc main_label addr}
+		    {high_pc main_label2 addr}
+		    {call_file 1 data1}
+		    {call_line $func_call data1}
+		} {
+		    DW_TAG_variable {
+			{abstract_origin %$num_label}
+			{location {DW_OP_fbreg -4} SPECIAL_expr}
+		    }
+		    lexical_block {
+			{low_pc scope_label1 addr}
+			{high_pc scope_label2 addr}
+		    } {
+			DW_TAG_variable {
+			    {abstract_origin %$value_label}
+			    {location {DW_OP_fbreg -8} SPECIAL_expr}
+			}
+		    }
+		}
+	    }
+	}
+    }
+
+    lines {version 2} lines_label {
+	include_dir "${srcdir}/${subdir}"
+	file_name "$srcfile" 1
+
+	program {
+	    {DW_LNE_set_address $main_start}
+	    {line [gdb_get_line_number "main prologue"]}
+	    {DW_LNS_copy}
+	    {DW_LNE_set_address main_label}
+	    {line [gdb_get_line_number "func call"]}
+	    {DW_LNS_copy}
+	    {DW_LNE_set_address main_label}
+	    {line [gdb_get_line_number "func end"]}
+	    {DW_LNS_copy}
+	    {DW_LNE_set_address main_label2}
+	    {line [gdb_get_line_number "main end"]}
+	    {DW_LNS_copy}
+	    {DW_LNE_set_address $main_end}
+	    {DW_LNE_end_sequence}
+	}
+    }
+}
+
+if {[prepare_for_testing "failed to prepare" ${testfile} \
+	 [list $srcfile $asm_file] {nodebug}]} {
+    return -1
+}
+
+runto breakpoint_label
+
+# Bad GDB was printing an additional "value = <optimized out>".
+gdb_test "info locals" "value = 42\r\nnum = 42"
diff --git a/gdb/testsuite/gdb.opt/inline-locals.c b/gdb/testsuite/gdb.opt/inline-locals.c
index b949152a3c0..f8910dadca3 100644
--- a/gdb/testsuite/gdb.opt/inline-locals.c
+++ b/gdb/testsuite/gdb.opt/inline-locals.c
@@ -53,6 +53,24 @@ inline ATTR int func2(int arg2)
   return x * func1 (arg2);
 }
 
+inline ATTR
+void
+scoped (int s)
+{
+  int loc1 = 10;
+  if (s > 0)
+    {
+      int loc2 = 20;
+      s++; /* bp for locals 1 */
+      if (s > 1)
+	{
+	  int loc3 = 30;
+	  s++; /* bp for locals 2 */
+	}
+    }
+  s++; /* bp for locals 3 */
+}
+
 int main (void)
 {
   int val;
@@ -67,5 +85,7 @@ int main (void)
   val = func2 (result);
   result = val;
 
+  scoped (40);
+
   return 0;
 }
diff --git a/gdb/testsuite/gdb.opt/inline-locals.exp b/gdb/testsuite/gdb.opt/inline-locals.exp
index 2d8af285a88..d0acb4ae8b5 100644
--- a/gdb/testsuite/gdb.opt/inline-locals.exp
+++ b/gdb/testsuite/gdb.opt/inline-locals.exp
@@ -124,3 +124,33 @@ if { ! $no_frames } {
 }
 
 gdb_test "print array\[0\]" "\\\$$decimal = 184" "print local 3"
+
+# Test printing scoped local variables.
+
+proc check_scoped_locals {bp_label pass_re} {
+    global srcfile
+
+    set locals_bp [gdb_get_line_number $bp_label ${srcfile}]
+    gdb_breakpoint $srcfile:$locals_bp
+
+    gdb_continue_to_breakpoint "$bp_label" ".*$srcfile:$locals_bp.*"
+    set kfail_re [multi_line $pass_re ".*<optimized out>"]
+    gdb_test_multiple "info locals" "scoped info locals at $bp_label" {
+	-re -wrap $pass_re {
+	    pass $gdb_test_name
+	}
+	-re -wrap $kfail_re {
+	    if {[test_compiler_info {gcc-[0-8]-*-*}]} {
+		kfail gdb/25695 $gdb_test_name
+	    } else {
+		fail $gdb_test_name
+	    }
+	}
+    }
+}
+
+if {! $no_frames } {
+    check_scoped_locals "bp for locals 1" "loc2 = 20\r\nloc1 = 10"
+    check_scoped_locals "bp for locals 2" "loc3 = 30\r\nloc2 = 20\r\nloc1 = 10"
+    check_scoped_locals "bp for locals 3" "loc1 = 10"
+}
-- 
2.17.1


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

* Re: [PATCH v2 1/2] testsuite, gdb: recognize DW_OP_fbreg in lib/dwarf.exp
  2021-04-14  8:14 ` [PATCH v2 1/2] testsuite, gdb: recognize DW_OP_fbreg in lib/dwarf.exp Tankut Baris Aktemur
@ 2021-04-14  9:50   ` Andrew Burgess
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Burgess @ 2021-04-14  9:50 UTC (permalink / raw)
  To: Tankut Baris Aktemur; +Cc: gdb-patches

* Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org> [2021-04-14 10:14:30 +0200]:

> gdb/testsuite/ChangeLog:
> 2021-04-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
> 
> 	* lib/dwarf.exp (_location): Recognize DW_OP_fbreg as an op.

LGTM.

Thanks,
Andrew


> ---
>  gdb/testsuite/lib/dwarf.exp | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
> index f6a35749cab..e4dc284f4ee 100644
> --- a/gdb/testsuite/lib/dwarf.exp
> +++ b/gdb/testsuite/lib/dwarf.exp
> @@ -1211,6 +1211,11 @@ namespace eval Dwarf {
>  		    _op .sleb128 $argvec(offset)
>  		}
>  
> +		DW_OP_fbreg {
> +		    _get_args $line $opcode offset
> +		    _op .sleb128 $argvec(offset)
> +		}
> +
>  		default {
>  		    if {[llength $line] > 1} {
>  			error "Unimplemented: operands in location for $opcode"
> -- 
> 2.17.1
> 

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

* RE: [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions
  2021-04-14  8:14 ` [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions Tankut Baris Aktemur
@ 2021-04-14 12:18   ` Aktemur, Tankut Baris
  2021-04-14 15:46     ` Andrew Burgess
  2021-04-14 13:30   ` Simon Marchi
  1 sibling, 1 reply; 9+ messages in thread
From: Aktemur, Tankut Baris @ 2021-04-14 12:18 UTC (permalink / raw)
  To: gdb-patches

On Wednesday, April 14, 2021 10:15 AM, Aktemur, Tankut Baris wrote:
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> new file mode 100644
> index 00000000000..e815c859639
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> @@ -0,0 +1,137 @@
> +# Copyright 2021 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/>.
> +
> +# Test that scoped local variables in an inlined function are printed
> +# properly.
> +
> +load_lib dwarf.exp
> +
> +# This test can only be run on targets that support DWARF-2 and use
> +# gas.
> +if {![dwarf2_support]} {
> +    return 0
> +}
> +
> +standard_testfile .c .S
> +
> +# Make some DWARF for the test.  The concrete inlined instance
> +# (i.e. the DW_TAG_inlined_subroutine) has a DW_TAG_lexical_block that
> +# does not contain a DW_AT_abstract_origin attribute.  This is
> +# deliberate.  Bad GDB printed duplicate local variables with
> +# "optimized out" values in this case.
> +
> +set asm_file [standard_output_file $srcfile2]
> +Dwarf::assemble $asm_file {
> +    global srcfile srcdir subdir
> +    declare_labels int_label func_label num_label value_label lines_label
> +
> +    get_func_info main
> +    set func_call [gdb_get_line_number "func call"]
> +
> +    cu {} {
> +	compile_unit {
> +	    {language @DW_LANG_C99}
> +	    {name $srcfile}
> +	    {low_pc $main_start addr}
> +	    {high_pc "$main_start + $main_len" addr}
> +	    {stmt_list ${lines_label} DW_FORM_sec_offset}
> +	} {
> +	    int_label: base_type {
> +                {name "int"}
> +                {byte_size 4 sdata}
> +		{encoding @DW_ATE_signed}
> +            }
> +
> +	    func_label: subprogram {
> +		{name func}
> +		{inline 3 data1}
> +	    } {
> +		num_label: DW_TAG_variable {
> +		    {name num}
> +		    {type :$int_label}
> +		}
> +		lexical_block {
> +		} {
> +		    value_label: DW_TAG_variable {
> +			{name value}
> +			{type :$int_label}
> +		    }
> +		}
> +	    }
> +
> +	    subprogram {
> +		{name main}
> +		{frame_base {DW_OP_reg6} SPECIAL_expr}

I think I'll have to limit the test to X86_64 targets.

-Baris



Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

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

* Re: [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions
  2021-04-14  8:14 ` [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions Tankut Baris Aktemur
  2021-04-14 12:18   ` Aktemur, Tankut Baris
@ 2021-04-14 13:30   ` Simon Marchi
  2021-04-14 17:08     ` Aktemur, Tankut Baris
  1 sibling, 1 reply; 9+ messages in thread
From: Simon Marchi @ 2021-04-14 13:30 UTC (permalink / raw)
  To: Tankut Baris Aktemur, gdb-patches

On 2021-04-14 4:14 a.m., Tankut Baris Aktemur wrote:
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> new file mode 100644
> index 00000000000..e815c859639
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> @@ -0,0 +1,137 @@
> +# Copyright 2021 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/>.
> +
> +# Test that scoped local variables in an inlined function are printed
> +# properly.
> +
> +load_lib dwarf.exp
> +
> +# This test can only be run on targets that support DWARF-2 and use
> +# gas.
> +if {![dwarf2_support]} {
> +    return 0
> +}
> +
> +standard_testfile .c .S
> +
> +# Make some DWARF for the test.  The concrete inlined instance
> +# (i.e. the DW_TAG_inlined_subroutine) has a DW_TAG_lexical_block that
> +# does not contain a DW_AT_abstract_origin attribute.  This is
> +# deliberate.  Bad GDB printed duplicate local variables with
> +# "optimized out" values in this case.
> +
> +set asm_file [standard_output_file $srcfile2]
> +Dwarf::assemble $asm_file {
> +    global srcfile srcdir subdir
> +    declare_labels int_label func_label num_label value_label lines_label
> +
> +    get_func_info main
> +    set func_call [gdb_get_line_number "func call"]
> +
> +    cu {} {
> +	compile_unit {
> +	    {language @DW_LANG_C99}
> +	    {name $srcfile}
> +	    {low_pc $main_start addr}
> +	    {high_pc "$main_start + $main_len" addr}
> +	    {stmt_list ${lines_label} DW_FORM_sec_offset}
> +	} {
> +	    int_label: base_type {
> +                {name "int"}
> +                {byte_size 4 sdata}
> +		{encoding @DW_ATE_signed}
> +            }
> +
> +	    func_label: subprogram {
> +		{name func}
> +		{inline 3 data1}

You could maybe use

  {inline @DW_INL_declared_inlined}

here.  The form will be sdata instead of data1, but I don't think that's
a problem.

Otherwise, LGTM, thanks!

Simon

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

* Re: [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions
  2021-04-14 12:18   ` Aktemur, Tankut Baris
@ 2021-04-14 15:46     ` Andrew Burgess
  2021-04-14 17:00       ` Aktemur, Tankut Baris
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Burgess @ 2021-04-14 15:46 UTC (permalink / raw)
  To: Aktemur, Tankut Baris; +Cc: gdb-patches

* Aktemur, Tankut Baris via Gdb-patches <gdb-patches@sourceware.org> [2021-04-14 12:18:26 +0000]:

> On Wednesday, April 14, 2021 10:15 AM, Aktemur, Tankut Baris wrote:
> > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> > b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> > new file mode 100644
> > index 00000000000..e815c859639
> > --- /dev/null
> > +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> > @@ -0,0 +1,137 @@
> > +# Copyright 2021 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/>.
> > +
> > +# Test that scoped local variables in an inlined function are printed
> > +# properly.
> > +
> > +load_lib dwarf.exp
> > +
> > +# This test can only be run on targets that support DWARF-2 and use
> > +# gas.
> > +if {![dwarf2_support]} {
> > +    return 0
> > +}
> > +
> > +standard_testfile .c .S
> > +
> > +# Make some DWARF for the test.  The concrete inlined instance
> > +# (i.e. the DW_TAG_inlined_subroutine) has a DW_TAG_lexical_block that
> > +# does not contain a DW_AT_abstract_origin attribute.  This is
> > +# deliberate.  Bad GDB printed duplicate local variables with
> > +# "optimized out" values in this case.
> > +
> > +set asm_file [standard_output_file $srcfile2]
> > +Dwarf::assemble $asm_file {
> > +    global srcfile srcdir subdir
> > +    declare_labels int_label func_label num_label value_label lines_label
> > +
> > +    get_func_info main
> > +    set func_call [gdb_get_line_number "func call"]
> > +
> > +    cu {} {
> > +	compile_unit {
> > +	    {language @DW_LANG_C99}
> > +	    {name $srcfile}
> > +	    {low_pc $main_start addr}
> > +	    {high_pc "$main_start + $main_len" addr}
> > +	    {stmt_list ${lines_label} DW_FORM_sec_offset}
> > +	} {
> > +	    int_label: base_type {
> > +                {name "int"}
> > +                {byte_size 4 sdata}
> > +		{encoding @DW_ATE_signed}
> > +            }
> > +
> > +	    func_label: subprogram {
> > +		{name func}
> > +		{inline 3 data1}
> > +	    } {
> > +		num_label: DW_TAG_variable {
> > +		    {name num}
> > +		    {type :$int_label}
> > +		}
> > +		lexical_block {
> > +		} {
> > +		    value_label: DW_TAG_variable {
> > +			{name value}
> > +			{type :$int_label}
> > +		    }
> > +		}
> > +	    }
> > +
> > +	    subprogram {
> > +		{name main}
> > +		{frame_base {DW_OP_reg6} SPECIAL_expr}
> 
> I think I'll have to limit the test to X86_64 targets.

As I understand the problem description, the important part of this
test is the lack of DW_AT_abstract_origin, not the location of the
variables.

The approach I usually take for tests like this is to mirror the
variables into global parameters, and just have the location attribute
point to the global location.

I tested this approach with your patch, the test still fails before
the fix, and works afterwards, so I think we're good - but now there's
no need to reference specific stack locations, or register numbers.

The patch below is what I came up with, feel free to use this if you
think it is helpful.  It should apply on top of your two patches.

Thanks,
Andrew

---

diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
index 0fd909459ba..57ef6a8f035 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
@@ -16,6 +16,9 @@
    along with this program.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+int global_num = 0;
+int global_value = 0;
+
 #ifdef __GNUC__
 #define ATTR __attribute__((always_inline))
 #else
@@ -26,12 +29,15 @@ inline ATTR
 static void
 func ()
 { /* func prologue */
-  int num= 42;
+  global_num = 42;
+  int num = 42;
   if (num > 2)
     {
       asm ("scope_label1: .globl scope_label1");
+      global_value = num;
       int value = num;
       asm ("breakpoint_label: .globl breakpoint_label");
+      global_value += 10;
       value += 10; /* break here */
       asm ("scope_label2: .globl scope_label2");
     }
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
index e815c859639..d85d2fe06b0 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
@@ -40,6 +40,9 @@ Dwarf::assemble $asm_file {
     get_func_info main
     set func_call [gdb_get_line_number "func call"]
 
+    set num_var [gdb_target_symbol global_num]
+    set value_var [gdb_target_symbol global_value]
+
     cu {} {
 	compile_unit {
 	    {language @DW_LANG_C99}
@@ -73,7 +76,6 @@ Dwarf::assemble $asm_file {
 
 	    subprogram {
 		{name main}
-		{frame_base {DW_OP_reg6} SPECIAL_expr}
 		{external 1 flag}
 		{low_pc $main_start addr}
 		{high_pc "$main_start + $main_len" addr}
@@ -87,7 +89,7 @@ Dwarf::assemble $asm_file {
 		} {
 		    DW_TAG_variable {
 			{abstract_origin %$num_label}
-			{location {DW_OP_fbreg -4} SPECIAL_expr}
+			{location {addr $num_var} SPECIAL_expr}
 		    }
 		    lexical_block {
 			{low_pc scope_label1 addr}
@@ -95,7 +97,7 @@ Dwarf::assemble $asm_file {
 		    } {
 			DW_TAG_variable {
 			    {abstract_origin %$value_label}
-			    {location {DW_OP_fbreg -8} SPECIAL_expr}
+			    {location {addr $value_var} SPECIAL_expr}
 			}
 		    }
 		}

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

* RE: [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions
  2021-04-14 15:46     ` Andrew Burgess
@ 2021-04-14 17:00       ` Aktemur, Tankut Baris
  0 siblings, 0 replies; 9+ messages in thread
From: Aktemur, Tankut Baris @ 2021-04-14 17:00 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

On Wednesday, April 14, 2021 5:47 PM, Andrew Burgess wrote:
> * Aktemur, Tankut Baris via Gdb-patches <gdb-patches@sourceware.org> [2021-04-14 12:18:26
> +0000]:
> 
> > On Wednesday, April 14, 2021 10:15 AM, Aktemur, Tankut Baris wrote:
> > > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> > > b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> > > new file mode 100644
> > > index 00000000000..e815c859639
> > > --- /dev/null
> > > +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> > > @@ -0,0 +1,137 @@
> > > +# Copyright 2021 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/>.
> > > +
> > > +# Test that scoped local variables in an inlined function are printed
> > > +# properly.
> > > +
> > > +load_lib dwarf.exp
> > > +
> > > +# This test can only be run on targets that support DWARF-2 and use
> > > +# gas.
> > > +if {![dwarf2_support]} {
> > > +    return 0
> > > +}
> > > +
> > > +standard_testfile .c .S
> > > +
> > > +# Make some DWARF for the test.  The concrete inlined instance
> > > +# (i.e. the DW_TAG_inlined_subroutine) has a DW_TAG_lexical_block that
> > > +# does not contain a DW_AT_abstract_origin attribute.  This is
> > > +# deliberate.  Bad GDB printed duplicate local variables with
> > > +# "optimized out" values in this case.
> > > +
> > > +set asm_file [standard_output_file $srcfile2]
> > > +Dwarf::assemble $asm_file {
> > > +    global srcfile srcdir subdir
> > > +    declare_labels int_label func_label num_label value_label lines_label
> > > +
> > > +    get_func_info main
> > > +    set func_call [gdb_get_line_number "func call"]
> > > +
> > > +    cu {} {
> > > +	compile_unit {
> > > +	    {language @DW_LANG_C99}
> > > +	    {name $srcfile}
> > > +	    {low_pc $main_start addr}
> > > +	    {high_pc "$main_start + $main_len" addr}
> > > +	    {stmt_list ${lines_label} DW_FORM_sec_offset}
> > > +	} {
> > > +	    int_label: base_type {
> > > +                {name "int"}
> > > +                {byte_size 4 sdata}
> > > +		{encoding @DW_ATE_signed}
> > > +            }
> > > +
> > > +	    func_label: subprogram {
> > > +		{name func}
> > > +		{inline 3 data1}
> > > +	    } {
> > > +		num_label: DW_TAG_variable {
> > > +		    {name num}
> > > +		    {type :$int_label}
> > > +		}
> > > +		lexical_block {
> > > +		} {
> > > +		    value_label: DW_TAG_variable {
> > > +			{name value}
> > > +			{type :$int_label}
> > > +		    }
> > > +		}
> > > +	    }
> > > +
> > > +	    subprogram {
> > > +		{name main}
> > > +		{frame_base {DW_OP_reg6} SPECIAL_expr}
> >
> > I think I'll have to limit the test to X86_64 targets.
> 
> As I understand the problem description, the important part of this
> test is the lack of DW_AT_abstract_origin, not the location of the
> variables.
> 
> The approach I usually take for tests like this is to mirror the
> variables into global parameters, and just have the location attribute
> point to the global location.
> 
> I tested this approach with your patch, the test still fails before
> the fix, and works afterwards, so I think we're good - but now there's
> no need to reference specific stack locations, or register numbers.
> 
> The patch below is what I came up with, feel free to use this if you
> think it is helpful.  It should apply on top of your two patches.
> 
> Thanks,
> Andrew

This worked very well.  Thank you for the suggestion.
I pushed the patch.

-Baris

> ---
> 
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
> b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
> index 0fd909459ba..57ef6a8f035 100644
> --- a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.c
> @@ -16,6 +16,9 @@
>     along with this program.  If not, see
>     <http://www.gnu.org/licenses/>.  */
> 
> +int global_num = 0;
> +int global_value = 0;
> +
>  #ifdef __GNUC__
>  #define ATTR __attribute__((always_inline))
>  #else
> @@ -26,12 +29,15 @@ inline ATTR
>  static void
>  func ()
>  { /* func prologue */
> -  int num= 42;
> +  global_num = 42;
> +  int num = 42;
>    if (num > 2)
>      {
>        asm ("scope_label1: .globl scope_label1");
> +      global_value = num;
>        int value = num;
>        asm ("breakpoint_label: .globl breakpoint_label");
> +      global_value += 10;
>        value += 10; /* break here */
>        asm ("scope_label2: .globl scope_label2");
>      }
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> index e815c859639..d85d2fe06b0 100644
> --- a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> @@ -40,6 +40,9 @@ Dwarf::assemble $asm_file {
>      get_func_info main
>      set func_call [gdb_get_line_number "func call"]
> 
> +    set num_var [gdb_target_symbol global_num]
> +    set value_var [gdb_target_symbol global_value]
> +
>      cu {} {
>  	compile_unit {
>  	    {language @DW_LANG_C99}
> @@ -73,7 +76,6 @@ Dwarf::assemble $asm_file {
> 
>  	    subprogram {
>  		{name main}
> -		{frame_base {DW_OP_reg6} SPECIAL_expr}
>  		{external 1 flag}
>  		{low_pc $main_start addr}
>  		{high_pc "$main_start + $main_len" addr}
> @@ -87,7 +89,7 @@ Dwarf::assemble $asm_file {
>  		} {
>  		    DW_TAG_variable {
>  			{abstract_origin %$num_label}
> -			{location {DW_OP_fbreg -4} SPECIAL_expr}
> +			{location {addr $num_var} SPECIAL_expr}
>  		    }
>  		    lexical_block {
>  			{low_pc scope_label1 addr}
> @@ -95,7 +97,7 @@ Dwarf::assemble $asm_file {
>  		    } {
>  			DW_TAG_variable {
>  			    {abstract_origin %$value_label}
> -			    {location {DW_OP_fbreg -8} SPECIAL_expr}
> +			    {location {addr $value_var} SPECIAL_expr}
>  			}
>  		    }
>  		}



Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

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

* RE: [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions
  2021-04-14 13:30   ` Simon Marchi
@ 2021-04-14 17:08     ` Aktemur, Tankut Baris
  0 siblings, 0 replies; 9+ messages in thread
From: Aktemur, Tankut Baris @ 2021-04-14 17:08 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On Wednesday, April 14, 2021 3:30 PM, Simon Marchi wrote:
> On 2021-04-14 4:14 a.m., Tankut Baris Aktemur wrote:
> > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> > new file mode 100644
> > index 00000000000..e815c859639
> > --- /dev/null
> > +++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
> > @@ -0,0 +1,137 @@
> > +# Copyright 2021 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/>.
> > +
> > +# Test that scoped local variables in an inlined function are printed
> > +# properly.
> > +
> > +load_lib dwarf.exp
> > +
> > +# This test can only be run on targets that support DWARF-2 and use
> > +# gas.
> > +if {![dwarf2_support]} {
> > +    return 0
> > +}
> > +
> > +standard_testfile .c .S
> > +
> > +# Make some DWARF for the test.  The concrete inlined instance
> > +# (i.e. the DW_TAG_inlined_subroutine) has a DW_TAG_lexical_block that
> > +# does not contain a DW_AT_abstract_origin attribute.  This is
> > +# deliberate.  Bad GDB printed duplicate local variables with
> > +# "optimized out" values in this case.
> > +
> > +set asm_file [standard_output_file $srcfile2]
> > +Dwarf::assemble $asm_file {
> > +    global srcfile srcdir subdir
> > +    declare_labels int_label func_label num_label value_label lines_label
> > +
> > +    get_func_info main
> > +    set func_call [gdb_get_line_number "func call"]
> > +
> > +    cu {} {
> > +	compile_unit {
> > +	    {language @DW_LANG_C99}
> > +	    {name $srcfile}
> > +	    {low_pc $main_start addr}
> > +	    {high_pc "$main_start + $main_len" addr}
> > +	    {stmt_list ${lines_label} DW_FORM_sec_offset}
> > +	} {
> > +	    int_label: base_type {
> > +                {name "int"}
> > +                {byte_size 4 sdata}
> > +		{encoding @DW_ATE_signed}
> > +            }
> > +
> > +	    func_label: subprogram {
> > +		{name func}
> > +		{inline 3 data1}
> 
> You could maybe use
> 
>   {inline @DW_INL_declared_inlined}
> 
> here.  The form will be sdata instead of data1, but I don't think that's
> a problem.
> 
> Otherwise, LGTM, thanks!
> 
> Simon

Ahh, I thought I had made this change, but I pushed the patch without it.
Sorry about that.  I'll fix it now.  I hope it's OK.

-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

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

end of thread, other threads:[~2021-04-14 17:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14  8:14 [PATCH v2 0/2] "info locals" for clang-compiled inlined functions Tankut Baris Aktemur
2021-04-14  8:14 ` [PATCH v2 1/2] testsuite, gdb: recognize DW_OP_fbreg in lib/dwarf.exp Tankut Baris Aktemur
2021-04-14  9:50   ` Andrew Burgess
2021-04-14  8:14 ` [PATCH v2 2/2] gdb/dwarf2: fix "info locals" for clang-compiled inlined functions Tankut Baris Aktemur
2021-04-14 12:18   ` Aktemur, Tankut Baris
2021-04-14 15:46     ` Andrew Burgess
2021-04-14 17:00       ` Aktemur, Tankut Baris
2021-04-14 13:30   ` Simon Marchi
2021-04-14 17:08     ` Aktemur, Tankut Baris

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