diff options
| author | Greg Clayton <gclayton@apple.com> | 2012-02-01 08:09:32 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2012-02-01 08:09:32 +0000 |
| commit | 6b2bd93918bceac12b0aea61fd13a65676cd4577 (patch) | |
| tree | 74c4eb0c2a271070e4606a396dc1f2ff79deefd1 /lldb/source/Interpreter/ScriptInterpreterPython.cpp | |
| parent | 0e48c70ba79cb9224a3e5cc1be60efdf8f840f23 (diff) | |
| download | bcm5719-llvm-6b2bd93918bceac12b0aea61fd13a65676cd4577.tar.gz bcm5719-llvm-6b2bd93918bceac12b0aea61fd13a65676cd4577.zip | |
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.
llvm-svn: 149489
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
| -rw-r--r-- | lldb/source/Interpreter/ScriptInterpreterPython.cpp | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 26d058c9574..15e66610ef1 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -208,8 +208,6 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete 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 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete // 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); |

