1/*
2** Debugging and introspection.
3** Copyright (C) 2005-2021 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
11typedef 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
29LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size);
30LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc);
31LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx);
32LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp,
33 GCobj **op);
34LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc,
35 BCReg slot, const char **name);
36LJ_FUNC const char *lj_debug_funcname(lua_State *L, cTValue *frame,
37 const char **name);
38LJ_FUNC void lj_debug_shortname(char *out, GCstr *str, BCLine line);
39LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg,
40 cTValue *frame, cTValue *nextframe);
41LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc);
42LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar,
43 int ext);
44#if LJ_HASPROFILE
45LJ_FUNC void lj_debug_dumpstack(lua_State *L, SBuf *sb, const char *fmt,
46 int depth);
47#endif
48
49/* Fixed internal variable names. */
50#define VARNAMEDEF(_) \
51 _(FOR_IDX, "(for index)") \
52 _(FOR_STOP, "(for limit)") \
53 _(FOR_STEP, "(for step)") \
54 _(FOR_GEN, "(for generator)") \
55 _(FOR_STATE, "(for state)") \
56 _(FOR_CTL, "(for control)")
57
58enum {
59 VARNAME_END,
60#define VARNAMEENUM(name, str) VARNAME_##name,
61 VARNAMEDEF(VARNAMEENUM)
62#undef VARNAMEENUM
63 VARNAME__MAX
64};
65
66#endif
67