Defines | Functions

# lua/ldebug.c File Reference

`#include <stdarg.h>`
`#include <stddef.h>`
`#include <string.h>`
`#include "lua.h"`
`#include "lapi.h"`
`#include "lcode.h"`
`#include "ldebug.h"`
`#include "ldo.h"`
`#include "lfunc.h"`
`#include "lobject.h"`
`#include "lopcodes.h"`
`#include "lstate.h"`
`#include "lstring.h"`
`#include "ltable.h"`
`#include "ltm.h"`
`#include "lvm.h"`
Include dependency graph for ldebug.c:

Go to the source code of this file.

## Defines
#define | ldebug_c
#define | LUA_CORE
#define | check(x) if (!(x)) return 0;
#define | checkjump(pt, pc) check(0 <= pc && pc < pt->sizecode)
#define | checkreg(pt, reg) check((reg) < (pt)->maxstacksize)
#define | checkopenop(pt, pc) luaG_checkopenop((pt)->code[(pc)+1])
## Functions
static const char * | getfuncname (lua_State *L, CallInfo *ci, const char **name)
static int | currentpc (lua_State *L, CallInfo *ci)
static int | currentline (lua_State *L, CallInfo *ci)
LUA_API int | lua_sethook (lua_State *L, lua_Hook func, int mask, int count)
LUA_API lua_Hook | lua_gethook (lua_State *L)
LUA_API int | lua_gethookmask (lua_State *L)
LUA_API int | lua_gethookcount (lua_State *L)
LUA_API int | lua_getstack (lua_State *L, int level, lua_Debug *ar)
static Proto * | getluaproto (CallInfo *ci)
static const char * | findlocal (lua_State *L, CallInfo *ci, int n)
LUA_API const char * | lua_getlocal (lua_State *L, const lua_Debug *ar, int n)
LUA_API const char * | lua_setlocal (lua_State *L, const lua_Debug *ar, int n)
static void | funcinfo (lua_Debug *ar, Closure *cl)
static void | info_tailcall (lua_Debug *ar)
static void | collectvalidlines (lua_State *L, Closure *f)
static int | auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, Closure *f, CallInfo *ci)
LUA_API int | lua_getinfo (lua_State *L, const char *what, lua_Debug *ar)
static int | precheck (const Proto *pt)
int | luaG_checkopenop (Instruction i)
static int | checkArgMode (const Proto *pt, int r, enum OpArgMask mode)
static Instruction | symbexec (const Proto *pt, int lastpc, int reg)
int | luaG_checkcode (const Proto *pt)
static const char * | kname (Proto *p, int c)
static const char * | getobjname (lua_State *L, CallInfo *ci, int stackpos, const char **name)
static int | isinstack (CallInfo *ci, const TValue *o)
void | luaG_typeerror (lua_State *L, const TValue *o, const char *op)
void | luaG_concaterror (lua_State *L, StkId p1, StkId p2)
void | luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2)
int | luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2)
static void | addinfo (lua_State *L, const char *msg)
void | luaG_errormsg (lua_State *L)
void | luaG_runerror (lua_State *L, const char *fmt,...)

## Define Documentation

#define check | ( |  | x ) | if (!(x)) return 0;

Definition at line 268 of file ldebug.c.

Referenced by checkArgMode(), luaG_checkopenop(), precheck(), and symbexec().

#define checkjump | ( |  | pt,
|  |  | pc
| ) |  | check(0 <= pc && pc < pt->sizecode)

Definition at line 270 of file ldebug.c.

#define checkopenop | ( |  | pt,
|  |  | pc
| ) |  | luaG_checkopenop((pt)->code[(pc)+1])

Definition at line 288 of file ldebug.c.

Referenced by symbexec().

#define checkreg | ( |  | pt,
|  |  | reg
| ) |  | check((reg) < (pt)->maxstacksize)

Definition at line 272 of file ldebug.c.

Referenced by checkArgMode(), and symbexec().

#define ldebug_c

Definition at line 13 of file ldebug.c.

#define LUA_CORE

Definition at line 14 of file ldebug.c.

## Function Documentation

static void addinfo | ( | lua_State * | L,
|  | const char * | msg
| ) |  | `[static]`

Definition at line 591 of file ldebug.c.

References lua_State::ci, currentline(), getluaproto(), getstr, isLua, luaO_chunkid(), and luaO_pushfstring().

Referenced by luaG_runerror().

static int auxgetinfo | ( | lua_State * | L,
|  | const char * | what,
|  | lua_Debug * | ar,
|  | Closure * | f,
|  | CallInfo * | ci
| ) |  | `[static]`

Definition at line 193 of file ldebug.c.

References Closure::c, currentline(), funcinfo(), getfuncname(), info_tailcall(), and CClosure::nupvalues.

Referenced by lua_getinfo().

static int checkArgMode | ( | const Proto * | pt,
|  | int | r,
|  | enum OpArgMask | mode
| ) |  | `[static]`

Definition at line 304 of file ldebug.c.

References check, checkreg, INDEXK, ISK, OpArgK, OpArgN, OpArgR, OpArgU, and Proto::sizek.

Referenced by symbexec().

static void collectvalidlines | ( | lua_State * | L,
|  | Closure * | f
| ) |  | `[static]`

Definition at line 177 of file ldebug.c.

References Closure::c, incr_top, CClosure::isC, Closure::l, Proto::lineinfo, luaH_new(), luaH_setnum(), LClosure::p, setbvalue, sethvalue, setnilvalue, Proto::sizelineinfo, and lua_State::top.

Referenced by lua_getinfo().

static int currentline | ( | lua_State * | L,
|  | CallInfo * | ci
| ) |  | `[static]`

Definition at line 44 of file ldebug.c.

References ci_func, currentpc(), and getline.

Referenced by addinfo(), and auxgetinfo().

static int currentpc | ( | lua_State * | L,
|  | CallInfo * | ci
| ) |  | `[static]`

Definition at line 36 of file ldebug.c.

References lua_State::ci, ci_func, isLua, pcRel, lua_State::savedpc, and CallInfo::savedpc.

Referenced by currentline(), findlocal(), getfuncname(), and getobjname().

static const char* findlocal | ( | lua_State * | L,
|  | CallInfo * | ci,
|  | int | n
| ) |  | `[static]`

Definition at line 112 of file ldebug.c.

References CallInfo::base, lua_State::ci, currentpc(), getluaproto(), luaF_getlocalname(), name, and lua_State::top.

Referenced by lua_getlocal(), and lua_setlocal().

static void funcinfo | ( | lua_Debug * | ar,
|  | Closure * | cl
| ) |  | `[static]`

Definition at line 150 of file ldebug.c.

References Closure::c, getstr, CClosure::isC, Closure::l, Proto::lastlinedefined, Proto::linedefined, luaO_chunkid(), LClosure::p, and Proto::source.

Referenced by auxgetinfo().

static const char * getfuncname | ( | lua_State * | L,
|  | CallInfo * | ci,
|  | const char ** | name
| ) |  | `[static]`

Definition at line 528 of file ldebug.c.

References ci_func, currentpc(), GET_OPCODE, GETARG_A, getobjname(), isLua, OP_CALL, OP_TAILCALL, OP_TFORLOOP, and CallInfo::tailcalls.

Referenced by auxgetinfo().

static Proto* getluaproto | ( | CallInfo * | ci ) | `[static]`

Definition at line 107 of file ldebug.c.

References ci_func, and isLua.

Referenced by addinfo(), and findlocal().

static const char* getobjname | ( | lua_State * | L,
|  | CallInfo * | ci,
|  | int | stackpos,
|  | const char ** | name
| ) |  | `[static]`

