beefytech / Beef

Beef Programming Language
http://www.beeflang.org
Other
2.48k stars 126 forks source link

Inspector values while debugging are garbage #102

Open damianday opened 4 years ago

damianday commented 4 years ago

Set a breakpoint on the return 0 line. Inspect the value parameter in the debugger and compare with the debug output. The value parameter appears to be garbage. Running with Win32 and Debug, tried a Clean and Rebuild didnt help.

var sw = scope Stopwatch();

var str = scope String();
char32 ch = '¥'; 

sw.Start();
for (let i < 10000000)
{
    str.Append(ch);
}
sw.Stop();

let value = sw.ElapsedMilliseconds;
Debug.WriteLine("Average: {0}", sw.ElapsedMilliseconds);

return 0;
bfiete commented 4 years ago

Unfortunately LLVM has some Win32 debug info bugs. This is reproducible in Clang 10.0.0 - seems to be triggered by assigning a variable to the address of a stack-allocated structure.

This will do it:

struct StructA
{
    int64_t mA;
    int64_t mB;

    StructA()
    {
        mA = 0x112233;
        mB = 0x445566;
    }   
};

void Zap()
{
    StructA sa;

    StructA* saPtr = new StructA();
    StructA* saPtr2 = &sa;

    printf("%p %p\n", saPtr, saPtr2);
}

Debug info works when the = &sa is removed. It's not likely I can either fix or induce a fix to this myself any time in the near future.

bfiete commented 4 years ago

I'm glad someone is testing the Win32 side, but you'd have a much better experience with Win64.

damianday commented 4 years ago

I'm currently linking to Win32 DLLs I've not tested my bindings on Win64 but it shouldn't take much effort