Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an interactive debugger in gnoVM #54

Closed
mvertes opened this issue Jan 15, 2024 · 0 comments · Fixed by gnolang/gno#1563
Closed

Add an interactive debugger in gnoVM #54

mvertes opened this issue Jan 15, 2024 · 0 comments · Fixed by gnolang/gno#1563
Assignees

Comments

@mvertes
Copy link

mvertes commented Jan 15, 2024

Provide gnoVM with an interactive symbolic debugger similar to delve, except that the debugger facility is integrated in the gno executable.

@mvertes mvertes self-assigned this Jan 15, 2024
thehowl added a commit to gnolang/gno that referenced this issue May 14, 2024
![gno-debug](https://github.com/gnolang/gno/assets/5792239/96c50686-df6c-4dd8-a1d1-63f787a9328d)

We provide here an embedded interactive debugger to let the user control
and inspect its program at symbolic level, with the same features and
commands as classical debuggers: gdb, lldb or delve.

The debugger is enabled by setting the `-debug` flag in `gno run`
command, which loads the target program and immediately shows a debugger
prompt on the console:

	$ gno run -debug /tmp/my-program.gno
	Welcome to the Gnovm debugger. Type 'help' for list of commands.
	dbg>

Providing `-debug-addr` flag allows to start a remote debugging session,
and not interfer with the program stdin and stdout. For example, in a
first terminal:

	$ gno run -debug-addr :4000 /tmp/my-program.gno
	Waiting for debugger client to connect at :4000

And in a second terminal, using a netcat like nc(1):

	$ nc localhost 4000
	Welcome to the Gnovm debugger. Type 'help' for list of commands.
	dbg>

The debugger works by intercepting each execution step at virtual
machine level (each iteration within `Machine.Run` loop) to a callback,
which in turns can provide a debugger command REPL or check if the
execution can proceed to the next step, etc.

The general logic and structure is there. It is possible to `continue`,
`stepi`, `detach`, `print`, `stack`, etc and get a general feedback of
the user experience and the impact on the code.

Efforts are made to make this feature minimally intrusive in the actual
VM, and not interfering when the debugger is not used.

It is planned shortly after this PR is integrated to add the capacity to
attach to an already running program, and to taylor the data format for
existing debugging environments such as VScode, etc, as demand arises.

Resolves gnolang/hackerspace#54

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Morgan <morgan@morganbaz.com>
jefft0 pushed a commit to jefft0/gno that referenced this issue May 15, 2024
![gno-debug](https://github.com/gnolang/gno/assets/5792239/96c50686-df6c-4dd8-a1d1-63f787a9328d)

We provide here an embedded interactive debugger to let the user control
and inspect its program at symbolic level, with the same features and
commands as classical debuggers: gdb, lldb or delve.

The debugger is enabled by setting the `-debug` flag in `gno run`
command, which loads the target program and immediately shows a debugger
prompt on the console:

	$ gno run -debug /tmp/my-program.gno
	Welcome to the Gnovm debugger. Type 'help' for list of commands.
	dbg>

Providing `-debug-addr` flag allows to start a remote debugging session,
and not interfer with the program stdin and stdout. For example, in a
first terminal:

	$ gno run -debug-addr :4000 /tmp/my-program.gno
	Waiting for debugger client to connect at :4000

And in a second terminal, using a netcat like nc(1):

	$ nc localhost 4000
	Welcome to the Gnovm debugger. Type 'help' for list of commands.
	dbg>

The debugger works by intercepting each execution step at virtual
machine level (each iteration within `Machine.Run` loop) to a callback,
which in turns can provide a debugger command REPL or check if the
execution can proceed to the next step, etc.

The general logic and structure is there. It is possible to `continue`,
`stepi`, `detach`, `print`, `stack`, etc and get a general feedback of
the user experience and the impact on the code.

Efforts are made to make this feature minimally intrusive in the actual
VM, and not interfering when the debugger is not used.

It is planned shortly after this PR is integrated to add the capacity to
attach to an already running program, and to taylor the data format for
existing debugging environments such as VScode, etc, as demand arises.

Resolves gnolang/hackerspace#54

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Morgan <morgan@morganbaz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant