[Lldb-commits] [lldb] r162532 - in /lldb/trunk: examples/python/operating_system.py source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp source/Plugins/Process/Utility/DynamicRegisterInfo.cpp

Greg Clayton gclayton at apple.com
Thu Aug 23 19:01:39 PDT 2012


Author: gclayton
Date: Thu Aug 23 21:01:39 2012
New Revision: 162532

URL: http://llvm.org/viewvc/llvm-project?rev=162532&view=rev
Log:
We have a partially working OS plug-in through python!


Modified:
    lldb/trunk/examples/python/operating_system.py
    lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
    lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp

Modified: lldb/trunk/examples/python/operating_system.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/operating_system.py?rev=162532&r1=162531&r2=162532&view=diff
==============================================================================
--- lldb/trunk/examples/python/operating_system.py (original)
+++ lldb/trunk/examples/python/operating_system.py Thu Aug 23 21:01:39 2012
@@ -7,9 +7,11 @@
     
     def __init__(self, process):
         '''Initialization needs a valid.SBProcess object'''
+        self.process = None
+        self.registers = None
+        self.threads = None
         if type(process) is lldb.SBProcess and process.IsValid():
             self.process = process
-            self.registers = None # Will be an dictionary containing info for each register
             self.threads = None # Will be an dictionary containing info for each thread
     
     def get_thread_info(self):
@@ -22,14 +24,14 @@
         return self.threads
     
     def get_register_info(self):
-        if self.register_info == None:
-            self.register_info = dict()            
+        if self.registers == None:
+            self.registers = dict()            
             triple = self.process.target.triple
             if triple:
                 arch = triple.split('-')[0]
                 if arch == 'x86_64':
-                    self.register_info['sets'] = ['GPR', 'FPU', 'EXC']
-                    self.register_info['registers'] = [
+                    self.registers['sets'] = ['GPR', 'FPU', 'EXC']
+                    self.registers['registers'] = [
                         { 'name':'rax'       , 'bitsize' :  64, 'offset' :   0, 'encoding':'uint'  , 'format':'hex'         , 'set': 0, 'gcc' : 0, 'dwarf' : 0},
                         { 'name':'rbx'       , 'bitsize' :  64, 'offset' :   8, 'encoding':'uint'  , 'format':'hex'         , 'set': 0, 'gcc' : 3, 'dwarf' : 3},
                         { 'name':'rcx'       , 'bitsize' :  64, 'offset' :  16, 'encoding':'uint'  , 'format':'hex'         , 'set': 0, 'gcc' : 2, 'dwarf' : 2, 'generic':'arg4', 'alt-name':'arg4', },
@@ -52,7 +54,7 @@
                         { 'name':'fs'        , 'bitsize' :  64, 'offset' : 152, 'encoding':'uint'  , 'format':'hex'         , 'set': 0                          },
                         { 'name':'gs'        , 'bitsize' :  64, 'offset' : 160, 'encoding':'uint'  , 'format':'hex'         , 'set': 0                          },
                         ]
-        return self.register_info
+        return self.registers
             
     def get_register_data(self, tid):
         if tid == 0x111111111:

Modified: lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp?rev=162532&r1=162531&r2=162532&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp (original)
+++ lldb/trunk/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp Thu Aug 23 21:01:39 2012
@@ -95,7 +95,7 @@
         {
             m_python_object = object_sp->GetObject();
             
-            // GetDynamicRegisterInfo (); // Only for testing should this be done here
+            //GetDynamicRegisterInfo (); // COMMENT THIS LINE OUT PRIOR TO CHECKIN!!!
         }
     }
 }
@@ -156,9 +156,9 @@
     auto object_sp = m_interpreter->OSPlugin_QueryForThreadsInfo(m_interpreter->MakeScriptObject(m_python_object));
     if (!object_sp)
         return NULL;
-    PythonDataObject dictionary_data_obj((PyObject*)object_sp->GetObject());
-    PythonDataDictionary dictionary = dictionary_data_obj.GetDictionaryObject();
-    if(!dictionary)
+    PythonDataObject pyobj((PyObject*)object_sp->GetObject());
+    PythonDataArray array = pyobj.GetArrayObject();
+    if(!array)
         return NULL;
     
     // TODO: read from the dict

Modified: lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp?rev=162532&r1=162531&r2=162532&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp Thu Aug 23 21:01:39 2012
@@ -132,18 +132,24 @@
                     reg_info.encoding = eEncodingUint;
 
                 const int64_t set = reg_info_dict.GetItemForKeyAsInteger(set_pystr, -1);
-                if (set == -1)
+                if (set >= m_sets.size())
                 {
                     Clear();
                     return 0;
                 }
 
-                m_set_reg_nums[set].push_back(i);
                 reg_info.kinds[lldb::eRegisterKindLLDB]    = i;
                 reg_info.kinds[lldb::eRegisterKindGDB]     = i;
                 reg_info.kinds[lldb::eRegisterKindGCC]     = reg_info_dict.GetItemForKeyAsInteger(gcc_pystr, LLDB_INVALID_REGNUM);
                 reg_info.kinds[lldb::eRegisterKindDWARF]   = reg_info_dict.GetItemForKeyAsInteger(dwarf_pystr, LLDB_INVALID_REGNUM);
                 reg_info.kinds[lldb::eRegisterKindGeneric] = Args::StringToGenericRegister (reg_info_dict.GetItemForKeyAsString(generic_pystr));
+                const size_t end_reg_offset = reg_info.byte_offset + reg_info.byte_size;
+                if (m_reg_data_byte_size < end_reg_offset)
+                    m_reg_data_byte_size = end_reg_offset;
+
+                m_regs.push_back (reg_info);
+                m_set_reg_nums[set].push_back(i);
+
             }
             else
             {





More information about the lldb-commits mailing list