LUA_DEBUG(3) Library Functions Manual LUA_DEBUG(3)

lua_Debugstructure used to carry different pieces of information about an active function

#include <lua.h>

typedef struct lua_Debug;

() a structure used to carry different pieces of information about an active function. lua_getstack(3) fills only the private part of this structure, for later use. To fill the other fields of lua_Debug with useful information, call lua_getinfo(3).

lua_Debug is defined as:

typedef struct lua_Debug {
        int event;
        const char *name;           /* (n) */
        const char *namewhat;       /* (n) */
        const char *what;           /* (S) */
        const char *source;         /* (S) */
        int currentline;            /* (l) */
        int nups;                   /* (u) number of upvalues */
        int linedefined;            /* (S) */
        int lastlinedefined;        /* (S) */
        char short_src[LUA_IDSIZE]; /* (S) */
        /* private part */
        other fields
} lua_Debug;

The fields of lua_Debug have the following meaning:

:
If the function was defined in a string, then source is that string. If the function was defined in a file, then source starts with a '@' followed by the file name.
:
a "printable" version of source, to be used in error messages.
:
the line number where the definition of the function starts.
:
the line number where the definition of the function ends.
:
the string "Lua" if the function is a Lua function, "C" if it is a C function, "main" if it is the main part of a chunk, and "tail" if it was a function that did a tail call. In the latter case, Lua has no other information about the function.
:
the current line where the given function is executing. When no line information is available, currentline is set to -1.
:
a reasonable name for the given function. Because functions in Lua are first-class values, they do not have a fixed name: some functions can be the value of multiple global variables, while others can be stored only in a table field. The lua_getinfo(3) function checks how the function was called to find a suitable name. If it cannot find a name, then name is set to NULL.
:
explains the name field. The value of namewhat can be "global", "local", "method", "field", "upvalue", or "" (the empty string), according to how the function was called. (Lua uses the empty string when no other option seems to apply.)
:
the number of upvalues of the function.

lua_getinfo(3), lua_getstack(3)

Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes, Lua 5.1 Reference Manual.

The lua_Debug() manual page is based on Lua Reference Manual 5.1 and was created by Sergey Bronnikov.

July 19, 2022 Debian