14.10. Evaluate
Prev | Chapter 14. Lua Debugger | Next

## 14.10. Evaluate

The Evaluate panel is an inline Lua REPL against the paused state. The top half is an input editor; the bottom half is a read-only log of previous expressions and their results.

- Enter Lua code and press `Ctrl+Return` (or click Evaluate) to run it against the paused state. The evaluator runs the code in a protected way, so runtime errors are caught and reported in the output rather than terminating Wireshark.
- No `=` or `return` is needed — bare expressions auto-return their value, the same way Watch rows do (see Section 14.6, “Watch”). The legacy `=expr` prefix from older Lua REPLs is still tolerated, just redundant.
- Clear empties the output. To clear input, Select All (`Ctrl+A`) then `Delete` or `Backspace`.

The panel is enabled only while the debugger is paused. Typical uses:

- Inspect a value — `pinfo.src`, `tostring(pinfo.dst)`, or `sessions[pinfo.number]`.
- Mutate state — `_G.my_flag = true`, `my_table.field = 99`. (For read-only observation prefer the Watch panel; expression watches re-evaluate automatically on every pause without taking up the Evaluate output history.)
- Run a one-off statement — set a global, push a row into a table, or call a logging helper.

Scope. The evaluator runs against the paused state with the same custom `_ENV` as expression watches; bare identifiers resolve against locals, then upvalues, then globals (see Section 14.5, “Variables”). So `pinfo.src` works the same way `Locals.pinfo.src` works, and library names like `string` and `tostring` fall through to globals automatically.

Limitations.

- Locals cannot be mutated by assignment. A statement like `foo = 42` writes to `\_G.foo`, not to a local `foo`. Use `debug.setlocal()` if you really need to mutate a local. Locals with a assign method (`pinfo.src_port`) can be modified.
- Mutating globals is destructive. Changes persist after Continue and will affect subsequent dissection.
- Long-running expressions are aborted (Lua 5.4+). The evaluator caps execution time so a runaway `while true do end` cannot hang the GUI. On Lua 5.3 builds the cap is inactive (see Section 14.6, “Watch” for details).

After an evaluation the Stack Trace, Variables, and Watch panels are refreshed because the expression may have mutated state the other panels display.

Prev | Up | Next
14.9. Files | Home | 14.11. Editor