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

# debug.getinfo

Returns a table describing a function or a running stack frame.

```luau theme={null}
debug.getinfo(target: function | number): table
```

`debug.getinfo` accepts either a function or a number. Hand it a function and the returned table describes that function. Hand it a number and it is read as a stack level - `0` is the call you are in right now, `1` is the caller above it, and so on - and the returned table describes whichever frame is running at that level.

Most commonly used while reversing a game script: you find an unknown closure with `getgc` and call `debug.getinfo` on it to learn what it is, where it came from, and how many arguments it takes before you decide what to do with it.

## Parameters

### Form A - function

| Parameter | Type       | Description              |
| --------- | ---------- | ------------------------ |
| `func`    | `function` | The function to inspect. |

## Returns

`table` - a single table with the same fields for both forms:

| Field         | Type       | Description                                                                                                                                                             |
| ------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `source`      | `string`   | Name of the chunk that created the function.                                                                                                                            |
| `short_src`   | `string`   | Short, printable version of `source`.                                                                                                                                   |
| `func`        | `function` | The function itself.                                                                                                                                                    |
| `what`        | `string`   | `"Lua"` for a Luau function, `"[C]"` for a C function.                                                                                                                  |
| `currentline` | `number`   | The line currently running. `-1` when no line information is available.                                                                                                 |
| `name`        | `string`   | The function's name. A blank string when no name can be found.                                                                                                          |
| `nups`        | `number`   | Number of upvalues the function captured.                                                                                                                               |
| `numparams`   | `number`   | Number of declared parameters. Always `0` for C functions.                                                                                                              |
| `is_vararg`   | `number`   | `1` if the function takes a <abbr title="A function that takes any number of extra arguments - defined as `...` in Luau.">variadic argument</abbr>, `0` if it does not. |

## Aliases

* `getinfo`

## Example

While reversing a script in a Roblox game, sweep `getgc` for an unknown 2-arg Luau closure and identify it before you decide to hook or read it.

<CodeGroup>
  ```luau Example 1 theme={null}
  <<<<<<< HEAD
  local getinfo = debug.getinfo(function(...) end)
  =======
  -- debug.getinfo(target: function | number): table
  >>>>>>> 50e30f53759b0538759af25c9b271514aa2c9290
  ```

  ```luau Example 2 theme={null}
  for _, fn in ipairs(getgc()) do
      if type(fn) == "function" then
          local info = debug.getinfo(fn)
          if info.what == "Lua" and info.numparams == 2 then
              print(`candidate: {info.name} from {info.short_src} (line {info.currentline})`)
          end
      end
  end
  ```
</CodeGroup>

<Tip>
  Standard fields match Lua's debug library specifications.
</Tip>
