1 | /* |
2 | ** Debugging and introspection. |
3 | ** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h |
4 | */ |
5 | |
6 | #ifndef _LJ_DEBUG_H |
7 | #define _LJ_DEBUG_H |
8 | |
9 | #include "lj_obj.h" |
10 | |
11 | typedef struct lj_Debug { |
12 | /* Common fields. Must be in the same order as in lua.h. */ |
13 | int event; |
14 | const char *name; |
15 | const char *namewhat; |
16 | const char *what; |
17 | const char *source; |
18 | int currentline; |
19 | int nups; |
20 | int linedefined; |
21 | int lastlinedefined; |
22 | char short_src[LUA_IDSIZE]; |
23 | int i_ci; |
24 | /* Extended fields. Only valid if lj_debug_getinfo() is called with ext = 1.*/ |
25 | int nparams; |
26 | int isvararg; |
27 | } lj_Debug; |
28 | |
29 | LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size); |
30 | LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc); |
31 | LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx); |
32 | LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp); |
33 | LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc, |
34 | BCReg slot, const char **name); |
35 | LJ_FUNC const char *lj_debug_funcname(lua_State *L, TValue *frame, |
36 | const char **name); |
37 | LJ_FUNC void lj_debug_shortname(char *out, GCstr *str); |
38 | LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg, |
39 | cTValue *frame, cTValue *nextframe); |
40 | LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc); |
41 | LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, |
42 | int ext); |
43 | |
44 | /* Fixed internal variable names. */ |
45 | #define VARNAMEDEF(_) \ |
46 | _(FOR_IDX, "(for index)") \ |
47 | _(FOR_STOP, "(for limit)") \ |
48 | _(FOR_STEP, "(for step)") \ |
49 | _(FOR_GEN, "(for generator)") \ |
50 | _(FOR_STATE, "(for state)") \ |
51 | _(FOR_CTL, "(for control)") |
52 | |
53 | enum { |
54 | VARNAME_END, |
55 | #define VARNAMEENUM(name, str) VARNAME_##name, |
56 | VARNAMEDEF(VARNAMEENUM) |
57 | #undef VARNAMEENUM |
58 | VARNAME__MAX |
59 | }; |
60 | |
61 | #endif |
62 | |