[Lldb-commits] [lldb] r130792 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Caroline Tice ctice at apple.com
Tue May 3 14:21:50 PDT 2011


Author: ctice
Date: Tue May  3 16:21:50 2011
New Revision: 130792

URL: http://llvm.org/viewvc/llvm-project?rev=130792&view=rev
Log:

Pre-load the Python script interpreter with the following
convenience variables (from the ExecutionContext) each time
it is entered: lldb.debugger, lldb.target, lldb.process, 
lldb.thread, lldb.frame.

If a frame (or thread, process, etc) does not currently exist,
the variable contains the Python value 'None'.


Modified:
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=130792&r1=130791&r2=130792&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue May  3 16:21:50 2011
@@ -377,8 +377,49 @@
     run_string.Printf ("run_one_line (%s, 'lldb.debugger_unique_id = %d')", m_dictionary_name.c_str(),
                        GetCommandInterpreter().GetDebugger().GetID());
     PyRun_SimpleString (run_string.GetData());
+    run_string.Clear();
     
 
+    run_string.Printf ("run_one_line (%s, 'lldb.debugger = lldb.SBDebugger.FindDebuggerWithID (%d)')", 
+                       m_dictionary_name.c_str(),
+                       GetCommandInterpreter().GetDebugger().GetID());
+    PyRun_SimpleString (run_string.GetData());
+    run_string.Clear();
+    
+
+    ExecutionContext exe_ctx = m_interpreter.GetDebugger().GetSelectedExecutionContext();
+
+    if (exe_ctx.target)
+        run_string.Printf ("run_one_line (%s, 'lldb.target = lldb.debugger.GetSelectedTarget()')", 
+                           m_dictionary_name.c_str());
+    else
+        run_string.Printf ("run_one_line (%s, 'lldb.target = None')", m_dictionary_name.c_str());
+    PyRun_SimpleString (run_string.GetData());
+    run_string.Clear();
+
+    if (exe_ctx.process)
+        run_string.Printf ("run_one_line (%s, 'lldb.process = lldb.target.GetProcess()')", m_dictionary_name.c_str());
+    else
+        run_string.Printf ("run_one_line (%s, 'lldb.process = None')", m_dictionary_name.c_str());
+    PyRun_SimpleString (run_string.GetData());
+    run_string.Clear();
+
+    if (exe_ctx.thread)
+        run_string.Printf ("run_one_line (%s, 'lldb.thread = lldb.process.GetSelectedThread ()')", 
+                           m_dictionary_name.c_str());
+    else
+        run_string.Printf ("run_one_line (%s, 'lldb.thread = None')", m_dictionary_name.c_str());
+    PyRun_SimpleString (run_string.GetData());
+    run_string.Clear();
+    
+    if (exe_ctx.frame)
+        run_string.Printf ("run_one_line (%s, 'lldb.frame = lldb.thread.GetSelectedFrame ()')", 
+                           m_dictionary_name.c_str());
+    else
+        run_string.Printf ("run_one_line (%s, 'lldb.frame = None')", m_dictionary_name.c_str());
+    PyRun_SimpleString (run_string.GetData());
+    run_string.Clear();
+    
     PyObject *sysmod = PyImport_AddModule ("sys");
     PyObject *sysdict = PyModule_GetDict (sysmod);
     





More information about the lldb-commits mailing list