]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/cli] Show LOC_CONST_BYTES var for info locals
authorTom de Vries <tdevries@suse.de>
Mon, 6 Jan 2025 17:48:58 +0000 (18:48 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 6 Jan 2025 17:48:58 +0000 (18:48 +0100)
PR cli/32525 reports that a variable with this DWARF:
..
<2><423>: Abbrev Number: 14 (DW_TAG_variable)
    <424>   DW_AT_name        : var1867
    <42a>   DW_AT_type        : <0x2f8>
    <42e>   DW_AT_const_value : 8 byte block: 0 0 0 0 0 0 0 0
...
is not shown by info locals.

Fix this by handling LOC_CONST_BYTES in iterate_over_block_locals.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32525

Approved-By: Tom Tromey <tom@tromey.com>
gdb/stack.c
gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp

index 9785a94b858d093376a77aaca4448815bed7b4a4..73165c801343d87a6f1aa114f99c4e41148c3bce 100644 (file)
@@ -2221,6 +2221,7 @@ iterate_over_block_locals (const struct block *b,
       switch (sym->aclass ())
        {
        case LOC_CONST:
+       case LOC_CONST_BYTES:
        case LOC_LOCAL:
        case LOC_REGISTER:
        case LOC_STATIC:
index 0aa7b04fb3eefcd8cea56b542146b5ea8db7e393..f338fd44e89de2484d0608ba7846679af700596f 100644 (file)
@@ -53,6 +53,11 @@ Dwarf::assemble $asm_file {
                    {name "opt_out"}
                    {type :$int_type_label}
                }
+               DW_TAG_variable {
+                   {name const_bytes}
+                   {type :$int_type_label}
+                   {const_value "\x01\x01\x01\x01" DW_FORM_block1}
+               }
            }
        }
     }
@@ -67,5 +72,14 @@ if ![runto_main] {
     return -1
 }
 
+set lines [gdb_get_lines "info locals"]
+
 # Make sure "info locals" shows optimized out variables.
-gdb_test "info locals" ".*opt_out = <optimized out>.*" "info local shows optimized out variable"
+gdb_assert \
+    { [regexp [string_to_regexp "opt_out = <optimized out>"] $lines] } \
+    "info locals shows optimized out variable"
+
+# Regression test for PR cli/32525.
+gdb_assert \
+    { [regexp [string_to_regexp "const_bytes = 16843009"] $lines] } \
+    "info locals shows DW_FORM_block1 variable"