diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-03-05 22:03:11 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-03-05 22:38:00 -0800 |
commit | f2d29c22f86a88bfa0d0cbd9141e6ae60f840cb0 (patch) | |
tree | 4506091c47f15df46d8a86a3b34a1388e36626c3 /src/teliva.c | |
parent | 52ae23784b5474298c6ada6252f5a785fc5e8c19 (diff) | |
download | teliva-f2d29c22f86a88bfa0d0cbd9141e6ae60f840cb0.tar.gz |
a simple hack to make caller apparent
Teliva isn't yet smart enough to know the caller of an indirect function where the function being called goes through a local variable. I'd expected fixing this to be a long death march. However, there's a shockingly easy fix: just make every indirect call go through an additional direct function call. My policy for zet.tlv was that function 'main' could open any file. This stopped working since I introduced spawn_main. But with this commit it's working again. I can also drop all my special-casing of 'main' since it's now a regular Lua call. We still can't rely on the caller of an indirect call. That affects start_reading and start_writing, which really need to be part of the framework.
Diffstat (limited to 'src/teliva.c')
-rw-r--r-- | src/teliva.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/teliva.c b/src/teliva.c index 2e9c9d9..52c1ae3 100644 --- a/src/teliva.c +++ b/src/teliva.c @@ -322,7 +322,6 @@ void save_caller(lua_State* L, const char* name, int call_graph_depth) { lua_getstack(L, 1, &ar); lua_getinfo(L, "n", &ar); if (ar.name) save_caller_as(L, name, ar.name); - else if (call_graph_depth == 2) save_caller_as(L, name, "main"); // the way Teliva calls `main` messes with debug info } char* caller(lua_State* L) { @@ -396,9 +395,6 @@ restart: clear(); luaL_newmetatable(L, "__teliva_call_graph_depth"); int cgt = lua_gettop(L); - // special-case: we don't instrument the call to main, but it's always at depth 1 - lua_pushinteger(L, 1); - lua_setfield(L, cgt, "main"); // segment definitions by depth lua_getglobal(L, "teliva_program"); int history_array = lua_gettop(L); @@ -514,7 +510,7 @@ restart: y += 2; mvprintw(y, 0, "functions: "); y++; - for (int depth = 1; ; ++depth) { + for (int depth = /*ignore call_main*/2; ; ++depth) { mvaddstr(y, 0, " "); bool drew_anything = false; index_within_level = 0; |