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

Allow iterating over the frames of a CapturedJSStack #539

Merged
merged 3 commits into from
Dec 16, 2024

Conversation

simonwuelker
Copy link
Contributor

This adds CapturedJSStack::for_each_stack_frame which calls the provided closure for each element in the linked list of SavedFrames. Unfortunately, I don't think there's an easy way to make this an iterator over SavedFrames, because of the lifetime associated with a RootedGuard.

for_each_stack_frame is useful for providing js backtraces in functions like console.trace.

Copy link
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@jdm
Copy link
Member

jdm commented Dec 15, 2024

@simonwuelker
Copy link
Contributor Author

Could you add a test in https://github.com/servo/mozjs/blob/main/mozjs/tests/capture_stack.rs ?

Done. Should I create a new release for mozjs or is it fine to pin the git commit in servo?

@simonwuelker
Copy link
Contributor Author

simonwuelker commented Dec 15, 2024

Ugh, the test passes individually but the other tests are interfering with the engine initialization (because the engine is global state).

Fixed by moving the test into its own file.

This prevents other tests from interfering with the js engine
initialization

Signed-off-by: Simon Wülker <[email protected]>
@jdm
Copy link
Member

jdm commented Dec 16, 2024

Could you add a test in https://github.com/servo/mozjs/blob/main/mozjs/tests/capture_stack.rs ?

Done. Should I create a new release for mozjs or is it fine to pin the git commit in servo?

Since this PR only modifies Rust code, we can just update the git revision. C++ changes need a version number update to ensure new static library binaries are published.

@jdm jdm added this pull request to the merge queue Dec 16, 2024
Merged via the queue into servo:main with commit bb560b6 Dec 16, 2024
27 checks passed
@simonwuelker simonwuelker deleted the iterate-stack branch December 16, 2024 01:19
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.

2 participants