Code Monkey home page Code Monkey logo

goja_debugger's Introduction

Goja Debugger

An example Goja application to demonstrate the capabilities of the NEW debugger

References

How to build

This repositories contains an example application in Go for testing the debugger functionality I'm developing for Goja and a bunch of scripts in JavaScript, one (gen-srcmap.js) for generating sourcemaps for your JavaScript files and two other (test_*.js) for testing the debugger app.

To run the debugger application, just run go build in the cloned project on your machine, assuming you have Go.

git clone https://github.com/mostafa/goja_debugger
cd goja_debugger
go build

There are two scripts along with their sourcemaps for testing the debugger functionality. If you want to debug your own scripts, you might need to use Node.js to generate your own sourcemap for your JavaScript, which helps the debugger application easily pinpoint the lines in your script.

npm i
node gen-srcmap.js test.js > test.js.map

How to run

There's just one subcommand in the debugger application, inspect. If you use it, it'll tell the compiler to emit debugger instruction in your program and also let's the JS VM (Goja VM) to run your script in debug mode. Otherwise it'll just run the script normally.

./goja_debugger inspect test.js
Welcome to Goja debugger
Type 'help' or 'h' for list of commands.
debug[0]> n
Break on start in test.js:1:1
> 1     debugger
  2
  3     function test(val) {
  4         debugger
  5         val += 10

debug[0]>

Supported commands

When the debugger starts, it'll pause, so that you instruct it to run a command or set a breakpoint. Most of the following command are supported:

setBreakpoint, sb       Set a breakpoint on a given file and line
clearBreakpoint, cb     Clear a breakpoint on a given file and line
breakpoints             List all known breakpoints
next, n                 Continue to next line in current file
cont, c                 Resume execution until next debugger line
step, s                 Step into, potentially entering a function (Not Implemented Yet)
out, o                  Step out, leaving the current function (Not Implemented Yet)
exec, e                 Evaluate the expression and print the value
list, l                 Print the source around the current line where execution is currently paused
print, p                Print the provided variable's value
help, h                 Print this very help message
quit, q                 Exit debugger and quit (Ctrl+C)

Roadmap

  • Expose a debugger API (Thanks to @nwidger ๐Ÿ™)
  • Implement debugger event-loop using channels for the new API
  • Implementation of step-in and step-out commands
  • Possible sourcemap generation on the fly (not sure if it's possible in Go)
  • Fix Goja tests and try to see if changes are needed for TC39 tests
  • Revert changes to interfaces in compiler.go and others and use a flag for debugMode
  • DAP integration
  • Integration with k6

License

AGPL v3 or later

goja_debugger's People

Contributors

mostafa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.