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

Implement panic stack traces #18

Open
mbeckem opened this issue Jul 5, 2021 · 2 comments
Open

Implement panic stack traces #18

mbeckem opened this issue Jul 5, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@mbeckem
Copy link
Owner

mbeckem commented Jul 5, 2021

The exception type needs support for stack traces.
When an exception is thrown, the N topmost tiro function names should be represented in the trace.

Exact positions within those functions (e.g. line numbers) are currently out of scope because the compiler does not yet emit those information.

@mbeckem mbeckem added the enhancement New feature or request label Jul 5, 2021
@mbeckem
Copy link
Owner Author

mbeckem commented Jan 22, 2022

If panic stack traces are enabled (a flag during vm construction, off by default), a very simple stack trace is attached to every exception.

The stack trace reflects function names only at the moment.

Example:

import std;

export func test() {
    nested(2);
}

func nested(n) {
    if n == 0 {
        std.panic("help!");
    }
    nested(n - 1);
}

Calling test produces the following trace (most nested function on top):

Coroutine-1:
  - nested
  - nested
  - nested
  - test

@mbeckem
Copy link
Owner Author

mbeckem commented Jan 22, 2022

Note: module names etc. are currently not part of the function name. Modules are not fleshed out well, yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant