> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Debug

> Inspeção de tempo de execução e utilitários de depuração.

<div className="real-category-page">
  Inspeção de tempo de execução e utilitários de depuração.

  ## Funções disponíveis

  <CardGroup cols={2}>
    <Card title="getconstant" href="./getconstant">
      Returns one constant from a Lua function or stack level by one-based index. target must be a function or stack level number. Invalid stack levels raise "Level out of range". Non-function and non-number targets raise a type error expecting "function or number". C closures raise "Lua function expected". Indexes below 1 raise "Constant index starts at 1", and indexes past the available constants raise "Constant index out of range". Function and table constants are returned as nil. debug.getconstant is an alias.
    </Card>

    <Card title="getconstants" href="./getconstants">
      Returns constants from a Lua function or stack level as a table keyed by one-based constant index. target must be a function or stack level number. Invalid stack levels raise "Level out of range". Non-function and non-number targets raise a type error expecting "function or number". C closures raise "Lua function expected". Nil, function, and table constants are absent from the returned table. debug.getconstants is an alias.
    </Card>

    <Card title="getinfo" href="./getinfo">
      Returns a metadata table for a function or stack level. target must be a function or number. Invalid target types raise "function or number expected", invalid stack levels raise "Level out of range", and unavailable levels raise "invalid level". The returned table includes func, nups, source, short\_src, currentline, what, linedefined, is\_vararg, numparams, and name. sizep is included only for direct Lua function targets. debug.getinfo is an alias.
    </Card>

    <Card title="getproto" href="./getproto">
      Returns a nested Lua function by one-based index. target must be a Lua function or stack level number. Invalid stack levels raise "Level out of range", non-Lua functions raise "Lua function expected", and indexes outside the nested function range raise "index out of bounds". When active is true, returns currently live closures for that nested function instead. debug.getproto is an alias.
    </Card>

    <Card title="getprotos" href="./getprotos">
      Returns all nested Lua functions from a Lua function or stack level as a one-based array table. Invalid stack levels raise "Level out of range", and non-Lua functions raise "Lua function expected". debug.getprotos is an alias.
    </Card>

    <Card title="getreg" href="./getreg">
      Returns the current Lua registry table. The function takes no arguments and returns the registry table directly.
    </Card>

    <Card title="getstack" href="./getstack">
      Reads stack slot values from a Lua stack frame. level is required and must be a number; it is converted to an integer and must be between 0 and the current call stack depth minus one. Invalid levels raise "Level out of range". The selected frame is L->ci - level, so level 0 refers to the current frame in this function. If the selected frame is a C closure, the function raises "Lua function expected". index is optional and is only used when the second argument is a number; it is converted to an integer and must be between 1 and the frame stack size. Without a numeric index, the function returns a one-based array table containing values from frame->base\[0] with frame->base\[top - 1]. With a numeric index, it returns the single value at frame->base\[index - 1]. Collectable values trigger luaC\_threadbarrier before being pushed. debug.getstack is exposed with the debug table alias.
    </Card>

    <Card title="getupvalue" href="./getupvalue">
      Returns one upvalue from a Lua function or stack level by one-based index. Invalid stack levels raise "Level out of range", non-Lua functions raise "Lua Function expected", indexes below 1 raise "Upvalue index starts at 1", and indexes past the available upvalues raise "Upvalue index out of range". debug.getupvalue is an alias.
    </Card>

    <Card title="getupvalues" href="./getupvalues">
      Returns all upvalues from a Lua function or stack level as a one-based array table. Invalid stack levels raise "Level out of range", and non-Lua functions raise "Lua function expected". debug.getupvalues is an alias.
    </Card>

    <Card title="isvalidlevel" href="./isvalidlevel">
      Verifica se um numeric stack level está dentro do current call stack range. level é obrigatório e deve ser number porque a function chama requires a number. O value é convertido com integer conversion. A function retorna false quando level \< 0 ou level >= the current call stack depth; caso contrário, true. Ela não inspeciona a frame closure e não lança "Level out of range" para invalid numeric levels. validlevel é um global alias, e debug.isvalidlevel junto com debug.validlevel são expostos pelos debug table aliases.
    </Card>

    <Card title="setconstant" href="./setconstant">
      Replaces one constant in a Lua function or stack level by one-based index. Invalid stack levels raise "Level out of range", non-Lua functions raise "Lua function expected", indexes below 1 raise "Constant index starts at 1", and indexes past the available constants raise "Constant index out of range". debug.setconstant is an alias.
    </Card>

    <Card title="setstack" href="./setstack">
      Replaces one stack slot value in a Lua stack frame. level and index are required numbers. level must satisfy 0 \<= level \< the current call stack depth; invalid levels raise "Level out of range". C closure frames raise "Lua function expected". index is one-based and must refer to an existing stack slot; invalid indexes raise "Stack index out of range". debug.setstack is an alias.
    </Card>

    <Card title="setupvalue" href="./setupvalue">
      Replaces one upvalue in a Lua function or stack level by one-based index. Invalid stack levels raise "Level out of range", non-Lua functions raise "Lua function expected", indexes below 1 raise "Upvalue index starts at 1", and indexes past the available upvalues raise "Upvalue index is out of range". debug.setupvalue is an alias.
    </Card>
  </CardGroup>
</div>
