Skip to content

Commit

Permalink
llscan: initial
Browse files Browse the repository at this point in the history
  • Loading branch information
hhellyer authored and indutny committed Jun 28, 2016
1 parent e8874ce commit c517e0c
Show file tree
Hide file tree
Showing 8 changed files with 704 additions and 1 deletion.
1 change: 1 addition & 0 deletions llnode.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"src/llnode.cc",
"src/llv8.cc",
"src/llv8-constants.cc",
"src/llscan.cc",
],

"conditions": [
Expand Down
43 changes: 43 additions & 0 deletions scripts/otool2segments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python
'''
Created on 7 Apr 2016
@author: hhellyer
'''
import sys,os,subprocess

OTOOL_COMMAND = "otool -l {0}"

# Grab the details of the memory ranges in the process from otool.
def main():
if( len(sys.argv) < 2 ):
print("Usage " + sys.argv[0] + " <core_file>")
sys.exit(1)
core_file = sys.argv[1]

otool_proc = subprocess.Popen(
OTOOL_COMMAND.format(core_file), shell=True, bufsize=1,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
(otool_stdin, otool_stdout) = (otool_proc.stdin, otool_proc.stdout)

reading_segment = False
vaddress = ""

for line in otool_stdout:
line = line.strip()
if not line.startswith("vmaddr") and not reading_segment:
continue
elif line.startswith("vmaddr"):
# Might need to filer out segments that have a file offset of 0
# (ie segments that aren't in the core!)
reading_segment = True
(name, vaddress) = line.split()
elif line.startswith("vmsize") and reading_segment:
reading_segment = False
memsize = line.split()[1]
# Simple format "address size", both in hex
print("{0} {1}".format(vaddress, memsize))
vaddress = ""

if __name__ == '__main__':
main()
43 changes: 43 additions & 0 deletions scripts/readelf2segments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python
'''
Created on 7 Apr 2016
@author: hhellyer
'''
import sys,os,subprocess

READELF_COMMAND = "readelf --segments {0}"

# Grab the details of the memory ranges in the process from readelf.
def main():
if( len(sys.argv) < 2 ):
print("Usage " + sys.argv[0] + " <core_file>")
sys.exit(1)
core_file = sys.argv[1]

readelf_proc = subprocess.Popen(
READELF_COMMAND.format(core_file), shell=True, bufsize=1,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
(readelf_stdin, readelf_stdout) = (readelf_proc.stdin, readelf_proc.stdout)

reading_segment = False
vaddress = ""

for line in readelf_stdout:
line = line.strip()
if not line.startswith("LOAD") and not reading_segment:
continue
elif line.startswith("LOAD"):
# Might need to filer out segments that have a file offset of 0
# (ie segments that aren't in the core!)
reading_segment = True
(type, offset, vaddress, paddr) = line.split()
elif reading_segment:
reading_segment = False
memsize = line.split()[1]
# Simple format "address size", both in hex
print("{0} {1}".format(vaddress, memsize))
vaddress = ""

if __name__ == '__main__':
main()
21 changes: 20 additions & 1 deletion src/llnode.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include <errno.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>

#include <lldb/API/SBExpressionOptions.h>

#include "src/llnode.h"
#include "src/llscan.h"
#include "src/llv8.h"

namespace llnode {
Expand Down Expand Up @@ -282,6 +283,24 @@ bool PluginInitialize(SBDebugger d) {
interpreter.AddCommand("jssource", new llnode::ListCmd(),
"Alias for `v8 source list`");

v8.AddCommand("findjsobjects", new llnode::FindObjectsCmd(),
"List all object types and instance counts grouped by map and "
"sorted by instance count.\n"
"Requires `LLNODE_RANGESFILE` environment variable to be set "
"to a file containing memory ranges for the core file being "
"debugged.");

interpreter.AddCommand("findjsobjects", new llnode::FindObjectsCmd(),
"Alias for `v8 findjsobjects`");

v8.AddCommand("findjsinstances", new llnode::FindInstancesCmd(),
"List all objects which share the specified map.\n"
"Accepts the same options as `v8 inspect`");

interpreter.AddCommand("findjsinstances", new llnode::FindInstancesCmd(),
"List all objects which share the specified map.\n");


return true;
}

Expand Down
Loading

0 comments on commit c517e0c

Please sign in to comment.