3 * a simple execution tracer for Lua
11 static FILE* LOG
; /* output file */
12 static int L
=0; /* indentation level */
14 static void linehook(int line
)
16 fprintf(LOG
,"%*sLINE(%d)\t-- %d\n",L
,"",line
,L
);
19 static void callhook(lua_Function func
, char* file
, int line
)
21 fprintf(LOG
,"%*sCALL('%s',%d)\t-- %d\n",L
,"",file
,line
,L
);
22 if (line
==0 && strcmp(file
,"(return)")==0) --L
; else ++L
;
25 void start_trace(FILE* logfile
)
27 lua_setlinehook(linehook
);
28 lua_setcallhook(callhook
);
35 lua_setlinehook(NULL
);
36 lua_setcallhook(NULL
);