Thread overview
[Issue 18984] Debugging stack struct's which are returned causes incorrect debuginfo.
Jun 15, 2018
Rainer Schuetze
Jun 15, 2018
Manu
Jun 18, 2018
Manu
Jun 18, 2018
Rainer Schuetze
Jun 21, 2018
Manu
Jun 21, 2018
Rainer Schuetze
Jun 21, 2018
Manu
June 15, 2018
https://issues.dlang.org/show_bug.cgi?id=18984

Rainer Schuetze <r.sagitario@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario@gmx.de
          Component|visuald                     |dmd

--- Comment #1 from Rainer Schuetze <r.sagitario@gmx.de> ---
To be pedantic, this is an issue with dmd generated debug info. This is a simpler test case:

struct S
{
        int a;
        int b;
        int c;
}

S foo()
{
        S s = S(1, 2, 3);
        s.a = 4; // break here, s shows junk, __HID1 has the expected values
        return s;
}

void main()
{
        S s = foo();
}

Here's the relevant snippet for x64 from the debug info as dumped by cvdump:

(00004C) S_GPROC32: [0000:00000000], Cb: 00000042, Type: 0x1006, rvo.foo
         Parent: 00000000, End: 00000000, Next: 00000000
         Debug start: 0000000E, Debug end: 0000003B

(00007B)  S_REGREL32: rbp+00000010, Type:             0x1007, __HID1
(000090)  S_ENDARG
(000094)  S_REGREL32: rbp+FFFFFFE0, Type:             0x1004, s

(0000A4) S_END

Happens with OMF aswell, LDC doesn't generate any information for locals.

--
June 15, 2018
https://issues.dlang.org/show_bug.cgi?id=18984

Manu <turkeyman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |symdeb

--
June 18, 2018
https://issues.dlang.org/show_bug.cgi?id=18984

--- Comment #2 from Manu <turkeyman@gmail.com> ---
Do you have any feel for the difficulty of this patch?
Is it just an if somewhere to detect if RVO and point the debuginfo at a
different location?

It'd be really good to get a fix in 2.081 if possible, since the guys at work doing the evaluation all use symbolic debugging (in VisualD) very extensively, and they'll likely run into this within minutes of doing any real work. (I think one of them already has. He was complaining that it 'didn't work', but didn't elaborate how)

How motivated are they to pull bugfix patches like this in 2.081 after the beta has been cut? I didn't realise the next release was imminent..

--
June 18, 2018
https://issues.dlang.org/show_bug.cgi?id=18984

Rainer Schuetze <r.sagitario@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Rainer Schuetze <r.sagitario@gmx.de> ---
Might not be too complicated: https://github.com/dlang/dmd/pull/8368

--
June 21, 2018
https://issues.dlang.org/show_bug.cgi?id=18984

--- Comment #4 from Manu <turkeyman@gmail.com> ---
This is closed right?

--
June 21, 2018
https://issues.dlang.org/show_bug.cgi?id=18984

--- Comment #5 from Rainer Schuetze <r.sagitario@gmx.de> ---
> This is closed right?

IIRC fixes to stable no longer cause automatic closing. This is done when it is merged back to master to avoid spamming bugzilla with multiple messages.

I think the patch can still be improved, because the RVO variable is now magically converted to a pointer of a struct, but I have not been able to get RVO from C++ to see what happens there.

--
June 21, 2018
https://issues.dlang.org/show_bug.cgi?id=18984

--- Comment #6 from Manu <turkeyman@gmail.com> ---
> but I have not been able to
> get RVO from C++ to see what happens there.

I think if you build with C++14 (RVO guaranteed) and std::move the result to return value you should be able to force it.

Copy elision is all bundled up in move semantics.

--
June 25, 2018
https://issues.dlang.org/show_bug.cgi?id=18984

--- Comment #7 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/b3c9c561ce8a52b9997a0fef8912eecd296f8c32 fix issue 18984 - Debugging stack struct's which are returned causes incorrect debuginfo.

change the names of the hidden return value and the NRVO variable

https://github.com/dlang/dmd/commit/b9cf7458c2c6521bf78cd97822d1905e2e43da4e Merge pull request #8368 from rainers/issue18984

fix issue 18984 - stack struct's which are returned causes incorrect debuginfo. merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>

--
June 25, 2018
https://issues.dlang.org/show_bug.cgi?id=18984

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--