Re: [PATCH] KFAIL variable-length array tests which fail with Clang

Tom de Vries
2020-11-19T22:53:21Z

On 11/18/20 5:14 PM, Tom Tromey wrote:
>>>>>> "Gary" == Gary Benson via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Gary> Clang describes the upper bounds of variable length arrays using
> Gary> a DW_AT_count attribute which references the DIE of a synthetic
> Gary> variable whose value is specified using a DW_AT_location. In
> Gary> some cases GDB correctly handles these, but in other cases GDB
> Gary> adds an extra dereference causing the test to fail. This commit
> Gary> marks these failing tests as caused by PR gdb/26905 when the
> Gary> test executable was built using Clang.
>
> Shouldn't we just fix the gdb bug instead?

This adhoc patch:
...
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3c598262913..d27e8613d1c 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -18644,7 +18644,9 @@ attr_to_dynamic_prop (const struct attribute
*attr, struct die
_info *die,
struct dwarf_block *block = target_attr->as_block ();
baton->locexpr.size = block->size;
baton->locexpr.data = block->data;
- baton->locexpr.is_reference = true;
+ gdb_byte last = block->data[block->size - 1];
+ baton->locexpr.is_reference
+ = !(last == DW_OP_stack_value || last ==
DW_OP_implicit_value);
prop->set_locexpr (baton);
gdb_assert (prop->baton () != NULL);
}
...
fixes gdb.base/vla-optimized-out.exp with clang-10 for me.

Thanks,
- Tom

> Or is there something preventing that? I feel like I may not fully
> appreciate the problem.
>
> Tom
>