Definition at line 481 of file ldebug.c.

References ci_func, currentpc(), GET_OPCODE, GETARG_A, GETARG_B, GETARG_Bx, GETARG_C, getstr, isLua, Proto::k, kname(), lua_assert, luaF_getlocalname(), OP_GETGLOBAL, OP_GETTABLE, OP_GETUPVAL, OP_MOVE, OP_SELF, svalue, symbexec(), ttisstring, and Proto::upvalues.

Referenced by getfuncname(), and luaG_typeerror().

static void info_tailcall | ( | lua_Debug * | ar ) | `[static]`

Definition at line 167 of file ldebug.c.

References luaO_chunkid().

Referenced by auxgetinfo().

static int isinstack | ( | CallInfo * | ci,
|  | const TValue * | o
| ) |  | `[static]`

Definition at line 543 of file ldebug.c.

References CallInfo::base.

Referenced by luaG_typeerror().

static const char* kname | ( | Proto * | p,
|  | int | c
| ) |  | `[static]`

Definition at line 473 of file ldebug.c.

References INDEXK, ISK, Proto::k, svalue, and ttisstring.

Referenced by getobjname().

LUA_API lua_Hook lua_gethook | ( | lua_State * | L ) |

Definition at line 69 of file ldebug.c.

References lua_State::hook.

LUA_API int lua_gethookcount | ( | lua_State * | L ) |

Definition at line 79 of file ldebug.c.

References lua_State::basehookcount.

LUA_API int lua_gethookmask | ( | lua_State * | L ) |

Definition at line 74 of file ldebug.c.

References lua_State::hookmask.

LUA_API int lua_getinfo | ( | lua_State * | L,
|  | const char * | what,
|  | lua_Debug * | ar
| ) |  |

Definition at line 232 of file ldebug.c.

References auxgetinfo(), lua_State::base_ci, clvalue, collectvalidlines(), CallInfo::func, CCallS::func, incr_top, lua_assert, lua_lock, lua_unlock, setclvalue, setnilvalue, lua_State::top, and ttisfunction.

LUA_API const char* lua_getlocal | ( | lua_State * | L,
|  | const lua_Debug * | ar,
|  | int | n
| ) |  |

Definition at line 127 of file ldebug.c.

References CallInfo::base, lua_State::base_ci, findlocal(), lua_lock, lua_unlock, luaA_pushobject(), and name.

LUA_API int lua_getstack | ( | lua_State * | L,
|  | int | level,
|  | lua_Debug * | ar
| ) |  |

Definition at line 84 of file ldebug.c.

References lua_State::base_ci, cast_int, lua_State::ci, f_isLua, lua_lock, lua_unlock, and CallInfo::tailcalls.

LUA_API int lua_sethook | ( | lua_State * | L,
|  | lua_Hook | func,
|  | int | mask,
|  | int | count
| ) |  |

Definition at line 56 of file ldebug.c.

References lua_State::basehookcount, cast_byte, CCallS::func, lua_State::hook, lua_State::hookmask, and resethookcount.

LUA_API const char* lua_setlocal | ( | lua_State * | L,
|  | const lua_Debug * | ar,
|  | int | n
| ) |  |

Definition at line 138 of file ldebug.c.

References CallInfo::base, lua_State::base_ci, findlocal(), lua_lock, lua_unlock, name, setobjs2s, and lua_State::top.

void luaG_aritherror | ( | lua_State * | L,
|  | const TValue * | p1,
|  | const TValue * | p2
| ) |  |

Definition at line 572 of file ldebug.c.

References luaG_typeerror(), and luaV_tonumber().

Referenced by Arith().

int luaG_checkcode | ( | const Proto * | pt ) |

Definition at line 468 of file ldebug.c.

References NO_REG, Proto::sizecode, and symbexec().

Referenced by close_func(), and LoadFunction().

int luaG_checkopenop | ( | Instruction | i ) |

Definition at line 290 of file ldebug.c.

References check, GET_OPCODE, GETARG_B, OP_CALL, OP_RETURN, OP_SETLIST, and OP_TAILCALL.

Referenced by luaV_execute().

void luaG_concaterror | ( | lua_State * | L,
|  | StkId | p1,
|  | StkId | p2
| ) |  |

Definition at line 565 of file ldebug.c.

References lua_assert, luaG_typeerror(), ttisnumber, and ttisstring.

Referenced by luaV_concat().

void luaG_errormsg | ( | lua_State * | L ) |

Definition at line 602 of file ldebug.c.

References lua_State::errfunc, incr_top, luaD_call(), luaD_throw(), restorestack, setobjs2s, lua_State::top, and ttisfunction.

Referenced by lua_error(), and luaG_runerror().

int luaG_ordererror | ( | lua_State * | L,
|  | const TValue * | p1,
|  | const TValue * | p2
| ) |  |

Definition at line 580 of file ldebug.c.

References luaG_runerror(), luaT_typenames, and ttype.

Referenced by lessequal(), and luaV_lessthan().

void luaG_runerror | ( | lua_State * | L,
|  | const char * | fmt,
|  |  | ...
| ) |  |

Definition at line 615 of file ldebug.c.

References addinfo(), luaG_errormsg(), and luaO_pushvfstring().

Referenced by findindex(), growCI(), lua_replace(), lua_yield(), luaD_call(), luaG_ordererror(), luaG_typeerror(), luaH_set(), luaM_growaux_(), luaM_toobig(), luaV_concat(), luaV_execute(), luaV_gettable(), luaV_settable(), and setnodevector().

void luaG_typeerror | ( | lua_State * | L,
|  | const TValue * | o,
|  | const char * | op
| ) |  |

Definition at line 551 of file ldebug.c.

References lua_State::base, cast_int, lua_State::ci, getobjname(), isinstack(), luaG_runerror(), luaT_typenames, name, and ttype.

Referenced by luaG_aritherror(), luaG_concaterror(), luaV_execute(), luaV_gettable(), luaV_settable(), and tryfuncTM().

static int precheck | ( | const Proto * | pt ) | `[static]`

Definition at line 276 of file ldebug.c.

References check, Proto::code, GET_OPCODE, Proto::is_vararg, lua_assert, MAXSTACK, Proto::maxstacksize, Proto::numparams, Proto::nups, OP_RETURN, Proto::sizecode, Proto::sizelineinfo, Proto::sizeupvalues, VARARG_HASARG, and VARARG_NEEDSARG.

Referenced by symbexec().

static Instruction symbexec | ( | const Proto * | pt,
|  | int | lastpc,
|  | int | reg
| ) |  | `[static]`

Definition at line 317 of file ldebug.c.

References check, checkArgMode(), checkopenop, checkreg, Proto::code, GET_OPCODE, GETARG_A, GETARG_B, GETARG_Bx, GETARG_C, GETARG_sBx, getBMode, getCMode, getOpMode, iABC, iABx, iAsBx, Proto::is_vararg, Proto::k, NO_REG, NUM_OPCODES, Proto::nups, OP_CALL, OP_CLOSURE, OP_CONCAT, OP_FORLOOP, OP_FORPREP, OP_GETGLOBAL, OP_GETUPVAL, OP_JMP, OP_LOADBOOL, OP_LOADNIL, OP_MOVE, OP_RETURN, OP_SELF, OP_SETGLOBAL, OP_SETLIST, OP_SETUPVAL, OP_TAILCALL, OP_TFORLOOP, OP_VARARG, OpArgK, OpArgR, Proto::p, precheck(), Proto::sizecode, testAMode, testTMode, ttisstring, VARARG_ISVARARG, and VARARG_NEEDSARG.

Referenced by getobjname(), and luaG_checkcode().