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

findjsobjects #9

Closed
yunong opened this issue Nov 25, 2015 · 15 comments
Closed

findjsobjects #9

yunong opened this issue Nov 25, 2015 · 15 comments

Comments

@yunong
Copy link
Member

yunong commented Nov 25, 2015

Great work Fedor. Any idea whether it's possible within LLDB to find heap objects? Something along the lines of https://github.com/joyent/mdb_v8/blob/master/docs/usage.md#finding-javascript-objects would be extremely helpful.

Actually, now that I think about it, what about porting some of the functionality over from mdb_v8 to lldb? The code for mdb_v8 is already open source, I wonder if it would be easier to try and port that library? In any case we should talk about your work with llnode here at an upcoming nodejs post mortem working group meeting.

@indutny
Copy link
Member

indutny commented Nov 25, 2015

Thank you for kind words, @yunong !

It is definitely possible, though, the code will be very different from the mdb_v8. The reason for this is that lldb does not provide any information about mmap regions. So llnode can't iterate through them.

While again possible in llnode, this feature is currently blocked by https://codereview.chromium.org/1437133006/ , and I am not sure if there will be any resolution there. Need to find a better way to get this introspection, possibly detaching postmortem from v8 project and putting it into node.js.

About other features from mdb_v8. Is there anything that you are interested in? From a quick look it seems that most of the commands are already there (if not all of them), just under different names.

@indutny
Copy link
Member

indutny commented Nov 25, 2015

Oh, and regarding post mortem working group. When is the next meeting?

@yunong
Copy link
Member Author

yunong commented Nov 25, 2015

We haven't set one up yet, but I think we should file an issue in that group to set one up, since this is something we should all sync up on.

The commands we use quite often are listed on this slide: http://www.slideshare.net/yunongx/debugging-node-in-prod/57

I think the most important, obviously out of all these would be some facility to walk and query all objects on the heap -- and something we should chat about at the WG meeting.

@indutny
Copy link
Member

indutny commented Nov 25, 2015

Ok, so here is a map:

::help -> help v8
::jsstack -> v8 bt
::jsprint -> v8 print
::jssource -> list
# Though, this command is not fully complete yet
::jsconstructor -> v8 inspect
::findjsobjects -> we don't have this one yet
::jsfunctions -> v8 code-map (This works only with that postmortem CL)

@yunong
Copy link
Member Author

yunong commented Nov 30, 2015

Cool! @indutny I created an issue here: nodejs/post-mortem#12 to kick start a new post mortem WG meeting.

@lucamaraschi
Copy link

👍 @indutny I really like the effort and I am actually using it aside of mdb.
It might be useful, if the most agree on the approach, to map the commands to the one of mdb as the majority of "post-mortemers" are using it. Does it make sense to you?

@yunong I think the most used command is actually ::findjsobjects -p "name" ;-)

indutny added a commit that referenced this issue Dec 1, 2015
@indutny
Copy link
Member

indutny commented Dec 1, 2015

Just pushed aliases for these commands.

@lucamaraschi
Copy link

👍

@indutny
Copy link
Member

indutny commented May 25, 2016

@hhellyer hello!

I just wanted to ask you if you are still interested in continuing your efforts? It looks like I may have some spare cycles for this, and could do something based on your approach, unless you feel like you want to do it.

Thanks!

@hhellyer
Copy link
Collaborator

@indutny - I am definitely still interested and working on it. I looked into whether it would be possible to get memory regions out of lldb to fix problem with being unable to walk memory regions to remove the need to run pre-processing scripts and the lldb community was really helpful, I'm working on patches for that:

http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20160523/029772.html

If I can get that delivered I was planning on updating my fork so llnode can build against source from the head of the lldb development stream but anything based off my work can have the need for pre-processing removed once the new LLDB API is available. Most of my time has been spent on that lately.

@indutny
Copy link
Member

indutny commented May 27, 2016

@hhellyer wooow, you rock 👍 ! Thank you for letting me know!

@hhellyer
Copy link
Collaborator

I’m tidying my code that provides the ability to locate the objects on the heap and dump them with a view to making it available for you to pull (if you want to).

Initially it will still be dependant on parsing the memory region data from the core dump before starting lldb. Do you want me to add the python scripts for this to those changes or shall I leave them as gists? (It looks like you might be making llnode installable as an npm in which case it might be helpful to have them inside the project.)

Is python the right language for those or would it fit better with future plans if the scripts were converted to Javascript? (They’re pretty simple, it wouldn’t be much effort.)

Hopefully the need to do that pre-processing will be removed but users will still be dependent on when the standard versions of lldb actually receive those changes.

@indutny
Copy link
Member

indutny commented Jun 16, 2016

@hhellyer I think adding scripts to this repo should be the best for llnode, this way they could be kept up to date.

The python script is absolutely fine, I'll either port it to JavaScript later, or to C++ to embed it into the plugin.

These are my hopes too! Thank you so much for your work, and looking forward to see the patch. 👍

@hhellyer
Copy link
Collaborator

I’ve created a pull request #13 which addresses this missing functionality.
It’s a bit different in that there are two commands, listobjects and listinstances. The first command prints a histogram of object counts and sizes with the objects grouped by map id. The second will print all the object instances that share a map.

@indutny
Copy link
Member

indutny commented Jun 28, 2016

Implemented in c517e0c

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

No branches or pull requests

4 participants