evo-lua / evo-luvi

[Obsolete] Experimental Lua runtime environment built on Luvi (libuv + LuaJIT)
https://evo-lua.github.io
Apache License 2.0
1 stars 0 forks source link

Improve the readability of stack traces originating in the runtime's main function #139

Closed Duckwhale closed 1 year ago

Duckwhale commented 1 year ago

Goals:


Right now this is how they appear:

image

With tiny adjustments, the output can be turned into something like this:

image

The parentheses are consistent with what Lua (and LuaJIT) use when running code, but a bit more verbose to hopefully be less confusing. The other issues with readability of stack traces can be fixed by including debug symbols in the object files.


While experimenting, I just swapped the initialization code with this:

#define S1(x) #x
#define S2(x) S1(x)
#define LOCATION __FILE__ ":" S2(__LINE__)
    const char* entry_point = "return require('init')(...)";

    if (luaL_loadbuffer(L, entry_point, strlen(entry_point), "=(Lua entry point, at " LOCATION ")")) {
        fprintf(stderr, "%s\n", lua_tostring(L, -1));
        vm_release(L);
        return -1;
    }

#undef LOCATION

Split off from #4 because this is probably "good enough" for the time being and should be committed separately.