GitHub - ahmedakef/gotutor: Online Go Debugger & Visualizer (original) (raw)
GoTutor
GoTutor is a project aimed at capturing the execution steps of a Go program by interacting with the Delve debugger server. It retrieves variable values and stack information of all running Goroutines at each Go statement.
Features
- Capture running Goroutines and its stack frames state at each Go statement of the main Goroutine.
- Interactive online Debugging tool: https://gotutor.dev/.
Architecture
The project is split into three components:
- CLI tool: that takes a go program and produces
output/steps.jsonfile which represent the execution steps of the program (exists under.) - backend: run the CLI tool for the given program and return the execution steps (exists under
backend/) - frontend: the frontend of https://gotutor.dev/ which is build using elm-lang (exists under
frontend/)
Limitations
Currently, the project has limitations when handling multiple goroutines. When using next or step on a single goroutine, all goroutines progress, making it difficult to capture the state of other goroutines. This issue is documented in Delve Issue #1529. Attempts to create a client for each goroutine and step through them individually have been unsuccessful and have caused runtime errors in the Delve server.
Usage
the commands follow dlv cli terminology
exec
run delve server with the binary that gotutor will interact with to get execution steps
debug
build the go module in the current directory then contine the same as exec
connect
gotutor connect delve_server_address
connect to already running delve server
the execution steps will be written to steps.json file in the current direcotry
Prerequisites
- Go (latest version)
- Delve debugger
Installation
go install github.com/ahmedakef/gotutor@latest
docker
docker build -t gotutor . # or directly use ahmedakef/gotutor image to download it from docker hub
docker run --rm -v <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>p</mi><mi>w</mi><mi>d</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi>e</mi><mi>x</mi><mi>a</mi><mi>m</mi><mi>p</mi><mi>l</mi><mi>e</mi><mi mathvariant="normal">/</mi><mi>m</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi mathvariant="normal">.</mi><mi>g</mi><mi>o</mi><mo>:</mo><mi mathvariant="normal">/</mi><mi>d</mi><mi>a</mi><mi>t</mi><mi>a</mi><mi mathvariant="normal">/</mi><mi>m</mi><mi>a</mi><mi>i</mi><mi>n</mi><mi mathvariant="normal">.</mi><mi>g</mi><mi>o</mi><mo>−</mo><mi>v</mi></mrow><annotation encoding="application/x-tex">(pwd)/example/main.go:/data/main.go -v </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.02691em;">pw</span><span class="mord mathnormal">d</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathnormal">e</span><span class="mord mathnormal">x</span><span class="mord mathnormal">am</span><span class="mord mathnormal" style="margin-right:0.01968em;">pl</span><span class="mord mathnormal">e</span><span class="mord">/</span><span class="mord mathnormal">main</span><span class="mord">.</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">o</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">/</span><span class="mord mathnormal">d</span><span class="mord mathnormal">a</span><span class="mord mathnormal">t</span><span class="mord mathnormal">a</span><span class="mord">/</span><span class="mord mathnormal">main</span><span class="mord">.</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">o</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span></span></span></span>(pwd)/output/:/root/output gotutor debug /data/main.go
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License.
Give a Star! ⭐
If you like this project or are using it to learn or start your own solution, give it a star to get updates on new releases. Your support matters!
