Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
ldebug.h File Reference
#include "lstate.h"

Go to the source code of this file.

Macros

#define pcRel(pc, p)   (cast_int((pc) - (p)->code) - 1)
 
#define ci_func(ci)   (clLvalue(s2v((ci)->func)))
 
#define resethookcount(L)   (L->hookcount = L->basehookcount)
 
#define ABSLINEINFO   (-0x80)
 
#define MAXIWTHABS   128
 

Functions

LUAI_FUNC int luaG_getfuncline (const Proto *f, int pc)
 
LUAI_FUNC const char * luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos)
 
LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *opname)
 
LUAI_FUNC l_noret luaG_callerror (lua_State *L, const TValue *o)
 
LUAI_FUNC l_noret luaG_forerror (lua_State *L, const TValue *o, const char *what)
 
LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2)
 
LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, const TValue *p2, const char *msg)
 
LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2)
 
LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2)
 
LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt,...)
 
LUAI_FUNC const char * luaG_addinfo (lua_State *L, const char *msg, TString *src, int line)
 
LUAI_FUNC l_noret luaG_errormsg (lua_State *L)
 
LUAI_FUNC int luaG_traceexec (lua_State *L, const Instruction *pc)
 

Macro Definition Documentation

◆ ABSLINEINFO

#define ABSLINEINFO   (-0x80)

◆ ci_func

#define ci_func ( ci)    (clLvalue(s2v((ci)->func)))

Definition at line 18 of file lua-5.4.3/src/ldebug.h.

◆ MAXIWTHABS

#define MAXIWTHABS   128

Definition at line 35 of file lua-5.4.3/src/ldebug.h.

Referenced by changedline(), getbaseline(), removelastlineinfo(), and savelineinfo().

◆ pcRel

#define pcRel ( pc,
p )   (cast_int((pc) - (p)->code) - 1)

Definition at line 14 of file lua-5.4.3/src/ldebug.h.

◆ resethookcount

#define resethookcount ( L)    (L->hookcount = L->basehookcount)

Definition at line 21 of file lua-5.4.3/src/ldebug.h.

Function Documentation

◆ luaG_addinfo()

LUAI_FUNC const char * luaG_addinfo ( lua_State * L,
const char * msg,
TString * src,
int line )

Definition at line 629 of file lua-5.3.6/src/ldebug.c.

630 {
631 char buff[LUA_IDSIZE];
632 if (src)
633 luaO_chunkid(buff, getstr(src), LUA_IDSIZE);
634 else { /* no source available; use "?" instead */
635 buff[0] = '?'; buff[1] = '\0';
636 }
637 return luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
638}
void luaO_chunkid(char *out, const char *source, size_t bufflen)
const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
#define getstr(ts)
#define LUA_IDSIZE

References getstr, LUA_IDSIZE, luaO_chunkid(), luaO_pushfstring(), and tsslen.

Referenced by lexerror(), lexerror(), and luaG_runerror().

◆ luaG_callerror()

LUAI_FUNC l_noret luaG_callerror ( lua_State * L,
const TValue * o )

Definition at line 698 of file lua-5.4.3/src/ldebug.c.

698 {
699 CallInfo *ci = L->ci;
700 const char *name = NULL; /* to avoid warnings */
701 const char *what = (isLua(ci)) ? funcnamefromcode(L, ci, &name) : NULL;
702 if (what != NULL) {
703 const char *t = luaT_objtypename(L, o);
704 luaG_runerror(L, "%s '%s' is not callable (a %s value)", what, name, t);
705 }
706 else
707 luaG_typeerror(L, o, "call");
708}
#define NULL
Definition gmacros.h:924
const char * name
Definition lsqlite3.c:2154
#define isLua(ci)
const char * luaT_objtypename(lua_State *L, const TValue *o)
l_noret luaG_typeerror(lua_State *L, const TValue *o, const char *op)
l_noret luaG_runerror(lua_State *L, const char *fmt,...)
static const char * funcnamefromcode(lua_State *L, CallInfo *ci, const char **name)

References lua_State::ci, funcnamefromcode(), isLua, luaG_runerror(), luaG_typeerror(), luaT_objtypename(), name, and NULL.

Referenced by luaD_tryfuncTM().

◆ luaG_concaterror()

LUAI_FUNC l_noret luaG_concaterror ( lua_State * L,
const TValue * p1,
const TValue * p2 )

Definition at line 592 of file lua-5.3.6/src/ldebug.c.

592 {
593 if (ttisstring(p1) || cvt2str(p1)) p1 = p2;
594 luaG_typeerror(L, p1, "concatenate");
595}
#define ttisstring(o)
l_noret luaG_typeerror(lua_State *L, const TValue *o, const char *op)
#define cvt2str(o)

References cvt2str, luaG_typeerror(), and ttisstring.

◆ luaG_errormsg()

LUAI_FUNC l_noret luaG_errormsg ( lua_State * L)

Definition at line 618 of file lua-5.1.5/src/ldebug.c.

618 {
619 if (L->errfunc != 0) { /* is there an error handling function? */
620 StkId errfunc = restorestack(L, L->errfunc);
621 if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
622 setobjs2s(L, L->top, L->top - 1); /* move argument */
623 setobjs2s(L, L->top - 1, errfunc); /* push function */
624 incr_top(L);
625 luaD_call(L, L->top - 2, 1); /* call it */
626 }
628}
void luaD_call(lua_State *L, StkId func, int nResults)
void luaD_throw(lua_State *L, int errcode)
#define restorestack(L, n)
#define incr_top(L)
#define ttisfunction(o)
#define setobjs2s
#define LUA_ERRERR
#define LUA_ERRRUN

References lua_State::errfunc, incr_top, lua_assert, LUA_ERRERR, LUA_ERRRUN, luaD_call(), luaD_callnoyield(), luaD_throw(), restorestack, s2v, setobjs2s, lua_State::top, and ttisfunction.

Referenced by lua_error(), and luaG_runerror().

◆ luaG_findlocal()

LUAI_FUNC const char * luaG_findlocal ( lua_State * L,
CallInfo * ci,
int n,
StkId * pos )

Definition at line 196 of file lua-5.4.3/src/ldebug.c.

196 {
197 StkId base = ci->func + 1;
198 const char *name = NULL;
199 if (isLua(ci)) {
200 if (n < 0) /* access to vararg values? */
201 return findvararg(ci, n, pos);
202 else
203 name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));
204 }
205 if (name == NULL) { /* no 'standard' name? */
206 StkId limit = (ci == L->ci) ? L->top : ci->next->func;
207 if (limit - base >= n && n > 0) { /* is 'n' inside 'ci' stack? */
208 /* generic name for any valid slot */
209 name = isLua(ci) ? "(temporary)" : "(C temporary)";
210 }
211 else
212 return NULL; /* no name */
213 }
214 if (pos)
215 *pos = base + (n - 1);
216 return name;
217}
const char * luaF_getlocalname(const Proto *f, int local_number, int pc)
#define next(ls)
#define ci_func(ci)
static int currentpc(CallInfo *ci)
static const char * findvararg(CallInfo *ci, int n, StkId *pos)

References lua_State::ci, ci_func, currentpc(), findvararg(), CallInfo::func, isLua, luaF_getlocalname(), name, CallInfo::next, NULL, and lua_State::top.

Referenced by checkclosemth(), lua_getlocal(), and lua_setlocal().

◆ luaG_forerror()

LUAI_FUNC l_noret luaG_forerror ( lua_State * L,
const TValue * o,
const char * what )

Definition at line 711 of file lua-5.4.3/src/ldebug.c.

711 {
712 luaG_runerror(L, "bad 'for' %s (number expected, got %s)",
713 what, luaT_objtypename(L, o));
714}

References luaG_runerror(), and luaT_objtypename().

Referenced by forlimit(), and forprep().

◆ luaG_getfuncline()

LUAI_FUNC int luaG_getfuncline ( const Proto * f,
int pc )

Definition at line 83 of file lua-5.4.3/src/ldebug.c.

