---
title: "debug.getinfo"
description: "Returns function/frame metadata and the function itself."
---

```lua
debug.getinfo(target: function | number): DebugInfo
```

---

## Aliases

- `getinfo`

---

## Arguments

<ParamField body="target" type="function | number" required>
  The function to inspect, or a positive stack level identifying a caller.
</ParamField>

---

## Returns

<ResponseField name="info" type="DebugInfo">
  Function metadata including source, name, line numbers, parameter/upvalue counts, and func.
</ResponseField>

See DebugInfo below. Many selectors use positive stack levels; do not assume stack numbering is identical across all debug APIs.

**Related types:** [Debug types & behavior](/reference/debug/types).

---

## Example

```lua
local function sample(a) return a end
local info = debug.getinfo(sample)
print(info.source, info.numparams, info.what)
```
