https://github.com/csirmaz/lua-torch-interactive
A Lua package that stops the execution of a script and creates an interactive prompt to inspect and change variables (Lua)
https://github.com/csirmaz/lua-torch-interactive
interactive lua luajit prompt torch
Last synced: 7 months ago
JSON representation
A Lua package that stops the execution of a script and creates an interactive prompt to inspect and change variables (Lua)
- Host: GitHub
- URL: https://github.com/csirmaz/lua-torch-interactive
- Owner: csirmaz
- License: mit
- Created: 2017-05-27T21:19:48.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-28T01:56:53.000Z (almost 9 years ago)
- Last Synced: 2025-04-12T12:43:46.364Z (12 months ago)
- Topics: interactive, lua, luajit, prompt, torch
- Language: Lua
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lua-Torch-Interactive
`dbg` is Lua package that stops the execution of a script and uses the Lua debug prompt to
allow interactively inspecting and changing variables.
## Triggering the prompt
Use `dbg.enter()` in the program to drop the user into the prompt.
Alternatively, use `dbg.enter_if_file(triggerfile)` to drop the user into the prompt if
`triggerfile` exists. If not given, the argument defaults to `dbg.trigger_file`, which is a
filename in `/tmp/` derived from the current PID.
## Inside the debug prompt
Before displaying the prompt, `dbg` collects and lists the available local variables from the
current scope and the parent scopes, and assigns unique names to them.
The variable names may be prefixed by the name
of the current level or function, or '*' may be added to them to disambiguate them.
In the prompt, use:
- `dbg.print('variablename')` or `dbg.p('variablename')` to print the value of a
local variable.
- `dbg.get('variablename')` or `dbg.g('variablename')` to return the value of a
local variable (useful if it is a table, to modify a value in it).
- `dbg.set('variablename', value)` or `dbg.s('variablename', value)` to change the
value of a local variable.
- `dbg.varinfo()` to repeat the list of local variables.
- Type `cont` or press `^D` to allow the script to continue.
- Type `^C,^D` or run `os.exit()` to abort.
## Demo
Run `th test.lua` for a demo (using torch).
## License
dbg.lua is copyright (c) 2017 Elod Csirmaz, released under the MIT license.