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

Add stacktrace API #70

Merged
merged 1 commit into from
May 16, 2019
Merged

Add stacktrace API #70

merged 1 commit into from
May 16, 2019

Conversation

rossberg
Copy link
Member

Provides API to get the frame from which a trap originates as well as an entire stacktrace. For each frame, instance, module offset, function index, and function offset can be inquired.

These functions are considered to be "best effort", i.e., an engine doesn't need to provide the information and can return null instead in some or all cases. The current V8 prototype always returns null for the origin, since the respective information isn't easily available through the V8 API.

See here for the interface.

If an embedder wants to associate file name information with an instance, then it can do so by setting the file name as host info on an instance object.

Addresses #54. @nomeata, @titzer

@nomeata
Copy link
Contributor

nomeata commented May 16, 2019

I only see `module_offset , not function index or function offset, in the diff (but my ability to read C++ is limited).

@rossberg
Copy link
Member Author

@nomeata, oops, forgot to push. PTAL.

@titzer
Copy link

titzer commented May 16, 2019

API lgtm. This would fulfill my use case, and I think it's sufficiently general to allow other embedders to implement source-level stacktraces however they like.

If understand correctly, the "origin" is just the frame in which the trap actually occurred, not the entire stack trace. In the V8 implementation, this should be the topmost frame, if the trap is actually caused by Wasm (and not an exception thrown by calling out to the embedder).

@rossberg
Copy link
Member Author

@titzer, yes, origin() is just an efficient shorthand for trace()[0], in case you only care about that. I could also imagine that some engines provide origin but not a full trace.

@titzer
Copy link

titzer commented May 16, 2019

@rossberg Cool, that matches my understanding then. Still lgtm.

@titzer
Copy link

titzer commented May 16, 2019

Btw, did you encounter a case where the origin frame is not correct? It should be in the full stack trace in V8, and if it is not, then this is a bug.

@rossberg
Copy link
Member Author

Since I don't know how to actually get this data through the V8 API (esp. the instance), I haven't implemented it in the prototype -- origin always returns null atm. So no. :)

@jakobkummerow will hopefully know how this can be implemented internally.

@rossberg rossberg merged commit dc8cc29 into master May 16, 2019
@rossberg rossberg deleted the traptrace branch May 16, 2019 19:03
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

Successfully merging this pull request may close these issues.

3 participants