function hang_me() {
while (true) {
digitalWrite(LED1,1);
digitalWrite(LED1,0);
}
}
function bob() {
console.log(1);
hang_me();
console.log(2);
}
Then type bob() on the left. It'll hang because of the while(true).
Press Ctrl-C - it'll show where you are in the code, with debug> prompt
Then you can type in commands to do stuff
>bob()
1
while (true) {
^
debug>
In debug mode: Expected a simple ID, type 'help' for more info.
debug>help
Commands:
help / h - this information
quit / q / Ctrl-C - Quit debug mode, break execution
continue / c - Continue execution
next / n - execute to next line
step / s - execute to next line, or step into function call
print ... / p ... - evaluate and print the next argument
debug>n
digitalWrite(LED1,1);
^
debug>n
digitalWrite(LED1,0);
^
debug>n
}
^
debug>n
}
^
debug>n
digitalWrite(LED1,1);
^
debug>q
Execution Interrupted
at line 2 col 14
while (true) {
^
in function "hang_me" called from line 3 col 11
hang_me();
^
in function "bob" called from line 1 col 5
bob()
^
>
So overall, I think it's actually pretty useful as-is?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ok, I've just come up with a branch for the debugger.
There should be builds with it in here
To use it, try uploading:
bob()
on the left. It'll hang because of thewhile(true)
.Ctrl-C
- it'll show where you are in the code, withdebug>
promptThen you can type in commands to do stuff
So overall, I think it's actually pretty useful as-is?