Bug 19307 – Variables moved to a closure show nonsense in debugger

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2018-10-16T06:10:31Z
Last change time
2018-10-26T09:16:59Z
Keywords
pull, symdeb
Assigned to
No Owner
Creator
Rainer Schuetze

Comments

Comment #0 by r.sagitario — 2018-10-16T06:10:31Z
Compile this program with -g: int main() { int x = 7; auto dg = delegate() { return x; }; return dg(); } and step through it in a debugger: the assignment to x does not seem to do anyhing, the value of 'x' stays random.
Comment #1 by r.sagitario — 2018-10-16T06:13:11Z
This is caused by 'x' being emitted as if it is still accessed via the frame pointer. This is the relevant snippet form the cvdump output: (000024) S_GPROC32: [0001:00009F10], Cb: 0000004F, Type: 0x1003, D main Parent: 00000000, End: 00000094, Next: 00000000 Debug start: 00000008, Debug end: 0000004A (000054) S_ENDARG (000058) S_REGREL32: rbp+FFFFFFE0, Type: 0x3BF6, __closptr (000070) S_REGREL32: rbp+FFFFFFE8, Type: 0x1006, x (000080) S_REGREL32: rbp+FFFFFFF0, Type: 0x100A, dg
Comment #2 by r.sagitario — 2018-10-19T19:23:20Z
Comment #3 by github-bugzilla — 2018-10-26T09:16:58Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/098cfdcc4a5ef3532816c11636934cd781c996f5 fix issue 19307 - Variables moved to a closure show nonsense in debugger generate struct type debug information for allocated closures https://github.com/dlang/dmd/commit/a4eeab9b83e5c614a6bbe7b44224340c93068377 Merge pull request #8847 from rainers/issue_19307 fix issue 19307 - Variables moved to a closure show nonsense in debugger merged-on-behalf-of: Walter Bright <[email protected]>