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

src: Treat embeded builtins as V8 functions #301

Closed

Conversation

mmarchini
Copy link
Contributor

On Node.js v12 most builtins are compiled during build time and embeded
in the binary. Because of that, LLDB will think it knows how to handle
these frames (especially JavaScript frames). To correctly handle those
frames, we check the function name, if it starts with Builtins_ we'll
handle it as a JIT function. This method should be safe since any C++
function coming from V8 or Node.js will be mangled, thus beginning with
_Z.... There might be a better way to handle this, but for now this
check should be enough.

On Node.js v12 most builtins are compiled during build time and embeded
in the binary. Because of that, LLDB will think it knows how to handle
these frames (especially JavaScript frames). To correctly handle those
frames, we check the function name, if it starts with `Builtins_` we'll
handle it as a JIT function. This method should be safe since any C++
function coming from V8 or Node.js will be mangled, thus beginning with
`_Z...`. There might be a better way to handle this, but for now this
check should be enough.
@codecov-io
Copy link

Codecov Report

Merging #301 into master will increase coverage by 0.29%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #301      +/-   ##
==========================================
+ Coverage    78.6%   78.89%   +0.29%     
==========================================
  Files          33       33              
  Lines        4225     4227       +2     
==========================================
+ Hits         3321     3335      +14     
+ Misses        904      892      -12
Impacted Files Coverage Δ
src/llnode.cc 74.4% <100%> (+0.2%) ⬆️
src/llv8.cc 71.58% <0%> (+0.46%) ⬆️
src/llv8-inl.h 93.43% <0%> (+0.84%) ⬆️
src/llv8-constants.cc 83.49% <0%> (+0.97%) ⬆️
src/llv8-constants.h 100% <0%> (+1.51%) ⬆️
src/llv8.h 83.33% <0%> (+2.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c4c99c...a903447. Read the comment docs.

@mmarchini
Copy link
Contributor Author

cc @nodejs/llnode

@@ -69,7 +69,12 @@ bool BacktraceCmd::DoExecute(SBDebugger d, char** cmd,
const char star = (frame == selected_frame ? '*' : ' ');
const uint64_t pc = frame.GetPC();

if (!frame.GetSymbol().IsValid()) {
// TODO(mmarchini): There might be a better way to check for V8 builtins
// embeded in the binary.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// embeded in the binary.
// embedded in the binary.

mmarchini added a commit that referenced this pull request Oct 7, 2019
On Node.js v12 most builtins are compiled during build time and embeded
in the binary. Because of that, LLDB will think it knows how to handle
these frames (especially JavaScript frames). To correctly handle those
frames, we check the function name, if it starts with `Builtins_` we'll
handle it as a JIT function. This method should be safe since any C++
function coming from V8 or Node.js will be mangled, thus beginning with
`_Z...`. There might be a better way to handle this, but for now this
check should be enough.

PR-URL: #301
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@mmarchini
Copy link
Contributor Author

Landed in 2964af5

@mmarchini mmarchini closed this Oct 7, 2019
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