83 {
84 if (f->lineinfo == NULL) /* no debug information? */
85 return -1;
86 else {
87 int basepc;
88 int baseline = getbaseline(f, pc, &basepc);
89 while (basepc++ < pc) { /* walk until given instruction */
90 lua_assert(f->lineinfo[basepc] != ABSLINEINFO);
91 baseline += f->lineinfo[basepc]; /* correct line */
92 }
93 return baseline;
94 }
95}
#define lua_assert(c)
static int getbaseline(const Proto *f, int pc, int *basepc)
#define ABSLINEINFO

References ABSLINEINFO, getbaseline(), Proto::lineinfo, lua_assert, and NULL.

Referenced by changedline(), getcurrentline(), luaG_traceexec(), nextline(), and PrintCode().

◆ luaG_opinterror()

LUAI_FUNC l_noret luaG_opinterror ( lua_State * L,
const TValue * p1,
const TValue * p2,
const char * msg )

Definition at line 598 of file lua-5.3.6/src/ldebug.c.

599 {
600 lua_Number temp;
601 if (!tonumber(p1, &temp)) /* first operand is wrong? */
602 p2 = p1; /* now second is wrong */
603 luaG_typeerror(L, p2, msg);
604}
LUA_NUMBER lua_Number
#define tonumber(o, n)

References luaG_typeerror(), tonumber, and ttisnumber.

Referenced by luaT_trybinTM().

◆ luaG_ordererror()

LUAI_FUNC l_noret luaG_ordererror ( lua_State * L,
const TValue * p1,
const TValue * p2 )

Definition at line 596 of file lua-5.1.5/src/ldebug.c.

596 {
597 const char *t1 = luaT_typenames[ttype(p1)];
598 const char *t2 = luaT_typenames[ttype(p2)];
599 if (t1[2] == t2[2])
600 luaG_runerror(L, "attempt to compare two %s values", t1);
601 else
602 luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
603 return 0;
604}
void luaG_runerror(lua_State *L, const char *fmt,...)
#define ttype(o)
const char *const luaT_typenames[]

References luaG_runerror(), luaT_objtypename(), luaT_typenames, objtypename, and ttype.

Referenced by lessequal(), luaT_callorderTM(), luaV_lessequal(), and luaV_lessthan().

◆ luaG_runerror()

LUAI_FUNC l_noret luaG_runerror ( lua_State * L,
const char * fmt,
... )

◆ luaG_tointerror()

LUAI_FUNC l_noret luaG_tointerror ( lua_State * L,
const TValue * p1,
const TValue * p2 )

Definition at line 610 of file lua-5.3.6/src/ldebug.c.

610 {
611 lua_Integer temp;
612 if (!tointeger(p1, &temp))
613 p2 = p1;
614 luaG_runerror(L, "number%s has no integer representation", varinfo(L, p2));
615}
LUA_INTEGER lua_Integer
l_noret luaG_runerror(lua_State *L, const char *fmt,...)
static const char * varinfo(lua_State *L, const TValue *o)
#define tointeger(o, i)

References LUA_FLOORN2I, luaG_runerror(), luaV_tointegerns(), tointeger, varinfo(), and varinfo().

Referenced by luaT_trybinTM().

◆ luaG_traceexec()

LUAI_FUNC int luaG_traceexec ( lua_State * L,
const Instruction * pc )

Definition at line 833 of file lua-5.4.3/src/ldebug.c.

