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

Debugger feature: add backtrace command #2490

Open
bobrippling opened this issue Apr 21, 2024 · 2 comments
Open

Debugger feature: add backtrace command #2490

bobrippling opened this issue Apr 21, 2024 · 2 comments

Comments

@bobrippling
Copy link
Contributor

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
Copy link
Member

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:

  • Actually skip back down the stack (this will be platform dependent) a bit like GDB's bt would do, and find instances of jspeFunctionCall
  • Add an oldLex pointer to JsLex, and as we replace it when we're executing the function (
    JsLex *oldLex = jslSetLex(&newLex);
    ) link in the 'old' lexer rather than storing it in JsLex *oldLex. That way the debugger could skip back down all the lexers and reconstruct the call stack.

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

@bobrippling
Copy link
Contributor Author

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

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

No branches or pull requests

2 participants