forked from OSchip/llvm-project
Remove the "-x" from the finish-swig-Python-LLDB.sh shell options so it doesn't print out all of the commands when executing the shell script.
Cleaned up the lldb.utils.symbolication, lldb.macosx.heap and lldb.macosx.crashlog. The lldb.macosx.heap can now build a dylib for the current triple into a temp directory and use it from there. llvm-svn: 155577
This commit is contained in:
parent
6fe744cc38
commit
d712ef0fd7
|
@ -1,36 +1,46 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Be sure to add the python path that points to the LLDB shared library.
|
||||
# This module is designed to live inside the "lldb" python package
|
||||
# in the "lldb.macosx" package. To use this in the embedded python
|
||||
# interpreter using "lldb" just import it:
|
||||
#
|
||||
# # To use this in the embedded python interpreter using "lldb" just
|
||||
# import it with the full path using the "command script import"
|
||||
# command
|
||||
# (lldb) command script import /path/to/heap.py
|
||||
#
|
||||
# For the shells csh, tcsh:
|
||||
# ( setenv PYTHONPATH /path/to/LLDB.framework/Resources/Python ; ./heap.py )
|
||||
#
|
||||
# For the shells sh, bash:
|
||||
# PYTHONPATH=/path/to/LLDB.framework/Resources/Python ./heap.py
|
||||
# (lldb) script import lldb.macosx.heap
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
import lldb
|
||||
import commands
|
||||
import optparse
|
||||
import os
|
||||
import os.path
|
||||
import shlex
|
||||
import string
|
||||
import tempfile
|
||||
import lldb.utils.symbolication
|
||||
|
||||
g_libheap_dylib_dir = None
|
||||
g_libheap_dylib_dict = dict()
|
||||
|
||||
def load_dylib():
|
||||
if lldb.target:
|
||||
python_module_directory = os.path.dirname(__file__)
|
||||
heap_code_directory = python_module_directory + '/heap'
|
||||
libheap_dylib_path = heap_code_directory + '/heap/libheap.dylib'
|
||||
global g_libheap_dylib_dir
|
||||
global g_libheap_dylib_dict
|
||||
triple = lldb.target.triple
|
||||
if triple not in g_libheap_dylib_dict:
|
||||
if not g_libheap_dylib_dir:
|
||||
g_libheap_dylib_dir = tempfile.mkdtemp()
|
||||
triple_dir = g_libheap_dylib_dir + '/' + triple
|
||||
if not os.path.exists(triple_dir):
|
||||
os.mkdir(triple_dir)
|
||||
libheap_dylib_path = triple_dir + '/libheap.dylib'
|
||||
g_libheap_dylib_dict[triple] = libheap_dylib_path
|
||||
libheap_dylib_path = g_libheap_dylib_dict[triple]
|
||||
if not os.path.exists(libheap_dylib_path):
|
||||
make_command = '(cd "%s" ; make)' % heap_code_directory
|
||||
print make_command
|
||||
print commands.getoutput(make_command)
|
||||
heap_code_directory = os.path.dirname(__file__) + '/heap'
|
||||
make_command = '(cd "%s" ; make EXE="%s" ARCH=%s)' % (heap_code_directory, libheap_dylib_path, string.split(triple, '-')[0])
|
||||
#print make_command
|
||||
make_output = commands.getoutput(make_command)
|
||||
#print make_output
|
||||
if os.path.exists(libheap_dylib_path):
|
||||
libheap_dylib_spec = lldb.SBFileSpec(libheap_dylib_path)
|
||||
if lldb.target.FindModule(libheap_dylib_spec):
|
||||
|
@ -77,7 +87,7 @@ def heap_search(options, arg_str):
|
|||
default_memory_format = "Y" # 'Y' is "bytes with ASCII" format
|
||||
#memory_chunk_size = 1
|
||||
if options.type == 'pointer':
|
||||
expr = 'find_pointer_in_heap((void *)%s)' % arg_str
|
||||
expr = 'find_pointer_in_heap((void *)%s)' % (arg_str)
|
||||
arg_str_description = 'malloc block containing pointer %s' % arg_str
|
||||
default_memory_format = "A" # 'A' is "address" format
|
||||
#memory_chunk_size = lldb.process.GetAddressByteSize()
|
||||
|
@ -285,13 +295,15 @@ def malloc_info(debugger, command, result, dict):
|
|||
else:
|
||||
print 'error: no c string arguments were given to search for'
|
||||
|
||||
def __lldb_init_module (debugger, dict):
|
||||
# This initializer is being run from LLDB in the embedded command interpreter
|
||||
# Add any commands contained in this module to LLDB
|
||||
debugger.HandleCommand('command script add -f heap.ptr_refs ptr_refs')
|
||||
debugger.HandleCommand('command script add -f heap.cstr_refs cstr_refs')
|
||||
debugger.HandleCommand('command script add -f heap.malloc_info malloc_info')
|
||||
print '"ptr_refs", "cstr_refs", and "malloc_info" commands have been installed, use the "--help" options on these commands for detailed help.'
|
||||
if __name__ == '__main__':
|
||||
lldb.debugger = lldb.SBDebugger.Create()
|
||||
|
||||
# This initializer is being run from LLDB in the embedded command interpreter
|
||||
# Add any commands contained in this module to LLDB
|
||||
lldb.debugger.HandleCommand('command script add -f lldb.macosx.heap.ptr_refs ptr_refs')
|
||||
lldb.debugger.HandleCommand('command script add -f lldb.macosx.heap.cstr_refs cstr_refs')
|
||||
lldb.debugger.HandleCommand('command script add -f lldb.macosx.heap.malloc_info malloc_info')
|
||||
print '"ptr_refs", "cstr_refs", and "malloc_info" commands have been installed, use the "--help" options on these commands for detailed help.'
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,42 +7,27 @@
|
|||
#----------------------------------------------------------------------
|
||||
# Change any build/tool options needed
|
||||
#----------------------------------------------------------------------
|
||||
DS := /usr/bin/dsymutil
|
||||
CFLAGS ?=-arch x86_64 -arch i386 -gdwarf-2 -O0
|
||||
CPLUSPLUSFLAGS +=$(CFLAGS)
|
||||
CPPFLAGS +=$(CFLAGS)
|
||||
LDFLAGS = $(CFLAGS) -install_name "@executable_path/libheap.dylib" -dynamiclib
|
||||
CXX := $(shell xcrun -find clang++)
|
||||
LD := $(CXX)
|
||||
TEMPS =
|
||||
EXE=libheap.dylib
|
||||
DSYM=$(EXE).dSYM
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Make the dSYM file from the executable
|
||||
#----------------------------------------------------------------------
|
||||
$(DSYM) : $(EXE)
|
||||
$(DS) -o "$(DSYM)" "$(EXE)"
|
||||
ARCH ?= x86_64
|
||||
CFLAGS ?=-arch $(ARCH) -gdwarf-2 -O0
|
||||
CXX ?= $(shell xcrun -find clang++)
|
||||
EXE ?= libheap.dylib
|
||||
DSYM ?= $(EXE).dSYM
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Compile the executable from all the objects (default rule) with no
|
||||
# dsym file.
|
||||
#----------------------------------------------------------------------
|
||||
$(EXE) : heap_find.o
|
||||
$(LD) $(LDFLAGS) heap_find.o -o "$(EXE)"
|
||||
|
||||
heap_find.o : heap_find.cpp
|
||||
$(CXX) $(CFLAGS) -c heap_find.cpp
|
||||
$(EXE) : heap_find.cpp
|
||||
$(CXX) $(CFLAGS) -install_name "@executable_path/libheap.dylib" -dynamiclib heap_find.cpp -o "$(EXE)"
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Include all of the makefiles for each source file so we don't have
|
||||
# to manually track all of the prerequisites for each source file.
|
||||
#----------------------------------------------------------------------
|
||||
.PHONY: clean
|
||||
dsym: $(DSYM)
|
||||
all: $(EXE) $(DSYM)
|
||||
all: $(EXE)
|
||||
clean:
|
||||
rm -rf "$(EXE)" "$(DSYM)" heap_find.o $(TEMPS)
|
||||
rm -rf "$(EXE)" "$(DSYM)"
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ class CrashLog(lldb.utils.symbolication.Symbolicator):
|
|||
if self.resolved_path:
|
||||
# Don't load a module twice...
|
||||
return True
|
||||
print 'Locating %s %s...' % (self.uuid, self.path),
|
||||
print 'Getting symbols for %s %s...' % (self.uuid, self.path),
|
||||
if os.path.exists(self.dsymForUUIDBinary):
|
||||
dsym_for_uuid_command = '%s %s' % (self.dsymForUUIDBinary, self.uuid)
|
||||
s = commands.getoutput(dsym_for_uuid_command)
|
||||
|
@ -147,10 +147,10 @@ class CrashLog(lldb.utils.symbolication.Symbolicator):
|
|||
return False
|
||||
if (self.resolved_path and os.path.exists(self.resolved_path)) or (self.path and os.path.exists(self.path)):
|
||||
print 'ok'
|
||||
if self.resolved_path:
|
||||
print ' exe = "%s"' % self.resolved_path
|
||||
if self.symfile:
|
||||
print ' dsym = "%s"' % self.symfile
|
||||
# if self.resolved_path:
|
||||
# print ' exe = "%s"' % self.resolved_path
|
||||
# if self.symfile:
|
||||
# print ' dsym = "%s"' % self.symfile
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -424,7 +424,7 @@ be disassembled and lookups can be performed using the addresses found in the cr
|
|||
if err:
|
||||
print err
|
||||
else:
|
||||
print 'loaded %s' % image
|
||||
#print 'loaded %s' % image
|
||||
loaded_images.append(image)
|
||||
|
||||
for thread in crash_log.threads:
|
||||
|
|
|
@ -288,7 +288,6 @@ class Image:
|
|||
if not self.module:
|
||||
self.locate_module_and_debug_symbols ()
|
||||
resolved_path = self.get_resolved_path()
|
||||
print 'target.AddModule (path="%s", arch="%s", uuid=%s, symfile="%s")' % (resolved_path, self.arch, self.uuid, self.symfile)
|
||||
self.module = target.AddModule (resolved_path, self.arch, self.uuid)#, self.symfile)
|
||||
if not self.module:
|
||||
return 'error: unable to get module for (%s) "%s"' % (self.arch, self.get_resolved_path())
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#! /bin/sh -x
|
||||
#! /bin/sh
|
||||
|
||||
# finish-swig-Python.sh
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue