Bug 31427 - DWARF expression evaluation misconception
Summary: DWARF expression evaluation misconception
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-28 15:56 UTC by Tom Tromey
Modified: 2024-02-28 17:44 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
test case (1.00 KB, text/plain)
2024-02-28 17:44 UTC, Tom Tromey
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2024-02-28 15:56:23 UTC
This comes from:

https://lists.dwarfstd.org/pipermail/dwarf-discuss/2024-February/002375.html
https://dwarfstd.org/issues/181205.1.html

gdb should reset the DWARF expression stack after a piece operation.
Apparently nobody noticed this text in 2.6.1 "Single Location Descriptions":

Each simple location description that is a DWARF expression is
evaluated independently of any others.

Also an empty first piece is ok.
Comment 1 Tom Tromey 2024-02-28 17:33:03 UTC
I'm not sure there's a valid expression that would give
a different result if values were left on the stack
between pieces.

Maybe it can only be done in the situation where an initial
value must be pushed.  Presumably in the pieced case,
the initial value must be pushed before each piece is
evaluated.
Comment 2 Tom Tromey 2024-02-28 17:35:31 UTC
The empty first piece part works, according to a test
case I wrote:

(gdb) print s1
$1 = {a = <optimized out>, b = 23}
Comment 3 Tom Tromey 2024-02-28 17:43:48 UTC
(In reply to Tom Tromey from comment #1)

> Maybe it can only be done in the situation where an initial
> value must be pushed.  Presumably in the pieced case,
> the initial value must be pushed before each piece is
> evaluated.

It's hard to imagine this even being useful, as the cases
where a value is pushed on the stack aren't really ones
where a pieced result would be useful or expected.
I'll attach my test case here but I think this bug
is probably only of pedantic interest; and the bug
in the rust support pointed out in those links is,
I think, a problem in rust-lang.c.  I'll file a separate
bug for that.
Comment 4 Tom Tromey 2024-02-28 17:44:30 UTC
Created attachment 15382 [details]
test case