beta-0.89.2
[luatex.git] / source / libs / luajit / LuaJIT-src / src / lj_debug.h
blob11d308a41b3e3552e8b5cfb31a70e97d520c4f40
1 /*
2 ** Debugging and introspection.
3 ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
4 */
6 #ifndef _LJ_DEBUG_H
7 #define _LJ_DEBUG_H
9 #include "lj_obj.h"
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;
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, cTValue *frame,
36 const char **name);
37 LJ_FUNC void lj_debug_shortname(char *out, GCstr *str, BCLine line);
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 #if LJ_HASPROFILE
44 LJ_FUNC void lj_debug_dumpstack(lua_State *L, SBuf *sb, const char *fmt,
45 int depth);
46 #endif
48 /* Fixed internal variable names. */
49 #define VARNAMEDEF(_) \
50 _(FOR_IDX, "(for index)") \
51 _(FOR_STOP, "(for limit)") \
52 _(FOR_STEP, "(for step)") \
53 _(FOR_GEN, "(for generator)") \
54 _(FOR_STATE, "(for state)") \
55 _(FOR_CTL, "(for control)")
57 enum {
58 VARNAME_END,
59 #define VARNAMEENUM(name, str) VARNAME_##name,
60 VARNAMEDEF(VARNAMEENUM)
61 #undef VARNAMEENUM
62 VARNAME__MAX
65 #endif