[Lldb-commits] [lldb] r149489 - in /lldb/trunk: scripts/ scripts/Python/interface/ source/Interpreter/ source/Symbol/
Greg Clayton
gclayton at apple.com
Wed Feb 1 00:09:33 PST 2012
Author: gclayton
Date: Wed Feb 1 02:09:32 2012
New Revision: 149489
URL: http://llvm.org/viewvc/llvm-project?rev=149489&view=rev
Log:
Added many more python convenience accessors:
You can now access a frame in a thread using:
lldb.SBThread.frame[int] -> lldb.SBFrame object for a frame in a thread
Where "int" is an integer index. You can also access a list object with all of
the frames using:
lldb.SBThread.frames => list() of lldb.SBFrame objects
All SB objects that give out SBAddress objects have properties named "addr"
lldb.SBInstructionList now has the following convenience accessors for len() and
instruction access using an index:
insts = lldb.frame.function.instructions
for idx in range(len(insts)):
print insts[idx]
Instruction lists can also lookup an isntruction using a lldb.SBAddress as the key:
pc_inst = lldb.frame.function.instructions[lldb.frame.addr]
lldb.SBProcess now exposes:
lldb.SBProcess.is_alive => BOOL Check if a process is exists and is alive
lldb.SBProcess.is_running => BOOL check if a process is running (or stepping):
lldb.SBProcess.is_running => BOOL check if a process is currently stopped or crashed:
lldb.SBProcess.thread[int] => lldb.SBThreads for a given "int" zero based index
lldb.SBProcess.threads => list() containing all lldb.SBThread objects in a process
SBInstruction now exposes:
lldb.SBInstruction.mnemonic => python string for instruction mnemonic
lldb.SBInstruction.operands => python string for instruction operands
lldb.SBInstruction.command => python string for instruction comment
SBModule now exposes:
lldb.SBModule.uuid => uuid.UUID(), an UUID object from the "uuid" python module
lldb.SBModule.symbol[int] => lldb.Symbol, lookup symbol by zero based index
lldb.SBModule.symbol[str] => list() of lldb.Symbol objects that match "str"
lldb.SBModule.symbol[re] => list() of lldb.Symbol objecxts that match the regex
lldb.SBModule.symbols => list() of all symbols in a module
SBAddress objects can now access the current load address with the "lldb.SBAddress.load_addr"
property. The current "lldb.target" will be used to try and resolve the load address.
Load addresses can also be set using this accessor:
addr = lldb.SBAddress()
addd.load_addr = 0x123023
Then you can check the section and offset to see if the address got resolved.
SBTarget now exposes:
lldb.SBTarget.module[int] => lldb.SBModule from zero based module index
lldb.SBTarget.module[str] => lldb.SBModule by basename or fullpath or uuid string
lldb.SBTarget.module[uuid.UUID()] => lldb.SBModule whose UUID matches
lldb.SBTarget.module[re] => list() of lldb.SBModule objects that match the regex
lldb.SBTarget.modules => list() of all lldb.SBModule objects in the target
SBSymbol now exposes:
lldb.SBSymbol.name => python string for demangled symbol name
lldb.SBSymbol.mangled => python string for mangled symbol name or None if there is none
lldb.SBSymbol.type => lldb.eSymbolType enum value
lldb.SBSymbol.addr => SBAddress object that represents the start address for this symbol (if there is one)
lldb.SBSymbol.end_addr => SBAddress for the end address of the symbol (if there is one)
lldb.SBSymbol.prologue_size => pythin int containing The size of the prologue in bytes
lldb.SBSymbol.instructions => SBInstructionList containing all instructions for this symbol
SBFunction now also has these new properties in addition to what is already has:
lldb.SBFunction.addr => SBAddress object that represents the start address for this function
lldb.SBFunction.end_addr => SBAddress for the end address of the function
lldb.SBFunction.instructions => SBInstructionList containing all instructions for this function
SBFrame now exposes the SBAddress for the frame:
lldb.SBFrame.addr => SBAddress which is the section offset address for the current frame PC
These are all in addition to what was already added. Documentation and website
updates coming soon.
Modified:
lldb/trunk/scripts/Python/interface/SBAddress.i
lldb/trunk/scripts/Python/interface/SBFileSpec.i
lldb/trunk/scripts/Python/interface/SBFrame.i
lldb/trunk/scripts/Python/interface/SBFunction.i
lldb/trunk/scripts/Python/interface/SBInstruction.i
lldb/trunk/scripts/Python/interface/SBInstructionList.i
lldb/trunk/scripts/Python/interface/SBLineEntry.i
lldb/trunk/scripts/Python/interface/SBModule.i
lldb/trunk/scripts/Python/interface/SBProcess.i
lldb/trunk/scripts/Python/interface/SBSymbol.i
lldb/trunk/scripts/Python/interface/SBTarget.i
lldb/trunk/scripts/Python/interface/SBThread.i
lldb/trunk/scripts/lldb.swig
lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
lldb/trunk/source/Symbol/Symbol.cpp
Modified: lldb/trunk/scripts/Python/interface/SBAddress.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBAddress.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBAddress.i (original)
+++ lldb/trunk/scripts/Python/interface/SBAddress.i Wed Feb 1 02:09:32 2012
@@ -129,6 +129,28 @@
GetLineEntry ();
%pythoncode %{
+ def __get_load_addr_property__ (self):
+ '''Get the load address for a lldb.SBAddress using the current target.'''
+ return self.GetLoadAddress (target)
+
+ def __set_load_addr_property__ (self, load_addr):
+ '''Set the load address for a lldb.SBAddress using the current target.'''
+ return self.SetLoadAddress (load_addr, target)
+
+ def __int__(self):
+ '''Convert an address to a load address if there is a process and that
+ process is alive, or to a file address otherwise.'''
+ if process.is_alive:
+ return self.GetLoadAddress (target)
+ else:
+ return self.GetFileAddress ()
+
+ def __oct__(self):
+ return '%o' % int(self)
+
+ def __hex__(self):
+ return '0x%x' % int(self)
+
__swig_getmethods__["module"] = GetModule
if _newclass: x = property(GetModule, None)
@@ -156,6 +178,10 @@
__swig_getmethods__["file_addr"] = GetFileAddress
if _newclass: x = property(GetFileAddress, None)
+ __swig_getmethods__["load_addr"] = __get_load_addr_property__
+ __swig_setmethods__["load_addr"] = __set_load_addr_property__
+ if _newclass: x = property(__get_load_addr_property__, __set_load_addr_property__)
+
%}
};
Modified: lldb/trunk/scripts/Python/interface/SBFileSpec.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFileSpec.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBFileSpec.i (original)
+++ lldb/trunk/scripts/Python/interface/SBFileSpec.i Wed Feb 1 02:09:32 2012
@@ -68,6 +68,20 @@
GetDescription (lldb::SBStream &description) const;
%pythoncode %{
+ def __get_fullpath__(self):
+ spec_dir = self.GetDirectory()
+ spec_file = self.GetFilename()
+ if spec_dir and spec_file:
+ return '%s/%s' % (spec_dir, spec_file)
+ elif spec_dir:
+ return spec_dir
+ elif spec_file:
+ return spec_file
+ return None
+
+ __swig_getmethods__["fullpath"] = __get_fullpath__
+ if _newclass: x = property(__get_fullpath__, None)
+
__swig_getmethods__["basename"] = GetFilename
if _newclass: x = property(GetFilename, None)
Modified: lldb/trunk/scripts/Python/interface/SBFrame.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFrame.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBFrame.i (original)
+++ lldb/trunk/scripts/Python/interface/SBFrame.i Wed Feb 1 02:09:32 2012
@@ -223,6 +223,9 @@
__swig_setmethods__["pc"] = SetPC
if _newclass: x = property(GetPC, SetPC)
+ __swig_getmethods__["addr"] = GetPCAddress
+ if _newclass: x = property(GetPCAddress, None)
+
__swig_getmethods__["fp"] = GetFP
if _newclass: x = property(GetFP, None)
Modified: lldb/trunk/scripts/Python/interface/SBFunction.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFunction.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBFunction.i (original)
+++ lldb/trunk/scripts/Python/interface/SBFunction.i Wed Feb 1 02:09:32 2012
@@ -78,13 +78,16 @@
GetDescription (lldb::SBStream &description);
%pythoncode %{
+ def get_instructions_from_current_target (self):
+ return self.GetInstructions (target)
+
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
__swig_getmethods__["mangled"] = GetMangledName
if _newclass: x = property(GetMangledName, None)
- __swig_getmethods__["start_addr"] = GetStartAddress
+ __swig_getmethods__["addr"] = GetStartAddress
if _newclass: x = property(GetStartAddress, None)
__swig_getmethods__["end_addr"] = GetEndAddress
@@ -92,7 +95,10 @@
__swig_getmethods__["prologue_size"] = GetPrologueByteSize
if _newclass: x = property(GetPrologueByteSize, None)
-
+
+ __swig_getmethods__["instructions"] = get_instructions_from_current_target
+ if _newclass: x = property(get_instructions_from_current_target, None)
+
%}
};
Modified: lldb/trunk/scripts/Python/interface/SBInstruction.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBInstruction.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBInstruction.i (original)
+++ lldb/trunk/scripts/Python/interface/SBInstruction.i Wed Feb 1 02:09:32 2012
@@ -64,6 +64,26 @@
TestEmulation (lldb::SBStream &output_stream, const char *test_file);
%pythoncode %{
+ def __mnemonic_property__ (self):
+ return self.GetMnemonic (target)
+ def __operands_property__ (self):
+ return self.GetOperands (target)
+ def __comment_property__ (self):
+ return self.GetComment (target)
+ def __file_addr_property__ (self):
+ return self.GetAddress ().GetFileAddress()
+ def __load_adrr_property__ (self):
+ return self.GetComment (target)
+
+ __swig_getmethods__["mnemonic"] = __mnemonic_property__
+ if _newclass: x = property(__mnemonic_property__, None)
+
+ __swig_getmethods__["operands"] = __operands_property__
+ if _newclass: x = property(__operands_property__, None)
+
+ __swig_getmethods__["comment"] = __comment_property__
+ if _newclass: x = property(__comment_property__, None)
+
__swig_getmethods__["addr"] = GetAddress
if _newclass: x = property(GetAddress, None)
Modified: lldb/trunk/scripts/Python/interface/SBInstructionList.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBInstructionList.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBInstructionList.i (original)
+++ lldb/trunk/scripts/Python/interface/SBInstructionList.i Wed Feb 1 02:09:32 2012
@@ -58,6 +58,34 @@
bool
DumpEmulationForAllInstructions (const char *triple);
+
+ %pythoncode %{
+ def __len__(self):
+ '''Access len of the instruction list.'''
+ return self.GetSize();
+
+ def __getitem__(self, key):
+ '''Access instructions by integer index.'''
+ if type(key) is int:
+ # Find an instruction by index
+ if key < len(self):
+ return self.GetInstructionAtIndex(key)
+ elif type(key) is SBAddress:
+ # Find an instruction using a lldb.SBAddress object
+ lookup_file_addr = key.file_addr
+ closest_inst = None
+ for idx in range(self.GetSize()):
+ inst = self.GetInstructionAtIndex(idx)
+ inst_file_addr = inst.addr.file_addr
+ if inst_file_addr == lookup_file_addr:
+ return inst
+ elif inst_file_addr > lookup_file_addr:
+ return closest_inst
+ else:
+ closest_inst = inst
+ return None
+ %}
+
};
} // namespace lldb
Modified: lldb/trunk/scripts/Python/interface/SBLineEntry.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBLineEntry.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBLineEntry.i (original)
+++ lldb/trunk/scripts/Python/interface/SBLineEntry.i Wed Feb 1 02:09:32 2012
@@ -87,7 +87,7 @@
__swig_getmethods__["column"] = GetColumn
if _newclass: x = property(GetColumn, None)
- __swig_getmethods__["start_addr"] = GetStartAddress
+ __swig_getmethods__["addr"] = GetStartAddress
if _newclass: x = property(GetStartAddress, None)
__swig_getmethods__["end_addr"] = GetEndAddress
Modified: lldb/trunk/scripts/Python/interface/SBModule.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBModule.i (original)
+++ lldb/trunk/scripts/Python/interface/SBModule.i Wed Feb 1 02:09:32 2012
@@ -247,15 +247,82 @@
GetTriple ();
%pythoncode %{
+ class symbols_access(object):
+ re_type = type(re.compile('.'))
+ '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
+ def __init__(self, sbmodule):
+ self.sbmodule = sbmodule
+
+ def __len__(self):
+ if self.sbmodule:
+ return self.sbmodule.GetNumSymbols()
+ return 0
+
+ def __getitem__(self, key):
+ count = self.sbmodule.GetNumSymbols()
+ if type(key) is int:
+ if key < count:
+ return self.sbmodule.GetSymbolAtIndex(key)
+ elif type(key) is str:
+ matches = []
+ for idx in range(count):
+ symbol = self.sbmodule.GetSymbolAtIndex(idx)
+ if symbol.name == key or symbol.mangled == key:
+ matches.append(symbol)
+ if len(matches):
+ return matches
+ elif isinstance(key, self.re_type):
+ matches = []
+ for idx in range(count):
+ symbol = self.sbmodule.GetSymbolAtIndex(idx)
+ added = False
+ name = symbol.name
+ if name:
+ re_match = key.search(name)
+ if re_match:
+ matches.append(symbol)
+ added = True
+ if not added:
+ mangled = symbol.mangled
+ if mangled:
+ re_match = key.search(mangled)
+ if re_match:
+ matches.append(symbol)
+ if len(matches):
+ return matches
+ else:
+ print "error: unsupported item type: %s" % type(key)
+ return None
+
+ def get_symbols_access_object(self):
+ '''An accessor function that retuns a symbols_access() object which allows lazy module array access.'''
+ return self.symbols_access (self)
+
+ def get_symbols_array(self):
+ '''An accessor function that retuns an array object that contains all modules in this target object.'''
+ symbols = []
+ for idx in range(self.GetNumSymbols()):
+ symbols.append(self.GetSymbolAtIndex(idx))
+ return symbols
+
+ __swig_getmethods__["symbols"] = get_symbols_array
+ if _newclass: x = property(get_symbols_array, None)
+
+ __swig_getmethods__["symbol"] = get_symbols_access_object
+ if _newclass: x = property(get_symbols_access_object, None)
+
+ def get_uuid(self):
+ return uuid.UUID (self.GetUUIDString())
+
+ __swig_getmethods__["uuid"] = get_uuid
+ if _newclass: x = property(get_uuid, None)
+
__swig_getmethods__["file"] = GetFileSpec
if _newclass: x = property(GetFileSpec, None)
__swig_getmethods__["platform_file"] = GetPlatformFileSpec
if _newclass: x = property(GetPlatformFileSpec, None)
- __swig_getmethods__["uuid"] = GetUUIDString
- if _newclass: x = property(GetUUIDString, None)
-
__swig_getmethods__["byte_order"] = GetByteOrder
if _newclass: x = property(GetByteOrder, None)
Modified: lldb/trunk/scripts/Python/interface/SBProcess.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBProcess.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBProcess.i (original)
+++ lldb/trunk/scripts/Python/interface/SBProcess.i Wed Feb 1 02:09:32 2012
@@ -282,6 +282,73 @@
UnloadImage (uint32_t image_token);
%pythoncode %{
+ def __get_is_alive__(self):
+ '''Returns "True" if the process is currently alive, "False" otherwise'''
+ s = self.GetState()
+ if (s == eStateAttaching or
+ s == eStateLaunching or
+ s == eStateStopped or
+ s == eStateRunning or
+ s == eStateStepping or
+ s == eStateCrashed or
+ s == eStateSuspended):
+ return True
+ return False
+
+ def __get_is_running__(self):
+ '''Returns "True" if the process is currently running, "False" otherwise'''
+ state = self.GetState()
+ if state == eStateRunning or state == eStateStepping:
+ return True
+ return False
+
+ def __get_is_running__(self):
+ '''Returns "True" if the process is currently stopped, "False" otherwise'''
+ state = self.GetState()
+ if state == eStateStopped or state == eStateCrashed or state == eStateSuspended:
+ return True
+ return False
+
+ class thread_array_access(object):
+ '''A helper object that will lazily hand out thread for a process when supplied an index.'''
+ def __init__(self, sbprocess):
+ self.sbprocess = sbprocess
+
+ def __len__(self):
+ if self.sbprocess: return self.sbprocess.GetNumThreads()
+ return 0
+
+ def __getitem__(self, key):
+ if type(key) is int and key < len(self):
+ return self.sbprocess.GetThreadAtIndex(key)
+ return None
+
+ def get_thread_array_access_object(self):
+ '''An accessor function that retuns a thread_array_access() object which allows lazy thread array access.'''
+ return self.thread_array_access (self)
+
+ def get_process_thread_list(self):
+ '''An accessor function that retuns an array object that contains all threads in this process object.'''
+ threads = []
+ for idx in range(self.GetNumThreads()):
+ threads.append(GetThreadAtIndex(idx))
+ return threads
+
+ __swig_getmethods__["threads"] = get_process_thread_list
+ if _newclass: x = property(get_process_thread_list, None)
+
+ __swig_getmethods__["thread"] = get_thread_array_access_object
+ if _newclass: x = property(get_thread_array_access_object, None)
+
+ __swig_getmethods__["is_alive"] = __get_is_alive__
+ if _newclass: x = property(__get_is_alive__, None)
+
+ __swig_getmethods__["is_running"] = __get_is_running__
+ if _newclass: x = property(__get_is_running__, None)
+
+ __swig_getmethods__["is_stopped"] = __get_is_running__
+ if _newclass: x = property(__get_is_running__, None)
+
__swig_getmethods__["id"] = GetProcessID
if _newclass: x = property(GetProcessID, None)
Modified: lldb/trunk/scripts/Python/interface/SBSymbol.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSymbol.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBSymbol.i (original)
+++ lldb/trunk/scripts/Python/interface/SBSymbol.i Wed Feb 1 02:09:32 2012
@@ -52,6 +52,34 @@
bool
GetDescription (lldb::SBStream &description);
+
+ %pythoncode %{
+ def get_instructions_from_current_target (self):
+ return self.GetInstructions (target)
+
+ __swig_getmethods__["name"] = GetName
+ if _newclass: x = property(GetName, None)
+
+ __swig_getmethods__["mangled"] = GetMangledName
+ if _newclass: x = property(GetMangledName, None)
+
+ __swig_getmethods__["type"] = GetType
+ if _newclass: x = property(GetType, None)
+
+ __swig_getmethods__["addr"] = GetStartAddress
+ if _newclass: x = property(GetStartAddress, None)
+
+ __swig_getmethods__["end_addr"] = GetEndAddress
+ if _newclass: x = property(GetEndAddress, None)
+
+ __swig_getmethods__["prologue_size"] = GetPrologueByteSize
+ if _newclass: x = property(GetPrologueByteSize, None)
+
+ __swig_getmethods__["instructions"] = get_instructions_from_current_target
+ if _newclass: x = property(get_instructions_from_current_target, None)
+
+ %}
+
};
} // namespace lldb
Modified: lldb/trunk/scripts/Python/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/Python/interface/SBTarget.i Wed Feb 1 02:09:32 2012
@@ -487,6 +487,73 @@
GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
%pythoncode %{
+ class modules_access(object):
+ '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
+ def __init__(self, sbtarget):
+ self.sbtarget = sbtarget
+
+ def __len__(self):
+ if self.sbtarget:
+ return self.sbtarget.GetNumModules()
+ return 0
+
+ def __getitem__(self, key):
+ num_modules = self.sbtarget.GetNumModules()
+ if type(key) is int:
+ if key < num_modules:
+ return self.sbtarget.GetModuleAtIndex(key)
+ elif type(key) is str:
+ if key.find('/') == -1:
+ for idx in range(num_modules):
+ module = self.sbtarget.GetModuleAtIndex(idx)
+ if module.file.basename == key:
+ return module
+ else:
+ for idx in range(num_modules):
+ module = self.sbtarget.GetModuleAtIndex(idx)
+ if module.file.fullpath == key:
+ return module
+ # See if the string is a UUID
+ the_uuid = uuid.UUID(key)
+ if the_uuid:
+ for idx in range(num_modules):
+ module = self.sbtarget.GetModuleAtIndex(idx)
+ if module.uuid == the_uuid:
+ return module
+ elif type(key) is uuid.UUID:
+ for idx in range(num_modules):
+ module = self.sbtarget.GetModuleAtIndex(idx)
+ if module.uuid == key:
+ return module
+ elif type(key) is re.SRE_Pattern:
+ matching_modules = []
+ for idx in range(num_modules):
+ module = self.sbtarget.GetModuleAtIndex(idx)
+ re_match = key.search(module.path.fullpath)
+ if re_match:
+ matching_modules.append(module)
+ return matching_modules
+ else:
+ print "error: unsupported item type: %s" % type(key)
+ return None
+
+ def get_modules_access_object(self):
+ '''An accessor function that retuns a modules_access() object which allows lazy module array access.'''
+ return self.modules_access (self)
+
+ def get_modules_array(self):
+ '''An accessor function that retuns an array object that contains all modules in this target object.'''
+ modules = []
+ for idx in range(self.GetNumModules()):
+ modules.append(self.GetModuleAtIndex(idx))
+ return modules
+
+ __swig_getmethods__["modules"] = get_modules_array
+ if _newclass: x = property(get_modules_array, None)
+
+ __swig_getmethods__["module"] = get_modules_access_object
+ if _newclass: x = property(get_modules_access_object, None)
+
__swig_getmethods__["process"] = GetProcess
if _newclass: x = property(GetProcess, None)
Modified: lldb/trunk/scripts/Python/interface/SBThread.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBThread.i?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBThread.i (original)
+++ lldb/trunk/scripts/Python/interface/SBThread.i Wed Feb 1 02:09:32 2012
@@ -175,13 +175,32 @@
GetDescription (lldb::SBStream &description) const;
%pythoncode %{
+ class frame_array_access(object):
+ '''A helper object that will lazily hand out frames for a thread when supplied an index.'''
+ def __init__(self, sbthread):
+ self.sbthread = sbthread
+
+ def __len__(self):
+ if self.sbthread:
+ return self.sbthread.GetNumFrames()
+ return 0
+
+ def __getitem__(self, key):
+ if type(key) is int and key < self.sbthread.GetNumFrames():
+ return self.sbthread.GetFrameAtIndex(key)
+ return None
+
+ def get_frame_array_access_object(self):
+ '''An accessor function that retuns a frame_array_access() object which allows lazy frame array access.'''
+ return self.frame_array_access (self)
+
def get_thread_frames(self):
+ '''An accessor function that retuns an array object that contains all frames in this thread object.'''
frames = []
for frame in self:
frames.append(frame)
return frames
-
-
+
__swig_getmethods__["id"] = GetThreadID
if _newclass: x = property(GetThreadID, None)
@@ -200,6 +219,9 @@
__swig_getmethods__["frames"] = get_thread_frames
if _newclass: x = property(get_thread_frames, None)
+ __swig_getmethods__["frame"] = get_frame_array_access_object
+ if _newclass: x = property(get_frame_array_access_object, None)
+
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Wed Feb 1 02:09:32 2012
@@ -37,6 +37,11 @@
// Parameter types will be used in the autodoc string.
%feature("autodoc", "1");
+%pythoncode%{
+import uuid
+import re
+import os
+%}
%include "./Python/python-typemaps.swig"
/* The liblldb header files to be included. */
Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Wed Feb 1 02:09:32 2012
@@ -208,8 +208,6 @@
PyRun_SimpleString (run_string.GetData());
run_string.Clear();
- run_string.Printf ("run_one_line (%s, 'import sys')", m_dictionary_name.c_str());
- PyRun_SimpleString (run_string.GetData());
// Importing 'lldb' module calls SBDebugger::Initialize, which calls Debugger::Initialize, which increments a
// global debugger ref-count; therefore we need to check the ref-count before and after importing lldb, and if the
@@ -220,37 +218,22 @@
// which case the code inside it, including the call to SBDebugger::Initialize(), does not get executed.
int old_count = Debugger::TestDebuggerRefCount();
+
- run_string.Clear();
- run_string.Printf ("run_one_line (%s, 'import lldb')", m_dictionary_name.c_str());
+ run_string.Printf ("run_one_line (%s, 'import copy, os, re, sys, uuid, lldb, gnu_libstdcpp, objc')", m_dictionary_name.c_str());
PyRun_SimpleString (run_string.GetData());
+
int new_count = Debugger::TestDebuggerRefCount();
if (new_count > old_count)
Debugger::Terminate();
run_string.Clear();
- run_string.Printf ("run_one_line (%s, 'import copy')", m_dictionary_name.c_str());
- PyRun_SimpleString (run_string.GetData());
-
- run_string.Clear();
- run_string.Printf ("run_one_line (%s, 'import os')", m_dictionary_name.c_str());
- PyRun_SimpleString (run_string.GetData());
-
- run_string.Clear();
run_string.Printf ("run_one_line (%s, 'lldb.debugger_unique_id = %llu')", m_dictionary_name.c_str(),
interpreter.GetDebugger().GetID());
PyRun_SimpleString (run_string.GetData());
- run_string.Clear();
- run_string.Printf ("run_one_line (%s, 'import gnu_libstdcpp')", m_dictionary_name.c_str());
- PyRun_SimpleString (run_string.GetData());
-
- run_string.Clear();
- run_string.Printf ("run_one_line (%s, 'import objc')", m_dictionary_name.c_str());
- PyRun_SimpleString (run_string.GetData());
-
if (m_dbg_stdout != NULL)
{
m_new_sysout = PyFile_FromFile (m_dbg_stdout, (char *) "", (char *) "w", _check_and_flush);
Modified: lldb/trunk/source/Symbol/Symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=149489&r1=149488&r2=149489&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symbol.cpp (original)
+++ lldb/trunk/source/Symbol/Symbol.cpp Wed Feb 1 02:09:32 2012
@@ -183,7 +183,7 @@
void
Symbol::GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const
{
- *s << "id = " << (const UserID&)*this << ", name = \"" << m_mangled.GetName() << '"';
+ s->Printf("uid={%6u}", m_uid);
const Section *section = m_addr_range.GetBaseAddress().GetSection();
if (section != NULL)
@@ -211,6 +211,11 @@
else
s->Printf (", value = 0x%16.16llx", m_addr_range.GetBaseAddress().GetOffset());
}
+ if (m_mangled.GetDemangledName())
+ s->Printf(", name=\"%s\"", m_mangled.GetDemangledName().AsCString());
+ if (m_mangled.GetMangledName())
+ s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
+
}
void
More information about the lldb-commits
mailing list