Permalink
Browse files

llscan: initial

  • Loading branch information...
hhellyer authored and indutny committed Jun 17, 2016
1 parent e8874ce commit c517e0ca09b714a487850ca74730d89f4a1c321d
Showing with 704 additions and 1 deletion.
  1. +1 −0 llnode.gyp
  2. +43 −0 scripts/otool2segments.py
  3. +43 −0 scripts/readelf2segments.py
  4. +20 −1 src/llnode.cc
  5. +366 −0 src/llscan.cc
  6. +129 −0 src/llscan.h
  7. +96 −0 src/llv8.cc
  8. +6 −0 src/llv8.h
View
@@ -19,6 +19,7 @@
"src/llnode.cc",
"src/llv8.cc",
"src/llv8-constants.cc",
"src/llscan.cc",
],
"conditions": [
View
@@ -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()
@@ -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()
View
@@ -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 {
@@ -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;
}
Oops, something went wrong.

0 comments on commit c517e0c

Please sign in to comment.