833 {
834 CallInfo *ci = L->ci;
835 lu_byte mask = L->hookmask;
836 const Proto *p = ci_func(ci)->p;
837 int counthook;
838 if (!(mask & (LUA_MASKLINE | LUA_MASKCOUNT))) { /* no hooks? */
839 ci->u.l.trap = 0; /* don't need to stop again */
840 return 0; /* turn off 'trap' */
841 }
842 pc++; /* reference is always next instruction */
843 ci->u.l.savedpc = pc; /* save 'pc' */
844 counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT));
845 if (counthook)
846 resethookcount(L); /* reset count */
847 else if (!(mask & LUA_MASKLINE))
848 return 1; /* no line hook and count != 0; nothing to be done now */
849 if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */
850 ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */
851 return 1; /* do not call hook again (VM yielded, so it did not move) */
852 }
853 if (!isIT(*(ci->u.l.savedpc - 1))) /* top not being used? */
854 L->top = ci->top; /* correct top */
855 if (counthook)
856 luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */
857 if (mask & LUA_MASKLINE) {
858 /* 'L->oldpc' may be invalid; use zero in this case */
859 int oldpc = (L->oldpc < p->sizecode) ? L->oldpc : 0;
860 int npci = pcRel(pc, p);
861 if (npci <= oldpc || /* call hook when jump back (loop), */
862 changedline(p, oldpc, npci)) { /* or when enter new line */
863 int newline = luaG_getfuncline(p, npci);
864 luaD_hook(L, LUA_HOOKLINE, newline, 0, 0); /* call line hook */
865 }
866 L->oldpc = npci; /* 'pc' of last call to line hook */
867 }
868 if (L->status == LUA_YIELD) { /* did hook yield? */
869 if (counthook)
870 L->hookcount = 1; /* undo decrement to zero */
871 ci->u.l.savedpc--; /* undo increment (resume will increment it again) */
872 ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */
874 }
875 return 1; /* keep 'trap' on */
876}
#define pcRel(pc, p)
#define resethookcount(L)
unsigned char lu_byte
#define LUA_MASKCOUNT
#define LUA_MASKLINE
#define LUA_HOOKCOUNT
#define LUA_YIELD
#define LUA_HOOKLINE
#define mask(n)
void luaD_hook(lua_State *L, int event, int line)
#define CIST_HOOKYIELD
static int changedline(const Proto *p, int oldpc, int newpc)
int luaG_getfuncline(const Proto *f, int pc)
#define isIT(i)
volatile l_signalT trap
struct CallInfo::@64::@65 l
const Instruction * savedpc
union CallInfo::@64 u
struct Proto ** p
const Instruction * oldpc

References CallInfo::callstatus, changedline(), lua_State::ci, ci_func, CIST_HOOKYIELD, lua_State::hookcount, lua_State::hookmask, isIT, CallInfo::l, LUA_HOOKCOUNT, LUA_HOOKLINE, LUA_MASKCOUNT, LUA_MASKLINE, LUA_YIELD, luaD_hook(), luaD_throw(), luaG_getfuncline(), mask, lua_State::oldpc, Proto::p, pcRel, resethookcount, CallInfo::savedpc, Proto::sizecode, lua_State::status, CallInfo::top, lua_State::top, CallInfo::trap, and CallInfo::u.

◆ luaG_typeerror()

LUAI_FUNC l_noret luaG_typeerror ( lua_State * L,
const TValue * o,
const char * opname )

Definition at line 567 of file lua-5.1.5/src/ldebug.c.

567 {
568 const char *name = NULL;
569 const char *t = luaT_typenames[ttype(o)];
570 const char *kind = (isinstack(L->ci, o)) ?
571 getobjname(L, L->ci, cast_int(o - L->base), &name) :
572 NULL;
573 if (kind)
574 luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
575 op, kind, name, t);
576 else
577 luaG_runerror(L, "attempt to %s a %s value", op, t);
578}
static const char * getobjname(lua_State *L, CallInfo *ci, int stackpos, const char **name)
static int isinstack(CallInfo *ci, const TValue *o)
#define cast_int(i)
#define LUA_QS

References CallInfo::base, lua_State::base, cast_int, lua_State::ci, ci_func, currentpc(), getobjname(), getobjname(), getupvalname(), isinstack(), isinstack(), isLua, CallInfo::l, LUA_QS, luaG_runerror(), luaT_objtypename(), luaT_typenames, name, NULL, objtypename, ttype, CallInfo::u, varinfo(), and varinfo().

Referenced by luaG_aritherror(), luaG_callerror(), luaG_concaterror(), luaG_concaterror(), luaG_opinterror(), luaV_execute(), luaV_finishget(), luaV_finishset(), luaV_finishset(), luaV_gettable(), luaV_objlen(), luaV_settable(), tryfuncTM(), tryfuncTM(), and tryfuncTM().