0

I have a program written in C and Lua. Now, I want to perf this program, print the hot call stack for example.

I don't have any tool or any idea to do this.

function fa()
   dosomething()
end

function fb() 
   fa()
end
int main() {
    lua_call("fb")
}

When profiling this program, I hope to print the calling stack like this: 0: fa 1: fb 2: main

Egor Skriptunoff
  • 906
  • 1
  • 8
  • 23
  • See http://lua-users.org/wiki/ProfilingLuaCode, https://github.com/charlesmallah/lua-profiler, http://luaprofiler.luaforge.net – lhf Sep 23 '19 at 12:25
  • Possible duplicate of https://stackoverflow.com/questions/15725744/easy-lua-profiling – lhf Sep 23 '19 at 12:26
  • You must not understand what I mean. The program is written in C, and it calls Lua function. Now I need to profile this program to print the calling stack from C function to Lua function. As showed in the example, "main" is C code, while "fa" and "fb" are Lua code. – chunhui li Sep 24 '19 at 02:38
  • If you want to print a stacktrace (instead of profiling), just insert the line `print(debug.traceback())` inside your `fa` body – Egor Skriptunoff Sep 24 '19 at 14:46
  • debug.traceback() can print C's stack? Actually I need to print the call cost, something like calling frequency or time cost of each function from C to Lua or again from Lua to C ... – chunhui li Sep 26 '19 at 12:32

0 Answers0