espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.73k stars 741 forks source link

Debugger feature: add backtrace command #2490

Open bobrippling opened 2 months ago

bobrippling commented 2 months ago

I'd like to be able to see the call stack (useful for debugging what's called code, such as finding out where a width has been set), like bt in gdb - before I work on the feature though, is this something that would be accepted into espruino?

I'm thinking something like:

debug>bt
Frame 0: drawIcon(), "clock.js", line 5
Frame 1: draw(), "clock.js", line 20
Frame 2: anonymous, "clock.js", ...
gfwilliams commented 2 months ago

Well, if this were possible in an efficient way I'd be all for it. However if it were easy I'd have added it to the debugger already :)

Basically I don't want to calculate/store a bunch of extra stuff for each function call, because that would slow execution down.

So I guess you have two options really:

Now I think about it the second option should be possible with minimal extra overhead

bobrippling commented 2 months ago

Interesting - I'll take a look, thanks for the pointers