Uh oh!
There was an error while loading. Please reload this page.
src, test: node internals' postmortem metadata - #14901
Conversation
There was a problem hiding this comment.
style nit: align the * to the left (i.e. Environment* Environment::currentEnvironment)
There was a problem hiding this comment.
What’s the motivation for making this optional?
There was a problem hiding this comment.
I don’t think these guards are necessary either way.
There was a problem hiding this comment.
Tbh, I’d just put #define private public at the top of the generated file and use offsetof.
Added two new commands (getactivehandles and getactiverequests) which prints all pending handles and requests (same return given by process._getActiveHandles() and process._getActiveRequests()). Those changes were built upon the symbols added on nodejs/node#14901, which means it's currently not working with node's latest build. Fixes: nodejs#100 Ref: nodejs/node#14901
bnoordhuis
commented
Aug 18, 2017
The changes to src/ seem rather ad hoc. I'm also not a fan of adding global variables. You don't need to because the env can be found by following |
mmarchini
commented
Aug 18, 2017
Thanks for the feedbacks, I just updated the PR with the suggestions made by @addaleax. I'm just not sure if All changes previously made on |
There was a problem hiding this comment.
Is this the right place to include node-postmortem-metadata as a dependency?
There was a problem hiding this comment.
Seems fine to me but you should add a #host at the end. For consistency, I'd name it node_postmortem_metadata, i.e., underscores instead of dashes.
There was a problem hiding this comment.
I'll make those changes. Should I also rename gen-postmortem-metadata.py to gen_postmortem_metadata.py (most files on tools/ are using dashes, but there are some files using underscores)?
There was a problem hiding this comment.
This will be changed in the next update to this PR
There was a problem hiding this comment.
Is it safe to be used here?
rnchamberlain
commented
Aug 22, 2017
@bnoordhuis@mmarchini the isolate is a v8 class, the env is in node, and it looks to me that you could get the isolate from the env, but I don't see how you can go the other way? |
mmarchini
commented
Aug 22, 2017
@rnchamberlain the Environment is stored in a fixed position inside the Context, and the Context is reachable from the Isolate, but the offsets to get the Context from the Isolate and the position inside the Context where the Environment is stored are currently not available in the symbols table of V8. I'm writing a PR to add those symbols to V8, let's see how it goes. Another option would be to get the environment from |
mmarchini
commented
Aug 29, 2017
Pull Request updated:
Please let me know if there's any other changes needed. |
BridgeAR
commented
Sep 3, 2017
@nodejs/build @nodejs/post-mortem PTAL |
BridgeAR
commented
Sep 13, 2017
Again @nodejs/build @nodejs/post-mortem PTAL |
addaleax
commented
Sep 14, 2017
The code LGTM but I don’t think I have a sufficiently good feeling for the usefulness of this feature. |
There was a problem hiding this comment.
Seems fine to me but you should add a #host at the end. For consistency, I'd name it node_postmortem_metadata, i.e., underscores instead of dashes.
There was a problem hiding this comment.
Can you add 'process_outputs_as_sources': 1, here?
There was a problem hiding this comment.
Inconsistent casing of class variables.
There was a problem hiding this comment.
Why is this called type_ instead of type?
There was a problem hiding this comment.
There's a built-in function named type, so using it as a name for variables or attributes is usually discouraged, but I could rename that if you prefer.
There was a problem hiding this comment.
This seems like a convoluted way of doing:
headers=set()
fordindebug_symbols:
headers.update(d.headers)
returnlist(headers)Or even just:
returnlist(set(sum(d.headersfordindebug_symbols, [])))There was a problem hiding this comment.
I prefer these ways too, but the order the headers were declared should be preserved (some headers need to be included before others). I'll add a comment on this method explaining that.
There was a problem hiding this comment.
Minor nit but we usually use single quotes for strings.
There was a problem hiding this comment.
Unnecessary cast here and elsewhere: the return type of offsetof() is already size_t.
BridgeAR
commented
Sep 19, 2017
Ping @mmarchini |
8416bc4 to
dc9633fComparemmarchini
commented
Sep 20, 2017
Sorry for the late response. I've just updated the PR with changes requested by @bnoordhuis. I've also rebased it to match the current master. @addaleax for now, it can be used to inspect active handles and requests on debuggers like LLDB (nodejs/llnode#122) and MDB (not implemented yet, but certainly will be if this is accepted). As we were discussing in nodejs/post-mortem#46, this is a first step to increase the power of debuggers to do post-mortem analysis of Node applications. |
cjihrig
left a comment
There was a problem hiding this comment.
LGTM once @bnoordhuis is good with it.
bnoordhuis
left a comment
There was a problem hiding this comment.
LGTM if the last nits are addressed. Thanks for the PR.
There was a problem hiding this comment.
If you swap these two, you can reduce the diff by one line (because you don't need to append a comma to the nghttp2 dep.)
There was a problem hiding this comment.
Long line, can you wrap this at 80 columns?
There was a problem hiding this comment.
It probably makes no measurable difference. I'd simply drop this and use seen.add(h) below.
There was a problem hiding this comment.
or seen_add(h) is a somewhat misleading construct because seen.add(h) doesn't return anything (well, None.)
I'd spell it out for clarity:
result= []
forhinheaders:
ifnothinseen:
seen.add(h)
result.append(h)
returnresultmmarchini
commented
Sep 20, 2017
Pull Request updated with those last changes requested |
BridgeAR
commented
Sep 22, 2017
BridgeAR
commented
Sep 22, 2017
@mmarchini the commits should at least partially quashed and it is somewhat difficult for me to describe your changes in a single commit as I do not know what of the commit messages is still relevant and what not. Would you mind to either provide a single commit messages for all commits together or rebase on your own so this can be landed? Thanks a lot in advance! |
28136f3 to
a7dfd9aComparemmarchini
commented
Sep 25, 2017
I've squashed all commits into one and updated the commit message to best reflect these changes. If you need anything else please let me know :) |
BridgeAR
commented
Sep 27, 2017
BridgeAR
commented
Sep 28, 2017
Rerun the CI as it is very red https://ci.nodejs.org/job/node-test-commit/12650/ |
BridgeAR
commented
Sep 28, 2017
@mmarchini it seems like there are related failures on the CI. Please have a look. E.g. https://ci.nodejs.org/job/node-test-commit-linux/12698/nodes=centos5-64/console |
Another one...:https://ci.nodejs.org/job/node-test-commit-arm/13371/ EDIT: no luck, stopped. |
joyeecheung
commented
Jan 25, 2018
CI before landing: https://ci.nodejs.org/job/node-test-pull-request/12738/ |
joyeecheung
commented
Jan 26, 2018
Landed in 756a34e, thanks for being so patient and following along! @mmarchini |
Before these changes, only V8 added postmortem metadata to Node's binary, limiting the possibilities for debugger's developers to add some features that rely on investigating Node's internal structures. These changes are first steps towards empowering debug tools to navigate Node's internal structures. One example of what can be achieved with this is shown at nodejs/llnode#122 (a command which prints information about handles and requests on the queue for a core dump file). Node postmortem metadata are prefixed with nodedbg_. This also adds tests to validate if all postmortem metadata are calculated correctly, plus some documentation on what is postmortem metadata and a few care to be taken to avoid breaking it. Ref: nodejs/llnode#122 Ref: nodejs/post-mortem#46 PR-URL: #14901 Refs: nodejs/post-mortem#46 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Added two new commands (getactivehandles and getactiverequests) which prints all pending handles and requests (same return given by process._getActiveHandles() and process._getActiveRequests()). Those changes were built upon the symbols added on nodejs/node#14901, which means it's currently not working with node's latest build. Fixes: nodejs#100 Ref: nodejs/node#14901
MSLaguana
commented
Feb 8, 2018
I just ran into an issue caused by the redefinition of |
joyeecheung
commented
Feb 8, 2018
@MSLaguana How would they be broken? Do you mean that their members are now all accessible to |
@MSLaguana Ah, right, I realized that you are talking about that the inheritance statement will be broken...that is unintentional I believe. |
bnoordhuis
commented
Feb 8, 2018
It's of no concern since we don't use private inheritance. I don't foresee that happening either. |
joyeecheung
commented
Feb 8, 2018
@bnoordhuis Just curious, is that a convention? There is |
bnoordhuis
commented
Feb 8, 2018
I saw that by pure coincidence ten minutes after I posted that... the reason we don't use non-public inheritance is that there is never a reason to. The two files you mention both came from outside. Yes, a note in the style guide would be good. |
MylesBorins
commented
Feb 20, 2018
MylesBorins
commented
Feb 20, 2018
One more thing... should this be semver-minor? |
mmarchini
commented
Feb 20, 2018
AFAIK it's because there was one reverted commit here, see #14901 (comment) (this comment also explains why I opened a backport PR). |
mmarchini
commented
Feb 20, 2018
Yep, since it's a new feature. |
MylesBorins
commented
Feb 21, 2018
@mmarchini thanks for pointing it out! We'll get it in the next release! |
mmarchini
commented
May 22, 2018
Yes. There's already a backport PR open (#19176), I just need to rebase it to resolve conflicts. I'll do it today. |
Those changes are the first steps towards allowing debug tools to
navigate some of Node's internals strucutres, giving more possibilities
to developers doing post-mortem debugging. One example of what can be
achieved with the symbols added is a new command being developed for
llnode, which prints information about handles and requests on the
queue for a core dump file.
Ref: nodejs/post-mortem#46
Obs.: To add good tests for those changes, something like nodejs/build#777 is needed.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)