[Lldb-commits] [lldb] r215379 - Patch to enable LLDB to extract value bytes from DWARF block forms and udata/sdata forms. By Greg Clayton

Enrico Granata egranata at apple.com
Mon Aug 11 12:16:35 PDT 2014


Author: enrico
Date: Mon Aug 11 14:16:35 2014
New Revision: 215379

URL: http://llvm.org/viewvc/llvm-project?rev=215379&view=rev
Log:
Patch to enable LLDB to extract value bytes from DWARF block forms and udata/sdata forms. By Greg Clayton

Modified:
    lldb/trunk/include/lldb/Expression/DWARFExpression.h
    lldb/trunk/source/Expression/DWARFExpression.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/include/lldb/Expression/DWARFExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DWARFExpression.h?rev=215379&r1=215378&r2=215379&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/DWARFExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/DWARFExpression.h Mon Aug 11 14:16:35 2014
@@ -222,6 +222,17 @@ public:
                     lldb::offset_t data_offset,
                     lldb::offset_t data_length);
     
+    void
+    CopyOpcodeData (const void *data,
+                    lldb::offset_t data_length,
+                    lldb::ByteOrder byte_order,
+                    uint8_t addr_byte_size);
+    
+    void
+    CopyOpcodeData (uint64_t const_value,
+                    lldb::offset_t const_value_byte_size,
+                    uint8_t addr_byte_size);
+    
 
     //------------------------------------------------------------------
     /// Tells the expression that it refers to a location list.

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=215379&r1=215378&r2=215379&view=diff
==============================================================================
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Mon Aug 11 14:16:35 2014
@@ -282,6 +282,33 @@ DWARFExpression::CopyOpcodeData (lldb::M
 }
 
 void
+DWARFExpression::CopyOpcodeData (const void *data,
+                                 lldb::offset_t data_length,
+                                 ByteOrder byte_order,
+                                 uint8_t addr_byte_size)
+{
+    if (data && data_length)
+    {
+        m_data.SetData(DataBufferSP(new DataBufferHeap(data, data_length)));
+        m_data.SetByteOrder(byte_order);
+        m_data.SetAddressByteSize(addr_byte_size);
+    }
+}
+
+void
+DWARFExpression::CopyOpcodeData (uint64_t const_value,
+                                 lldb::offset_t const_value_byte_size,
+                                 uint8_t addr_byte_size)
+{
+    if (const_value_byte_size)
+    {
+        m_data.SetData(DataBufferSP(new DataBufferHeap(&const_value, const_value_byte_size)));
+        m_data.SetByteOrder(endian::InlHostByteOrder());
+        m_data.SetAddressByteSize(addr_byte_size);
+    }
+}
+
+void
 DWARFExpression::SetOpcodeData (lldb::ModuleSP module_sp, const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length)
 {
     m_module_wp = module_sp;
@@ -1307,7 +1334,7 @@ DWARFExpression::Evaluate
     ClangExpressionVariableList *expr_locals,
     ClangExpressionDeclMap *decl_map,
     RegisterContext *reg_ctx,
-    lldb::ModuleSP opcode_ctx,
+    lldb::ModuleSP module_sp,
     const DataExtractor& opcodes,
     const lldb::offset_t opcodes_offset,
     const lldb::offset_t opcodes_length,
@@ -2882,7 +2909,7 @@ DWARFExpression::Evaluate
                     return false;
                 }
 
-                if (!exe_ctx || !opcode_ctx)
+                if (!exe_ctx || !module_sp)
                 {
                     if (error_ptr)
                         error_ptr->SetErrorString("No context to evaluate TLS within.");
@@ -2898,7 +2925,7 @@ DWARFExpression::Evaluate
                 }
 
                 // Lookup the TLS block address for this thread and module.
-                addr_t tls_addr = thread->GetThreadLocalData (opcode_ctx);
+                addr_t tls_addr = thread->GetThreadLocalData (module_sp);
 
                 if (tls_addr == LLDB_INVALID_ADDRESS)
                 {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=215379&r1=215378&r2=215379&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Aug 11 14:16:35 2014
@@ -7333,6 +7333,7 @@ SymbolFileDWARF::ParseVariableDIE
             bool is_artificial = false;
             bool location_is_const_value_data = false;
             bool has_explicit_location = false;
+            DWARFFormValue const_value;
             //AccessType accessibility = eAccessNone;
 
             for (i=0; i<num_attributes; ++i)
@@ -7371,7 +7372,21 @@ SymbolFileDWARF::ParseVariableDIE
                                 const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize());
                                 uint32_t data_offset = attributes.DIEOffsetAtIndex(i);
                                 uint32_t data_length = fixed_form_sizes[form_value.Form()];
-                                location.CopyOpcodeData(module, debug_info_data, data_offset, data_length);
+                                if (data_length == 0)
+                                {
+                                    const uint8_t *data_pointer = form_value.BlockData();
+                                    if (data_pointer)
+                                    {
+                                        data_length = form_value.Unsigned();
+                                    }
+                                    else if (DWARFFormValue::IsDataForm(form_value.Form()))
+                                    {
+                                        // we need to get the byte size of the type later after we create the variable
+                                        const_value = form_value;
+                                    }
+                                }
+                                else
+                                    location.CopyOpcodeData(module, debug_info_data, data_offset, data_length);
                             }
                             else
                             {
@@ -7583,10 +7598,15 @@ SymbolFileDWARF::ParseVariableDIE
 
             if (symbol_context_scope)
             {
+                SymbolFileTypeSP type_sp(new SymbolFileType(*this, type_uid));
+                
+                if (const_value.Form() && type_sp && type_sp->GetType())
+                    location.CopyOpcodeData(const_value.Unsigned(), type_sp->GetType()->GetByteSize(), dwarf_cu->GetAddressByteSize());
+                
                 var_sp.reset (new Variable (MakeUserID(die->GetOffset()), 
                                             name, 
                                             mangled,
-                                            SymbolFileTypeSP (new SymbolFileType(*this, type_uid)),
+                                            type_sp,
                                             scope, 
                                             symbol_context_scope, 
                                             &decl, 





More information about the lldb-commits mailing list