[Lldb-commits] [lldb] r247789 - Add support for the DWARFLocationList used by split-dwarf

Tamas Berghammer via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 16 05:37:21 PDT 2015


Author: tberghammer
Date: Wed Sep 16 07:37:06 2015
New Revision: 247789

URL: http://llvm.org/viewvc/llvm-project?rev=247789&view=rev
Log:
Add support for the DWARFLocationList used by split-dwarf

Split-dwarf uses a different header format to specify the address range
for the elements of the location lists.

Differential revision: http://reviews.llvm.org/D12880

Removed:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h
Modified:
    lldb/trunk/include/lldb/Expression/DWARFExpression.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Expression/DWARFExpression.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Modified: lldb/trunk/include/lldb/Expression/DWARFExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DWARFExpression.h?rev=247789&r1=247788&r2=247789&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/DWARFExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/DWARFExpression.h Wed Sep 16 07:37:06 2015
@@ -42,6 +42,13 @@ class ClangExpressionVariableList;
 class DWARFExpression
 {
 public:
+    enum LocationListFormat : uint8_t
+    {
+        NonLocationList,        // Not a location list
+        RegularLocationList,    // Location list format used in non-split dwarf files
+        SplitDwarfLocationList, // Location list format used in split dwarf files
+    };
+
     //------------------------------------------------------------------
     /// Constructor
     //------------------------------------------------------------------
@@ -401,6 +408,24 @@ public:
                             lldb::addr_t address,
                             ABI *abi);
 
+    static size_t
+    LocationListSize(const DWARFCompileUnit* dwarf_cu,
+                     const DataExtractor& debug_loc_data,
+                     lldb::offset_t offset);
+
+    static bool
+    PrintDWARFExpression(Stream &s,
+                         const DataExtractor& data,
+                         int address_size,
+                         int dwarf_ref_size,
+                         bool location_expression);
+
+    static void
+    PrintDWARFLocationList(Stream &s,
+                           const DWARFCompileUnit* cu,
+                           const DataExtractor& debug_loc_data,
+                           lldb::offset_t offset);
+
 protected:
     //------------------------------------------------------------------
     /// Pretty-prints the location expression to a stream
@@ -434,6 +459,13 @@ protected:
                  lldb::offset_t &offset, 
                  lldb::offset_t &len);
 
+    static bool
+    AddressRangeForLocationListEntry(const DWARFCompileUnit* dwarf_cu,
+                                     const DataExtractor& debug_loc_data,
+                                     lldb::offset_t* offset_ptr,
+                                     lldb::addr_t& low_pc,
+                                     lldb::addr_t& high_pc);
+
     //------------------------------------------------------------------
     /// Classes that inherit from DWARFExpression can see and modify these
     //------------------------------------------------------------------
@@ -447,7 +479,6 @@ protected:
     lldb::addr_t m_loclist_slide;               ///< A value used to slide the location list offsets so that 
                                                 ///< they are relative to the object that owns the location list
                                                 ///< (the function for frame base and variable location lists)
-
 };
 
 } // namespace lldb_private

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=247789&r1=247788&r2=247789&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 16 07:37:06 2015
@@ -460,8 +460,6 @@
 		268900C413353E5F00698AC0 /* DWARFDefines.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89CF10F57C5600BB2B04 /* DWARFDefines.cpp */; };
 		268900C513353E5F00698AC0 /* DWARFDIECollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89D110F57C5600BB2B04 /* DWARFDIECollection.cpp */; };
 		268900C613353E5F00698AC0 /* DWARFFormValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89D310F57C5600BB2B04 /* DWARFFormValue.cpp */; };
-		268900C713353E5F00698AC0 /* DWARFLocationDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89D510F57C5600BB2B04 /* DWARFLocationDescription.cpp */; };
-		268900C813353E5F00698AC0 /* DWARFLocationList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89D710F57C5600BB2B04 /* DWARFLocationList.cpp */; };
 		268900C913353E5F00698AC0 /* NameToDIE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */; };
 		268900CA13353E5F00698AC0 /* SymbolFileDWARF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89D910F57C5600BB2B04 /* SymbolFileDWARF.cpp */; };
 		268900CB13353E5F00698AC0 /* LogChannelDWARF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26109B3B1155D70100CC3529 /* LogChannelDWARF.cpp */; };
@@ -744,15 +742,15 @@
 		9443B123140C26AB0013457C /* SBData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9443B120140C18A90013457C /* SBData.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		945215DF17F639EE00521C0B /* ValueObjectPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945215DE17F639EE00521C0B /* ValueObjectPrinter.cpp */; };
 		9452573A16262D0200325455 /* SBDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9452573916262D0200325455 /* SBDeclaration.cpp */; };
-		945261BF1B9A11FC00BF138D /* CxxStringTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B31B9A11E800BF138D /* CxxStringTypes.cpp */; settings = {ASSET_TAGS = (); }; };
-		945261C01B9A11FC00BF138D /* LibCxx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B51B9A11E800BF138D /* LibCxx.cpp */; settings = {ASSET_TAGS = (); }; };
-		945261C11B9A11FC00BF138D /* LibCxxInitializerList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B71B9A11E800BF138D /* LibCxxInitializerList.cpp */; settings = {ASSET_TAGS = (); }; };
-		945261C21B9A11FC00BF138D /* LibCxxList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B81B9A11E800BF138D /* LibCxxList.cpp */; settings = {ASSET_TAGS = (); }; };
-		945261C31B9A11FC00BF138D /* LibCxxMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B91B9A11E800BF138D /* LibCxxMap.cpp */; settings = {ASSET_TAGS = (); }; };
-		945261C41B9A11FC00BF138D /* LibCxxUnorderedMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261BA1B9A11E800BF138D /* LibCxxUnorderedMap.cpp */; settings = {ASSET_TAGS = (); }; };
-		945261C51B9A11FC00BF138D /* LibCxxVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261BB1B9A11E800BF138D /* LibCxxVector.cpp */; settings = {ASSET_TAGS = (); }; };
-		945261C61B9A11FC00BF138D /* LibStdcpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261BC1B9A11E800BF138D /* LibStdcpp.cpp */; settings = {ASSET_TAGS = (); }; };
-		945261C81B9A14D300BF138D /* CXXFunctionPointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261C71B9A14D300BF138D /* CXXFunctionPointer.cpp */; settings = {ASSET_TAGS = (); }; };
+		945261BF1B9A11FC00BF138D /* CxxStringTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B31B9A11E800BF138D /* CxxStringTypes.cpp */; };
+		945261C01B9A11FC00BF138D /* LibCxx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B51B9A11E800BF138D /* LibCxx.cpp */; };
+		945261C11B9A11FC00BF138D /* LibCxxInitializerList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B71B9A11E800BF138D /* LibCxxInitializerList.cpp */; };
+		945261C21B9A11FC00BF138D /* LibCxxList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B81B9A11E800BF138D /* LibCxxList.cpp */; };
+		945261C31B9A11FC00BF138D /* LibCxxMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261B91B9A11E800BF138D /* LibCxxMap.cpp */; };
+		945261C41B9A11FC00BF138D /* LibCxxUnorderedMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261BA1B9A11E800BF138D /* LibCxxUnorderedMap.cpp */; };
+		945261C51B9A11FC00BF138D /* LibCxxVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261BB1B9A11E800BF138D /* LibCxxVector.cpp */; };
+		945261C61B9A11FC00BF138D /* LibStdcpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261BC1B9A11E800BF138D /* LibStdcpp.cpp */; };
+		945261C81B9A14D300BF138D /* CXXFunctionPointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945261C71B9A14D300BF138D /* CXXFunctionPointer.cpp */; };
 		945759671534941F005A9070 /* PlatformPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945759651534941F005A9070 /* PlatformPOSIX.cpp */; };
 		945E8D80152F6AB40019BCCD /* StreamGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945E8D7F152F6AB40019BCCD /* StreamGDBRemote.cpp */; };
 		9461569A14E358A6003A195C /* SBTypeFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568A14E35621003A195C /* SBTypeFilter.cpp */; };
@@ -767,13 +765,13 @@
 		9475C18F14E5F858001BFC6D /* SBTypeNameSpecifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 9475C18C14E5F826001BFC6D /* SBTypeNameSpecifier.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		947A1D641616476B0017C8D1 /* CommandObjectPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 947A1D621616476A0017C8D1 /* CommandObjectPlugin.cpp */; };
 		949ADF031406F648004833E1 /* ValueObjectConstResultImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949ADF021406F648004833E1 /* ValueObjectConstResultImpl.cpp */; };
-		949EEDA01BA74B6D008C63CF /* CoreMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EED9E1BA74B64008C63CF /* CoreMedia.cpp */; settings = {ASSET_TAGS = (); }; };
-		949EEDA31BA76577008C63CF /* Cocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDA11BA76571008C63CF /* Cocoa.cpp */; settings = {ASSET_TAGS = (); }; };
-		949EEDAE1BA7671C008C63CF /* CF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDAC1BA76719008C63CF /* CF.cpp */; settings = {ASSET_TAGS = (); }; };
-		949EEDAF1BA76729008C63CF /* NSArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDA41BA765B5008C63CF /* NSArray.cpp */; settings = {ASSET_TAGS = (); }; };
-		949EEDB11BA7672D008C63CF /* NSDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDA51BA765B5008C63CF /* NSDictionary.cpp */; settings = {ASSET_TAGS = (); }; };
-		949EEDB21BA76731008C63CF /* NSIndexPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDA61BA765B5008C63CF /* NSIndexPath.cpp */; settings = {ASSET_TAGS = (); }; };
-		949EEDB31BA76736008C63CF /* NSSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDA71BA765B5008C63CF /* NSSet.cpp */; settings = {ASSET_TAGS = (); }; };
+		949EEDA01BA74B6D008C63CF /* CoreMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EED9E1BA74B64008C63CF /* CoreMedia.cpp */; };
+		949EEDA31BA76577008C63CF /* Cocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDA11BA76571008C63CF /* Cocoa.cpp */; };
+		949EEDAE1BA7671C008C63CF /* CF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDAC1BA76719008C63CF /* CF.cpp */; };
+		949EEDAF1BA76729008C63CF /* NSArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDA41BA765B5008C63CF /* NSArray.cpp */; };
+		949EEDB11BA7672D008C63CF /* NSDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDA51BA765B5008C63CF /* NSDictionary.cpp */; };
+		949EEDB21BA76731008C63CF /* NSIndexPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDA61BA765B5008C63CF /* NSIndexPath.cpp */; };
+		949EEDB31BA76736008C63CF /* NSSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949EEDA71BA765B5008C63CF /* NSSet.cpp */; };
 		94A5B3971AB9FE8D00A5EE7F /* EmulateInstructionMIPS64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94A5B3951AB9FE8300A5EE7F /* EmulateInstructionMIPS64.cpp */; };
 		94B638531B8F8E6C004FE1E4 /* Language.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94B638521B8F8E6C004FE1E4 /* Language.cpp */; };
 		94B6385D1B8FB178004FE1E4 /* CPlusPlusLanguage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94B6385B1B8FB174004FE1E4 /* CPlusPlusLanguage.cpp */; };
@@ -1264,10 +1262,6 @@
 		260C89D210F57C5600BB2B04 /* DWARFDIECollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWARFDIECollection.h; sourceTree = "<group>"; };
 		260C89D310F57C5600BB2B04 /* DWARFFormValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFFormValue.cpp; sourceTree = "<group>"; };
 		260C89D410F57C5600BB2B04 /* DWARFFormValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWARFFormValue.h; sourceTree = "<group>"; };
-		260C89D510F57C5600BB2B04 /* DWARFLocationDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFLocationDescription.cpp; sourceTree = "<group>"; };
-		260C89D610F57C5600BB2B04 /* DWARFLocationDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWARFLocationDescription.h; sourceTree = "<group>"; };
-		260C89D710F57C5600BB2B04 /* DWARFLocationList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DWARFLocationList.cpp; sourceTree = "<group>"; };
-		260C89D810F57C5600BB2B04 /* DWARFLocationList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWARFLocationList.h; sourceTree = "<group>"; };
 		260C89D910F57C5600BB2B04 /* SymbolFileDWARF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolFileDWARF.cpp; sourceTree = "<group>"; };
 		260C89DA10F57C5600BB2B04 /* SymbolFileDWARF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolFileDWARF.h; sourceTree = "<group>"; };
 		260C89DB10F57C5600BB2B04 /* SymbolFileDWARFDebugMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SymbolFileDWARFDebugMap.cpp; sourceTree = "<group>"; };
@@ -3187,10 +3181,6 @@
 				260C89D210F57C5600BB2B04 /* DWARFDIECollection.h */,
 				260C89D310F57C5600BB2B04 /* DWARFFormValue.cpp */,
 				260C89D410F57C5600BB2B04 /* DWARFFormValue.h */,
-				260C89D510F57C5600BB2B04 /* DWARFLocationDescription.cpp */,
-				260C89D610F57C5600BB2B04 /* DWARFLocationDescription.h */,
-				260C89D710F57C5600BB2B04 /* DWARFLocationList.cpp */,
-				260C89D810F57C5600BB2B04 /* DWARFLocationList.h */,
 				26A0DA4D140F721D006DA411 /* HashedNameToDIE.h */,
 				26109B3B1155D70100CC3529 /* LogChannelDWARF.cpp */,
 				26109B3C1155D70100CC3529 /* LogChannelDWARF.h */,
@@ -6424,9 +6414,7 @@
 				3FDFE53119A292F0009756A7 /* HostInfoPosix.cpp in Sources */,
 				233B007D1960C9F90090E598 /* ProcessInfo.cpp in Sources */,
 				3FDFE52C19A2917A009756A7 /* HostInfoMacOSX.mm in Sources */,
-				268900C713353E5F00698AC0 /* DWARFLocationDescription.cpp in Sources */,
 				26BC17B118C7F4CB00D2196D /* ThreadElfCore.cpp in Sources */,
-				268900C813353E5F00698AC0 /* DWARFLocationList.cpp in Sources */,
 				268900C913353E5F00698AC0 /* NameToDIE.cpp in Sources */,
 				268900CA13353E5F00698AC0 /* SymbolFileDWARF.cpp in Sources */,
 				268900CB13353E5F00698AC0 /* LogChannelDWARF.cpp in Sources */,

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=247789&r1=247788&r2=247789&view=diff
==============================================================================
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Wed Sep 16 07:37:06 2015
@@ -43,183 +43,15 @@
 using namespace lldb;
 using namespace lldb_private;
 
-// TODO- why is this also defined (in a better way) in DWARFDefines.cpp?
-const char *
-DW_OP_value_to_name (uint32_t val)
-{
-  static char invalid[100];
-  switch (val) {
-    case 0x03: return "DW_OP_addr";
-    case 0x06: return "DW_OP_deref";
-    case 0x08: return "DW_OP_const1u";
-    case 0x09: return "DW_OP_const1s";
-    case 0x0a: return "DW_OP_const2u";
-    case 0x0b: return "DW_OP_const2s";
-    case 0x0c: return "DW_OP_const4u";
-    case 0x0d: return "DW_OP_const4s";
-    case 0x0e: return "DW_OP_const8u";
-    case 0x0f: return "DW_OP_const8s";
-    case 0x10: return "DW_OP_constu";
-    case 0x11: return "DW_OP_consts";
-    case 0x12: return "DW_OP_dup";
-    case 0x13: return "DW_OP_drop";
-    case 0x14: return "DW_OP_over";
-    case 0x15: return "DW_OP_pick";
-    case 0x16: return "DW_OP_swap";
-    case 0x17: return "DW_OP_rot";
-    case 0x18: return "DW_OP_xderef";
-    case 0x19: return "DW_OP_abs";
-    case 0x1a: return "DW_OP_and";
-    case 0x1b: return "DW_OP_div";
-    case 0x1c: return "DW_OP_minus";
-    case 0x1d: return "DW_OP_mod";
-    case 0x1e: return "DW_OP_mul";
-    case 0x1f: return "DW_OP_neg";
-    case 0x20: return "DW_OP_not";
-    case 0x21: return "DW_OP_or";
-    case 0x22: return "DW_OP_plus";
-    case 0x23: return "DW_OP_plus_uconst";
-    case 0x24: return "DW_OP_shl";
-    case 0x25: return "DW_OP_shr";
-    case 0x26: return "DW_OP_shra";
-    case 0x27: return "DW_OP_xor";
-    case 0x2f: return "DW_OP_skip";
-    case 0x28: return "DW_OP_bra";
-    case 0x29: return "DW_OP_eq";
-    case 0x2a: return "DW_OP_ge";
-    case 0x2b: return "DW_OP_gt";
-    case 0x2c: return "DW_OP_le";
-    case 0x2d: return "DW_OP_lt";
-    case 0x2e: return "DW_OP_ne";
-    case 0x30: return "DW_OP_lit0";
-    case 0x31: return "DW_OP_lit1";
-    case 0x32: return "DW_OP_lit2";
-    case 0x33: return "DW_OP_lit3";
-    case 0x34: return "DW_OP_lit4";
-    case 0x35: return "DW_OP_lit5";
-    case 0x36: return "DW_OP_lit6";
-    case 0x37: return "DW_OP_lit7";
-    case 0x38: return "DW_OP_lit8";
-    case 0x39: return "DW_OP_lit9";
-    case 0x3a: return "DW_OP_lit10";
-    case 0x3b: return "DW_OP_lit11";
-    case 0x3c: return "DW_OP_lit12";
-    case 0x3d: return "DW_OP_lit13";
-    case 0x3e: return "DW_OP_lit14";
-    case 0x3f: return "DW_OP_lit15";
-    case 0x40: return "DW_OP_lit16";
-    case 0x41: return "DW_OP_lit17";
-    case 0x42: return "DW_OP_lit18";
-    case 0x43: return "DW_OP_lit19";
-    case 0x44: return "DW_OP_lit20";
-    case 0x45: return "DW_OP_lit21";
-    case 0x46: return "DW_OP_lit22";
-    case 0x47: return "DW_OP_lit23";
-    case 0x48: return "DW_OP_lit24";
-    case 0x49: return "DW_OP_lit25";
-    case 0x4a: return "DW_OP_lit26";
-    case 0x4b: return "DW_OP_lit27";
-    case 0x4c: return "DW_OP_lit28";
-    case 0x4d: return "DW_OP_lit29";
-    case 0x4e: return "DW_OP_lit30";
-    case 0x4f: return "DW_OP_lit31";
-    case 0x50: return "DW_OP_reg0";
-    case 0x51: return "DW_OP_reg1";
-    case 0x52: return "DW_OP_reg2";
-    case 0x53: return "DW_OP_reg3";
-    case 0x54: return "DW_OP_reg4";
-    case 0x55: return "DW_OP_reg5";
-    case 0x56: return "DW_OP_reg6";
-    case 0x57: return "DW_OP_reg7";
-    case 0x58: return "DW_OP_reg8";
-    case 0x59: return "DW_OP_reg9";
-    case 0x5a: return "DW_OP_reg10";
-    case 0x5b: return "DW_OP_reg11";
-    case 0x5c: return "DW_OP_reg12";
-    case 0x5d: return "DW_OP_reg13";
-    case 0x5e: return "DW_OP_reg14";
-    case 0x5f: return "DW_OP_reg15";
-    case 0x60: return "DW_OP_reg16";
-    case 0x61: return "DW_OP_reg17";
-    case 0x62: return "DW_OP_reg18";
-    case 0x63: return "DW_OP_reg19";
-    case 0x64: return "DW_OP_reg20";
-    case 0x65: return "DW_OP_reg21";
-    case 0x66: return "DW_OP_reg22";
-    case 0x67: return "DW_OP_reg23";
-    case 0x68: return "DW_OP_reg24";
-    case 0x69: return "DW_OP_reg25";
-    case 0x6a: return "DW_OP_reg26";
-    case 0x6b: return "DW_OP_reg27";
-    case 0x6c: return "DW_OP_reg28";
-    case 0x6d: return "DW_OP_reg29";
-    case 0x6e: return "DW_OP_reg30";
-    case 0x6f: return "DW_OP_reg31";
-    case 0x70: return "DW_OP_breg0";
-    case 0x71: return "DW_OP_breg1";
-    case 0x72: return "DW_OP_breg2";
-    case 0x73: return "DW_OP_breg3";
-    case 0x74: return "DW_OP_breg4";
-    case 0x75: return "DW_OP_breg5";
-    case 0x76: return "DW_OP_breg6";
-    case 0x77: return "DW_OP_breg7";
-    case 0x78: return "DW_OP_breg8";
-    case 0x79: return "DW_OP_breg9";
-    case 0x7a: return "DW_OP_breg10";
-    case 0x7b: return "DW_OP_breg11";
-    case 0x7c: return "DW_OP_breg12";
-    case 0x7d: return "DW_OP_breg13";
-    case 0x7e: return "DW_OP_breg14";
-    case 0x7f: return "DW_OP_breg15";
-    case 0x80: return "DW_OP_breg16";
-    case 0x81: return "DW_OP_breg17";
-    case 0x82: return "DW_OP_breg18";
-    case 0x83: return "DW_OP_breg19";
-    case 0x84: return "DW_OP_breg20";
-    case 0x85: return "DW_OP_breg21";
-    case 0x86: return "DW_OP_breg22";
-    case 0x87: return "DW_OP_breg23";
-    case 0x88: return "DW_OP_breg24";
-    case 0x89: return "DW_OP_breg25";
-    case 0x8a: return "DW_OP_breg26";
-    case 0x8b: return "DW_OP_breg27";
-    case 0x8c: return "DW_OP_breg28";
-    case 0x8d: return "DW_OP_breg29";
-    case 0x8e: return "DW_OP_breg30";
-    case 0x8f: return "DW_OP_breg31";
-    case 0x90: return "DW_OP_regx";
-    case 0x91: return "DW_OP_fbreg";
-    case 0x92: return "DW_OP_bregx";
-    case 0x93: return "DW_OP_piece";
-    case 0x94: return "DW_OP_deref_size";
-    case 0x95: return "DW_OP_xderef_size";
-    case 0x96: return "DW_OP_nop";
-    case 0x97: return "DW_OP_push_object_address";
-    case 0x98: return "DW_OP_call2";
-    case 0x99: return "DW_OP_call4";
-    case 0x9a: return "DW_OP_call_ref";
-    case 0xfb: return "DW_OP_GNU_addr_index";
-    case 0xfc: return "DW_OP_GNU_const_index";
-//    case DW_OP_APPLE_array_ref: return "DW_OP_APPLE_array_ref";
-//    case DW_OP_APPLE_extern: return "DW_OP_APPLE_extern";
-    case DW_OP_APPLE_uninit: return "DW_OP_APPLE_uninit";
-//    case DW_OP_APPLE_assign: return "DW_OP_APPLE_assign";
-//    case DW_OP_APPLE_address_of: return "DW_OP_APPLE_address_of";
-//    case DW_OP_APPLE_value_of: return "DW_OP_APPLE_value_of";
-//    case DW_OP_APPLE_deref_type: return "DW_OP_APPLE_deref_type";
-//    case DW_OP_APPLE_expr_local: return "DW_OP_APPLE_expr_local";
-//    case DW_OP_APPLE_constf: return "DW_OP_APPLE_constf";
-//    case DW_OP_APPLE_scalar_cast: return "DW_OP_APPLE_scalar_cast";
-//    case DW_OP_APPLE_clang_cast: return "DW_OP_APPLE_clang_cast";
-//    case DW_OP_APPLE_clear: return "DW_OP_APPLE_clear";
-//    case DW_OP_APPLE_error: return "DW_OP_APPLE_error";
-    default:
-       snprintf (invalid, sizeof(invalid), "Unknown DW_OP constant: 0x%x", val);
-       return invalid;
-  }
+static lldb::addr_t
+ReadAddressFromDebugAddrSection(const DWARFCompileUnit* dwarf_cu, uint32_t index)
+{
+    uint32_t index_size = dwarf_cu->GetAddressByteSize();
+    dw_offset_t addr_base = dwarf_cu->GetAddrBase();
+    lldb::offset_t offset = addr_base + index * index_size;
+    return dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(&offset, index_size);
 }
 
-
 //----------------------------------------------------------------------
 // DWARFExpression constructor
 //----------------------------------------------------------------------
@@ -726,8 +558,14 @@ DWARFExpression::GetDescription (Stream
         addr_t curr_base_addr = location_list_base_addr;
         while (m_data.ValidOffset(offset))
         {
-            lldb::addr_t begin_addr_offset = m_data.GetAddress(&offset);
-            lldb::addr_t end_addr_offset = m_data.GetAddress(&offset);
+            addr_t begin_addr_offset = LLDB_INVALID_ADDRESS;
+            addr_t end_addr_offset = LLDB_INVALID_ADDRESS;
+            if (!AddressRangeForLocationListEntry(m_dwarf_cu, m_data, &offset, begin_addr_offset, end_addr_offset))
+                break;
+
+            if (begin_addr_offset == 0 && end_addr_offset == 0)
+                break;
+            
             if (begin_addr_offset < end_addr_offset)
             {
                 if (count > 0)
@@ -740,11 +578,6 @@ DWARFExpression::GetDescription (Stream
                 s->PutChar('}');
                 offset += location_length;
             }
-            else if (begin_addr_offset == 0 && end_addr_offset == 0)
-            {
-                // The end of the location list is marked by both the start and end offset being zero
-                break;
-            }
             else
             {
                 if ((m_data.GetAddressByteSize() == 4 && (begin_addr_offset == UINT32_MAX)) ||
@@ -1070,8 +903,7 @@ GetOpcodeDataSize (const DataExtractor &
 }
 
 lldb::addr_t
-DWARFExpression::GetLocation_DW_OP_addr (uint32_t op_addr_idx,
-                                         bool &error) const
+DWARFExpression::GetLocation_DW_OP_addr (uint32_t op_addr_idx, bool &error) const
 {
     error = false;
     if (IsLocationList())
@@ -1101,10 +933,7 @@ DWARFExpression::GetLocation_DW_OP_addr
                     break;
                 }
 
-                uint32_t index_size = m_dwarf_cu->GetAddressByteSize();
-                dw_offset_t addr_base = m_dwarf_cu->GetAddrBase();
-                lldb::offset_t offset = addr_base + index * index_size;
-                return m_dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(&offset, index_size);
+                return ReadAddressFromDebugAddrSection(m_dwarf_cu, index);
             }
             else
                 ++curr_op_addr_idx;
@@ -1189,20 +1018,21 @@ DWARFExpression::LocationListContainsAdd
         while (m_data.ValidOffset(offset))
         {
             // We need to figure out what the value is for the location.
-            addr_t lo_pc = m_data.GetAddress(&offset);
-            addr_t hi_pc = m_data.GetAddress(&offset);
+            addr_t lo_pc = LLDB_INVALID_ADDRESS;
+            addr_t hi_pc = LLDB_INVALID_ADDRESS;
+            if (!AddressRangeForLocationListEntry(m_dwarf_cu, m_data, &offset, lo_pc, hi_pc))
+                break;
+
             if (lo_pc == 0 && hi_pc == 0)
                 break;
-            else
-            {
-                lo_pc += loclist_base_addr - m_loclist_slide;
-                hi_pc += loclist_base_addr - m_loclist_slide;
 
-                if (lo_pc <= addr && addr < hi_pc)
-                    return true;
+            lo_pc += loclist_base_addr - m_loclist_slide;
+            hi_pc += loclist_base_addr - m_loclist_slide;
 
-                offset += m_data.GetU16(&offset);
-            }
+            if (lo_pc <= addr && addr < hi_pc)
+                return true;
+
+            offset += m_data.GetU16(&offset);
         }
     }
     return false;
@@ -1225,24 +1055,23 @@ DWARFExpression::GetLocation (addr_t bas
         while (m_data.ValidOffset(offset))
         {
             // We need to figure out what the value is for the location.
-            addr_t lo_pc = m_data.GetAddress(&offset);
-            addr_t hi_pc = m_data.GetAddress(&offset);
+            addr_t lo_pc = LLDB_INVALID_ADDRESS;
+            addr_t hi_pc = LLDB_INVALID_ADDRESS;
+            if (!AddressRangeForLocationListEntry(m_dwarf_cu, m_data, &offset, lo_pc, hi_pc))
+                break;
+
             if (lo_pc == 0 && hi_pc == 0)
-            {
                 break;
-            }
-            else
-            {
-                lo_pc += curr_base_addr - m_loclist_slide;
-                hi_pc += curr_base_addr - m_loclist_slide;
-                
-                length = m_data.GetU16(&offset);
-                
-                if (length > 0 && lo_pc <= pc && pc < hi_pc)
-                    return true;
 
-                offset += length;
-            }
+            lo_pc += curr_base_addr - m_loclist_slide;
+            hi_pc += curr_base_addr - m_loclist_slide;
+            
+            length = m_data.GetU16(&offset);
+            
+            if (length > 0 && lo_pc <= pc && pc < hi_pc)
+                return true;
+
+            offset += length;
         }
     }
     offset = LLDB_INVALID_OFFSET;
@@ -1334,37 +1163,36 @@ DWARFExpression::Evaluate
             while (m_data.ValidOffset(offset))
             {
                 // We need to figure out what the value is for the location.
-                addr_t lo_pc = m_data.GetAddress(&offset);
-                addr_t hi_pc = m_data.GetAddress(&offset);
+                addr_t lo_pc = LLDB_INVALID_ADDRESS;
+                addr_t hi_pc = LLDB_INVALID_ADDRESS;
+                if (!AddressRangeForLocationListEntry(m_dwarf_cu, m_data, &offset, lo_pc, hi_pc))
+                    break;
+
                 if (lo_pc == 0 && hi_pc == 0)
-                {
                     break;
-                }
-                else
-                {
-                    lo_pc += curr_loclist_base_load_addr - m_loclist_slide;
-                    hi_pc += curr_loclist_base_load_addr - m_loclist_slide;
 
-                    uint16_t length = m_data.GetU16(&offset);
+                lo_pc += curr_loclist_base_load_addr - m_loclist_slide;
+                hi_pc += curr_loclist_base_load_addr - m_loclist_slide;
 
-                    if (length > 0 && lo_pc <= pc && pc < hi_pc)
-                    {
-                        return DWARFExpression::Evaluate (exe_ctx,
-                                                          expr_locals,
-                                                          decl_map,
-                                                          reg_ctx,
-                                                          module_sp,
-                                                          m_data,
-                                                          m_dwarf_cu,
-                                                          offset,
-                                                          length,
-                                                          m_reg_kind,
-                                                          initial_value_ptr,
-                                                          result,
-                                                          error_ptr);
-                    }
-                    offset += length;
+                uint16_t length = m_data.GetU16(&offset);
+
+                if (length > 0 && lo_pc <= pc && pc < hi_pc)
+                {
+                    return DWARFExpression::Evaluate (exe_ctx,
+                                                      expr_locals,
+                                                      decl_map,
+                                                      reg_ctx,
+                                                      module_sp,
+                                                      m_data,
+                                                      m_dwarf_cu,
+                                                      offset,
+                                                      length,
+                                                      m_reg_kind,
+                                                      initial_value_ptr,
+                                                      result,
+                                                      error_ptr);
                 }
+                offset += length;
             }
         }
         if (error_ptr)
@@ -3117,3 +2945,254 @@ DWARFExpression::Evaluate
     return true;    // Return true on success
 }
 
+size_t
+DWARFExpression::LocationListSize(const DWARFCompileUnit* dwarf_cu,
+                                  const DataExtractor& debug_loc_data,
+                                  lldb::offset_t offset)
+{
+    const lldb::offset_t debug_loc_offset = offset;
+    while (debug_loc_data.ValidOffset(offset))
+    {
+        lldb::addr_t start_addr = LLDB_INVALID_ADDRESS;
+        lldb::addr_t end_addr = LLDB_INVALID_ADDRESS;
+        if (!AddressRangeForLocationListEntry(dwarf_cu, debug_loc_data, &offset, start_addr, end_addr))
+            break;
+
+        if (start_addr == 0 && end_addr == 0)
+            break;
+
+        uint16_t loc_length = debug_loc_data.GetU16(&offset);
+        offset += loc_length;
+    }
+
+    if (offset > debug_loc_offset)
+        return offset - debug_loc_offset;
+    return 0;
+}
+
+bool
+DWARFExpression::AddressRangeForLocationListEntry(const DWARFCompileUnit* dwarf_cu,
+                                                  const DataExtractor& debug_loc_data,
+                                                  lldb::offset_t* offset_ptr,
+                                                  lldb::addr_t& low_pc,
+                                                  lldb::addr_t& high_pc)
+{
+    if (!debug_loc_data.ValidOffset(*offset_ptr))
+        return false;
+
+    switch (dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat())
+    {
+        case NonLocationList:
+            return false;
+        case RegularLocationList:
+            low_pc = debug_loc_data.GetAddress(offset_ptr);
+            high_pc = debug_loc_data.GetAddress(offset_ptr);
+            return true;
+        case SplitDwarfLocationList:
+            switch (debug_loc_data.GetU8(offset_ptr))
+            {
+                case DW_LLE_end_of_list_entry:
+                    return false;
+                case DW_LLE_start_end_entry:
+                    {
+                        uint64_t index = debug_loc_data.GetULEB128(offset_ptr);
+                        low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
+                        index = debug_loc_data.GetULEB128(offset_ptr);
+                        high_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
+                        return true;
+                    }
+                case DW_LLE_start_length_entry:
+                    {
+                        uint64_t index = debug_loc_data.GetULEB128(offset_ptr);
+                        low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
+                        uint32_t length = debug_loc_data.GetU32(offset_ptr);
+                        high_pc = low_pc + length;
+                        return true;
+                    }
+                default:
+                    // Not supported entry type
+                    return false;
+            }
+            return true;
+    }
+}
+
+static bool
+print_dwarf_exp_op (Stream &s,
+                    const DataExtractor& data,
+                    lldb::offset_t *offset_ptr,
+                    int address_size,
+                    int dwarf_ref_size)
+{
+    uint8_t opcode = data.GetU8(offset_ptr);
+    DRC_class opcode_class;
+    uint64_t  uint;
+    int64_t   sint;
+
+    int size;
+
+    opcode_class = DW_OP_value_to_class (opcode) & (~DRC_DWARFv3);
+
+    s.Printf("%s ", DW_OP_value_to_name (opcode));
+
+    /* Does this take zero parameters?  If so we can shortcut this function.  */
+    if (opcode_class == DRC_ZEROOPERANDS)
+        return true;
+
+    if (opcode_class == DRC_TWOOPERANDS && opcode == DW_OP_bregx)
+    {
+        uint = data.GetULEB128(offset_ptr);
+        sint = data.GetSLEB128(offset_ptr);
+        s.Printf("%" PRIu64 " %" PRIi64, uint, sint);
+        return true;
+    }
+    if (opcode_class != DRC_ONEOPERAND)
+    {
+        s.Printf("UNKNOWN OP %u", opcode);
+        return false;
+    }
+
+    switch (opcode)
+    {
+        case DW_OP_addr:    size = address_size;    break;
+        case DW_OP_const1u: size = 1;               break;
+        case DW_OP_const1s: size = -1;              break;
+        case DW_OP_const2u: size = 2;               break;
+        case DW_OP_const2s: size = -2;              break;
+        case DW_OP_const4u: size = 4;               break;
+        case DW_OP_const4s: size = -4;              break;
+        case DW_OP_const8u: size = 8;               break;
+        case DW_OP_const8s: size = -8;              break;
+        case DW_OP_constu:  size = 128;             break;
+        case DW_OP_consts:  size = -128;            break;
+        case DW_OP_fbreg:   size = -128;            break;
+        case DW_OP_breg0:
+        case DW_OP_breg1:
+        case DW_OP_breg2:
+        case DW_OP_breg3:
+        case DW_OP_breg4:
+        case DW_OP_breg5:
+        case DW_OP_breg6:
+        case DW_OP_breg7:
+        case DW_OP_breg8:
+        case DW_OP_breg9:
+        case DW_OP_breg10:
+        case DW_OP_breg11:
+        case DW_OP_breg12:
+        case DW_OP_breg13:
+        case DW_OP_breg14:
+        case DW_OP_breg15:
+        case DW_OP_breg16:
+        case DW_OP_breg17:
+        case DW_OP_breg18:
+        case DW_OP_breg19:
+        case DW_OP_breg20:
+        case DW_OP_breg21:
+        case DW_OP_breg22:
+        case DW_OP_breg23:
+        case DW_OP_breg24:
+        case DW_OP_breg25:
+        case DW_OP_breg26:
+        case DW_OP_breg27:
+        case DW_OP_breg28:
+        case DW_OP_breg29:
+        case DW_OP_breg30:
+        case DW_OP_breg31:
+            size = -128; break;
+        case DW_OP_pick:
+        case DW_OP_deref_size:
+        case DW_OP_xderef_size:
+            size = 1; break;
+        case DW_OP_skip:
+        case DW_OP_bra:
+            size = -2; break;
+        case DW_OP_call2:
+            size = 2; break;
+        case DW_OP_call4:
+            size = 4; break;
+        case DW_OP_call_ref:
+            size = dwarf_ref_size; break;
+        case DW_OP_piece:
+        case DW_OP_plus_uconst:
+        case DW_OP_regx:
+        case DW_OP_GNU_addr_index:
+        case DW_OP_GNU_const_index:
+            size = 128; break;
+        default:
+            s.Printf("UNKNOWN ONE-OPERAND OPCODE, #%u", opcode);
+            return true;
+    }
+
+    switch (size)
+    {
+    case -1:    sint = (int8_t)     data.GetU8(offset_ptr);     s.Printf("%+" PRIi64, sint); break;
+    case -2:    sint = (int16_t)    data.GetU16(offset_ptr);    s.Printf("%+" PRIi64, sint); break;
+    case -4:    sint = (int32_t)    data.GetU32(offset_ptr);    s.Printf("%+" PRIi64, sint); break;
+    case -8:    sint = (int64_t)    data.GetU64(offset_ptr);    s.Printf("%+" PRIi64, sint); break;
+    case -128:  sint = data.GetSLEB128(offset_ptr);             s.Printf("%+" PRIi64, sint); break;
+    case 1:     uint = data.GetU8(offset_ptr);                  s.Printf("0x%2.2" PRIx64, uint); break;
+    case 2:     uint = data.GetU16(offset_ptr);                 s.Printf("0x%4.4" PRIx64, uint); break;
+    case 4:     uint = data.GetU32(offset_ptr);                 s.Printf("0x%8.8" PRIx64, uint); break;
+    case 8:     uint = data.GetU64(offset_ptr);                 s.Printf("0x%16.16" PRIx64, uint); break;
+    case 128:   uint = data.GetULEB128(offset_ptr);             s.Printf("0x%" PRIx64, uint); break;
+    }
+
+    return false;
+}
+
+bool
+DWARFExpression::PrintDWARFExpression(Stream &s,
+                                      const DataExtractor& data,
+                                      int address_size,
+                                      int dwarf_ref_size,
+                                      bool location_expression)
+{
+    int op_count = 0;
+    lldb::offset_t offset = 0;
+    while (data.ValidOffset(offset))
+    {
+        if (location_expression && op_count > 0)
+            return false;
+        if (op_count > 0)
+            s.PutCString(", ");
+        if (!print_dwarf_exp_op (s, data, &offset, address_size, dwarf_ref_size))
+            return false;
+        op_count++;
+    }
+
+    return true;
+}
+
+void
+DWARFExpression::PrintDWARFLocationList(Stream &s,
+                                        const DWARFCompileUnit* cu,
+                                        const DataExtractor& debug_loc_data,
+                                        lldb::offset_t offset)
+{
+    uint64_t start_addr, end_addr;
+    uint32_t addr_size = DWARFCompileUnit::GetAddressByteSize(cu);
+    s.SetAddressByteSize(DWARFCompileUnit::GetAddressByteSize(cu));
+    dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
+    while (debug_loc_data.ValidOffset(offset))
+    {
+        start_addr = debug_loc_data.GetMaxU64(&offset,addr_size);
+        end_addr = debug_loc_data.GetMaxU64(&offset,addr_size);
+
+        if (start_addr == 0 && end_addr == 0)
+            break;
+
+        s.PutCString("\n            ");
+        s.Indent();
+        if (cu)
+            s.AddressRange (start_addr + base_addr, 
+                            end_addr + base_addr, 
+                            cu->GetAddressByteSize(), 
+                            NULL,
+                            ": ");
+        uint32_t loc_length = debug_loc_data.GetU16(&offset);
+
+        DataExtractor locationData(debug_loc_data, offset, loc_length);
+        PrintDWARFExpression (s, locationData, addr_size, 4, false);
+        offset += loc_length;
+    }
+}

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt?rev=247789&r1=247788&r2=247789&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/CMakeLists.txt Wed Sep 16 07:37:06 2015
@@ -22,8 +22,6 @@ add_lldb_library(lldbPluginSymbolFileDWA
   DWARFDIE.cpp
   DWARFDIECollection.cpp
   DWARFFormValue.cpp
-  DWARFLocationDescription.cpp
-  DWARFLocationList.cpp
   HashedNameToDIE.cpp
   LogChannelDWARF.cpp
   NameToDIE.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp?rev=247789&r1=247788&r2=247789&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp Wed Sep 16 07:37:06 2015
@@ -18,8 +18,6 @@
 #include "DWARFDeclContext.h"
 #include "DWARFDIECollection.h"
 #include "DWARFFormValue.h"
-#include "DWARFLocationDescription.h"
-#include "DWARFLocationList.h"
 #include "SymbolFileDWARF.h"
 
 #include "lldb/Core/Module.h"

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=247789&r1=247788&r2=247789&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Wed Sep 16 07:37:06 2015
@@ -25,8 +25,6 @@
 #include "DWARFDeclContext.h"
 #include "DWARFDIECollection.h"
 #include "DWARFFormValue.h"
-#include "DWARFLocationDescription.h"
-#include "DWARFLocationList.h"
 #include "DWARFDebugRanges.h"
 #include "SymbolFileDWARF.h"
 #include "SymbolFileDWARFDwo.h"
@@ -555,7 +553,7 @@ DWARFDebugInfoEntry::GetDIENamesAndRange
                             const DWARFDataExtractor &debug_loc_data = dwarf2Data->get_debug_loc_data();
                             const dw_offset_t debug_loc_offset = form_value.Unsigned();
 
-                            size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset);
+                            size_t loc_list_length = DWARFExpression::LocationListSize(cu, debug_loc_data, debug_loc_offset);
                             if (loc_list_length > 0)
                             {
                                 frame_base->SetOpcodeData(module, debug_loc_data, debug_loc_offset, loc_list_length);
@@ -801,7 +799,11 @@ DWARFDebugInfoEntry::DumpAttribute
                 // Location description is inlined in data in the form value
                 DWARFDataExtractor locationData(debug_info_data, (*offset_ptr) - form_value.Unsigned(), form_value.Unsigned());
                 if ( verbose ) s.PutCString(" ( ");
-                print_dwarf_expression (s, locationData, DWARFCompileUnit::GetAddressByteSize(cu), 4, false);
+                DWARFExpression::PrintDWARFExpression(s,
+                                                      locationData,
+                                                      DWARFCompileUnit::GetAddressByteSize(cu),
+                                                      4,
+                                                      false);
                 if ( verbose ) s.PutCString(" )");
             }
             else
@@ -814,7 +816,10 @@ DWARFDebugInfoEntry::DumpAttribute
                 {
                     if ( !verbose )
                         form_value.Dump(s);
-                    DWARFLocationList::Dump(s, cu, dwarf2Data->get_debug_loc_data(), debug_loc_offset);
+                    DWARFExpression::PrintDWARFLocationList(s,
+                                                            cu,
+                                                            dwarf2Data->get_debug_loc_data(),
+                                                            debug_loc_offset);
                 }
                 else
                 {

Removed: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp?rev=247788&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp (removed)
@@ -1,175 +0,0 @@
-//===-- DWARFLocationDescription.cpp ----------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "DWARFLocationDescription.h"
-#include "DWARFDefines.h"
-#include "lldb/lldb-private.h"
-#include "lldb/Core/Stream.h"
-
-
-using namespace lldb_private;
-
-static int print_dwarf_exp_op (Stream &s, const DWARFDataExtractor& data, lldb::offset_t *offset_ptr, int address_size, int dwarf_ref_size);
-
-int
-print_dwarf_expression (Stream &s,
-                        const DWARFDataExtractor& data,
-                        int address_size,
-                        int dwarf_ref_size,
-                        bool location_expression)
-{
-    int op_count = 0;
-    lldb::offset_t offset = 0;
-    while (data.ValidOffset(offset))
-    {
-        if (location_expression && op_count > 0)
-        {
-            //  err (baton, "Dwarf location expressions may only have one operand!");
-            return 1;
-        }
-        if (op_count > 0)
-        {
-            s.PutCString(", ");
-        }
-        if (print_dwarf_exp_op (s, data, &offset, address_size, dwarf_ref_size) == 1)
-            return 1;
-        op_count++;
-    }
-
-    return 0;
-}
-
-static int
-print_dwarf_exp_op (Stream &s,
-                    const DWARFDataExtractor& data,
-                    lldb::offset_t *offset_ptr,
-                    int address_size,
-                    int dwarf_ref_size)
-{
-    uint8_t opcode = data.GetU8(offset_ptr);
-    DRC_class opcode_class;
-    uint64_t  uint;
-    int64_t   sint;
-
-    int size;
-
-    opcode_class = DW_OP_value_to_class (opcode) & (~DRC_DWARFv3);
-
-    s.Printf("%s ", DW_OP_value_to_name (opcode));
-
-    /* Does this take zero parameters?  If so we can shortcut this function.  */
-    if (opcode_class == DRC_ZEROOPERANDS)
-        return 0;
-
-    if (opcode_class == DRC_TWOOPERANDS && opcode == DW_OP_bregx)
-    {
-        uint = data.GetULEB128(offset_ptr);
-        sint = data.GetSLEB128(offset_ptr);
-        s.Printf("%" PRIu64 " %" PRIi64, uint, sint);
-        return 0;
-    }
-    if (opcode_class != DRC_ONEOPERAND)
-    {
-        s.Printf("UNKNOWN OP %u", opcode);
-        return 1;
-    }
-
-    switch (opcode)
-    {
-        case DW_OP_addr:    size = address_size;    break;
-        case DW_OP_const1u: size = 1;               break;
-        case DW_OP_const1s: size = -1;              break;
-        case DW_OP_const2u: size = 2;               break;
-        case DW_OP_const2s: size = -2;              break;
-        case DW_OP_const4u: size = 4;               break;
-        case DW_OP_const4s: size = -4;              break;
-        case DW_OP_const8u: size = 8;               break;
-        case DW_OP_const8s: size = -8;              break;
-        case DW_OP_constu:  size = 128;             break;
-        case DW_OP_consts:  size = -128;            break;
-        case DW_OP_fbreg:   size = -128;            break;
-        case DW_OP_breg0:
-        case DW_OP_breg1:
-        case DW_OP_breg2:
-        case DW_OP_breg3:
-        case DW_OP_breg4:
-        case DW_OP_breg5:
-        case DW_OP_breg6:
-        case DW_OP_breg7:
-        case DW_OP_breg8:
-        case DW_OP_breg9:
-        case DW_OP_breg10:
-        case DW_OP_breg11:
-        case DW_OP_breg12:
-        case DW_OP_breg13:
-        case DW_OP_breg14:
-        case DW_OP_breg15:
-        case DW_OP_breg16:
-        case DW_OP_breg17:
-        case DW_OP_breg18:
-        case DW_OP_breg19:
-        case DW_OP_breg20:
-        case DW_OP_breg21:
-        case DW_OP_breg22:
-        case DW_OP_breg23:
-        case DW_OP_breg24:
-        case DW_OP_breg25:
-        case DW_OP_breg26:
-        case DW_OP_breg27:
-        case DW_OP_breg28:
-        case DW_OP_breg29:
-        case DW_OP_breg30:
-        case DW_OP_breg31:
-            size = -128; break;
-        case DW_OP_pick:
-            size = 1;       break;
-        case DW_OP_deref_size:
-            size = 1;       break;
-        case DW_OP_xderef_size:
-            size = 1;       break;
-        case DW_OP_plus_uconst:
-            size = 128;     break;
-        case DW_OP_skip:
-            size = -2;      break;
-        case DW_OP_bra:
-            size = -2;      break;
-        case DW_OP_call2:
-            size = 2;       break;
-        case DW_OP_call4:
-            size = 4;       break;
-        case DW_OP_call_ref:
-            size = dwarf_ref_size;  break;
-        case DW_OP_piece:
-            size = 128; break;
-        case DW_OP_regx:
-            size = 128; break;
-        case DW_OP_GNU_addr_index:
-        case DW_OP_GNU_const_index:
-            size = 128; break;
-        default:
-            s.Printf("UNKNOWN ONE-OPERAND OPCODE, #%u", opcode);
-            return 1;
-    }
-
-    switch (size)
-    {
-    case -1:    sint = (int8_t)     data.GetU8(offset_ptr);     s.Printf("%+" PRIi64, sint); break;
-    case -2:    sint = (int16_t)    data.GetU16(offset_ptr);    s.Printf("%+" PRIi64, sint); break;
-    case -4:    sint = (int32_t)    data.GetU32(offset_ptr);    s.Printf("%+" PRIi64, sint); break;
-    case -8:    sint = (int64_t)    data.GetU64(offset_ptr);    s.Printf("%+" PRIi64, sint); break;
-    case -128:  sint = data.GetSLEB128(offset_ptr);             s.Printf("%+" PRIi64, sint); break;
-    case 1:     uint = data.GetU8(offset_ptr);                  s.Printf("0x%2.2" PRIx64, uint); break;
-    case 2:     uint = data.GetU16(offset_ptr);                 s.Printf("0x%4.4" PRIx64, uint); break;
-    case 4:     uint = data.GetU32(offset_ptr);                 s.Printf("0x%8.8" PRIx64, uint); break;
-    case 8:     uint = data.GetU64(offset_ptr);                 s.Printf("0x%16.16" PRIx64, uint); break;
-    case 128:   uint = data.GetULEB128(offset_ptr);             s.Printf("0x%" PRIx64, uint); break;
-    }
-
-    return 0;
-}

Removed: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h?rev=247788&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.h (removed)
@@ -1,24 +0,0 @@
-//===-- DWARFLocationDescription.h ------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef SymbolFileDWARF_DWARFLocationDescription_h_
-#define SymbolFileDWARF_DWARFLocationDescription_h_
-
-#include "SymbolFileDWARF.h"
-
-int
-print_dwarf_expression (lldb_private::Stream &s,
-                        const lldb_private::DWARFDataExtractor& data,
-                        int address_size,
-                        int dwarf_ref_size,
-                        bool location_expression);
-
-
-
-#endif  // SymbolFileDWARF_DWARFLocationDescription_h_

Removed: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp?rev=247788&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp (removed)
@@ -1,94 +0,0 @@
-//===-- DWARFLocationList.cpp -----------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "DWARFLocationList.h"
-
-#include "lldb/Core/Stream.h"
-
-#include "DWARFCompileUnit.h"
-#include "DWARFDebugInfo.h"
-#include "DWARFLocationDescription.h"
-
-using namespace lldb_private;
-
-dw_offset_t
-DWARFLocationList::Dump(Stream &s, const DWARFCompileUnit* cu, const DWARFDataExtractor& debug_loc_data, lldb::offset_t offset)
-{
-    uint64_t start_addr, end_addr;
-    uint32_t addr_size = DWARFCompileUnit::GetAddressByteSize(cu);
-    s.SetAddressByteSize(DWARFCompileUnit::GetAddressByteSize(cu));
-    dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
-    while (debug_loc_data.ValidOffset(offset))
-    {
-        start_addr = debug_loc_data.GetMaxU64(&offset,addr_size);
-        end_addr = debug_loc_data.GetMaxU64(&offset,addr_size);
-
-        if (start_addr == 0 && end_addr == 0)
-            break;
-
-        s.PutCString("\n            ");
-        s.Indent();
-        if (cu)
-            s.AddressRange (start_addr + base_addr, 
-                            end_addr + base_addr, 
-                            cu->GetAddressByteSize(), 
-                            NULL,
-                            ": ");
-        uint32_t loc_length = debug_loc_data.GetU16(&offset);
-
-        DWARFDataExtractor locationData(debug_loc_data, offset, loc_length);
-    //  if ( dump_flags & DWARFDebugInfo::eDumpFlag_Verbose ) *ostrm_ptr << " ( ";
-        print_dwarf_expression (s, locationData, addr_size, 4, false);
-        offset += loc_length;
-    }
-
-    return offset;
-}
-
-bool
-DWARFLocationList::Extract(const DWARFDataExtractor& debug_loc_data, lldb::offset_t* offset_ptr, DWARFDataExtractor& location_list_data)
-{
-    // Initialize with no data just in case we don't find anything
-    location_list_data.Clear();
-
-    size_t loc_list_length = Size(debug_loc_data, *offset_ptr);
-    if (loc_list_length > 0)
-    {
-        location_list_data.SetData(debug_loc_data, *offset_ptr, loc_list_length);
-        *offset_ptr += loc_list_length;
-        return true;
-    }
-
-    return false;
-}
-
-size_t
-DWARFLocationList::Size(const DWARFDataExtractor& debug_loc_data, lldb::offset_t offset)
-{
-    const dw_offset_t debug_loc_offset = offset;
-
-    while (debug_loc_data.ValidOffset(offset))
-    {
-        dw_addr_t start_addr = debug_loc_data.GetAddress(&offset);
-        dw_addr_t end_addr = debug_loc_data.GetAddress(&offset);
-
-        if (start_addr == 0 && end_addr == 0)
-            break;
-
-        uint16_t loc_length = debug_loc_data.GetU16(&offset);
-        offset += loc_length;
-    }
-
-    if (offset > debug_loc_offset)
-        return offset - debug_loc_offset;
-    return 0;
-}
-
-
-

Removed: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h?rev=247788&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h (removed)
@@ -1,34 +0,0 @@
-//===-- DWARFLocationList.h -------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef SymbolFileDWARF_DWARFLocationList_h_
-#define SymbolFileDWARF_DWARFLocationList_h_
-
-#include "SymbolFileDWARF.h"
-
-class DWARFLocationList
-{
-public:
-    static dw_offset_t
-    Dump (lldb_private::Stream &s,
-          const DWARFCompileUnit* cu,
-          const lldb_private::DWARFDataExtractor& debug_loc_data,
-          lldb::offset_t offset);
-
-    static bool
-    Extract (const lldb_private::DWARFDataExtractor& debug_loc_data,
-             lldb::offset_t* offset_ptr,
-             lldb_private::DWARFDataExtractor& location_list_data);
-
-    static size_t
-    Size (const lldb_private::DWARFDataExtractor& debug_loc_data,
-          lldb::offset_t offset);
-
-};
-#endif  // SymbolFileDWARF_DWARFLocationList_h_

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=247789&r1=247788&r2=247789&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Sep 16 07:37:06 2015
@@ -72,7 +72,6 @@
 #include "DWARFDeclContext.h"
 #include "DWARFDIECollection.h"
 #include "DWARFFormValue.h"
-#include "DWARFLocationList.h"
 #include "LogChannelDWARF.h"
 #include "SymbolFileDWARFDwo.h"
 #include "SymbolFileDWARFDebugMap.h"
@@ -3874,10 +3873,10 @@ SymbolFileDWARF::ParseVariableDIE
                             }
                             else
                             {
-                                const DWARFDataExtractor&    debug_loc_data = get_debug_loc_data();
+                                const DWARFDataExtractor& debug_loc_data = get_debug_loc_data();
                                 const dw_offset_t debug_loc_offset = form_value.Unsigned();
 
-                                size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset);
+                                size_t loc_list_length = DWARFExpression::LocationListSize(die.GetCU(), debug_loc_data, debug_loc_offset);
                                 if (loc_list_length > 0)
                                 {
                                     location.CopyOpcodeData(module, debug_loc_data, debug_loc_offset, loc_list_length);
@@ -4339,3 +4338,9 @@ SymbolFileDWARF::GetDebugMapSymfile ()
     }
     return m_debug_map_symfile;
 }
+
+DWARFExpression::LocationListFormat
+SymbolFileDWARF::GetLocationListFormat() const
+{
+    return DWARFExpression::RegularLocationList;
+}

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=247789&r1=247788&r2=247789&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Wed Sep 16 07:37:06 2015
@@ -29,6 +29,7 @@
 #include "lldb/Core/Flags.h"
 #include "lldb/Core/RangeMap.h"
 #include "lldb/Core/UniqueCStringMap.h"
+#include "lldb/Expression/DWARFExpression.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/SymbolContext.h"
@@ -319,6 +320,9 @@ public:
     virtual lldb::CompUnitSP
     ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx);
 
+    virtual lldb_private::DWARFExpression::LocationListFormat
+    GetLocationListFormat() const;
+
 protected:
     typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr;
     typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp?rev=247789&r1=247788&r2=247789&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp Wed Sep 16 07:37:06 2015
@@ -10,6 +10,7 @@
 #include "SymbolFileDWARFDwo.h"
 
 #include "lldb/Core/Section.h"
+#include "lldb/Expression/DWARFExpression.h"
 #include "lldb/Symbol/ObjectFile.h"
 
 #include "DWARFCompileUnit.h"
@@ -118,3 +119,9 @@ SymbolFileDWARFDwo::GetBaseSymbolFile()
 {
     return m_base_dwarf_cu->GetSymbolFileDWARF();
 }
+
+DWARFExpression::LocationListFormat
+SymbolFileDWARFDwo::GetLocationListFormat() const
+{
+    return DWARFExpression::SplitDwarfLocationList;
+}
\ No newline at end of file

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h?rev=247789&r1=247788&r2=247789&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h Wed Sep 16 07:37:06 2015
@@ -38,6 +38,9 @@ public:
     DWARFCompileUnit*
     GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) override;
 
+    lldb_private::DWARFExpression::LocationListFormat
+    GetLocationListFormat() const override;
+
 protected:
     DIEToTypePtr&
     GetDIEToType() override;




More information about the lldb-commits mailing list