-
Notifications
You must be signed in to change notification settings - Fork 20
Linux support for mdb #17
Comments
I think that prototype implementation would be great to have available publicly! We've discussed this a lot, and I think by far the better longer-term approach for getting mdb_v8 on Linux is to turn mdb_v8 into a C library that could be easily loaded into different programs, including mdb. I've started doing that work, but it's basically a background project (see TritonDataCenter/mdb_v8#35 for an example). Porting MDB itself to Linux would be great too, but I don't think anybody has volunteered to do it. I believe the file format we've been discussing under #13 addresses some people's more immediate needs for this because they intend to run the real MDB to extract this information and then process it with other tools (that can be more cross-platform). All that aside, a working implementation would be very useful! |
@Raynos if you guys could share your PoC, that would be awesome. Any ETA? |
ETA is 2 weeks out. Currently On holiday. I'll reach to the engineer next week. Might need some cleanup, I'll try and get it out. |
@indutny was working on an lldb thing with similar capabilities not that long ago. |
Yeah, this work is here: https://github.com/indutny/llnode . Appears to be working just fine on linux |
👍 for not needing to dust off OmniOs instances to look at dumps. |
mdb_v8 as a C library would be great, hopefully we could make use of this when reading core dumps with other OS debuggers. windbg has support for extensions via a C API, the support in gdb is a python API, but maybe we'd just need a thin layer to get to/from mdb_v8 library. For the uber stand-alone tool I guess they wrote their own Linux/ELF core reader, which is more work than using a debugger (but still quite doable). |
This issue on nodejs/node nodejs/node#5696 talks about making debug symbol files available generally on all platforms. That would be a big help inside any debugger (gdb, lldb or windbg) and potentially make if far easier to navigate the dumps and ease a lot of the problems around writing debug extensions. |
@Raynos Do you have any update on the tools that you guys are developing at Uber? |
@lucamaraschi I've got a copy of the linux mdb; I'm going to try and build it locally and write a README with reproducable steps. |
We are looking at implementing the MDB V8 DMOD commands as GDB extensions (in Python). Do folks think this is worth doing, given the general availability of LLDB on Linux? |
@rnchamberlain Yes, this would be great! There's a huge amount of appetite for the mdb_v8 commands to be made available as LLDB extensions. @tjfontaine already started on a port here: https://github.com/tjfontaine/lldb-v8 |
@yunong the main difference between LLDB and mdb plugin is that you can't iterate allocated memory in LLDB. LLDB just does not keep mapped regions after parsing core file. Wish they did! (Or perhaps I should contribute it myself...) |
Ah yes, we noticed that to list JS objects, the MDB DMOD walks all the memory sections. We think 'maintenance info sections' returns the malloc'ed memory in GDB. It would be very useful to be able to do that in LLDB. An alternative could be locate the JS heap bounds, perhaps via some PD data stored at Node start-up. My question was about the relative merits of investing in a GDB plugin vs the LLDB plugin. So there is an issue of what the plugin APIs support. There is a GDB vs LLDB command comparison here: http://lldb.llvm.org/lldb-gdb.html. |
@rnchamberlain well, technically we already have at least two LLDB plugins: https://github.com/indutny/llnode and https://github.com/tjfontaine/lldb-v8 . This |
@indutny thanks, corrected, and yours being the more recent and active of the two. Also you used the C++ API rather than the Python one, which could be better for sharing code with the mdb one? |
@rnchamberlain perhaps... :) |
@indutny @rnchamberlain I am currently using llnode as a quick daily tool, even if I fallback to use mdb in my VM when I need deeper analysis on the dumps. I would suggest that we create a repo and collaborate all on it, starting from creating a list of issues which represents the feature that we want to expose/rollout so that we can maybe democratically vote for priorities. @yunong shall we summon soon a quick catch-up with this topic on the agenda? |
@lucamaraschi I totally agree, guess if we want - I won't mind to move llnode to nodejs org. |
@indutny I guess that would be a great start (and a new beginning!). |
Is it already scheduled? |
@indutny re iterating allocated memory in LLDB you are right, there is no equivalent in the LLDB API for what we get with 'maintenance info sections' in GDB. We are looking at a work-around using readelf to get the memory ranges, but it really needs fixing in LLDB. Internally LLDB knows from the core file what memory is allocated, it just needs to expose that via one of the plugin APIs. |
I believe LLDB discards this info, but agree that it should fixed On Tuesday, April 12, 2016, Richard Chamberlain [email protected]
|
@indutny ProcessElfCore::DoReadMemory() seems to be using a saved array of memory chunks |
@rnchamberlain you are right, I thought it discards it everywhere, because it does this for Macho Cores. |
Gosh, nevermind. I don't know what I was looking at, but it indeed does read it in Mach-O cores too. |
I’ve prototyped a dumpobjects command based on llnode which scans the whole memory for anything that looks like a v8 heap object. (Much like the findjsobjects command in mdb_v8.) With this is it possible to get a simple set of totals of object by map and then using a second command (dumpinstances) list all the objects that use that map:
I need to work on the sizes and group but initially I wanted to confirm I could scan the memory and locate a sensible number of objects. It gives a similar object total to a heap dump generated at the same time. |
Woow! This looks awesome! I would love to take a look at the code! 😉 Thanks for sharing. On Monday, April 18, 2016, Howard Hellyer [email protected] wrote:
|
Pushed prototype here: https://github.com/hhellyer/llnode/tree/dumpobjects_prototype - please don't review the code too closely :-) |
Looks great! Let me know if I can help you debug llnode on your OSX. I'm an OSX user Could it be just a lldb headers version mismatch? On Tue, Apr 19, 2016 at 11:09 AM, Howard Hellyer [email protected]
|
Thanks, if I can't figure it out I'll ask in an issue on https://github.com/indutny/llnode to avoid cluttering this issue up. (I think it might be a mismatch of some kind, my lldb reports version 350 so it's probably either that or a C++ linking issue.) |
@hhellyer after investigation, it looks like it is compatible with 380, not 350... despite the version :( |
Yep, having just gone to the lengths of building the 380 release from source I can see that the newly built lldb gives a 350 version number: |
@Raynos any update on the Uber's implementation? |
LLDB 3.9 is now available, which has the @hhellyer enhancement to find all the memory ranges in a core dump without the need for his readelf script workaround. The 3.9 packages are here: http://apt.llvm.org/ The installation of LLDB 3.9 on ubuntu was a bit tricky, I found this earlier info useful: and I ended up with this (for ubuntu 14)
Then rebuild the @indutny project https://github.com/indutny/llnode against LLDB 3.9 and off we go:
|
@indutny has now moved llnode to nodejs org here: https://github.com/nodejs/llnode A table comparing commands available in the MDB and LLDB plugins is here: |
Closing due to inactivity. https://github.com/nodejs/llnode is a thing. If this needs to remain open please raise a new issue in https://github.com/nodejs/diagnostics. |
There was a conversation about post mortem on nodejs/node where an engineer did not know how mdb worked because he's never run a smartos vm. This started me thinking about Linux support.
one of the uber engineers ported a subset of mdb to Linux.
He observed that mdb_v8 is just a c program with function calls into mdb and he just had to implement the mdb functions for Linux outside of mdb.
This creates a standalone Linux binary that can debug cores.
The code is in a really hacky place and I don't think uber or the engineer has time to polish it up to a good state.
However we would love to share this proof of concept (currently private).
The text was updated successfully, but these errors were encountered: