From johnny.chen at apple.com Mon Oct 3 15:56:40 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 03 Oct 2011 20:56:40 -0000 Subject: [Lldb-commits] [lldb] r141021 - /lldb/trunk/source/API/SBSourceManager.cpp Message-ID: <20111003205640.D47452A6C12C@llvm.org> Author: johnny Date: Mon Oct 3 15:56:39 2011 New Revision: 141021 URL: http://llvm.org/viewvc/llvm-project?rev=141021&view=rev Log: Fix regression of test SourceManagerTestCase.test_display_source_python. Modified: lldb/trunk/source/API/SBSourceManager.cpp Modified: lldb/trunk/source/API/SBSourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSourceManager.cpp?rev=141021&r1=141020&r2=141021&view=diff ============================================================================== --- lldb/trunk/source/API/SBSourceManager.cpp (original) +++ lldb/trunk/source/API/SBSourceManager.cpp Mon Oct 3 15:56:39 2011 @@ -51,7 +51,7 @@ const char* current_line_cstr, lldb_private::Stream *s) { - if (file) + if (!file) return 0; if (m_debugger_sp) From johnny.chen at apple.com Mon Oct 3 16:48:41 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 03 Oct 2011 21:48:41 -0000 Subject: [Lldb-commits] [lldb] r141033 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20111003214841.AFC842A6C12C@llvm.org> Author: johnny Date: Mon Oct 3 16:48:40 2011 New Revision: 141033 URL: http://llvm.org/viewvc/llvm-project?rev=141033&view=rev Log: Add comment markers for in_range(symbol, section). Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=141033&r1=141032&r2=141033&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Mon Oct 3 16:48:40 2011 @@ -62,6 +62,9 @@ # lldb_helpers and lldb_iter() should appear before our first SB* class definition. # lldb_helpers = ''' +# ================================== +# Helper function for SBModule class +# ================================== def in_range(symbol, section): """Test whether a symbol is within the range of a section.""" symSA = symbol.GetStartAddress().GetFileAddress() From johnny.chen at apple.com Mon Oct 3 17:02:59 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 03 Oct 2011 22:02:59 -0000 Subject: [Lldb-commits] [lldb] r141035 - in /lldb/trunk/test/python_api/default-constructor: sb_breakpoint.py sb_compileunit.py sb_debugger.py sb_instructionlist.py sb_module.py sb_process.py sb_stringlist.py sb_target.py sb_thread.py sb_type.py sb_value.py sb_valuelist.py Message-ID: <20111003220259.A21D62A6C12C@llvm.org> Author: johnny Date: Mon Oct 3 17:02:59 2011 New Revision: 141035 URL: http://llvm.org/viewvc/llvm-project?rev=141035&view=rev Log: Add fuzz calls for various iterators, too. Modified: lldb/trunk/test/python_api/default-constructor/sb_breakpoint.py lldb/trunk/test/python_api/default-constructor/sb_compileunit.py lldb/trunk/test/python_api/default-constructor/sb_debugger.py lldb/trunk/test/python_api/default-constructor/sb_instructionlist.py lldb/trunk/test/python_api/default-constructor/sb_module.py lldb/trunk/test/python_api/default-constructor/sb_process.py lldb/trunk/test/python_api/default-constructor/sb_stringlist.py lldb/trunk/test/python_api/default-constructor/sb_target.py lldb/trunk/test/python_api/default-constructor/sb_thread.py lldb/trunk/test/python_api/default-constructor/sb_type.py lldb/trunk/test/python_api/default-constructor/sb_value.py lldb/trunk/test/python_api/default-constructor/sb_valuelist.py Modified: lldb/trunk/test/python_api/default-constructor/sb_breakpoint.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_breakpoint.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_breakpoint.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_breakpoint.py Mon Oct 3 17:02:59 2011 @@ -31,3 +31,5 @@ obj.GetNumResolvedLocations() obj.GetNumLocations() obj.GetDescription(lldb.SBStream()) + for bp_loc in obj: + print bp_loc Modified: lldb/trunk/test/python_api/default-constructor/sb_compileunit.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_compileunit.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_compileunit.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_compileunit.py Mon Oct 3 17:02:59 2011 @@ -11,3 +11,5 @@ obj.GetLineEntryAtIndex(0xffffffff) obj.FindLineEntryIndex(0, 0xffffffff, None) obj.GetDescription(lldb.SBStream()) + for line_entry in obj: + print line_entry Modified: lldb/trunk/test/python_api/default-constructor/sb_debugger.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_debugger.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_debugger.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_debugger.py Mon Oct 3 17:02:59 2011 @@ -52,3 +52,5 @@ obj.SetCloseInputOnEOF(True) obj.SetCloseInputOnEOF(False) obj.Clear() + for target in obj: + print target Modified: lldb/trunk/test/python_api/default-constructor/sb_instructionlist.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_instructionlist.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_instructionlist.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_instructionlist.py Mon Oct 3 17:02:59 2011 @@ -13,3 +13,5 @@ obj.GetDescription(lldb.SBStream()) obj.DumpEmulationForAllInstructions("armv7") obj.Clear() + for inst in obj: + print inst Modified: lldb/trunk/test/python_api/default-constructor/sb_module.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_module.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_module.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_module.py Mon Oct 3 17:02:59 2011 @@ -17,3 +17,10 @@ obj.GetSymbolAtIndex(sys.maxint) obj.FindFunctions("my_func", 0xffffffff, True, lldb.SBSymbolContextList()) obj.FindGlobalVariables(lldb.SBTarget(), "my_global_var", 1) + for section in obj.section_iter(): + print section + for symbol in obj.symbol_in_section_iter(lldb.SBSection()): + print symbol + for symbol in obj: + print symbol + Modified: lldb/trunk/test/python_api/default-constructor/sb_process.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_process.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_process.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_process.py Mon Oct 3 17:02:59 2011 @@ -41,3 +41,5 @@ obj.LoadImage(lldb.SBFileSpec(), error) obj.UnloadImage(0) obj.Clear() + for thread in obj: + print thread Modified: lldb/trunk/test/python_api/default-constructor/sb_stringlist.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_stringlist.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_stringlist.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_stringlist.py Mon Oct 3 17:02:59 2011 @@ -12,3 +12,5 @@ obj.GetSize() obj.GetStringAtIndex(0xffffffff) obj.Clear() + for str in obj: + print str Modified: lldb/trunk/test/python_api/default-constructor/sb_target.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_target.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_target.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_target.py Mon Oct 3 17:02:59 2011 @@ -51,3 +51,7 @@ obj.GetBroadcaster() obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief) obj.Clear() + for module in obj.module_iter(): + print module + for bp in obj.breakpoint_iter(): + print bp Modified: lldb/trunk/test/python_api/default-constructor/sb_thread.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_thread.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_thread.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_thread.py Mon Oct 3 17:02:59 2011 @@ -33,3 +33,5 @@ obj.GetProcess() obj.GetDescription(lldb.SBStream()) obj.Clear() + for frame in obj: + print frame Modified: lldb/trunk/test/python_api/default-constructor/sb_type.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_type.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_type.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_type.py Mon Oct 3 17:02:59 2011 @@ -18,4 +18,5 @@ obj.GetDescription(lldb.SBStream()) obj.IsPointerType(None) lldb.SBType.IsPointerType(None) - + for child_type in obj: + print child_type Modified: lldb/trunk/test/python_api/default-constructor/sb_value.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_value.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_value.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_value.py Mon Oct 3 17:02:59 2011 @@ -33,3 +33,5 @@ obj.GetDescription(stream) obj.GetExpressionPath(stream) obj.GetExpressionPath(stream, True) + for child_val in obj: + print child_val Modified: lldb/trunk/test/python_api/default-constructor/sb_valuelist.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_valuelist.py?rev=141035&r1=141034&r2=141035&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_valuelist.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_valuelist.py Mon Oct 3 17:02:59 2011 @@ -10,3 +10,5 @@ obj.GetSize() obj.GetValueAtIndex(100) obj.FindValueObjectByUID(200) + for val in obj: + print val From johnny.chen at apple.com Mon Oct 3 17:08:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 03 Oct 2011 22:08:39 -0000 Subject: [Lldb-commits] [lldb] r141036 - /lldb/trunk/test/python_api/default-constructor/sb_target.py Message-ID: <20111003220842.0DBA72A6C12C@llvm.org> Author: johnny Date: Mon Oct 3 17:08:35 2011 New Revision: 141036 URL: http://llvm.org/viewvc/llvm-project?rev=141036&view=rev Log: Add fuzz call for watchpoint location iterator, too. Modified: lldb/trunk/test/python_api/default-constructor/sb_target.py Modified: lldb/trunk/test/python_api/default-constructor/sb_target.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_target.py?rev=141036&r1=141035&r2=141036&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_target.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_target.py Mon Oct 3 17:08:35 2011 @@ -55,3 +55,5 @@ print module for bp in obj.breakpoint_iter(): print bp + for wp_loc in obj.watchpoint_location_iter(): + print wp_loc From johnny.chen at apple.com Mon Oct 3 17:30:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 03 Oct 2011 22:30:56 -0000 Subject: [Lldb-commits] [lldb] r141039 - in /lldb/trunk/test/python_api/default-constructor: TestDefaultConstructorForAPIObjects.py sb_section.py Message-ID: <20111003223056.557732A6C12C@llvm.org> Author: johnny Date: Mon Oct 3 17:30:56 2011 New Revision: 141039 URL: http://llvm.org/viewvc/llvm-project?rev=141039&view=rev Log: Add SBSection API to the fuzz testing. Added: lldb/trunk/test/python_api/default-constructor/sb_section.py Modified: lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py Modified: lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py?rev=141039&r1=141038&r2=141039&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py (original) +++ lldb/trunk/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py Mon Oct 3 17:30:56 2011 @@ -228,6 +228,16 @@ sb_process.fuzz_obj(obj) @python_api_test + def test_SBSection(self): + obj = lldb.SBSection() + if self.TraceOn(): + print obj + self.assertFalse(obj) + # Do fuzz testing on the invalid obj, it should not crash lldb. + import sb_section + sb_section.fuzz_obj(obj) + + @python_api_test def test_SBStream(self): """SBStream object is valid after default construction.""" obj = lldb.SBStream() Added: lldb/trunk/test/python_api/default-constructor/sb_section.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_section.py?rev=141039&view=auto ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_section.py (added) +++ lldb/trunk/test/python_api/default-constructor/sb_section.py Mon Oct 3 17:30:56 2011 @@ -0,0 +1,20 @@ +""" +Fuzz tests an object after the default construction to make sure it does not crash lldb. +""" + +import sys +import lldb + +def fuzz_obj(obj): + obj.IsValid() + obj.GetName() + obj.FindSubSection("hello_section_name") + obj.GetNumSubSections() + obj.GetSubSectionAtIndex(600) + obj.GetFileAddress() + obj.GetByteSize() + obj.GetFileOffset() + obj.GetFileByteSize() + obj.GetSectionData(1000, 100) + obj.GetSectionType() + obj.GetDescription(lldb.SBStream()) From johnny.chen at apple.com Mon Oct 3 17:43:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 03 Oct 2011 22:43:06 -0000 Subject: [Lldb-commits] [lldb] r141041 - /lldb/trunk/test/python_api/default-constructor/sb_section.py Message-ID: <20111003224306.69FE12A6C12C@llvm.org> Author: johnny Date: Mon Oct 3 17:43:06 2011 New Revision: 141041 URL: http://llvm.org/viewvc/llvm-project?rev=141041&view=rev Log: Add fuzz call for sub-section iteration for SBSection. Modified: lldb/trunk/test/python_api/default-constructor/sb_section.py Modified: lldb/trunk/test/python_api/default-constructor/sb_section.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_section.py?rev=141041&r1=141040&r2=141041&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_section.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_section.py Mon Oct 3 17:43:06 2011 @@ -18,3 +18,5 @@ obj.GetSectionData(1000, 100) obj.GetSectionType() obj.GetDescription(lldb.SBStream()) + for subsec in obj: + print subsec From johnny.chen at apple.com Mon Oct 3 18:06:33 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 03 Oct 2011 23:06:33 -0000 Subject: [Lldb-commits] [lldb] r141044 - /lldb/trunk/scripts/Python/interface/SBSection.i Message-ID: <20111003230633.C9E212A6C12C@llvm.org> Author: johnny Date: Mon Oct 3 18:06:33 2011 New Revision: 141044 URL: http://llvm.org/viewvc/llvm-project?rev=141044&view=rev Log: Add more docstring to the Python interface file for SBSection. Modified: lldb/trunk/scripts/Python/interface/SBSection.i Modified: lldb/trunk/scripts/Python/interface/SBSection.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSection.i?rev=141044&r1=141043&r2=141044&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBSection.i (original) +++ lldb/trunk/scripts/Python/interface/SBSection.i Mon Oct 3 18:06:33 2011 @@ -13,7 +13,28 @@ "Represents an executable image section. SBSection supports iteration through its subsection, represented as SBSection -as well." +as well. For example, + + for sec in exe_module: + if sec.GetName() == '__TEXT': + print sec + break + print INDENT + 'Number of subsections: %d' % sec.GetNumSubSections() + for subsec in sec: + print INDENT + repr(subsec) + +produces: + +[0x0000000100000000-0x0000000100002000) a.out.__TEXT + Number of subsections: 6 + [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text + [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs + [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper + [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring + [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info + [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame + +See also SBModule." ) SBSection; class SBSection From gclayton at apple.com Tue Oct 4 17:41:52 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 04 Oct 2011 22:41:52 -0000 Subject: [Lldb-commits] [lldb] r141128 - in /lldb/trunk: include/lldb/ lldb.xcodeproj/ source/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ source/Target/ Message-ID: <20111004224152.E476B312800A@llvm.org> Author: gclayton Date: Tue Oct 4 17:41:51 2011 New Revision: 141128 URL: http://llvm.org/viewvc/llvm-project?rev=141128&view=rev Log: Enable all the new accelerator tables if they are present and don't manually index the DWARF. Also fixed an issue with memory accelerator tables with a size of 1 where we would loop infinitely. Added support for parsing the new .apple_namespaces section which gives us a memory hash table for looking up namespaces. Modified: lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/ObjectFile.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/source/Target/ObjCLanguageRuntime.cpp lldb/trunk/source/lldb.cpp Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Tue Oct 4 17:41:51 2011 @@ -477,6 +477,7 @@ eSectionTypeDWARFDebugStr, eSectionTypeDWARFAppleNames, eSectionTypeDWARFAppleTypes, + eSectionTypeDWARFAppleNamespaces, eSectionTypeEHFrame, eSectionTypeOther Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Oct 4 17:41:51 2011 @@ -80,6 +80,7 @@ 26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */; }; 267C012B136880DF006E963E /* OptionGroupValueObjectDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */; }; 267C01371368C49C006E963E /* OptionGroupOutputFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC531368B3E4006DC050 /* OptionGroupOutputFile.cpp */; }; + 2682100D143A59AE004BCF2D /* MappedHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 2682100C143A59AE004BCF2D /* MappedHash.h */; }; 2686536C1370ACB200D186A3 /* OptionGroupBoolean.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2686536B1370ACB200D186A3 /* OptionGroupBoolean.cpp */; }; 268653701370AE7200D186A3 /* OptionGroupUInt64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2686536F1370AE7200D186A3 /* OptionGroupUInt64.cpp */; }; 2689000113353DB600698AC0 /* BreakpointResolverAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5310FE555900271C65 /* BreakpointResolverAddress.cpp */; }; @@ -742,6 +743,7 @@ 2676A094119C93C8008A98EF /* StringExtractorGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringExtractorGDBRemote.h; path = source/Utility/StringExtractorGDBRemote.h; sourceTree = ""; }; 267C0128136880C7006E963E /* OptionGroupValueObjectDisplay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupValueObjectDisplay.h; path = include/lldb/Interpreter/OptionGroupValueObjectDisplay.h; sourceTree = ""; }; 267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupValueObjectDisplay.cpp; path = source/Interpreter/OptionGroupValueObjectDisplay.cpp; sourceTree = ""; }; + 2682100C143A59AE004BCF2D /* MappedHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MappedHash.h; path = include/lldb/Core/MappedHash.h; sourceTree = ""; }; 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PseudoTerminal.cpp; path = source/Utility/PseudoTerminal.cpp; sourceTree = ""; }; 2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PseudoTerminal.h; path = include/lldb/Utility/PseudoTerminal.h; sourceTree = ""; }; 2682F284115EF3A700CCFF99 /* SBError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBError.cpp; path = source/API/SBError.cpp; sourceTree = ""; }; @@ -2121,6 +2123,7 @@ 26BC7E7F10F1B85900F91463 /* Log.cpp */, 26BC7D6910F1B77400F91463 /* Mangled.h */, 26BC7E8010F1B85900F91463 /* Mangled.cpp */, + 2682100C143A59AE004BCF2D /* MappedHash.h */, 26BC7D6A10F1B77400F91463 /* Module.h */, 26BC7E8110F1B85900F91463 /* Module.cpp */, 26BC7D6B10F1B77400F91463 /* ModuleChild.h */, @@ -2885,6 +2888,7 @@ buildActionMask = 2147483647; files = ( 496B015B1406DEB100F830D5 /* IRInterpreter.h in Headers */, + 2682100D143A59AE004BCF2D /* MappedHash.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Oct 4 17:41:51 2011 @@ -257,6 +257,7 @@ case eSectionTypeDWARFDebugStr: return eAddressClassDebug; case eSectionTypeDWARFAppleNames: return eAddressClassDebug; case eSectionTypeDWARFAppleTypes: return eAddressClassDebug; + case eSectionTypeDWARFAppleNamespaces: return eAddressClassDebug; case eSectionTypeEHFrame: return eAddressClassRuntime; case eSectionTypeOther: return eAddressClassUnknown; } @@ -509,6 +510,7 @@ static ConstString g_sect_name_dwarf_debug_str ("__debug_str"); static ConstString g_sect_name_dwarf_apple_names ("__apple_names"); static ConstString g_sect_name_dwarf_apple_types ("__apple_types"); + static ConstString g_sect_name_dwarf_apple_namespaces ("__apple_namespac"); static ConstString g_sect_name_eh_frame ("__eh_frame"); static ConstString g_sect_name_DATA ("__DATA"); static ConstString g_sect_name_TEXT ("__TEXT"); @@ -541,6 +543,8 @@ sect_type = eSectionTypeDWARFAppleNames; else if (section_name == g_sect_name_dwarf_apple_types) sect_type = eSectionTypeDWARFAppleTypes; + else if (section_name == g_sect_name_dwarf_apple_namespaces) + sect_type = eSectionTypeDWARFAppleNamespaces; else if (section_name == g_sect_name_objc_selrefs) sect_type = eSectionTypeDataCStringPointers; else if (section_name == g_sect_name_objc_msgrefs) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Tue Oct 4 17:41:51 2011 @@ -675,7 +675,7 @@ bool has_address = false; bool has_location = false; bool is_global_or_static_variable = false; - + dw_offset_t specification_die_offset = DW_INVALID_OFFSET; const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, fixed_form_sizes, attributes); if (num_attributes > 0) @@ -786,21 +786,20 @@ if (ObjCLanguageRuntime::IsPossibleObjCMethodName(name)) { ConstString objc_class_name; - ConstString objc_method_name; - ConstString objc_base_name; + ConstString objc_selector_name; + ConstString objc_fullname_no_category_name; if (ObjCLanguageRuntime::ParseMethodName (name, &objc_class_name, - &objc_method_name, - &objc_base_name)) + &objc_selector_name, + &objc_fullname_no_category_name)) { objc_class_selectors.Insert(objc_class_name, die.GetOffset()); - func_selectors.Insert (objc_method_name, die.GetOffset()); - - if (!objc_base_name.IsEmpty()) + func_selectors.Insert (objc_selector_name, die.GetOffset()); + func_fullnames.Insert (ConstString(name), die.GetOffset()); + if (objc_fullname_no_category_name) { - func_basenames.Insert (objc_base_name, die.GetOffset()); - func_fullnames.Insert (objc_base_name, die.GetOffset()); + func_fullnames.Insert (objc_fullname_no_category_name, die.GetOffset()); } } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp?rev=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp Tue Oct 4 17:41:51 2011 @@ -152,6 +152,7 @@ const uint32_t name_hash = dl_new_hash (name_cstr); const uint32_t bucket_count = m_header.bucket_count; + const uint32_t hashes_count = m_header.bucket_count; // Find the correct bucket for the using the hash value const uint32_t bucket_idx = name_hash % bucket_count; @@ -172,6 +173,9 @@ uint32_t hash; while (((hash = m_data.GetU32 (&hash_offset)) % bucket_count) == bucket_idx) { + if (hash_idx >= hashes_count) + break; + if (hash == name_hash) { // The hash matches, but we still need to verify that the @@ -232,6 +236,7 @@ uint32_t hash_collisions = 0; uint32_t hash_idx_offset = GetOffsetOfBucketEntry (0); const uint32_t bucket_count = m_header.bucket_count; + const uint32_t hashes_count = m_header.hashes_count; for (uint32_t bucket_idx=0; bucket_idx= hashes_count) + break; + uint32_t hash_data_offset = m_data.GetU32 (&data_offset); s.Printf(" hash[%u] = 0x%8.8x\n", hash_idx, hash); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h?rev=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Tue Oct 4 17:41:51 2011 @@ -13,6 +13,7 @@ #include #include "lldb/lldb-defines.h" #include "lldb/Core/dwarf.h" +#include "lldb/Core/RegularExpression.h" class SymbolFileDWARF; @@ -267,4 +268,396 @@ }; }; +#include "lldb/Core/MappedHash.h" + +struct DWARFMappedHash +{ + typedef std::vector DIEArray; + + enum AtomType + { + eAtomTypeNULL = 0u, + eAtomTypeHashString = 1u, // String value for hash, use DW_FORM_strp (preferred) or DW_FORM_string + eAtomTypeHashLength = 2u, // Length of data for the previous string refered by the last eAtomTypeHashString atom + eAtomTypeArraySize = 3u, // A count that specifies a number of atoms that follow this entry, the next atom defines what the atom type for the array is + eAtomTypeDIEOffset = 4u, // DIE offset, check form for encoding. If DW_FORM_ref1,2,4,8 or DW_FORM_ref_udata, then this value is added to the prologue + eAtomTypeTag = 5u, // DW_TAG_xxx value, should be encoded as DW_FORM_data1 (if no tags exceed 255) or DW_FORM_data2 + eAtomTypeNameFlags = 6u, // Flags from enum NameFlags + eAtomTypeTypeFlags = 7u, // Flags from enum TypeFlags + }; + + struct Atom + { + uint16_t type; + dw_form_t form; + + Atom (uint16_t t = eAtomTypeNULL, dw_form_t f = 0) : + type (t), + form (f) + { + } + }; + + typedef std::vector AtomArray; + + + static const char * + GetAtomTypeName (uint16_t atom) + { + switch (atom) + { + case eAtomTypeNULL: return "NULL"; + case eAtomTypeHashString: return "hash-string"; + case eAtomTypeHashLength: return "hash-data-length"; + case eAtomTypeArraySize: return "array-size"; + case eAtomTypeDIEOffset: return "die-offset"; + case eAtomTypeTag: return "die-tag"; + case eAtomTypeNameFlags: return "name-flags"; + case eAtomTypeTypeFlags: return "type-flags"; + } + return ""; + } + struct Prologue + { + // DIE offset base so die offsets in hash_data can be CU relative + dw_offset_t die_base_offset; + AtomArray atoms; + + Prologue (dw_offset_t _die_base_offset = 0) : + die_base_offset (_die_base_offset) + { + // Define an array of DIE offsets by first defining an array, + // and then define the atom type for the array, in this case + // we have an array of DIE offsets + atoms.push_back (Atom(eAtomTypeArraySize, DW_FORM_data4)); + atoms.push_back (Atom(eAtomTypeDIEOffset, DW_FORM_data4)); + } + + virtual ~Prologue() + { + } + + virtual void + Clear () + { + die_base_offset = 0; + atoms.clear(); + } + +// void +// Dump (std::ostream* ostrm_ptr); + + uint32_t + Read (const lldb_private::DataExtractor &data, uint32_t offset) + { + die_base_offset = data.GetU32 (&offset); + Atom atom; + while (offset != UINT32_MAX) + { + atom.type = data.GetU16 (&offset); + atom.form = data.GetU16 (&offset); + if (atom.type == eAtomTypeNULL) + break; + atoms.push_back(atom); + } + return offset; + } + +// virtual void +// Write (BinaryStreamBuf &s); + + size_t + GetByteSize () const + { + // Add an extra count to the atoms size for the zero termination Atom that gets + // written to disk + return sizeof(die_base_offset) + ((atoms.size() + 1) * sizeof(Atom)); + } + }; + + struct Header : public MappedHash::Header + { + Header (dw_offset_t _die_base_offset = 0) + { + } + + virtual + ~Header() + { + } + + virtual size_t + GetByteSize (const HeaderData &header_data) + { + return header_data.GetByteSize(); + } + + + // virtual void + // Dump (std::ostream* ostrm_ptr); + // + virtual uint32_t + Read (lldb_private::DataExtractor &data, uint32_t offset) + { + offset = MappedHash::Header::Read (data, offset); + if (offset != UINT32_MAX) + { + offset = header_data.Read (data, offset); + } + return offset; + } + // + // virtual void + // Write (BinaryStreamBuf &s); + }; + +// class ExportTable +// { +// public: +// ExportTable (); +// +// void +// AppendNames (DWARFDebugPubnamesSet &pubnames_set, +// StringTable &string_table); +// +// void +// AppendNamesEntry (SymbolFileDWARF *dwarf2Data, +// const DWARFCompileUnit* cu, +// const DWARFDebugInfoEntry* die, +// StringTable &string_table); +// +// void +// AppendTypesEntry (DWARFData *dwarf2Data, +// const DWARFCompileUnit* cu, +// const DWARFDebugInfoEntry* die, +// StringTable &string_table); +// +// size_t +// Save (BinaryStreamBuf &names_data, const StringTable &string_table); +// +// void +// AppendName (const char *name, +// uint32_t die_offset, +// StringTable &string_table, +// dw_offset_t name_debug_str_offset = DW_INVALID_OFFSET); // If "name" has already been looked up, then it can be supplied +// void +// AppendType (const char *name, +// uint32_t die_offset, +// StringTable &string_table); +// +// +// protected: +// struct Entry +// { +// uint32_t hash; +// uint32_t str_offset; +// uint32_t die_offset; +// }; +// +// // Map uniqued .debug_str offset to the corresponding DIE offsets +// typedef std::map NameInfo; +// // Map a name hash to one or more name infos +// typedef std::map BucketEntry; +// +// static uint32_t +// GetByteSize (const NameInfo &name_info); +// +// typedef std::vector BucketEntryColl; +// typedef std::vector EntryColl; +// EntryColl m_entries; +// +// }; + + + // A class for reading and using a saved hash table from a block of data + // in memory + class MemoryTable : public MappedHash::MemoryTable + { + public: + + MemoryTable (lldb_private::DataExtractor &table_data, + const lldb_private::DataExtractor &string_table, + bool is_apple_names) : + MappedHash::MemoryTable (table_data), + m_data (table_data), + m_string_table (string_table), + m_is_apple_names (is_apple_names) + { + } + + virtual + ~MemoryTable () + { + } + + virtual const char * + GetStringForKeyType (KeyType key) const + { + // The key in the DWARF table is the .debug_str offset for the string + return m_string_table.PeekCStr (key); + } + + virtual Result + GetHashDataForName (const char *name, + uint32_t* hash_data_offset_ptr, + Pair &pair) const + { + pair.key = m_data.GetU32 (hash_data_offset_ptr); + // If the key is zero, this terminates our chain of HashData objects + // for this hash value. + if (pair.key == 0) + return eResultEndOfHashData; + + // There definitely should be a string for this string offset, if + // there isn't, there is something wrong, return and error + const char *strp_cstr = m_string_table.PeekCStr (pair.key); + if (strp_cstr == NULL) + return eResultError; + + const uint32_t count = m_data.GetU32 (hash_data_offset_ptr); + const uint32_t data_size = count * sizeof(uint32_t); + if (count > 0 && m_data.ValidOffsetForDataOfSize (*hash_data_offset_ptr, data_size)) + { + if (strcmp (name, strp_cstr) == 0) + { + pair.value.clear(); + for (uint32_t i=0; i 0 && m_data.ValidOffsetForDataOfSize (*hash_data_offset_ptr, data_size)) + { + if (regex.Execute(strp_cstr)) + { + for (uint32_t i=0; i .apple_names, false => .apple_types + }; +}; + + #endif // SymbolFileDWARF_HashedNameToDIE_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=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Oct 4 17:41:51 2011 @@ -173,11 +173,13 @@ m_data_debug_str (), m_data_apple_names (), m_data_apple_types (), + m_data_apple_namespaces (), m_abbr(), m_info(), m_line(), - m_apple_names (this, m_data_apple_names, true), - m_apple_types (this, m_data_apple_types, true), + m_apple_names_ap (), + m_apple_types_ap (), + m_apple_namespaces_ap (), m_function_basename_index(), m_function_fullname_index(), m_function_method_index(), @@ -252,9 +254,27 @@ section->MemoryMapSectionDataFromObjectFile(m_obj_file, m_dwarf_data); } get_apple_names_data(); + if (m_data_apple_names.GetByteSize() > 0) + { + m_apple_names_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_names, get_debug_str_data(), true)); + if (!m_apple_names_ap->IsValid()) + m_apple_names_ap.reset(); + } get_apple_types_data(); - m_apple_names.Initialize(); - m_apple_types.Initialize(); + if (m_data_apple_types.GetByteSize() > 0) + { + m_apple_types_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_types, get_debug_str_data(), false)); + if (!m_apple_types_ap->IsValid()) + m_apple_types_ap.reset(); + } + + get_apple_namespaces_data(); + if (m_data_apple_namespaces.GetByteSize() > 0) + { + m_apple_namespaces_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_namespaces, get_debug_str_data(), false)); + if (!m_apple_namespaces_ap->IsValid()) + m_apple_namespaces_ap.reset(); + } } @@ -470,6 +490,12 @@ return GetCachedSectionData (flagsGotDebugTypesData, eSectionTypeDWARFAppleTypes, m_data_apple_types); } +const DataExtractor& +SymbolFileDWARF::get_apple_namespaces_data() +{ + return GetCachedSectionData (flagsGotDebugTypesData, eSectionTypeDWARFAppleNamespaces, m_data_apple_namespaces); +} + DWARFDebugAbbrev* SymbolFileDWARF::DebugAbbrev() @@ -1937,21 +1963,36 @@ // we are appending the results to a variable list. const uint32_t original_size = variables.GetSize(); - // Index the DWARF if we haven't already - if (!m_indexed) - Index (); + DIEArray die_offsets; + + if (m_apple_names_ap.get()) + { + const char *name_cstr = name.GetCString(); + DWARFMappedHash::MemoryTable::Pair kv_pair; + if (m_apple_names_ap->Find (name_cstr, kv_pair)) + { + die_offsets.swap(kv_pair.value); + } + } + else + { + // Index the DWARF if we haven't already + if (!m_indexed) + Index (); - SymbolContext sc; - sc.module_sp = m_obj_file->GetModule(); - assert (sc.module_sp); + m_global_index.Find (name, die_offsets); + } - DWARFCompileUnit* dwarf_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; - DIEArray die_offsets; - const size_t num_matches = m_global_index.Find (name, die_offsets); + const size_t num_matches = die_offsets.size(); if (num_matches) { + SymbolContext sc; + sc.module_sp = m_obj_file->GetModule(); + assert (sc.module_sp); + DWARFDebugInfo* debug_info = DebugInfo(); + DWARFCompileUnit* dwarf_cu = NULL; + const DWARFDebugInfoEntry* die = NULL; for (size_t i=0; iAppendAllDIEsThatMatchingRegex (regex, die_offsets); + } + else + { + // Index the DWARF if we haven't already + if (!m_indexed) + Index (); + + m_global_index.Find (regex, die_offsets); + } SymbolContext sc; sc.module_sp = m_obj_file->GetModule(); @@ -1996,8 +2048,7 @@ DWARFCompileUnit* dwarf_cu = NULL; const DWARFDebugInfoEntry* die = NULL; - DIEArray die_offsets; - const size_t num_matches = m_global_index.Find (regex, die_offsets); + const size_t num_matches = die_offsets.size(); if (num_matches) { DWARFDebugInfo* debug_info = DebugInfo(); @@ -2006,7 +2057,6 @@ const dw_offset_t die_offset = die_offsets[i]; die = debug_info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); - assert(sc.comp_unit != NULL); ParseVariables(sc, dwarf_cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); @@ -2066,84 +2116,8 @@ break; } } - assert (die->Tag() == DW_TAG_subprogram); - if (GetFunction (dwarf_cu, die, sc)) + if (die->Tag() == DW_TAG_subprogram) { - Address addr; - // Parse all blocks if needed - if (inlined_die) - { - sc.block = sc.function->GetBlock (true).FindBlockByID (inlined_die->GetOffset()); - assert (sc.block != NULL); - if (sc.block->GetStartAddress (addr) == false) - addr.Clear(); - } - else - { - sc.block = NULL; - addr = sc.function->GetAddressRange().GetBaseAddress(); - } - - if (addr.IsValid()) - { - - // We found the function, so we should find the line table - // and line table entry as well - LineTable *line_table = sc.comp_unit->GetLineTable(); - if (line_table == NULL) - { - if (ParseCompileUnitLineTable(sc)) - line_table = sc.comp_unit->GetLineTable(); - } - if (line_table != NULL) - line_table->FindLineEntryByAddress (addr, sc.line_entry); - - sc_list.Append(sc); - } - } - } - return sc_list.GetSize() - sc_list_initial_size; -} - -void -SymbolFileDWARF::FindFunctions -( - const ConstString &name, - const NameToDIE &name_to_die, - SymbolContextList& sc_list -) -{ - DWARFDebugInfo* info = DebugInfo(); - if (info == NULL) - return; - - SymbolContext sc; - sc.module_sp = m_obj_file->GetModule(); - assert (sc.module_sp); - - DWARFCompileUnit* dwarf_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; - DIEArray die_offsets; - const size_t num_matches = name_to_die.Find (name, die_offsets); - if (num_matches) - { - DWARFDebugInfo* debug_info = DebugInfo(); - for (size_t i=0; iGetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); - const DWARFDebugInfoEntry* inlined_die = NULL; - if (die->Tag() == DW_TAG_inlined_subroutine) - { - inlined_die = die; - - while ((die = die->GetParent()) != NULL) - { - if (die->Tag() == DW_TAG_subprogram) - break; - } - } - assert (die->Tag() == DW_TAG_subprogram); if (GetFunction (dwarf_cu, die, sc)) { Address addr; @@ -2160,10 +2134,10 @@ sc.block = NULL; addr = sc.function->GetAddressRange().GetBaseAddress(); } - + if (addr.IsValid()) { - + // We found the function, so we should find the line table // and line table entry as well LineTable *line_table = sc.comp_unit->GetLineTable(); @@ -2174,43 +2148,72 @@ } if (line_table != NULL) line_table->FindLineEntryByAddress (addr, sc.line_entry); - + sc_list.Append(sc); } } } } + return sc_list.GetSize() - sc_list_initial_size; } + void -SymbolFileDWARF::FindFunctions -( - const RegularExpression ®ex, - const NameToDIE &name_to_die, - SymbolContextList& sc_list -) +SymbolFileDWARF::FindFunctions (const ConstString &name, + const NameToDIE &name_to_die, + SymbolContextList& sc_list) { - DWARFDebugInfo* info = DebugInfo(); - if (info == NULL) - return; + DIEArray die_offsets; + if (name_to_die.Find (name, die_offsets)) + { + ParseFunctions (die_offsets, sc_list); + } +} - SymbolContext sc; - sc.module_sp = m_obj_file->GetModule(); - assert (sc.module_sp); - - DWARFCompileUnit* dwarf_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; + +void +SymbolFileDWARF::FindFunctions (const RegularExpression ®ex, + const NameToDIE &name_to_die, + SymbolContextList& sc_list) +{ + DIEArray die_offsets; + if (name_to_die.Find (regex, die_offsets)) + { + ParseFunctions (die_offsets, sc_list); + } +} + + +void +SymbolFileDWARF::FindFunctions (const RegularExpression ®ex, + const DWARFMappedHash::MemoryTable &memory_table, + SymbolContextList& sc_list) +{ DIEArray die_offsets; - const size_t num_matches = name_to_die.Find (regex, die_offsets); + if (memory_table.AppendAllDIEsThatMatchingRegex (regex, die_offsets)) + { + ParseFunctions (die_offsets, sc_list); + } +} + +void +SymbolFileDWARF::ParseFunctions (const DIEArray &die_offsets, + SymbolContextList& sc_list) +{ + const size_t num_matches = die_offsets.size(); if (num_matches) { + SymbolContext sc; + sc.module_sp = m_obj_file->GetModule(); + + DWARFCompileUnit* dwarf_cu = NULL; + const DWARFDebugInfoEntry* die = NULL; DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; iGetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); - const DWARFDebugInfoEntry* inlined_die = NULL; if (die->Tag() == DW_TAG_inlined_subroutine) { @@ -2239,10 +2242,10 @@ sc.block = NULL; addr = sc.function->GetAddressRange().GetBaseAddress(); } - + if (addr.IsValid()) { - + // We found the function, so we should find the line table // and line table entry as well LineTable *line_table = sc.comp_unit->GetLineTable(); @@ -2253,7 +2256,7 @@ } if (line_table != NULL) line_table->FindLineEntryByAddress (addr, sc.line_entry); - + sc_list.Append(sc); } } @@ -2261,6 +2264,7 @@ } } + uint32_t SymbolFileDWARF::FindFunctions (const ConstString &name, uint32_t name_type_mask, @@ -2280,31 +2284,31 @@ const uint32_t original_size = sc_list.GetSize(); - // Index the DWARF if we haven't already - if (!m_indexed) - Index (); + if (m_apple_names_ap.get()) + { + const char *name_cstr = name.GetCString(); + DWARFMappedHash::MemoryTable::Pair kv_pair; + if (m_apple_names_ap->Find (name_cstr, kv_pair)) + ResolveFunctions (kv_pair.value, sc_list, name, name_type_mask); + } + else + { - if (name_type_mask & eFunctionNameTypeBase) - FindFunctions (name, m_function_basename_index, sc_list); + // Index the DWARF if we haven't already + if (!m_indexed) + Index (); - if (name_type_mask & eFunctionNameTypeFull) - FindFunctions (name, m_function_fullname_index, sc_list); + if (name_type_mask & eFunctionNameTypeBase) + FindFunctions (name, m_function_basename_index, sc_list); - if (name_type_mask & eFunctionNameTypeMethod) - FindFunctions (name, m_function_method_index, sc_list); + if (name_type_mask & eFunctionNameTypeFull) + FindFunctions (name, m_function_fullname_index, sc_list); - if (name_type_mask & eFunctionNameTypeSelector) - FindFunctions (name, m_function_selector_index, sc_list); + if (name_type_mask & eFunctionNameTypeMethod) + FindFunctions (name, m_function_method_index, sc_list); - if (m_apple_names.IsValid()) - { - SymbolContextList sc_list_apple; - DIEArray die_offsets; - const uint32_t num_matches = m_apple_names.Find(name.GetCString(), die_offsets); - if (num_matches > 0) - ResolveFunctions (die_offsets, sc_list_apple, name, name_type_mask); - if (sc_list != sc_list_apple) - assert (!"__apple_names results differ from DWARF index results"); + if (name_type_mask & eFunctionNameTypeSelector) + FindFunctions (name, m_function_selector_index, sc_list); } // Return the number of variable that were appended to the list @@ -2328,12 +2332,19 @@ uint32_t original_size = sc_list.GetSize(); // Index the DWARF if we haven't already - if (!m_indexed) - Index (); + if (m_apple_names_ap.get()) + { + FindFunctions (regex, *m_apple_names_ap, sc_list); + } + else + { + if (!m_indexed) + Index (); - FindFunctions (regex, m_function_basename_index, sc_list); + FindFunctions (regex, m_function_basename_index, sc_list); - FindFunctions (regex, m_function_fullname_index, sc_list); + FindFunctions (regex, m_function_fullname_index, sc_list); + } // Return the number of variable that were appended to the list return sc_list.GetSize() - original_size; @@ -2384,18 +2395,33 @@ if (!append) types.Clear(); - // Index if we already haven't to make sure the compile units - // get indexed and make their global DIE index list - if (!m_indexed) - Index (); - - const uint32_t initial_types_size = types.GetSize(); - DWARFCompileUnit* dwarf_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; DIEArray die_offsets; - const size_t num_matches = m_type_index.Find (name, die_offsets); + + if (m_apple_types_ap.get()) + { + const char *name_cstr = name.GetCString(); + DWARFMappedHash::MemoryTable::Pair kv_pair; + if (m_apple_types_ap->Find (name_cstr, kv_pair)) + { + die_offsets.swap(kv_pair.value); + } + } + else + { + if (!m_indexed) + Index (); + + m_type_index.Find (name, die_offsets); + } + + + const size_t num_matches = die_offsets.size(); + if (num_matches) { + const uint32_t initial_types_size = types.GetSize(); + DWARFCompileUnit* dwarf_cu = NULL; + const DWARFDebugInfoEntry* die = NULL; DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; iFind (name_cstr, kv_pair)) + { + die_offsets.swap(kv_pair.value); + } + } + else + { + if (!m_indexed) + Index (); + m_namespace_index.Find (name, die_offsets); + } DWARFCompileUnit* dwarf_cu = NULL; const DWARFDebugInfoEntry* die = NULL; - DIEArray die_offsets; - const size_t num_matches = m_namespace_index.Find (name, die_offsets); + const size_t num_matches = die_offsets.size(); if (num_matches) { DWARFDebugInfo* debug_info = DebugInfo(); @@ -3079,26 +3120,41 @@ // This function can be used when a DIE is found that is a forward declaration // DIE and we want to try and find a type that has the complete definition. TypeSP -SymbolFileDWARF::FindDefinitionTypeForDIE ( - DWARFCompileUnit* cu, - const DWARFDebugInfoEntry *die, - const ConstString &type_name -) +SymbolFileDWARF::FindDefinitionTypeForDIE (DWARFCompileUnit* cu, + const DWARFDebugInfoEntry *die, + const ConstString &type_name) { TypeSP type_sp; if (cu == NULL || die == NULL || !type_name) return type_sp; - if (!m_indexed) - Index (); + DIEArray die_offsets; + + if (m_apple_types_ap.get()) + { + const char *name_cstr = type_name.GetCString(); + DWARFMappedHash::MemoryTable::Pair kv_pair; + if (m_apple_types_ap->Find (name_cstr, kv_pair)) + { + die_offsets.swap(kv_pair.value); + } + } + else + { + if (!m_indexed) + Index (); + + m_type_index.Find (type_name, die_offsets); + } + + + const size_t num_matches = die_offsets.size(); const dw_tag_t type_tag = die->Tag(); DWARFCompileUnit* type_cu = NULL; const DWARFDebugInfoEntry* type_die = NULL; - DIEArray die_offsets; - const size_t num_matches = m_type_index.Find (type_name, die_offsets); if (num_matches) { DWARFDebugInfo* debug_info = DebugInfo(); @@ -4235,17 +4291,29 @@ variables.reset(new VariableList()); sc.comp_unit->SetVariableList(variables); - // Index if we already haven't to make sure the compile units - // get indexed and make their global DIE index list - if (!m_indexed) - Index (); - DWARFCompileUnit* match_dwarf_cu = NULL; const DWARFDebugInfoEntry* die = NULL; DIEArray die_offsets; - const size_t num_matches = m_global_index.FindAllEntriesForCompileUnit (dwarf_cu->GetOffset(), - dwarf_cu->GetNextCompileUnitOffset(), - die_offsets); + if (m_apple_names_ap.get()) + { + // TODO: implement finding all items in + m_apple_names_ap->AppendAllDIEsInRange (dwarf_cu->GetOffset(), + dwarf_cu->GetNextCompileUnitOffset(), + die_offsets); + } + else + { + // Index if we already haven't to make sure the compile units + // get indexed and make their global DIE index list + if (!m_indexed) + Index (); + + m_global_index.FindAllEntriesForCompileUnit (dwarf_cu->GetOffset(), + dwarf_cu->GetNextCompileUnitOffset(), + die_offsets); + } + + const size_t num_matches = die_offsets.size(); if (num_matches) { DWARFDebugInfo* debug_info = DebugInfo(); @@ -4284,130 +4352,136 @@ return var_sp; // Already been parsed! const dw_tag_t tag = die->Tag(); - DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); - if (num_attributes > 0) - { - const char *name = NULL; - const char *mangled = NULL; - Declaration decl; - uint32_t i; - Type *var_type = NULL; - DWARFExpression location; - bool is_external = false; - bool is_artificial = false; - bool location_is_const_value_data = false; - AccessType accessibility = eAccessNone; - - for (i=0; iGetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; - case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; - case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; - case DW_AT_name: name = form_value.AsCString(&get_debug_str_data()); break; - case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break; - case DW_AT_type: var_type = ResolveTypeUID(form_value.Reference(dwarf_cu)); break; - case DW_AT_external: is_external = form_value.Unsigned() != 0; break; - case DW_AT_const_value: - location_is_const_value_data = true; - // Fall through... - case DW_AT_location: - { - if (form_value.BlockData()) - { - const DataExtractor& debug_info_data = get_debug_info_data(); - - uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); - uint32_t block_length = form_value.Unsigned(); - location.SetOpcodeData(get_debug_info_data(), block_offset, block_length); - } - else + + if ((tag == DW_TAG_variable) || + (tag == DW_TAG_constant) || + (tag == DW_TAG_formal_parameter && sc.function)) + { + DWARFDebugInfoEntry::Attributes attributes; + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); + if (num_attributes > 0) + { + const char *name = NULL; + const char *mangled = NULL; + Declaration decl; + uint32_t i; + Type *var_type = NULL; + DWARFExpression location; + bool is_external = false; + bool is_artificial = false; + bool location_is_const_value_data = false; + AccessType accessibility = eAccessNone; + + for (i=0; iGetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; + case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; + case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; + case DW_AT_name: name = form_value.AsCString(&get_debug_str_data()); break; + case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break; + case DW_AT_type: var_type = ResolveTypeUID(form_value.Reference(dwarf_cu)); break; + case DW_AT_external: is_external = form_value.Unsigned() != 0; break; + case DW_AT_const_value: + location_is_const_value_data = true; + // Fall through... + case DW_AT_location: { - const DataExtractor& debug_loc_data = get_debug_loc_data(); - const dw_offset_t debug_loc_offset = form_value.Unsigned(); + if (form_value.BlockData()) + { + const DataExtractor& debug_info_data = get_debug_info_data(); - size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset); - if (loc_list_length > 0) + uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); + uint32_t block_length = form_value.Unsigned(); + location.SetOpcodeData(get_debug_info_data(), block_offset, block_length); + } + else { - location.SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length); - assert (func_low_pc != LLDB_INVALID_ADDRESS); - location.SetLocationListSlide (func_low_pc - dwarf_cu->GetBaseAddress()); + const DataExtractor& 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); + if (loc_list_length > 0) + { + location.SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length); + assert (func_low_pc != LLDB_INVALID_ADDRESS); + location.SetLocationListSlide (func_low_pc - dwarf_cu->GetBaseAddress()); + } } } - } - break; + break; - case DW_AT_artificial: is_artificial = form_value.Unsigned() != 0; break; - case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; - case DW_AT_declaration: - case DW_AT_description: - case DW_AT_endianity: - case DW_AT_segment: - case DW_AT_start_scope: - case DW_AT_visibility: - default: - case DW_AT_abstract_origin: - case DW_AT_sibling: - case DW_AT_specification: - break; + case DW_AT_artificial: is_artificial = form_value.Unsigned() != 0; break; + case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; + case DW_AT_declaration: + case DW_AT_description: + case DW_AT_endianity: + case DW_AT_segment: + case DW_AT_start_scope: + case DW_AT_visibility: + default: + case DW_AT_abstract_origin: + case DW_AT_sibling: + case DW_AT_specification: + break; + } } } - } - if (location.IsValid()) - { - assert(var_type != DIE_IS_BEING_PARSED); + if (location.IsValid()) + { + assert(var_type != DIE_IS_BEING_PARSED); - ValueType scope = eValueTypeInvalid; + ValueType scope = eValueTypeInvalid; - const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die); - dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; + const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die); + dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; - if (tag == DW_TAG_formal_parameter) - scope = eValueTypeVariableArgument; - else if (is_external || parent_tag == DW_TAG_compile_unit) - scope = eValueTypeVariableGlobal; - else - scope = eValueTypeVariableLocal; + if (tag == DW_TAG_formal_parameter) + scope = eValueTypeVariableArgument; + else if (is_external || parent_tag == DW_TAG_compile_unit) + scope = eValueTypeVariableGlobal; + else + scope = eValueTypeVariableLocal; - SymbolContextScope * symbol_context_scope = NULL; - if (parent_tag == DW_TAG_compile_unit) - { - symbol_context_scope = sc.comp_unit; + SymbolContextScope * symbol_context_scope = NULL; + if (parent_tag == DW_TAG_compile_unit) + { + symbol_context_scope = sc.comp_unit; + } + else if (sc.function != NULL) + { + symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); + if (symbol_context_scope == NULL) + symbol_context_scope = sc.function; + } + + assert(symbol_context_scope != NULL); + var_sp.reset (new Variable(die->GetOffset(), + name, + mangled, + var_type, + scope, + symbol_context_scope, + &decl, + location, + is_external, + is_artificial)); + + var_sp->SetLocationIsConstantValueData (location_is_const_value_data); } - else if (sc.function != NULL) - { - symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); - if (symbol_context_scope == NULL) - symbol_context_scope = sc.function; - } - - assert(symbol_context_scope != NULL); - var_sp.reset (new Variable(die->GetOffset(), - name, - mangled, - var_type, - scope, - symbol_context_scope, - &decl, - location, - is_external, - is_artificial)); - - var_sp->SetLocationIsConstantValueData (location_is_const_value_data); } + // Cache var_sp even if NULL (the variable was just a specification or + // was missing vital information to be able to be displayed in the debugger + // (missing location due to optimization, etc)) so we don't re-parse + // this DIE over and over later... + m_die_to_variable_sp[die] = var_sp; } - // Cache var_sp even if NULL (the variable was just a specification or - // was missing vital information to be able to be displayed in the debugger - // (missing location due to optimization, etc)) so we don't re-parse - // this DIE over and over later... - m_die_to_variable_sp[die] = var_sp; return var_sp; } 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=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Tue Oct 4 17:41:51 2011 @@ -166,6 +166,8 @@ const lldb_private::DataExtractor& get_debug_str_data (); const lldb_private::DataExtractor& get_apple_names_data (); const lldb_private::DataExtractor& get_apple_types_data (); + const lldb_private::DataExtractor& get_apple_namespaces_data (); + DWARFDebugAbbrev* DebugAbbrev(); const DWARFDebugAbbrev* DebugAbbrev() const; @@ -326,11 +328,18 @@ const NameToDIE &name_to_die, lldb_private::SymbolContextList& sc_list); + void FindFunctions ( + const lldb_private::RegularExpression ®ex, + const DWARFMappedHash::MemoryTable &memory_table, + lldb_private::SymbolContextList& sc_list); + lldb::TypeSP FindDefinitionTypeForDIE ( DWARFCompileUnit* cu, const DWARFDebugInfoEntry *die, const lldb_private::ConstString &type_name); + void ParseFunctions (const DIEArray &die_offsets, + lldb_private::SymbolContextList& sc_list); lldb::TypeSP GetTypeForDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die); @@ -388,22 +397,24 @@ lldb_private::DataExtractor m_data_debug_str; lldb_private::DataExtractor m_data_apple_names; lldb_private::DataExtractor m_data_apple_types; + lldb_private::DataExtractor m_data_apple_namespaces; // The auto_ptr items below are generated on demand if and when someone accesses // them through a non const version of this class. std::auto_ptr m_abbr; std::auto_ptr m_info; std::auto_ptr m_line; - HashedNameToDIE::MemoryTable m_apple_names; - HashedNameToDIE::MemoryTable m_apple_types; + std::auto_ptr m_apple_names_ap; + std::auto_ptr m_apple_types_ap; + std::auto_ptr m_apple_namespaces_ap; NameToDIE m_function_basename_index; // All concrete functions NameToDIE m_function_fullname_index; // All concrete functions NameToDIE m_function_method_index; // All inlined functions NameToDIE m_function_selector_index; // All method names for functions of classes NameToDIE m_objc_class_selectors_index; // Given a class name, find all selectors for the class - NameToDIE m_global_index; // Global and static variables - NameToDIE m_type_index; // All type DIE offsets - NameToDIE m_namespace_index; // All type DIE offsets + NameToDIE m_global_index; // Global and static variables + NameToDIE m_type_index; // All type DIE offsets + NameToDIE m_namespace_index; // All type DIE offsets bool m_indexed:1, m_is_external_ast_source:1; Modified: lldb/trunk/source/Symbol/ObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ObjectFile.cpp (original) +++ lldb/trunk/source/Symbol/ObjectFile.cpp Tue Oct 4 17:41:51 2011 @@ -223,6 +223,7 @@ case eSectionTypeDWARFDebugStr: return eAddressClassDebug; case eSectionTypeDWARFAppleNames: return eAddressClassDebug; case eSectionTypeDWARFAppleTypes: return eAddressClassDebug; + case eSectionTypeDWARFAppleNamespaces: return eAddressClassDebug; case eSectionTypeEHFrame: return eAddressClassRuntime; case eSectionTypeOther: return eAddressClassUnknown; } Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Tue Oct 4 17:41:51 2011 @@ -981,7 +981,8 @@ collection::const_iterator pos, end = m_symbol_contexts.end(); for (pos = m_symbol_contexts.begin(); pos != end; ++pos) { - pos->Dump(s, target); + //pos->Dump(s, target); + pos->GetDescription(s, eDescriptionLevelVerbose, target); } s->IndentLess(); } Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original) +++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Tue Oct 4 17:41:51 2011 @@ -104,12 +104,12 @@ bool ObjCLanguageRuntime::ParseMethodName (const char *name, ConstString *class_name, - ConstString *method_name, - ConstString *base_name) + ConstString *selector_name, + ConstString *name_sans_category) { if (class_name) { class_name->Clear(); } - if (method_name) { method_name->Clear(); } - if (base_name) { base_name->Clear(); } + if (selector_name) { selector_name->Clear(); } + if (name_sans_category) { name_sans_category->Clear(); } if (IsPossibleObjCMethodName (name)) { @@ -122,35 +122,35 @@ // "]" suffix if (name_len >= 6 && name[name_len - 1] == ']') { - const char *method_name_ptr; - method_name_ptr = strchr (name, ' '); - if (method_name_ptr) + const char *selector_name_ptr; + selector_name_ptr = strchr (name, ' '); + if (selector_name_ptr) { if (class_name) - class_name->SetCStringWithLength (name + 2, method_name_ptr - name - 2); + class_name->SetCStringWithLength (name + 2, selector_name_ptr - name - 2); // Skip the space - ++method_name_ptr; + ++selector_name_ptr; // Extract the objective C basename and add it to the // accelerator tables - size_t method_name_len = name_len - (method_name_ptr - name) - 1; - if (method_name) - method_name->SetCStringWithLength (method_name_ptr, method_name_len); + size_t selector_name_len = name_len - (selector_name_ptr - name) - 1; + if (selector_name) + selector_name->SetCStringWithLength (selector_name_ptr, selector_name_len); // Also see if this is a "category" on our class. If so strip off the category name, // and add the class name without it to the basename table. - if (base_name) + if (name_sans_category) { - const char *first_paren = (char *) memchr (name, '(', method_name_ptr - name); + const char *first_paren = (char *) memchr (name, '(', selector_name_ptr - name); if (first_paren) { - const char *second_paren = (char *) memchr (first_paren, ')', method_name_ptr - first_paren); + const char *second_paren = (char *) memchr (first_paren, ')', selector_name_ptr - first_paren); if (second_paren) { std::string buffer (name, first_paren - name); buffer.append (second_paren + 1); - base_name->SetCString (buffer.c_str()); + name_sans_category->SetCString (buffer.c_str()); } } Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=141128&r1=141127&r2=141128&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Tue Oct 4 17:41:51 2011 @@ -261,6 +261,7 @@ case eSectionTypeDWARFDebugStr: return "dwarf-str"; case eSectionTypeDWARFAppleNames: return "apple-names"; case eSectionTypeDWARFAppleTypes: return "apple-types"; + case eSectionTypeDWARFAppleNamespaces: return "apple-namespaces"; case eSectionTypeEHFrame: return "eh-frame"; case eSectionTypeOther: return "regular"; } From gclayton at apple.com Tue Oct 4 17:56:44 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 04 Oct 2011 22:56:44 -0000 Subject: [Lldb-commits] [lldb] r141130 - /lldb/trunk/include/lldb/Core/MappedHash.h Message-ID: <20111004225646.E8179312800A@llvm.org> Author: gclayton Date: Tue Oct 4 17:56:35 2011 New Revision: 141130 URL: http://llvm.org/viewvc/llvm-project?rev=141130&view=rev Log: Added missing file. Added: lldb/trunk/include/lldb/Core/MappedHash.h Added: lldb/trunk/include/lldb/Core/MappedHash.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/MappedHash.h?rev=141130&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/MappedHash.h (added) +++ lldb/trunk/include/lldb/Core/MappedHash.h Tue Oct 4 17:56:35 2011 @@ -0,0 +1,343 @@ +// +// MappedHash.h +// + +#ifndef liblldb_MappedHash_h_ +#define liblldb_MappedHash_h_ + +#include +#include +#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/Stream.h" + +class MappedHash +{ +public: + + enum HashFunctionType + { + eHashFunctionDJB = 0u, // Daniel J Bernstein hash function that is also used by the ELF GNU_HASH sections + }; + + + static uint32_t + HashStringUsingDJB (const char *s) + { + uint32_t h = 5381; + + for (unsigned char c = *s; c; c = *++s) + h = ((h << 5) + h) + c; + + return h; + } + + static uint32_t + HashString (const uint8_t hash_function, const char *s) + { + switch (hash_function) + { + case MappedHash::eHashFunctionDJB: + return HashStringUsingDJB (s); + + default: + break; + } + assert (!"Invalid hash function index"); + return 0; + } + + + static const uint32_t HASH_MAGIC = 0x48415348u; + static const uint32_t HASH_CIGAM = 0x48534148u; + + template + struct Header + { + typedef T HeaderData; + + uint32_t magic; // 'HASH' magic value to allow endian detection + uint16_t version; // Version number + uint8_t addr_bytesize; // Size in bytes of an address + uint8_t hash_function; // The hash function enumeration that was used + uint32_t bucket_count; // The number of buckets in this hash table + uint32_t hashes_count; // The total number of unique hash values and hash data offsets in this table + uint32_t header_data_len; // The size in bytes of the "header_data" template member below + HeaderData header_data; // + + Header () : + magic ('HASH'), + version (1), + addr_bytesize (4), + hash_function (eHashFunctionDJB), + bucket_count (0), + hashes_count (0), + header_data_len (sizeof(T)), + header_data () + { + } + + virtual + ~Header() + { + } + + size_t + GetByteSize() const + { + return sizeof(magic) + + sizeof(version) + + sizeof(addr_bytesize) + + sizeof(hash_function) + + sizeof(bucket_count) + + sizeof(hashes_count) + + sizeof(header_data_len) + + header_data_len; + } + + virtual size_t + GetByteSize (const HeaderData &header_data) = 0; + + size_t + SetHeaderDataByteSize (uint32_t header_data_byte_size) + { + header_data_len = header_data_byte_size; + } + + void + Dump (lldb_private::Stream &s) + { + s.Printf ("header.magic = 0x%8.8x\n", magic); + s.Printf ("header.version = 0x%4.4x\n", version); + s.Printf ("header.addr_bytesize = 0x%2.2x\n", addr_bytesize); + s.Printf ("header.hash_function = 0x%2.2x\n", hash_function); + s.Printf ("header.bucket_count = 0x%8.8x %u\n", bucket_count, bucket_count); + s.Printf ("header.hashes_count = 0x%8.8x %u\n", hashes_count, hashes_count); + s.Printf ("header.header_data_len = 0x%8.8x %u\n", header_data_len, header_data_len); + } + + virtual uint32_t + Read (lldb_private::DataExtractor &data, uint32_t offset) + { + if (data.ValidOffsetForDataOfSize (offset, + sizeof(magic) + + sizeof(version) + + sizeof(addr_bytesize) + + sizeof(hash_function) + + sizeof(bucket_count) + + sizeof(hashes_count) + + sizeof(header_data_len))) + { + magic = data.GetU32 (&offset); + if (magic != HASH_MAGIC) + { + if (magic == HASH_CIGAM) + { + switch (data.GetByteOrder()) + { + case lldb::eByteOrderBig: + data.SetByteOrder(lldb::eByteOrderLittle); + break; + case lldb::eByteOrderLittle: + data.SetByteOrder(lldb::eByteOrderBig); + break; + default: + return UINT32_MAX; + } + } + else + { + // Magic bytes didn't match + version = 0; + return UINT32_MAX; + } + } + + version = data.GetU16 (&offset); + if (version != 1) + { + // Unsupported version + return UINT32_MAX; + } + addr_bytesize = data.GetU8 (&offset); + hash_function = data.GetU8 (&offset); + bucket_count = data.GetU32 (&offset); + hashes_count = data.GetU32 (&offset); + header_data_len = data.GetU32 (&offset); + return offset; + } + return UINT32_MAX; + } +// +// // Returns a buffer that contains a serialized version of this table +// // that must be freed with free(). +// virtual void * +// Write (int fd); + }; + + // A class for reading and using a saved hash table from a block of data + // in memory + template + class MemoryTable + { + public: + typedef __HeaderType HeaderType; + typedef __KeyType KeyType; + typedef __HashData HashData; + + enum Result + { + eResultKeyMatch = 0u, // The entry was found, key matched and "pair" was filled in successfully + eResultKeyMismatch = 1u, // Bucket hash data collision, but key didn't match + eResultEndOfHashData = 2u, // The chain of items for this hash data in this bucket is terminated, search no more + eResultError = 3u // Error parsing the hash data, abort + }; + + struct Pair + { + KeyType key; + HashData value; + }; + + MemoryTable (lldb_private::DataExtractor &data) : + m_header (), + m_hash_indexes (NULL), + m_hash_values (NULL), + m_hash_offsets (NULL) + { + uint32_t offset = m_header.Read (data, 0); + if (offset != UINT32_MAX) + { + m_hash_indexes = (uint32_t *)data.GetData (&offset, m_header.bucket_count * sizeof(uint32_t)); + m_hash_values = (uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t)); + m_hash_offsets = (uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t)); + } + } + + virtual + ~MemoryTable () + { + } + + bool + IsValid () const + { + return m_header.version == 1 && m_header.hash_function == eHashFunctionDJB; + } + + uint32_t + GetHashIndex (uint32_t bucket_idx) const + { + if (m_hash_indexes && bucket_idx < m_header.bucket_count) + return m_hash_indexes[bucket_idx]; + return UINT32_MAX; + } + + uint32_t + GetHashValue (uint32_t hash_idx) const + { + if (m_hash_values && hash_idx < m_header.hashes_count) + return m_hash_values[hash_idx]; + return UINT32_MAX; + } + + uint32_t + GetHashDataOffset (uint32_t hash_idx) const + { + if (m_hash_offsets && hash_idx < m_header.hashes_count) + return m_hash_offsets[hash_idx]; + return UINT32_MAX; + } + + bool + Find (const char *name, Pair &pair) const + { + if (IsValid ()) + { + const uint32_t bucket_count = m_header.bucket_count; + const uint32_t hash_count = m_header.hashes_count; + const uint32_t hash_value = MappedHash::HashString (m_header.hash_function, name); + const uint32_t bucket_idx = hash_value % bucket_count; + uint32_t hash_idx = GetHashIndex (bucket_idx); + if (hash_idx < hash_count) + { + for (; hash_idx < hash_count; ++hash_idx) + { + const uint32_t curr_hash_value = GetHashValue (hash_idx); + if (curr_hash_value == hash_value) + { + uint32_t hash_data_offset = GetHashDataOffset (hash_idx); + while (hash_data_offset != UINT32_MAX) + { + const uint32_t prev_hash_data_offset = hash_data_offset; + Result hash_result = GetHashDataForName (name, &hash_data_offset, pair); + // Check the result of getting our hash data + switch (hash_result) + { + case eResultKeyMatch: + return true; + + case eResultKeyMismatch: + if (prev_hash_data_offset == hash_data_offset) + return false; + break; + + case eResultEndOfHashData: + // The last HashData for this key has been reached, stop searching + return false; + case eResultError: + // Error parsing the hash data, abort + return false; + } + } + } + if ((curr_hash_value % bucket_count) != bucket_idx) + break; + } + } + } + return false; + } + + // This method must be implemented in any subclasses. + // The KeyType is user specified and must somehow result in a string + // value. For example, the KeyType might be a string offset in a string + // table and subclasses can store their string table as a member of the + // subclass and return a valie "const char *" given a "key". The value + // could also be a C string pointer, in which case just returning "key" + // will suffice. + + virtual const char * + GetStringForKeyType (KeyType key) const = 0; + + // This method must be implemented in any subclasses and it must try to + // read one "Pair" at the offset pointed to by the "hash_data_offset_ptr" + // parameter. This offset should be updated as bytes are consumed and + // a value "Result" enum should be returned. If the "name" matches the + // full name for the "pair.key" (which must be filled in by this call), + // then the HashData in the pair ("pair.value") should be extracted and + // filled in and "eResultKeyMatch" should be returned. If "name" doesn't + // match this string for the key, then "eResultKeyMismatch" should be + // returned and all data for the current HashData must be consumed or + // skipped and the "hash_data_offset_ptr" offset needs to be updated to + // point to the next HashData. If the end of the HashData objects for + // a given hash value have been reached, then "eResultEndOfHashData" + // should be returned. If anything else goes wrong during parsing, + // return "eResultError" and the corresponding "Find()" function will + // be canceled and return false. + + virtual Result + GetHashDataForName (const char *name, + uint32_t* hash_data_offset_ptr, + Pair &pair) const = 0; + + protected: + // Implementation agnostic information + HeaderType m_header; + uint32_t *m_hash_indexes; + uint32_t *m_hash_values; + uint32_t *m_hash_offsets; + }; + +}; + +#endif // #ifndef liblldb_MappedHash_h_ \ No newline at end of file From johnny.chen at apple.com Tue Oct 4 19:43:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 05 Oct 2011 00:43:00 -0000 Subject: [Lldb-commits] [lldb] r141144 - in /lldb/trunk: include/lldb/Interpreter/CommandInterpreter.h source/Interpreter/CommandInterpreter.cpp test/functionalities/stop-hook/multiple_threads/ test/functionalities/stop-hook/multiple_threads/Makefile test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py test/functionalities/stop-hook/multiple_threads/main.cpp Message-ID: <20111005004301.6B3252A6C12C@llvm.org> Author: johnny Date: Tue Oct 4 19:42:59 2011 New Revision: 141144 URL: http://llvm.org/viewvc/llvm-project?rev=141144&view=rev Log: Fix a problem where the stop-hook command 'frame variable g_val' produces nothing when newly created threads were subsequently stopped due to breakpoint hit. The stop-hook mechanism delegates to CommandInterpreter::HandleCommands() to execuet the commands. Make sure the execution context is switched only once at the beginning of HandleCommands() only and don't update the context while looping on each individual command to be executed. rdar://problem/10228156 Added: lldb/trunk/test/functionalities/stop-hook/multiple_threads/ lldb/trunk/test/functionalities/stop-hook/multiple_threads/Makefile lldb/trunk/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py lldb/trunk/test/functionalities/stop-hook/multiple_threads/main.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=141144&r1=141143&r2=141144&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Tue Oct 4 19:42:59 2011 @@ -147,7 +147,8 @@ bool add_to_history, CommandReturnObject &result, ExecutionContext *override_context = NULL, - bool repeat_on_empty_command = true); + bool repeat_on_empty_command = true, + bool no_context_switching = false); //------------------------------------------------------------------ /// Execute a list of commands in sequence. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=141144&r1=141143&r2=141144&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Oct 4 19:42:59 2011 @@ -952,7 +952,8 @@ bool add_to_history, CommandReturnObject &result, ExecutionContext *override_context, - bool repeat_on_empty_command) + bool repeat_on_empty_command, + bool no_context_switching) { @@ -975,7 +976,8 @@ Timer scoped_timer (__PRETTY_FUNCTION__, "Handling command: %s.", command_line); - UpdateExecutionContext (override_context); + if (!no_context_switching) + UpdateExecutionContext (override_context); bool empty_command = false; bool comment_command = false; @@ -1911,7 +1913,12 @@ } CommandReturnObject tmp_result; - bool success = HandleCommand(cmd, false, tmp_result, NULL); + // If override_context is not NULL, pass no_context_switching = true for + // HandleCommand() since we updated our context already. + bool success = HandleCommand(cmd, false, tmp_result, + NULL, /* override_context */ + true, /* repeat_on_empty_command */ + override_context != NULL /* no_context_switching */); if (print_results) { Added: lldb/trunk/test/functionalities/stop-hook/multiple_threads/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/multiple_threads/Makefile?rev=141144&view=auto ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/multiple_threads/Makefile (added) +++ lldb/trunk/test/functionalities/stop-hook/multiple_threads/Makefile Tue Oct 4 19:42:59 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py?rev=141144&view=auto ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py (added) +++ lldb/trunk/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py Tue Oct 4 19:42:59 2011 @@ -0,0 +1,74 @@ +""" +Test that lldb stop-hook works for multiple threads. +""" + +import os, time +import unittest2 +import lldb +import pexpect +from lldbtest import * + +class StopHookForMultipleThreadsTestCase(TestBase): + + mydir = os.path.join("functionalities", "stop-hook", "multiple_threads") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_stop_hook_multiple_threads_with_dsym(self): + """Test that lldb stop-hook works for multiple threads.""" + self.buildDsym(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.stop_hook_multiple_threads() + + def test_stop_hook_multiple_threads_with_dwarf(self): + """Test that lldb stop-hook works for multiple threads.""" + self.buildDwarf(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.stop_hook_multiple_threads() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Our simple source filename. + self.source = 'main.cpp' + # Find the line number to break inside main(). + self.first_stop = line_number(self.source, '// Set break point at this line, and add a stop-hook.') + self.thread_function = line_number(self.source, '// Break here to test that the stop-hook mechanism works for multiple threads.') + # Build dictionary to have unique executable names for each test method. + self.exe_name = self.testMethodName + self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} + + def stop_hook_multiple_threads(self): + """Test that lldb stop-hook works for multiple threads.""" + exe = os.path.join(os.getcwd(), self.exe_name) + prompt = "(lldb) " + + # So that the child gets torn down after the test. + self.child = pexpect.spawn('%s %s' % (self.lldbHere, exe)) + child = self.child + # Turn on logging for what the child sends back. + if self.TraceOn(): + child.logfile_read = sys.stdout + + # Set the breakpoint, followed by the target stop-hook commands. + child.expect_exact(prompt) + child.sendline('breakpoint set -f main.cpp -l %d' % self.first_stop) + child.expect_exact(prompt) + child.sendline('breakpoint set -f main.cpp -l %d' % self.thread_function) + child.expect_exact(prompt) + + # Now run the program, expect to stop at the the first breakpoint which is within the stop-hook range. + child.sendline('run') + child.expect_exact(prompt) + child.sendline('target stop-hook add -o "frame variable -g g_val"') + child.expect_exact(prompt) + + # Continue and expect to find the output emitted by the firing of our stop hook. + child.sendline('continue') + child.expect_exact('(uint32_t) g_val = ') + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/stop-hook/multiple_threads/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/multiple_threads/main.cpp?rev=141144&view=auto ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/multiple_threads/main.cpp (added) +++ lldb/trunk/test/functionalities/stop-hook/multiple_threads/main.cpp Tue Oct 4 19:42:59 2011 @@ -0,0 +1,88 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// C includes +#include +#include +#include +#include +#include + +pthread_t g_thread_1 = NULL; +pthread_t g_thread_2 = NULL; +pthread_t g_thread_3 = NULL; + +uint32_t g_val = 0; + +uint32_t access_pool (uint32_t flag = 0); + +uint32_t +access_pool (uint32_t flag) +{ + static pthread_mutex_t g_access_mutex = PTHREAD_MUTEX_INITIALIZER; + if (flag == 0) + ::pthread_mutex_lock (&g_access_mutex); + + uint32_t old_val = g_val; + if (flag != 0) + g_val = old_val + 1; + + if (flag == 0) + ::pthread_mutex_unlock (&g_access_mutex); + return g_val; +} + +void * +thread_func (void *arg) +{ + uint32_t thread_index = *((uint32_t *)arg); // Break here to test that the stop-hook mechanism works for multiple threads. + printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index); + + uint32_t count = 0; + uint32_t val; + while (count++ < 15) + { + // random micro second sleep from zero to 3 seconds + int usec = ::rand() % 3000000; + printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec); + ::usleep (usec); + + if (count < 7) + val = access_pool (); + else + val = access_pool (1); + + printf ("%s (thread = %u) after usleep access_pool returns %d (count=%d)...\n", __FUNCTION__, thread_index, val, count); + } + printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index); + return NULL; +} + + +int main (int argc, char const *argv[]) +{ + int err; + void *thread_result = NULL; + uint32_t thread_index_1 = 1; + uint32_t thread_index_2 = 2; + uint32_t thread_index_3 = 3; + + printf ("Before turning all three threads loose...\n"); // Set break point at this line, and add a stop-hook. + // Create 3 threads + err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1); + err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2); + err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3); + + // Join all of our threads + err = ::pthread_join (g_thread_1, &thread_result); + err = ::pthread_join (g_thread_2, &thread_result); + err = ::pthread_join (g_thread_3, &thread_result); + + return 0; +} From gclayton at apple.com Tue Oct 4 22:14:31 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 05 Oct 2011 03:14:31 -0000 Subject: [Lldb-commits] [lldb] r141160 - /lldb/trunk/source/Target/StackFrameList.cpp Message-ID: <20111005031432.315FA2A6C12C@llvm.org> Author: gclayton Date: Tue Oct 4 22:14:31 2011 New Revision: 141160 URL: http://llvm.org/viewvc/llvm-project?rev=141160&view=rev Log: Fixed a crasher where the m_frames collection was being accessed without using the mutex. Modified: lldb/trunk/source/Target/StackFrameList.cpp Modified: lldb/trunk/source/Target/StackFrameList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=141160&r1=141159&r2=141160&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrameList.cpp (original) +++ lldb/trunk/source/Target/StackFrameList.cpp Tue Oct 4 22:14:31 2011 @@ -395,12 +395,13 @@ { if (m_thread.GetID() == m_thread.GetProcess().GetThreadList().GetSelectedThread()->GetID()) { - StackFrameSP frame_sp = m_frames[m_selected_frame_idx]; + StackFrameSP frame_sp (GetFrameAtIndex (GetSelectedFrameIndex())); if (frame_sp) { - SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextEverything); + SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextLineEntry); if (sc.line_entry.file) - m_thread.GetProcess().GetTarget().GetSourceManager().SetDefaultFileAndLine (sc.line_entry.file, sc.line_entry.line); + m_thread.GetProcess().GetTarget().GetSourceManager().SetDefaultFileAndLine (sc.line_entry.file, + sc.line_entry.line); } } } From johnny.chen at apple.com Wed Oct 5 16:35:46 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 05 Oct 2011 21:35:46 -0000 Subject: [Lldb-commits] [lldb] r141217 - in /lldb/trunk: include/lldb/Target/Target.h source/Commands/CommandObjectWatchpoint.cpp source/Commands/CommandObjectWatchpoint.h source/Target/Target.cpp test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py test/functionalities/watchpoint/watchpoint_commands/main.c test/python_api/watchpoint/TestWatchpointIgnoreCount.py Message-ID: <20111005213546.D3301312800A@llvm.org> Author: johnny Date: Wed Oct 5 16:35:46 2011 New Revision: 141217 URL: http://llvm.org/viewvc/llvm-project?rev=141217&view=rev Log: Add capability to set ignore count for watchpoint on the command line: watchpoint ignore -i [] Add tests of watchpoint ignore_count for command line as well as API. Added: lldb/trunk/test/python_api/watchpoint/TestWatchpointIgnoreCount.py Modified: lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp lldb/trunk/source/Commands/CommandObjectWatchpoint.h lldb/trunk/source/Target/Target.cpp lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/main.c Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=141217&r1=141216&r2=141217&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Wed Oct 5 16:35:46 2011 @@ -341,6 +341,9 @@ EnableAllWatchpointLocations (bool end_to_end = true); bool + IgnoreAllWatchpointLocations (uint32_t ignore_count); + + bool DisableWatchpointLocationByID (lldb::watch_id_t watch_id); bool @@ -349,6 +352,9 @@ bool RemoveWatchpointLocationByID (lldb::watch_id_t watch_id); + bool + IgnoreWatchpointLocationByID (lldb::watch_id_t watch_id, uint32_t ignore_count); + void ModulesDidLoad (ModuleList &module_list); Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp?rev=141217&r1=141216&r2=141217&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp Wed Oct 5 16:35:46 2011 @@ -155,16 +155,19 @@ CommandObjectSP enable_command_object (new CommandObjectWatchpointEnable (interpreter)); CommandObjectSP disable_command_object (new CommandObjectWatchpointDisable (interpreter)); CommandObjectSP delete_command_object (new CommandObjectWatchpointDelete (interpreter)); + CommandObjectSP ignore_command_object (new CommandObjectWatchpointIgnore (interpreter)); list_command_object->SetCommandName ("watchpoint list"); enable_command_object->SetCommandName("watchpoint enable"); disable_command_object->SetCommandName("watchpoint disable"); delete_command_object->SetCommandName("watchpoint delete"); + ignore_command_object->SetCommandName("watchpoint ignore"); status = LoadSubCommand ("list", list_command_object); status = LoadSubCommand ("enable", enable_command_object); status = LoadSubCommand ("disable", disable_command_object); status = LoadSubCommand ("delete", delete_command_object); + status = LoadSubCommand ("ignore", ignore_command_object); } CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint() @@ -555,3 +558,138 @@ return result.Succeeded(); } +//------------------------------------------------------------------------- +// CommandObjectWatchpointIgnore::CommandOptions +//------------------------------------------------------------------------- +#pragma mark Ignore::CommandOptions + +CommandObjectWatchpointIgnore::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : + Options (interpreter), + m_ignore_count (0) +{ +} + +CommandObjectWatchpointIgnore::CommandOptions::~CommandOptions () +{ +} + +OptionDefinition +CommandObjectWatchpointIgnore::CommandOptions::g_option_table[] = +{ + { LLDB_OPT_SET_ALL, true, "ignore-count", 'i', required_argument, NULL, NULL, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping." }, + { 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL } +}; + +const OptionDefinition* +CommandObjectWatchpointIgnore::CommandOptions::GetDefinitions () +{ + return g_option_table; +} + +Error +CommandObjectWatchpointIgnore::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) +{ + Error error; + char short_option = (char) m_getopt_table[option_idx].val; + + switch (short_option) + { + case 'i': + { + m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); + if (m_ignore_count == UINT32_MAX) + error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", option_arg); + } + break; + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; +} + +void +CommandObjectWatchpointIgnore::CommandOptions::OptionParsingStarting () +{ + m_ignore_count = 0; +} + +//------------------------------------------------------------------------- +// CommandObjectWatchpointIgnore +//------------------------------------------------------------------------- +#pragma mark Ignore + +CommandObjectWatchpointIgnore::CommandObjectWatchpointIgnore(CommandInterpreter &interpreter) : + CommandObject(interpreter, + "watchpoint ignore", + "Set ignore count on the specified watchpoint(s). If no watchpoints are specified, set them all.", + NULL), + m_options (interpreter) +{ + CommandArgumentEntry arg; + CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); + // Add the entry for the first argument for this command to the object's arguments vector. + m_arguments.push_back(arg); +} + +CommandObjectWatchpointIgnore::~CommandObjectWatchpointIgnore() +{ +} + +Options * +CommandObjectWatchpointIgnore::GetOptions () +{ + return &m_options; +} + +bool +CommandObjectWatchpointIgnore::Execute(Args& args, CommandReturnObject &result) +{ + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + if (!CheckTargetForWatchpointOperations(target, result)) + return false; + + Mutex::Locker locker; + target->GetWatchpointLocationList().GetListMutex(locker); + + const WatchpointLocationList &watchpoints = target->GetWatchpointLocationList(); + + size_t num_watchpoints = watchpoints.GetSize(); + + if (num_watchpoints == 0) + { + result.AppendError("No watchpoints exist to be ignored."); + result.SetStatus(eReturnStatusFailed); + return false; + } + + if (args.GetArgumentCount() == 0) + { + target->IgnoreAllWatchpointLocations(m_options.m_ignore_count); + result.AppendMessageWithFormat("All watchpoints ignored. (%lu watchpoints)\n", num_watchpoints); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + // Particular watchpoints selected; ignore them. + std::vector wp_ids; + if (!VerifyWatchpointIDs(args, wp_ids)) + { + result.AppendError("Invalid watchpoints specification."); + result.SetStatus(eReturnStatusFailed); + return false; + } + + int count = 0; + const size_t size = wp_ids.size(); + for (size_t i = 0; i < size; ++i) + if (target->IgnoreWatchpointLocationByID(wp_ids[i], m_options.m_ignore_count)) + ++count; + result.AppendMessageWithFormat("%d watchpoints ignored.\n",count); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + + return result.Succeeded(); +} + Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.h?rev=141217&r1=141216&r2=141217&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectWatchpoint.h (original) +++ lldb/trunk/source/Commands/CommandObjectWatchpoint.h Wed Oct 5 16:35:46 2011 @@ -140,6 +140,56 @@ private: }; +//------------------------------------------------------------------------- +// CommandObjectWatchpointIgnore +//------------------------------------------------------------------------- + +class CommandObjectWatchpointIgnore : public CommandObject +{ +public: + CommandObjectWatchpointIgnore (CommandInterpreter &interpreter); + + virtual + ~CommandObjectWatchpointIgnore (); + + virtual bool + Execute (Args& command, + CommandReturnObject &result); + + virtual Options * + GetOptions (); + + class CommandOptions : public Options + { + public: + + CommandOptions (CommandInterpreter &interpreter); + + virtual + ~CommandOptions (); + + virtual Error + SetOptionValue (uint32_t option_idx, const char *option_arg); + + void + OptionParsingStarting (); + + const OptionDefinition * + GetDefinitions (); + + // Options table: Required for subclasses of Options. + + static OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + uint32_t m_ignore_count; + }; + +private: + CommandOptions m_options; +}; + } // namespace lldb_private #endif // liblldb_CommandObjectWatchpoint_h_ Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=141217&r1=141216&r2=141217&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Wed Oct 5 16:35:46 2011 @@ -672,6 +672,30 @@ return true; // Success! } +// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list +// during these operations. +bool +Target::IgnoreAllWatchpointLocations (uint32_t ignore_count) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); + if (log) + log->Printf ("Target::%s\n", __FUNCTION__); + + if (!ProcessIsValid()) + return false; + + size_t num_watchpoints = m_watchpoint_location_list.GetSize(); + for (size_t i = 0; i < num_watchpoints; ++i) + { + WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); + if (!wp_loc_sp) + return false; + + wp_loc_sp->SetIgnoreCount(ignore_count); + } + return true; // Success! +} + // Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. bool Target::DisableWatchpointLocationByID (lldb::watch_id_t watch_id) @@ -734,6 +758,26 @@ return false; } +// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. +bool +Target::IgnoreWatchpointLocationByID (lldb::watch_id_t watch_id, uint32_t ignore_count) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); + if (log) + log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); + + if (!ProcessIsValid()) + return false; + + WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.FindByID (watch_id); + if (wp_loc_sp) + { + wp_loc_sp->SetIgnoreCount(ignore_count); + return true; + } + return false; +} + ModuleSP Target::GetExecutableModule () { Modified: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py?rev=141217&r1=141216&r2=141217&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py (original) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py Wed Oct 5 16:35:46 2011 @@ -52,6 +52,19 @@ self.delete_read_write_watchpoint() @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_rw_watchpoint_set_ignore_count_with_dsym(self): + """Test watchpoint ignore count and expect to not to stop at all.""" + self.buildDsym(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.ignore_read_write_watchpoint() + + def test_rw_watchpoint_set_ignore_count_with_dwarf(self): + """Test watchpoint ignore count and expect to not to stop at all.""" + self.buildDwarf(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.ignore_read_write_watchpoint() + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_rw_disable_after_first_stop_with_dsym(self): """Test read_write watchpoint but disable it after the first stop.""" self.buildDsym(dictionary=self.d) @@ -175,6 +188,52 @@ self.expect("process status", substrs = ['exited']) + def ignore_read_write_watchpoint(self): + """Test watchpoint ignore count and expect to not to stop at all.""" + exe = os.path.join(os.getcwd(), self.exe_name) + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Add a breakpoint to set a watchpoint when stopped on the breakpoint. + self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % + (self.source, self.line)) + + # Run the program. + self.runCmd("run", RUN_SUCCEEDED) + + # We should be stopped again due to the breakpoint. + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # Now let's set a read_write-type watchpoint for 'global'. + # There should be two watchpoint hits (see main.c). + self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED, + substrs = ['Watchpoint created', 'size = 4', 'type = rw', + '%s:%d' % (self.source, self.decl)]) + + # Set the ignore count of the watchpoint immediately. + self.expect("watchpoint ignore -i 2", + substrs = ['All watchpoints ignored.']) + + # Use the '-v' option to do verbose listing of the watchpoint. + # Expect to find an ignore_count of 2. + self.expect("watchpoint list -v", + substrs = ['hit_count = 0', 'ignore_count = 2']) + + self.runCmd("process continue") + + # There should be no more watchpoint hit and the process status should + # be 'exited'. + self.expect("process status", + substrs = ['exited']) + + # Use the '-v' option to do verbose listing of the watchpoint. + # Expect to find a hit_count of 2 as well. + self.expect("watchpoint list -v", + substrs = ['hit_count = 2', 'ignore_count = 2']) + def read_write_watchpoint_disable_after_first_stop(self): """Do read_write watchpoint but disable it after the first stop.""" exe = os.path.join(os.getcwd(), self.exe_name) Modified: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/main.c?rev=141217&r1=141216&r2=141217&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/main.c (original) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/main.c Wed Oct 5 16:35:46 2011 @@ -15,7 +15,7 @@ int local = 0; printf("&global=%p\n", &global); printf("about to write to 'global'...\n"); // Set break point at this line. - // When stopped, watch 'global' for write. + // When stopped, watch 'global'. global = 20; local += argc; ++local; // Set 2nd break point for disable_then_enable test case. Added: lldb/trunk/test/python_api/watchpoint/TestWatchpointIgnoreCount.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/TestWatchpointIgnoreCount.py?rev=141217&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/TestWatchpointIgnoreCount.py (added) +++ lldb/trunk/test/python_api/watchpoint/TestWatchpointIgnoreCount.py Wed Oct 5 16:35:46 2011 @@ -0,0 +1,102 @@ +""" +Use lldb Python SBWatchpointLocation API to set the ignore count. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class WatchpointIgnoreCountTestCase(TestBase): + + mydir = os.path.join("python_api", "watchpoint") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Our simple source filename. + self.source = 'main.c' + # Find the line number to break inside main(). + self.line = line_number(self.source, '// Set break point at this line.') + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_set_watch_loc_ignore_count_with_dsym(self): + """Test SBWatchpointLocation.SetIgnoreCount() API.""" + self.buildDsym() + self.do_watchpoint_location_ignore_count() + + @python_api_test + def test_set_watch_loc_ignore_count_with_dwarf(self): + """Test SBWatchpointLocation.SetIgnoreCount() API.""" + self.buildDwarf() + self.do_watchpoint_location_ignore_count() + + def do_watchpoint_location_ignore_count(self): + """Test SBWatchpointLocation.SetIgnoreCount() API.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Create a breakpoint on main.c in order to set our watchpoint later. + breakpoint = target.BreakpointCreateByLocation(self.source, self.line) + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at the entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + + # We should be stopped due to the breakpoint. Get frame #0. + process = target.GetProcess() + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + frame0 = thread.GetFrameAtIndex(0) + + # Watch 'global' for read and write. + value = frame0.WatchValue('global', + lldb.eValueTypeVariableGlobal, + lldb.LLDB_WATCH_TYPE_READ|lldb.LLDB_WATCH_TYPE_WRITE) + self.assertTrue(value, "Successfully found the variable and set a watchpoint") + self.DebugSBValue(value) + + # Hide stdout if not running with '-t' option. + if not self.TraceOn(): + self.HideStdout() + + # There should be only 1 watchpoint location under the target. + self.assertTrue(target.GetNumWatchpointLocations() == 1) + wp_loc = target.GetWatchpointLocationAtIndex(0) + last_created = target.GetLastCreatedWatchpointLocation() + self.assertTrue(wp_loc == last_created) + self.assertTrue(wp_loc.IsEnabled()) + self.assertTrue(wp_loc.GetIgnoreCount() == 0) + watch_id = wp_loc.GetID() + self.assertTrue(watch_id != 0) + print wp_loc + + # Now immediately set the ignore count to 2. When we continue, expect the + # inferior to run to its completion without stopping due to watchpoint. + wp_loc.SetIgnoreCount(2) + print wp_loc + process.Continue() + + # At this point, the inferior process should have exited. + self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) + + # Verify some vital statistics. + self.assertTrue(wp_loc) + self.assertTrue(wp_loc.GetWatchSize() == 4) + self.assertTrue(wp_loc.GetHitCount() == 2) + print wp_loc + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From gclayton at apple.com Wed Oct 5 17:17:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 05 Oct 2011 22:17:32 -0000 Subject: [Lldb-commits] [lldb] r141222 - /lldb/trunk/source/Commands/CommandObjectTarget.cpp Message-ID: <20111005221733.80D732A6C12C@llvm.org> Author: gclayton Date: Wed Oct 5 17:17:32 2011 New Revision: 141222 URL: http://llvm.org/viewvc/llvm-project?rev=141222&view=rev Log: "target variable" will now display the current frame's compile unit globals and statics when no arguments are given. Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=141222&r1=141221&r2=141222&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Oct 5 17:17:32 2011 @@ -623,9 +623,9 @@ if (target) { const size_t argc = args.GetArgumentCount(); + Stream &s = result.GetOutputStream(); if (argc > 0) { - Stream &s = result.GetOutputStream(); for (size_t idx = 0; idx < argc; ++idx) { @@ -692,8 +692,56 @@ } else { - result.AppendError ("'target variable' takes one or more global variable names as arguments\n"); - result.SetStatus (eReturnStatusFailed); + bool success = false; + StackFrame *frame = exe_ctx.GetFramePtr(); + CompileUnit *comp_unit = NULL; + if (frame) + { + comp_unit = frame->GetSymbolContext (eSymbolContextCompUnit).comp_unit; + if (comp_unit) + { + const bool can_create = true; + VariableListSP comp_unit_varlist_sp (comp_unit->GetVariableList(can_create)); + if (comp_unit_varlist_sp) + { + size_t count = comp_unit_varlist_sp->GetSize(); + if (count > 0) + { + s.Printf ("Global in %s/%s:\n", + comp_unit->GetDirectory().GetCString(), + comp_unit->GetFilename().GetCString()); + + success = true; + for (uint32_t i=0; iGetVariableAtIndex(i)); + if (var_sp) + { + ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_ctx.GetBestExecutionContextScope(), var_sp)); + + if (valobj_sp) + DumpValueObject (s, var_sp, valobj_sp, var_sp->GetName().GetCString()); + } + } + } + } + } + } + if (!success) + { + if (frame) + { + if (comp_unit) + result.AppendErrorWithFormat ("no global variables in current compile unit: %s/%s\n", + comp_unit->GetDirectory().GetCString(), + comp_unit->GetFilename().GetCString()); + else + result.AppendError ("no debug information for frame %u\n", frame->GetFrameIndex()); + } + else + result.AppendError ("'target variable' takes one or more global variable names as arguments\n"); + result.SetStatus (eReturnStatusFailed); + } } } else From gclayton at apple.com Wed Oct 5 17:19:51 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 05 Oct 2011 22:19:51 -0000 Subject: [Lldb-commits] [lldb] r141223 - /lldb/trunk/source/Core/ValueObject.cpp Message-ID: <20111005221954.0DC5F2A6C12C@llvm.org> Author: gclayton Date: Wed Oct 5 17:19:51 2011 New Revision: 141223 URL: http://llvm.org/viewvc/llvm-project?rev=141223&view=rev Log: Stop empty C strings in summaries from showing "" when a "const char *" is NULL. Also cleaned up the display of strings when you have an array of chars that are all NULL. Previously we were showing: ""... We now show: "" Modified: lldb/trunk/source/Core/ValueObject.cpp Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=141223&r1=141222&r2=141223&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Wed Oct 5 17:19:51 2011 @@ -794,11 +794,14 @@ uint32_t maxlen_value) { uint32_t len = 0; - while(*str) + if (str) { - len++;str++; - if (len > maxlen) - return maxlen_value; + while(*str) + { + len++;str++; + if (len > maxlen) + return maxlen_value; + } } return len; } @@ -853,11 +856,7 @@ // We have a pointer cstr_address = GetPointerValue (&cstr_address_type); } - if (cstr_address == 0 || cstr_address == LLDB_INVALID_ADDRESS) - { - s << ""; - } - else + if (cstr_address != 0 && cstr_address != LLDB_INVALID_ADDRESS) { Address cstr_so_addr (NULL, cstr_address); DataExtractor data; @@ -868,7 +867,7 @@ // but the pointed-to data lives in the debuggee, and GetPointeeData() automatically takes care of this GetPointeeData(data, 0, cstr_len); - if ( (bytes_read = data.GetByteSize()) > 0) + if ((bytes_read = data.GetByteSize()) > 0) { s << '"'; data.Dump (&s, @@ -884,8 +883,6 @@ s << "..."; s << '"'; } - else - s << "\"\""; } else { @@ -894,28 +891,29 @@ size_t offset = 0; - bool any_data = false; - bool finished = false; + int cstr_len_displayed = -1; + bool capped_cstr = false; // I am using GetPointeeData() here to abstract the fact that some ValueObjects are actually frozen pointers in the host // but the pointed-to data lives in the debuggee, and GetPointeeData() automatically takes care of this - while ( (bytes_read = GetPointeeData(data, offset, k_max_buf_size)) > 0 ) + while ((bytes_read = GetPointeeData(data, offset, k_max_buf_size)) > 0) { - size_t len = strlen_or_inf(data.PeekCStr(0), k_max_buf_size, k_max_buf_size+1); + const char *cstr = data.PeekCStr(0); + size_t len = strlen_or_inf (cstr, k_max_buf_size, k_max_buf_size+1); if (len > k_max_buf_size) len = k_max_buf_size; - if (!any_data) - { + if (cstr && cstr_len_displayed < 0) s << '"'; - any_data = true; - } + + if (cstr_len_displayed < 0) + cstr_len_displayed = len; + if (len == 0) break; + cstr_len_displayed += len; if (len > bytes_read) len = bytes_read; if (len > cstr_len) len = cstr_len; - else - finished = true; data.Dump (&s, 0, // Start offset in "data" @@ -931,18 +929,19 @@ break; if (len >= cstr_len) + { + capped_cstr = true; break; + } cstr_len -= len; offset += len; } - if (any_data == false) - s << ""; - else + if (cstr_len_displayed >= 0) { s << '"'; - if (finished == false) + if (capped_cstr) s << "..."; } } From gclayton at apple.com Wed Oct 5 17:22:08 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 05 Oct 2011 22:22:08 -0000 Subject: [Lldb-commits] [lldb] r141225 - in /lldb/trunk/source: Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Symbol/Function.cpp Message-ID: <20111005222209.21514312800A@llvm.org> Author: gclayton Date: Wed Oct 5 17:22:08 2011 New Revision: 141225 URL: http://llvm.org/viewvc/llvm-project?rev=141225&view=rev Log: Stop spurious "DW_AT_specification(0x%8.8x) has no decl" warnings that were due to not parsing the function types when the function blocks are made and parsed. Cached the Function object's m_type value after it has been calculated. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/Function.cpp 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=141225&r1=141224&r2=141225&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Oct 5 17:22:08 2011 @@ -1382,15 +1382,7 @@ clang::DeclContext* SymbolFileDWARF::GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) { - DWARFDebugInfo* debug_info = DebugInfo(); - if (debug_info) - { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp); - if (die) - return GetClangDeclContextForDIE (sc, cu_sp.get(), die); - } - return NULL; + return GetClangDeclContextForDIEOffset (sc, type_uid); } Type* @@ -1406,13 +1398,13 @@ // We might be coming in in the middle of a type tree (a class // withing a class, an enum within a class), so parse any needed // parent DIEs before we get to this one... - const DWARFDebugInfoEntry* parent_die = type_die->GetParent(); - switch (parent_die->Tag()) + const DWARFDebugInfoEntry *decl_ctx_die = GetDeclContextDIEContainingDIE (cu_sp.get(), type_die); + switch (decl_ctx_die->Tag()) { case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_class_type: - ResolveType(cu_sp.get(), parent_die); + ResolveType(cu_sp.get(), decl_ctx_die); break; } return ResolveType (cu_sp.get(), type_die); @@ -2953,9 +2945,14 @@ { if (die_offset != DW_INVALID_OFFSET) { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* die = DebugInfo()->GetDIEPtr(die_offset, &cu_sp); - return GetClangDeclContextForDIE (sc, cu_sp.get(), die); + DWARFDebugInfo* debug_info = DebugInfo(); + if (debug_info) + { + DWARFCompileUnitSP cu_sp; + const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(die_offset, &cu_sp); + if (die) + return GetClangDeclContextForDIE (sc, cu_sp.get(), die); + } } return NULL; } @@ -2981,6 +2978,9 @@ clang::DeclContext * SymbolFileDWARF::GetClangDeclContextForDIE (const SymbolContext &sc, DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die) { + clang::DeclContext *clang_decl_ctx = GetCachedClangDeclContextForDIE (die); + if (clang_decl_ctx) + return clang_decl_ctx; // If this DIE has a specification, or an abstract origin, then trace to those. dw_offset_t die_offset = die->GetAttributeValueAsReference(this, curr_cu, DW_AT_specification, DW_INVALID_OFFSET); @@ -2995,11 +2995,9 @@ ParseType(sc, curr_cu, die, NULL); - DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die); - if (pos != m_die_to_decl_ctx.end()) - return pos->second; - else - return NULL; + clang_decl_ctx = GetCachedClangDeclContextForDIE (die); + + return clang_decl_ctx; } clang::DeclContext * @@ -3880,27 +3878,48 @@ { if (specification_die_offset != DW_INVALID_OFFSET) { + // We have a specification which we are going to base our function + // prototype off of, so we need this type to be completed so that the + // m_die_to_decl_ctx for the method in the specification has a valid + // clang decl context. + class_type->GetClangFullType(); // If we have a specification, then the function type should have been // made with the specification and not with this die. DWARFCompileUnitSP spec_cu_sp; const DWARFDebugInfoEntry* spec_die = DebugInfo()->GetDIEPtr(specification_die_offset, &spec_cu_sp); - if (m_die_to_decl_ctx[spec_die] == NULL) + clang::DeclContext *spec_clang_decl_ctx = GetCachedClangDeclContextForDIE (spec_die); + if (spec_clang_decl_ctx) + { + LinkDeclContextToDIE(spec_clang_decl_ctx, die); + } + else { ReportWarning ("0x%8.8x: DW_AT_specification(0x%8.8x) has no decl\n", - die->GetOffset(), - specification_die_offset); + die->GetOffset(), + specification_die_offset); } type_handled = true; } else if (abstract_origin_die_offset != DW_INVALID_OFFSET) { + // We have a specification which we are going to base our function + // prototype off of, so we need this type to be completed so that the + // m_die_to_decl_ctx for the method in the abstract origin has a valid + // clang decl context. + class_type->GetClangFullType(); + DWARFCompileUnitSP abs_cu_sp; const DWARFDebugInfoEntry* abs_die = DebugInfo()->GetDIEPtr(abstract_origin_die_offset, &abs_cu_sp); - if (m_die_to_decl_ctx[abs_die] == NULL) + clang::DeclContext *abs_clang_decl_ctx = GetCachedClangDeclContextForDIE (abs_die); + if (abs_clang_decl_ctx) + { + LinkDeclContextToDIE (abs_clang_decl_ctx, die); + } + else { ReportWarning ("0x%8.8x: DW_AT_abstract_origin(0x%8.8x) has no decl\n", - die->GetOffset(), - abstract_origin_die_offset); + die->GetOffset(), + abstract_origin_die_offset); } type_handled = true; } @@ -4450,30 +4469,46 @@ scope = eValueTypeVariableLocal; SymbolContextScope * symbol_context_scope = NULL; - if (parent_tag == DW_TAG_compile_unit) + switch (parent_tag) { + case DW_TAG_subprogram: + case DW_TAG_inlined_subroutine: + case DW_TAG_lexical_block: + if (sc.function) + { + symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); + if (symbol_context_scope == NULL) + symbol_context_scope = sc.function; + } + break; + + default: symbol_context_scope = sc.comp_unit; + break; } - else if (sc.function != NULL) + + if (symbol_context_scope) { - symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); - if (symbol_context_scope == NULL) - symbol_context_scope = sc.function; + var_sp.reset (new Variable(die->GetOffset(), + name, + mangled, + var_type, + scope, + symbol_context_scope, + &decl, + location, + is_external, + is_artificial)); + + var_sp->SetLocationIsConstantValueData (location_is_const_value_data); + } + else + { + // Not ready to parse this variable yet. It might be a global + // or static variable that is in a function scope and the function + // in the symbol context wasn't filled in yet + return var_sp; } - - assert(symbol_context_scope != NULL); - var_sp.reset (new Variable(die->GetOffset(), - name, - mangled, - var_type, - scope, - symbol_context_scope, - &decl, - location, - is_external, - is_artificial)); - - var_sp->SetLocationIsConstantValueData (location_is_const_value_data); } } // Cache var_sp even if NULL (the variable was just a specification or 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=141225&r1=141224&r2=141225&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Wed Oct 5 17:22:08 2011 @@ -187,6 +187,16 @@ SupportedVersion(uint16_t version); clang::DeclContext * + GetCachedClangDeclContextForDIE (const DWARFDebugInfoEntry *die) + { + DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die); + if (pos != m_die_to_decl_ctx.end()) + return pos->second; + else + return NULL; + } + + clang::DeclContext * GetClangDeclContextForDIE (const lldb_private::SymbolContext &sc, DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die); clang::DeclContext * Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=141225&r1=141224&r2=141225&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Wed Oct 5 17:22:08 2011 @@ -468,7 +468,7 @@ if (sym_file == NULL) return NULL; - return sym_file->ResolveTypeUID(m_type_uid); + m_type = sym_file->ResolveTypeUID(m_type_uid); } return m_type; } From johnny.chen at apple.com Wed Oct 5 17:53:08 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 05 Oct 2011 22:53:08 -0000 Subject: [Lldb-commits] [lldb] r141241 - in /lldb/trunk/www: emacs-integration.html lldb-gud-window.png sidebar.incl Message-ID: <20111005225308.C35F22A6C12C@llvm.org> Author: johnny Date: Wed Oct 5 17:53:08 2011 New Revision: 141241 URL: http://llvm.org/viewvc/llvm-project?rev=141241&view=rev Log: Add a page describing the emacs integration elisp code based on the Grand Unified Debugger. An lldb-enhanced gud.el is located under utils/emacs. Added: lldb/trunk/www/emacs-integration.html (with props) lldb/trunk/www/lldb-gud-window.png (with props) Modified: lldb/trunk/www/sidebar.incl Added: lldb/trunk/www/emacs-integration.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/emacs-integration.html?rev=141241&view=auto ============================================================================== --- lldb/trunk/www/emacs-integration.html (added) +++ lldb/trunk/www/emacs-integration.html Wed Oct 5 17:53:08 2011 @@ -0,0 +1,50 @@ + + + + + +LLDB Status + + + +
+ The Emacs Integration +
+ +
+
+ + +
+
+

Status

+
+ +

LLDB supports Emacs integration through customizing the GUD (Grand Unified Debugger) library. + Take a look at Grand Unified Debugger + and the Emacs Wiki Page for more details.

+ +

The lldb-enhanced gud.el is based on the emacs 22.3.1 version from Aquamacs 1.8c distribution. + To use it, within emacs, load the gud.el file located under the utils/emacs directory. + Type 'M-x lldb' to invoke lldb. The first time you do this, emacs will ask you to supply the command line to invoke lldb. + If lldb is not in your PATH, be sure to specify the full path to the lldb executable.

+ +

This is a screen shot of the gud (with lldb) at work on Aquamacs distribution 2.1 by loading gud.el and 'M-x lldb' + on the a.out file in the test/functionalities/conditional_break directory:

+ +

+ +

+ +

We welcome any help fleshing out missing pieces and improving the elisp code.

+ +

Last Update: Oct 05, 2011.

+ +
+ +
+
+
+
+ + Propchange: lldb/trunk/www/emacs-integration.html ------------------------------------------------------------------------------ svn:executable = * Added: lldb/trunk/www/lldb-gud-window.png URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/lldb-gud-window.png?rev=141241&view=auto ============================================================================== Binary file - no diff available. Propchange: lldb/trunk/www/lldb-gud-window.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: lldb/trunk/www/sidebar.incl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/sidebar.incl?rev=141241&r1=141240&r2=141241&view=diff ============================================================================== --- lldb/trunk/www/sidebar.incl (original) +++ lldb/trunk/www/sidebar.incl Wed Oct 5 17:53:08 2011 @@ -21,6 +21,7 @@
  • LLDB and GDB
  • Python Scripting
  • Tutorial
  • +
  • Emacs Integration
  • From gclayton at apple.com Wed Oct 5 19:09:08 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 06 Oct 2011 00:09:08 -0000 Subject: [Lldb-commits] [lldb] r141259 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: DWARFCompileUnit.cpp DWARFDebugAranges.cpp DWARFDebugInfo.cpp DWARFDebugLine.cpp DWARFDebugPubnames.cpp LogChannelDWARF.cpp LogChannelDWARF.h SymbolFileDWARF.cpp Message-ID: <20111006000908.A7BF4312800A@llvm.org> Author: gclayton Date: Wed Oct 5 19:09:08 2011 New Revision: 141259 URL: http://llvm.org/viewvc/llvm-project?rev=141259&view=rev Log: Added a new logging channel to the DWARF called "lookups": (lldb) log enable dwarf lookups This allows us to see when lookups are being done on functions, addresses, and types by both name and regular expresssion. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=141259&r1=141258&r2=141259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Wed Oct 5 19:09:08 2011 @@ -24,6 +24,7 @@ #include "NameToDIE.h" #include "SymbolFileDWARF.h" +using namespace lldb; using namespace lldb_private; using namespace std; @@ -353,7 +354,7 @@ if (m_func_aranges_ap.get() == NULL) { m_func_aranges_ap.reset (new DWARFDebugAranges()); - Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES); + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES)); if (log) log->Printf ("DWARFCompileUnit::GetFunctionAranges() for \"%s/%s\" compile unit at 0x%8.8x", Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=141259&r1=141258&r2=141259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Wed Oct 5 19:09:08 2011 @@ -23,6 +23,7 @@ #include "DWARFDebugInfo.h" #include "DWARFCompileUnit.h" +using namespace lldb; using namespace lldb_private; //---------------------------------------------------------------------- @@ -261,12 +262,12 @@ Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); - Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES); + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES)); const size_t orig_arange_size = m_aranges.size(); if (log) { log->Printf ("DWARFDebugAranges::Sort(minimize = %u, n = %u) with %zu entries", minimize, n, orig_arange_size); - Dump (log); + Dump (log.get()); } // Size of one? If so, no sorting is needed @@ -331,7 +332,7 @@ size_t delta = orig_arange_size - m_aranges.size(); log->Printf ("DWARFDebugAranges::Sort() %zu entries after minimizing (%zu entries combined for %zu bytes saved)", m_aranges.size(), delta, delta * sizeof(Range)); - Dump (log); + Dump (log.get()); } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=141259&r1=141258&r2=141259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Wed Oct 5 19:09:08 2011 @@ -24,6 +24,7 @@ #include "DWARFFormValue.h" #include "LogChannelDWARF.h" +using namespace lldb; using namespace lldb_private; using namespace std; @@ -53,7 +54,7 @@ { if (m_cu_aranges_ap.get() == NULL && m_dwarf2Data) { - Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES); + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES)); m_cu_aranges_ap.reset (new DWARFDebugAranges()); const DataExtractor &debug_aranges_data = m_dwarf2Data->get_debug_aranges_data(); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp?rev=141259&r1=141258&r2=141259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Wed Oct 5 19:09:08 2011 @@ -19,6 +19,7 @@ #include "SymbolFileDWARF.h" #include "LogChannelDWARF.h" +using namespace lldb; using namespace lldb_private; using namespace std; @@ -560,7 +561,7 @@ void* userData ) { - Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_LINE); + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_LINE)); Prologue::shared_ptr prologue(new Prologue()); @@ -580,11 +581,11 @@ } if (log) - prologue->Dump (log); + prologue->Dump (log.get()); const dw_offset_t end_offset = debug_line_offset + prologue->total_length + sizeof(prologue->total_length); - State state(prologue, log, callback, userData); + State state(prologue, log.get(), callback, userData); while (*offset_ptr < end_offset) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp?rev=141259&r1=141258&r2=141259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp Wed Oct 5 19:09:08 2011 @@ -20,6 +20,7 @@ #include "SymbolFileDWARF.h" +using namespace lldb; using namespace lldb_private; DWARFDebugPubnames::DWARFDebugPubnames() : @@ -33,7 +34,7 @@ Timer scoped_timer (__PRETTY_FUNCTION__, "DWARFDebugPubnames::Extract (byte_size = %zu)", data.GetByteSize()); - Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES); + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES)); if (log) log->Printf("DWARFDebugPubnames::Extract (byte_size = %zu)", data.GetByteSize()); @@ -53,7 +54,7 @@ break; } if (log) - Dump (log); + Dump (log.get()); return true; } return false; @@ -67,7 +68,7 @@ "DWARFDebugPubnames::GeneratePubnames (data = %p)", dwarf2Data); - Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES); + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES)); if (log) log->Printf("DWARFDebugPubnames::GeneratePubnames (data = %p)", dwarf2Data); @@ -207,7 +208,7 @@ if (m_sets.empty()) return false; if (log) - Dump (log); + Dump (log.get()); return true; } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp?rev=141259&r1=141258&r2=141259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp Wed Oct 5 19:09:08 2011 @@ -109,6 +109,7 @@ else if (::strcasecmp (arg, "pubnames") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_PUBNAMES; else if (::strcasecmp (arg, "pubtypes") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_PUBTYPES; else if (::strcasecmp (arg, "aranges") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_ARANGES; + else if (::strcasecmp (arg, "lookups") == 0 ) flag_bits &= ~DWARF_LOG_LOOKUPS; else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~DWARF_LOG_DEFAULT; else { @@ -151,6 +152,7 @@ else if (::strcasecmp (arg, "pubnames") == 0 ) flag_bits |= DWARF_LOG_DEBUG_PUBNAMES; else if (::strcasecmp (arg, "pubtypes") == 0 ) flag_bits |= DWARF_LOG_DEBUG_PUBTYPES; else if (::strcasecmp (arg, "aranges") == 0 ) flag_bits |= DWARF_LOG_DEBUG_ARANGES; + else if (::strcasecmp (arg, "lookups") == 0 ) flag_bits |= DWARF_LOG_LOOKUPS; else if (::strcasecmp (arg, "default") == 0 ) flag_bits |= DWARF_LOG_DEFAULT; else { @@ -177,29 +179,29 @@ " info - log the parsing if .debug_info\n" " line - log the parsing if .debug_line\n" " pubnames - log the parsing if .debug_pubnames\n" - " pubtypes - log the parsing if .debug_pubtypes\n\n", + " pubtypes - log the parsing if .debug_pubtypes\n" + " lookups - log any lookups that happen by name, regex, or address\n\n", SymbolFileDWARF::GetPluginNameStatic()); } -Log * +LogSP LogChannelDWARF::GetLog () { if (g_log_channel) - return g_log_channel->m_log_sp.get(); - else - return NULL; + return g_log_channel->m_log_sp; + + return LogSP(); } -Log * +LogSP LogChannelDWARF::GetLogIfAll (uint32_t mask) { - Log *log = GetLog(); - if (log) + if (g_log_channel && g_log_channel->m_log_sp) { - if (log->GetMask().AllSet(mask)) - return log; + if (g_log_channel->m_log_sp->GetMask().AllSet(mask)) + return g_log_channel->m_log_sp; } - return NULL; + return LogSP(); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h?rev=141259&r1=141258&r2=141259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h Wed Oct 5 19:09:08 2011 @@ -23,6 +23,7 @@ #define DWARF_LOG_DEBUG_PUBNAMES (1u << 3) #define DWARF_LOG_DEBUG_PUBTYPES (1u << 4) #define DWARF_LOG_DEBUG_ARANGES (1u << 5) +#define DWARF_LOG_LOOKUPS (1u << 6) #define DWARF_LOG_ALL (UINT32_MAX) #define DWARF_LOG_DEFAULT (DWARF_LOG_DEBUG_INFO) @@ -73,10 +74,10 @@ virtual void ListCategories (lldb_private::Stream *strm); - static lldb_private::Log * + static lldb::LogSP GetLog (); - static lldb_private::Log * + static lldb::LogSP GetLogIfAll (uint32_t mask); static void 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=141259&r1=141258&r2=141259&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Oct 5 19:09:08 2011 @@ -1943,6 +1943,15 @@ uint32_t SymbolFileDWARF::FindGlobalVariables (const ConstString &name, bool append, uint32_t max_matches, VariableList& variables) { + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); + + if (log) + { + log->Printf ("SymbolFileDWARF::FindGlobalVariables (file=\"%s/%s\", name=\"%s\", append=%u, max_matches=%u, variables)", + m_obj_file->GetFileSpec().GetDirectory().GetCString(), + m_obj_file->GetFileSpec().GetFilename().GetCString(), + name.GetCString(), append, max_matches); + } DWARFDebugInfo* info = DebugInfo(); if (info == NULL) return 0; @@ -2007,6 +2016,16 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) { + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); + + if (log) + { + log->Printf ("SymbolFileDWARF::FindGlobalVariables (file=\"%s/%s\", regex=\"%s\", append=%u, max_matches=%u, variables)", + m_obj_file->GetFileSpec().GetDirectory().GetCString(), + m_obj_file->GetFileSpec().GetFilename().GetCString(), + regex.GetText(), append, max_matches); + } + DWARFDebugInfo* info = DebugInfo(); if (info == NULL) return 0; @@ -2267,6 +2286,16 @@ "SymbolFileDWARF::FindFunctions (name = '%s')", name.AsCString()); + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); + + if (log) + { + log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", name=\"%s\", name_type_mask=0x%x, append=%u, sc_list)", + m_obj_file->GetFileSpec().GetDirectory().GetCString(), + m_obj_file->GetFileSpec().GetFilename().GetCString(), + name.GetCString(), name_type_mask, append); + } + // If we aren't appending the results to this list, then clear the list if (!append) sc_list.Clear(); @@ -2315,6 +2344,17 @@ "SymbolFileDWARF::FindFunctions (regex = '%s')", regex.GetText()); + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); + + if (log) + { + log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", regex=\"%s\"append=%u, sc_list)", + m_obj_file->GetFileSpec().GetDirectory().GetCString(), + m_obj_file->GetFileSpec().GetFilename().GetCString(), + regex.GetText(), append); + } + + // If we aren't appending the results to this list, then clear the list if (!append) sc_list.Clear(); @@ -2383,6 +2423,16 @@ if (info == NULL) return 0; + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); + + if (log) + { + log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", sc, name=\"%s\", append=%u, max_matches=%u, type_list)", + m_obj_file->GetFileSpec().GetDirectory().GetCString(), + m_obj_file->GetFileSpec().GetFilename().GetCString(), + name.GetCString(), append, max_matches); + } + // If we aren't appending the results to this list, then clear the list if (!append) types.Clear(); @@ -2447,6 +2497,16 @@ SymbolFileDWARF::FindNamespace (const SymbolContext& sc, const ConstString &name) { + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS)); + + if (log) + { + log->Printf ("SymbolFileDWARF::FindNamespace (file=\"%s/%s\", sc, name=\"%s\")", + m_obj_file->GetFileSpec().GetDirectory().GetCString(), + m_obj_file->GetFileSpec().GetFilename().GetCString(), + name.GetCString()); + } + ClangNamespaceDecl namespace_decl; DWARFDebugInfo* info = DebugInfo(); if (info) @@ -3206,7 +3266,7 @@ AccessType accessibility = eAccessNone; if (die != NULL) { - Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); if (log && dwarf_cu) { StreamString s; From johnny.chen at apple.com Wed Oct 5 20:01:05 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 06 Oct 2011 01:01:05 -0000 Subject: [Lldb-commits] [lldb] r141264 - /lldb/trunk/test/functionalities/target_command/TestTargetCommand.py Message-ID: <20111006010111.CE84D2A6C12C@llvm.org> Author: johnny Date: Wed Oct 5 20:00:53 2011 New Revision: 141264 URL: http://llvm.org/viewvc/llvm-project?rev=141264&view=rev Log: Add a test sequence for 'target variable' command when no arguments are given. Modified: lldb/trunk/test/functionalities/target_command/TestTargetCommand.py Modified: lldb/trunk/test/functionalities/target_command/TestTargetCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/target_command/TestTargetCommand.py?rev=141264&r1=141263&r2=141264&view=diff ============================================================================== --- lldb/trunk/test/functionalities/target_command/TestTargetCommand.py (original) +++ lldb/trunk/test/functionalities/target_command/TestTargetCommand.py Wed Oct 5 20:00:53 2011 @@ -178,6 +178,14 @@ self.runCmd("b main") self.runCmd("run") + # New feature: you don't need to specify the variable(s) to 'target vaiable'. + # It will find all the global and static variables in the current compile unit. + self.expect("target variable", + substrs = ['my_global_char', + 'my_global_str', + 'my_global_str_ptr', + 'my_static_int']) + self.expect("target variable my_global_str", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['my_global_str', '"abc"']) self.expect("target variable my_static_int", VARIABLES_DISPLAYED_CORRECTLY, From jmolenda at apple.com Wed Oct 5 20:46:10 2011 From: jmolenda at apple.com (Jason Molenda) Date: Thu, 06 Oct 2011 01:46:10 -0000 Subject: [Lldb-commits] [lldb] r141265 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20111006014619.C53C12A6C12C@llvm.org> Author: jmolenda Date: Wed Oct 5 20:45:46 2011 New Revision: 141265 URL: http://llvm.org/viewvc/llvm-project?rev=141265&view=rev Log: ProcessGDBRemote::BuildDynamicRegisterInfo() - even if we don't have a Target architecture set up yet, if we're talking to an Apple arm device set the register set based on the arm device's attributes; this is a safe assumption to make in this particular environment. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=141265&r1=141264&r2=141265&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Oct 5 20:45:46 2011 @@ -345,8 +345,18 @@ // We didn't get anything. See if we are debugging ARM and fill with // a hard coded register set until we can get an updated debugserver // down on the devices. - if (GetTarget().GetArchitecture().GetMachine() == llvm::Triple::arm) + + if (!GetTarget().GetArchitecture().IsValid() + && m_gdb_comm.GetHostArchitecture().IsValid() + && m_gdb_comm.GetHostArchitecture().GetMachine() == llvm::Triple::arm + && m_gdb_comm.GetHostArchitecture().GetTriple().getVendor() == llvm::Triple::Apple) + { + m_register_info.HardcodeARMRegisters(); + } + else if (GetTarget().GetArchitecture().GetMachine() == llvm::Triple::arm) + { m_register_info.HardcodeARMRegisters(); + } } m_register_info.Finalize (); } From johnny.chen at apple.com Thu Oct 6 15:27:05 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 06 Oct 2011 20:27:05 -0000 Subject: [Lldb-commits] [lldb] r141307 - /lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Message-ID: <20111006202705.585542A6C12C@llvm.org> Author: johnny Date: Thu Oct 6 15:27:05 2011 New Revision: 141307 URL: http://llvm.org/viewvc/llvm-project?rev=141307&view=rev Log: Simplify the verbose output of WatchpointLocation::DumpWithLevel(). Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=141307&r1=141306&r2=141307&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Thu Oct 6 15:27:05 2011 @@ -126,12 +126,18 @@ s->Printf("\n declare @ '%s'", m_decl_str.c_str()); if (description_level >= lldb::eDescriptionLevelVerbose) - s->Printf("\n hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %8p baton = %8p", - GetHardwareIndex(), - GetHitCount(), - GetIgnoreCount(), - m_callback, - m_callback_baton); + if (m_callback) + s->Printf("\n hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %8p baton = %8p", + GetHardwareIndex(), + GetHitCount(), + GetIgnoreCount(), + m_callback, + m_callback_baton); + else + s->Printf("\n hw_index = %i hit_count = %-4u ignore_count = %-4u", + GetHardwareIndex(), + GetHitCount(), + GetIgnoreCount()); } bool From johnny.chen at apple.com Thu Oct 6 17:48:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 06 Oct 2011 22:48:56 -0000 Subject: [Lldb-commits] [lldb] r141326 - /lldb/trunk/examples/python/symbolicate-crash.py Message-ID: <20111006224856.4C02F2A6C12C@llvm.org> Author: johnny Date: Thu Oct 6 17:48:56 2011 New Revision: 141326 URL: http://llvm.org/viewvc/llvm-project?rev=141326&view=rev Log: Simplify code to print symbols and sections within a module using the built-in iterators. Modified: lldb/trunk/examples/python/symbolicate-crash.py Modified: lldb/trunk/examples/python/symbolicate-crash.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/symbolicate-crash.py?rev=141326&r1=141325&r2=141326&view=diff ============================================================================== --- lldb/trunk/examples/python/symbolicate-crash.py (original) +++ lldb/trunk/examples/python/symbolicate-crash.py Thu Oct 6 17:48:56 2011 @@ -278,17 +278,12 @@ print_module_section (section.GetSubSectionAtIndex(sect_idx), depth - 1) def print_module_sections (module, depth): - num_sections = module.GetNumSections() - - for sect_idx in range(num_sections): - section = module.GetSectionAtIndex(sect_idx) - print_module_section (section, depth) + for sect in module.section_iter(): + print_module_section (sect, depth) def print_module_symbols (module): - n = module.GetNumSymbols() - - for i in range(n): - print module.GetSymbolAtIndex(i) + for sym in module: + print sym def usage(): print "Usage: lldb-symbolicate.py [-n name] executable-image" From gclayton at apple.com Thu Oct 6 18:32:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 06 Oct 2011 23:32:32 -0000 Subject: [Lldb-commits] [lldb] r141338 - /lldb/trunk/source/Symbol/SymbolContext.cpp Message-ID: <20111006233232.F21422A6C12C@llvm.org> Author: gclayton Date: Thu Oct 6 18:32:32 2011 New Revision: 141338 URL: http://llvm.org/viewvc/llvm-project?rev=141338&view=rev Log: Fixed an assertion that was causing a crash. The bug describes a case where we have an inlined block that doesn't contain the frame PC that was used to lookup the symbol context in the first place. This really shouldn't happen, so now we log if we run into this and don't assert. Modified: lldb/trunk/source/Symbol/SymbolContext.cpp Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=141338&r1=141337&r2=141338&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Thu Oct 6 18:32:32 2011 @@ -541,17 +541,35 @@ // the line table. So just use the call site info from our inlined block. AddressRange range; - bool got_range = curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range); - assert (got_range); - // To see there this new frame block it, we need to look at the - // call site information from - const InlineFunctionInfo* curr_inlined_block_inlined_info = curr_inlined_block->GetInlinedFunctionInfo(); - next_frame_pc = range.GetBaseAddress(); - next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc; - next_frame_sc.line_entry.file = curr_inlined_block_inlined_info->GetCallSite().GetFile(); - next_frame_sc.line_entry.line = curr_inlined_block_inlined_info->GetCallSite().GetLine(); - next_frame_sc.line_entry.column = curr_inlined_block_inlined_info->GetCallSite().GetColumn(); - return true; + if (curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range)) + { + // To see there this new frame block it, we need to look at the + // call site information from + const InlineFunctionInfo* curr_inlined_block_inlined_info = curr_inlined_block->GetInlinedFunctionInfo(); + next_frame_pc = range.GetBaseAddress(); + next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc; + next_frame_sc.line_entry.file = curr_inlined_block_inlined_info->GetCallSite().GetFile(); + next_frame_sc.line_entry.line = curr_inlined_block_inlined_info->GetCallSite().GetLine(); + next_frame_sc.line_entry.column = curr_inlined_block_inlined_info->GetCallSite().GetColumn(); + return true; + } + else + { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYMBOLS)); + + if (log) + { + log->Printf ("warning: inlined block 0x%8.8x doesn't have a range that contains file address 0x%llx", + curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress()); + } +#ifdef LLDB_CONFIGURATION_DEBUG + else + { + fprintf (stderr, "warning: inlined block 0x%8.8x doesn't have a range that contains file address 0x%llx\n", + curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress()); + } +#endif + } } } From johnny.chen at apple.com Thu Oct 6 18:36:01 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 06 Oct 2011 23:36:01 -0000 Subject: [Lldb-commits] [lldb] r141340 - /lldb/trunk/examples/python/symbolicate-crash.py Message-ID: <20111006233601.15C692A6C12E@llvm.org> Author: johnny Date: Thu Oct 6 18:36:00 2011 New Revision: 141340 URL: http://llvm.org/viewvc/llvm-project?rev=141340&view=rev Log: Allow the crash log file path to contain an initial tilde component. Modified: lldb/trunk/examples/python/symbolicate-crash.py Modified: lldb/trunk/examples/python/symbolicate-crash.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/symbolicate-crash.py?rev=141340&r1=141339&r2=141340&view=diff ============================================================================== --- lldb/trunk/examples/python/symbolicate-crash.py (original) +++ lldb/trunk/examples/python/symbolicate-crash.py Thu Oct 6 18:36:00 2011 @@ -99,7 +99,8 @@ self.images = list() self.crashed_thread_idx = -1 self.version = -1 - f = open(self.path) + # With possible initial component of ~ or ~user replaced by that user's home directory. + f = open(os.path.expanduser(self.path)) self.file_lines = f.read().splitlines() parse_mode = PARSE_MODE_NORMAL thread = None From johnny.chen at apple.com Thu Oct 6 20:06:37 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 07 Oct 2011 01:06:37 -0000 Subject: [Lldb-commits] [lldb] r141347 - /lldb/trunk/www/emacs-integration.html Message-ID: <20111007010637.7C9F82A6C12C@llvm.org> Author: johnny Date: Thu Oct 6 20:06:37 2011 New Revision: 141347 URL: http://llvm.org/viewvc/llvm-project?rev=141347&view=rev Log: Add a simple scenario of emacs and lldb interaction. Modified: lldb/trunk/www/emacs-integration.html Modified: lldb/trunk/www/emacs-integration.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/emacs-integration.html?rev=141347&r1=141346&r2=141347&view=diff ============================================================================== --- lldb/trunk/www/emacs-integration.html (original) +++ lldb/trunk/www/emacs-integration.html Thu Oct 6 20:06:37 2011 @@ -20,25 +20,35 @@

    Status

    -

    LLDB supports Emacs integration through customizing the GUD (Grand Unified Debugger) library. +

    LLDB supports emacs integration through customizing the GUD (Grand Unified Debugger) library. Take a look at Grand Unified Debugger and the Emacs Wiki Page for more details.

    The lldb-enhanced gud.el is based on the emacs 22.3.1 version from Aquamacs 1.8c distribution. To use it, within emacs, load the gud.el file located under the utils/emacs directory. - Type 'M-x lldb' to invoke lldb. The first time you do this, emacs will ask you to supply the command line to invoke lldb. + Type M-x lldb to invoke lldb. The first time you do this, emacs will ask you to supply the command line to invoke lldb. If lldb is not in your PATH, be sure to specify the full path to the lldb executable.

    -

    This is a screen shot of the gud (with lldb) at work on Aquamacs distribution 2.1 by loading gud.el and 'M-x lldb' +

    This is a screen shot of the gud (with lldb) at work on Aquamacs distribution 2.1 by loading gud.el and then M-x lldb on the a.out file in the test/functionalities/conditional_break directory:

    +

    For a very simple interaction using 'M-x lldb', you can supply your executable to the "Run lldb (like this)" prompt. + For example:

    + + Run lldb (like this): /Volumes/data/lldb/svn/trunk/build/Debug/lldb a.out +

    + +

    Visit your source code buffer, go to the line where you want to set the breakpoint on, type C-x <SPC> + to set a breakpoint on the source line that point is on, and then run the inferior program. The inferior should then stop and emacs + shows the buffer and marks the line where it breaks on.

    +

    We welcome any help fleshing out missing pieces and improving the elisp code.

    -

    Last Update: Oct 05, 2011.

    +

    Last Update: Oct 06, 2011.

    From gclayton at apple.com Thu Oct 6 20:49:45 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 07 Oct 2011 01:49:45 -0000 Subject: [Lldb-commits] [lldb] r141348 - /lldb/trunk/source/Symbol/SymbolContext.cpp Message-ID: <20111007014945.82D072A6C12C@llvm.org> Author: gclayton Date: Thu Oct 6 20:49:45 2011 New Revision: 141348 URL: http://llvm.org/viewvc/llvm-project?rev=141348&view=rev Log: Added better logging for the case where we don't find a PC in a block. Modified: lldb/trunk/source/Symbol/SymbolContext.cpp Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=141348&r1=141347&r2=141348&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Thu Oct 6 20:49:45 2011 @@ -15,6 +15,7 @@ #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Symbol.h" +#include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Target/Target.h" @@ -565,8 +566,32 @@ #ifdef LLDB_CONFIGURATION_DEBUG else { - fprintf (stderr, "warning: inlined block 0x%8.8x doesn't have a range that contains file address 0x%llx\n", - curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress()); + ObjectFile *objfile = NULL; + if (module_sp) + { + SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(); + if (symbol_vendor) + { + SymbolFile *symbol_file = symbol_vendor->GetSymbolFile(); + if (symbol_file) + objfile = symbol_file->GetObjectFile(); + } + } + if (objfile) + { + fprintf (stderr, "warning: inlined block 0x%8.8x doesn't have a range that contains file address 0x%llx in %s/%s\n", + curr_inlined_block->GetID(), + curr_frame_pc.GetFileAddress(), + objfile->GetFileSpec().GetDirectory().GetCString(), + objfile->GetFileSpec().GetFilename().GetCString()); + + curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range); // REMOVE THIS!!! + } + else + { + fprintf (stderr, "warning: inlined block 0x%8.8x doesn't have a range that contains file address 0x%llx\n", + curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress()); + } } #endif } From gclayton at apple.com Thu Oct 6 20:52:19 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 07 Oct 2011 01:52:19 -0000 Subject: [Lldb-commits] [lldb] r141349 - /lldb/trunk/source/Target/StackFrameList.cpp Message-ID: <20111007015219.EEB692A6C12C@llvm.org> Author: gclayton Date: Thu Oct 6 20:52:19 2011 New Revision: 141349 URL: http://llvm.org/viewvc/llvm-project?rev=141349&view=rev Log: Fixed the root cause of what was causing an assertion to fire during single stepping. We had an issue with the inlined stack frames where when we had inlined frames that were not in the first concrete frame where we passed the wrong PC down. We needed to decrement the PC by one for these frames to make sure we are using the same address that did the symbol context lookup. Modified: lldb/trunk/source/Target/StackFrameList.cpp Modified: lldb/trunk/source/Target/StackFrameList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=141349&r1=141348&r2=141349&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrameList.cpp (original) +++ lldb/trunk/source/Target/StackFrameList.cpp Thu Oct 6 20:52:19 2011 @@ -116,7 +116,15 @@ Block *unwind_block = unwind_sc.block; if (unwind_block) { - Address curr_frame_address = unwind_frame_sp->GetFrameCodeAddress(); + Address curr_frame_address (unwind_frame_sp->GetFrameCodeAddress()); + // Be sure to adjust the frame address to match the address + // that was used to lookup the symbol context above. If we are + // in the first concrete frame, then we lookup using the current + // address, else we decrement the address by one to get the correct + // location. + if (idx > 0) + curr_frame_address.Slide(-1); + SymbolContext next_frame_sc; Address next_frame_address; From dawn at burble.org Thu Oct 6 21:54:01 2011 From: dawn at burble.org (dawn at burble.org) Date: Thu, 6 Oct 2011 19:54:01 -0700 Subject: [Lldb-commits] patch to fix Linux build Message-ID: <20111007025401.GA6009@bloodbath.burble.org> The attached patch fixes the Linux build for llvm and clang revs 137311 (the revs documented in lldb/scripts/build-llvm.pl), and is based on lldb rev 141349 (current rev as of this email). Would it be OK to commit this? Thanks, -Dawn -------------- next part -------------- Index: source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp (revision 141349) +++ source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp (working copy) @@ -112,7 +112,7 @@ executable = m_process->GetTarget().GetExecutableModule(); load_offset = ComputeLoadOffset(); - if (!executable.empty() && load_offset != LLDB_INVALID_ADDRESS) + if (executable.get() && load_offset != LLDB_INVALID_ADDRESS) { ModuleList module_list; module_list.Append(executable); @@ -132,7 +132,7 @@ executable = m_process->GetTarget().GetExecutableModule(); load_offset = ComputeLoadOffset(); - if (!executable.empty() && load_offset != LLDB_INVALID_ADDRESS) + if (executable.get() && load_offset != LLDB_INVALID_ADDRESS) { ModuleList module_list; module_list.Append(executable); @@ -264,7 +264,7 @@ { FileSpec file(I->path.c_str(), true); ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr); - if (!module_sp.empty()) + if (module_sp.get()) new_modules.Append(module_sp); } m_process->GetTarget().ModulesDidLoad(new_modules); @@ -280,7 +280,7 @@ FileSpec file(I->path.c_str(), true); ModuleSP module_sp = loaded_modules.FindFirstModuleForFileSpec(file, NULL, NULL); - if (!module_sp.empty()) + if (module_sp.get()) old_modules.Append(module_sp); } m_process->GetTarget().ModulesDidUnload(old_modules); @@ -355,7 +355,7 @@ { FileSpec file(I->path.c_str(), false); ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr); - if (!module_sp.empty()) + if (module_sp.get()) module_list.Append(module_sp); } Index: source/Plugins/Process/Linux/ProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessLinux.cpp (revision 141349) +++ source/Plugins/Process/Linux/ProcessLinux.cpp (working copy) @@ -437,6 +437,35 @@ return m_thread_list.GetSize(false); } +uint32_t +ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) +{ +#if 0 // GetLogIfAllCategoriesSet is in lldb_private + // locker will keep a mutex locked until it goes out of scope + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (Linux_LOG_THREAD)); + if (log && log->GetMask().Test(Linux_LOG_VERBOSE)) + log->Printf ("ProcessLinux::%s (pid = %i)", __FUNCTION__, GetID()); + + // We currently are making only one thread per core and we + // actually don't know about actual threads. Eventually we + // want to get the thread list from memory and note which + // threads are on CPU as those are the only ones that we + // will be able to resume. + const uint32_t cpu_mask = m_comm.GetCPUMask(); + for (uint32_t cpu_mask_bit = 1; cpu_mask_bit & cpu_mask; cpu_mask_bit <<= 1) + { + lldb::tid_t tid = cpu_mask_bit; + ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false)); + if (!thread_sp) + thread_sp.reset(new ThreadLinux (*this, tid)); + new_thread_list.AddThread(thread_sp); + } + return new_thread_list.GetSize(false); +#else + return 0; +#endif +} + ByteOrder ProcessLinux::GetByteOrder() const { Index: source/Plugins/Process/Linux/ProcessLinux.h =================================================================== --- source/Plugins/Process/Linux/ProcessLinux.h (revision 141349) +++ source/Plugins/Process/Linux/ProcessLinux.h (working copy) @@ -129,6 +129,10 @@ virtual uint32_t UpdateThreadListIfNeeded(); + uint32_t + UpdateThreadList(lldb_private::ThreadList &old_thread_list, + lldb_private::ThreadList &new_thread_list); + virtual lldb::ByteOrder GetByteOrder() const; Index: source/Plugins/Process/Linux/ProcessMonitor.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessMonitor.cpp (revision 141349) +++ source/Plugins/Process/Linux/ProcessMonitor.cpp (working copy) @@ -241,7 +241,7 @@ // Set errno to zero so that we can detect a failed peek. errno = 0; - unsigned long data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL); + uint32_t data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL); if (data == -1UL && errno) m_result = false; Index: source/lldb.cpp =================================================================== --- source/lldb.cpp (revision 141349) +++ source/lldb.cpp (working copy) @@ -94,7 +94,9 @@ UnwindAssemblyInstEmulation::Initialize(); UnwindAssembly_x86::Initialize(); EmulateInstructionARM::Initialize (); +#if !defined (__linux__) ObjectFilePECOFF::Initialize (); +#endif #if defined (__APPLE__) //---------------------------------------------------------------------- // Apple/Darwin hosted plugins @@ -166,7 +168,9 @@ UnwindAssembly_x86::Terminate(); UnwindAssemblyInstEmulation::Terminate(); EmulateInstructionARM::Terminate (); +#if !defined (__linux__) ObjectFilePECOFF::Terminate (); +#endif #if defined (__APPLE__) DynamicLoaderMacOSXDYLD::Terminate(); From gclayton at apple.com Thu Oct 6 22:58:56 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 07 Oct 2011 03:58:56 -0000 Subject: [Lldb-commits] [lldb] r141352 - in /lldb/trunk: include/lldb/Core/RangeMap.h lldb.xcodeproj/project.pbxproj source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Message-ID: <20111007035856.54D62312800A@llvm.org> Author: gclayton Date: Thu Oct 6 22:58:56 2011 New Revision: 141352 URL: http://llvm.org/viewvc/llvm-project?rev=141352&view=rev Log: Since we use address ranges a lot I added a templatized class that allows us to easily control the base address type, the size type, and the data that is stored with each range. It is designed to be populated by appending all needed items, then sorting the resulting list, and optionally minimizing the list when done. I adopted this new list in the DWARFDebugAranges for even further memory savings. Added: lldb/trunk/include/lldb/Core/RangeMap.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Added: lldb/trunk/include/lldb/Core/RangeMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=141352&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/RangeMap.h (added) +++ lldb/trunk/include/lldb/Core/RangeMap.h Thu Oct 6 22:58:56 2011 @@ -0,0 +1,307 @@ +//===-- RangeMap.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_RangeMap_h_ +#define liblldb_RangeMap_h_ + +#include "lldb/lldb-private.h" +#include + +namespace lldb_private { + +//---------------------------------------------------------------------- +// A vm address range. These can represent offsets ranges or actual +// addresses. +//---------------------------------------------------------------------- +template +class RangeMap +{ +public: + typedef B RangeBaseType; + typedef S RangeSizeType; + typedef T EntryDataType; + + struct Range + { + RangeBaseType base; + RangeSizeType size; + + Range () : + base (0), + size (0) + { + } + + Range (RangeBaseType b, RangeSizeType s) : + base (b), + size (s) + { + } + + // Set the start value for the range, and keep the same size + RangeBaseType + GetBase () const + { + return base; + } + + void + SetBase (RangeBaseType b) + { + base = b; + } + + RangeBaseType + GetEnd () const + { + return base + size; + } + + void + SetEnd (RangeBaseType end) + { + if (end > base) + size = end - base; + else + size = 0; + } + + RangeSizeType + GetSize () const + { + return size; + } + + void + SetSize (RangeSizeType s) + { + size = s; + } + + bool + IsValid() const + { + return size > 0; + } + + bool + Contains (RangeBaseType r) const + { + return (GetBase() <= r) && (r < GetEnd()); + } + + bool + ContainsEndInclusive (RangeBaseType r) const + { + return (GetBase() <= r) && (r <= GetEnd()); + } + + bool + Contains (const Range& range) const + { + return Contains(range.GetBase()) && ContainsEndInclusive(range.GetEnd()); + } + + bool + operator < (const Range &rhs) + { + if (base == rhs.base) + return size < rhs.size; + return base < rhs.base; + } + + bool + operator == (const Range &rhs) + { + return base == rhs.base && size == rhs.size; + } + + bool + operator != (const Range &rhs) + { + return base != rhs.base || size != rhs.size; + } + }; + + struct Entry + { + Range range; + EntryDataType data; + + Entry () : + range (), + data () + { + } + + Entry (RangeBaseType base, RangeSizeType size, EntryDataType d) : + range (base, size), + data (d) + { + } + + bool + operator < (const Entry &rhs) const + { + const RangeBaseType lhs_base = range.GetBase(); + const RangeBaseType rhs_base = rhs.range.GetBase(); + if (lhs_base == rhs_base) + { + const RangeBaseType lhs_size = range.GetSize(); + const RangeBaseType rhs_size = rhs.range.GetSize(); + if (lhs_size == rhs_size) + return data < rhs.data; + else + return lhs_size < rhs_size; + } + return lhs_base < rhs_base; + } + + bool + operator == (const Entry &rhs) const + { + return range.GetBase() == rhs.range.GetBase() && + range.GetSize() == rhs.range.GetSize() && + data == rhs.data; + } + + bool + operator != (const Entry &rhs) const + { + return range.GetBase() != rhs.range.GetBase() || + range.GetSize() != rhs.range.GetSize() || + data != rhs.data; + } + }; + + RangeMap () + { + } + + ~RangeMap() + { + } + + void + Append (const Entry &entry) + { + m_entries.push_back (entry); + } + + void + Sort () + { + if (m_entries.size() > 1) + std::stable_sort (m_entries.begin(), m_entries.end()); + } + + void + CombineConsecutiveEntriesWithEqualData () + { + typename std::vector::iterator pos; + typename std::vector::iterator end; + typename std::vector::iterator prev; + bool can_combine = false; + // First we determine if we can combine any of the Entry objects so we + // don't end up allocating and making a new collection for no reason + for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + { + if (prev != end && prev->data == pos->data) + { + can_combine = true; + break; + } + } + + // We we can combine at least one entry, then we make a new collection + // and populate it accordingly, and then swap it into place. + if (can_combine) + { + std::vector minimal_ranges; + for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + { + if (prev != end && prev->data == pos->data) + minimal_ranges.back().range.SetEnd (pos->range.GetEnd()); + else + minimal_ranges.push_back (*pos); + } + // Use the swap technique in case our new vector is much smaller. + // We must swap when using the STL because std::vector objects never + // release or reduce the memory once it has been allocated/reserved. + m_entries.swap (minimal_ranges); + } + } + + void + Clear () + { + m_entries.clear(); + } + + bool + IsEmpty () const + { + return m_entries.empty(); + } + + size_t + GetNumEntries () const + { + return m_entries.size(); + } + + const Entry * + GetEntryAtIndex (uint32_t i) const + { + if (i::const_iterator begin = m_entries.begin(); + typename std::vector::const_iterator end = m_entries.end(); + typename std::vector::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + + if ((pos != end) && (pos->range.GetBase() <= addr && addr < pos->range.GetEnd())) + { + return &(*pos); + } + else if (pos != begin) + { + --pos; + if ((pos->range.GetBase() <= addr) && (addr < pos->range.GetEnd())) + { + return &(*pos); + } + } + } + return NULL; + } + +protected: + std::vector m_entries; +}; + + +} // namespace lldb_private + +#endif // liblldb_RangeMap_h_ Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=141352&r1=141351&r2=141352&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Oct 6 22:58:56 2011 @@ -12,6 +12,7 @@ 260E07C8136FAB9200CF21D3 /* OptionGroupFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260E07C7136FAB9200CF21D3 /* OptionGroupFile.cpp */; }; 261744781168585B005ADD65 /* SBType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261744771168585B005ADD65 /* SBType.cpp */; }; 2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2626B6AE143E1BEA00EF935C /* RangeMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2626B6AD143E1BEA00EF935C /* RangeMap.h */; }; 26274FA214030EEF006BA130 /* OperatingSystemDarwinKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26274FA014030EEF006BA130 /* OperatingSystemDarwinKernel.cpp */; }; 26274FA714030F79006BA130 /* DynamicLoaderDarwinKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26274FA514030F79006BA130 /* DynamicLoaderDarwinKernel.cpp */; }; 2628A4D513D4977900F5487A /* ThreadKDP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628A4D313D4977900F5487A /* ThreadKDP.cpp */; }; @@ -664,6 +665,7 @@ 26217930133BC8640083B112 /* lldb-private-types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-types.h"; path = "include/lldb/lldb-private-types.h"; sourceTree = ""; }; 26217932133BCB850083B112 /* lldb-private-enumerations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "lldb-private-enumerations.h"; path = "include/lldb/lldb-private-enumerations.h"; sourceTree = ""; }; 2623096E13D0EFFB006381D9 /* StreamBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StreamBuffer.h; path = include/lldb/Core/StreamBuffer.h; sourceTree = ""; }; + 2626B6AD143E1BEA00EF935C /* RangeMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RangeMap.h; path = include/lldb/Core/RangeMap.h; sourceTree = ""; }; 26274FA014030EEF006BA130 /* OperatingSystemDarwinKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OperatingSystemDarwinKernel.cpp; sourceTree = ""; }; 26274FA114030EEF006BA130 /* OperatingSystemDarwinKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OperatingSystemDarwinKernel.h; sourceTree = ""; }; 26274FA514030F79006BA130 /* DynamicLoaderDarwinKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLoaderDarwinKernel.cpp; sourceTree = ""; }; @@ -2137,6 +2139,7 @@ 26BC7D7010F1B77400F91463 /* PluginInterface.h */, 26BC7D7110F1B77400F91463 /* PluginManager.h */, 26BC7E8A10F1B85900F91463 /* PluginManager.cpp */, + 2626B6AD143E1BEA00EF935C /* RangeMap.h */, 26C6886D137880B900407EDF /* RegisterValue.h */, 26C6886E137880C400407EDF /* RegisterValue.cpp */, 26BC7D7310F1B77400F91463 /* RegularExpression.h */, @@ -2889,6 +2892,7 @@ files = ( 496B015B1406DEB100F830D5 /* IRInterpreter.h in Headers */, 2682100D143A59AE004BCF2D /* MappedHash.h in Headers */, + 2626B6AE143E1BEA00EF935C /* RangeMap.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=141352&r1=141351&r2=141352&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu Oct 6 22:58:56 2011 @@ -363,8 +363,7 @@ m_offset); DIE()->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get()); const bool minimize = false; - const uint32_t fudge_size = 0; - m_func_aranges_ap->Sort(minimize, fudge_size); + m_func_aranges_ap->Sort(minimize); } return *m_func_aranges_ap.get(); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h?rev=141352&r1=141351&r2=141352&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h Thu Oct 6 22:58:56 2011 @@ -18,21 +18,21 @@ class DWARFDebugArangeSet { public: - typedef struct HeaderTag + struct Header { uint32_t length; // The total length of the entries for that set, not including the length field itself. uint16_t version; // The DWARF version number uint32_t cu_offset; // The offset from the beginning of the .debug_info section of the compilation unit entry referenced by the table. uint8_t addr_size; // The size in bytes of an address on the target architecture. For segmented addressing, this is the size of the offset portion of the address uint8_t seg_size; // The size in bytes of a segment descriptor on the target architecture. If the target system uses a flat address space, this value is 0. - } Header; + }; - typedef struct DescriptorTag + struct Descriptor { dw_addr_t address; dw_addr_t length; dw_addr_t end_address() const { return address + length; } - } Descriptor; + }; DWARFDebugArangeSet(); @@ -55,6 +55,12 @@ return NULL; } + const Descriptor & + GetDescriptorRef (uint32_t i) const + { + return m_arange_descriptors[i]; + } + protected: typedef std::vector DescriptorColl; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=141352&r1=141351&r2=141352&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Thu Oct 6 22:58:56 2011 @@ -34,15 +34,6 @@ { } - -//---------------------------------------------------------------------- -// Compare function DWARFDebugAranges::Range structures -//---------------------------------------------------------------------- -static bool RangeLessThan (const DWARFDebugAranges::Range& range1, const DWARFDebugAranges::Range& range2) -{ - return range1.lo_pc < range2.lo_pc; -} - //---------------------------------------------------------------------- // CountArangeDescriptors //---------------------------------------------------------------------- @@ -60,41 +51,6 @@ uint32_t& count; }; -//---------------------------------------------------------------------- -// AddArangeDescriptors -//---------------------------------------------------------------------- -class AddArangeDescriptors -{ -public: - AddArangeDescriptors (DWARFDebugAranges::RangeColl& ranges) : range_collection(ranges) {} - void operator() (const DWARFDebugArangeSet& set) - { - const DWARFDebugArangeSet::Descriptor* arange_desc_ptr; - DWARFDebugAranges::Range range; - range.offset = set.GetCompileUnitDIEOffset(); - - for (uint32_t i=0; (arange_desc_ptr = set.GetDescriptor(i)) != NULL; ++i) - { - range.lo_pc = arange_desc_ptr->address; - range.length = arange_desc_ptr->length; - - // Insert each item in increasing address order so binary searching - // can later be done! - DWARFDebugAranges::RangeColl::iterator insert_pos = lower_bound(range_collection.begin(), range_collection.end(), range, RangeLessThan); - range_collection.insert(insert_pos, range); - } - } - DWARFDebugAranges::RangeColl& range_collection; -}; - -//---------------------------------------------------------------------- -// PrintRange -//---------------------------------------------------------------------- -static void PrintRange(const DWARFDebugAranges::Range& range) -{ - // Cast the address values in case the address type is compiled as 32 bit - printf("0x%8.8x: [0x%8.8llx - 0x%8.8llx)\n", range.offset, (long long)range.lo_pc, (long long)range.hi_pc()); -} //---------------------------------------------------------------------- // Extract @@ -106,28 +62,23 @@ { uint32_t offset = 0; - typedef std::vector SetCollection; - typedef SetCollection::const_iterator SetCollectionIter; - SetCollection sets; - DWARFDebugArangeSet set; Range range; while (set.Extract(debug_aranges_data, &offset)) - sets.push_back(set); - - uint32_t count = 0; - - for_each(sets.begin(), sets.end(), CountArangeDescriptors(count)); - - if (count > 0) { - m_aranges.reserve(count); - AddArangeDescriptors range_adder(m_aranges); - for_each(sets.begin(), sets.end(), range_adder); + const uint32_t num_descriptors = set.NumDescriptors(); + if (num_descriptors > 0) + { + const dw_offset_t cu_offset = set.GetCompileUnitDIEOffset(); + + for (uint32_t i=0; iPrintf ("0x%8.8x: [0x%8.8llx - 0x%8.8llx)", range.offset, (uint64_t)range.lo_pc, (uint64_t)range.hi_pc()); + const RangeToDIE::Entry *entry = m_aranges.GetEntryAtIndex(i); + log->Printf ("0x%8.8x: [0x%llx - 0x%llx)", + entry->data, + entry->range.GetBase(), + entry->range.GetEnd()); } } - -void -DWARFDebugAranges::Range::Dump(Stream *s) const -{ - s->Printf("{0x%8.8x}: [0x%8.8llx - 0x%8.8llx)\n", offset, lo_pc, hi_pc()); -} - -//---------------------------------------------------------------------- -// Dump -//---------------------------------------------------------------------- -//void -//DWARFDebugAranges::Dump(SymbolFileDWARF* dwarf2Data, Stream *s) -//{ -// const DataExtractor &debug_aranges_data = dwarf2Data->get_debug_aranges_data(); -// if (debug_aranges_data.ValidOffset(0)) -// { -// uint32_t offset = 0; -// -// DWARFDebugArangeSet set; -// while (set.Extract(debug_aranges_data, &offset)) -// set.Dump(s); -// } -// else -// s->PutCString("< EMPTY >\n"); -//} -// - -//---------------------------------------------------------------------- -// AppendDebugRanges -//---------------------------------------------------------------------- -//void -//DWARFDebugAranges::AppendDebugRanges(BinaryStreamBuf& debug_ranges, dw_addr_t cu_base_addr, uint32_t addr_size) const -//{ -// if (!m_aranges.empty()) -// { -// RangeCollIterator end = m_aranges.end(); -// RangeCollIterator pos; -// RangeCollIterator lo_pos = end; -// for (pos = m_aranges.begin(); pos != end; ++pos) -// { -// if (lo_pos == end) -// lo_pos = pos; -// -// RangeCollIterator next = pos + 1; -// if (next != end) -// { -// // Check to see if we can combine two consecutive ranges? -// if (pos->hi_pc == next->lo_pc) -// continue; // We can combine them! -// } -// -// if (cu_base_addr == 0 || cu_base_addr == DW_INVALID_ADDRESS) -// { -// debug_ranges.AppendMax64(lo_pos->lo_pc, addr_size); -// debug_ranges.AppendMax64(pos->hi_pc, addr_size); -// } -// else -// { -// assert(lo_pos->lo_pc >= cu_base_addr); -// assert(pos->hi_pc >= cu_base_addr); -// debug_ranges.AppendMax64(lo_pos->lo_pc - cu_base_addr, addr_size); -// debug_ranges.AppendMax64(pos->hi_pc - cu_base_addr, addr_size); -// } -// -// // Reset the low part of the next address range -// lo_pos = end; -// } -// } -// // Terminate the .debug_ranges with two zero addresses -// debug_ranges.AppendMax64(0, addr_size); -// debug_ranges.AppendMax64(0, addr_size); -// -//} void DWARFDebugAranges::AppendRange (dw_offset_t offset, dw_addr_t low_pc, dw_addr_t high_pc) { - if (!m_aranges.empty()) - { - if (m_aranges.back().offset == offset && m_aranges.back().hi_pc() == low_pc) - { - m_aranges.back().set_hi_pc(high_pc); - return; - } - } - m_aranges.push_back (DWARFDebugAranges::Range(low_pc, high_pc, offset)); + if (high_pc > low_pc) + m_aranges.Append(RangeToDIE::Entry (low_pc, high_pc - low_pc, offset)); } void -DWARFDebugAranges::Sort (bool minimize, uint32_t n) +DWARFDebugAranges::Sort (bool minimize) { Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES)); - const size_t orig_arange_size = m_aranges.size(); + size_t orig_arange_size = 0; if (log) { - log->Printf ("DWARFDebugAranges::Sort(minimize = %u, n = %u) with %zu entries", minimize, n, orig_arange_size); - Dump (log.get()); + orig_arange_size = m_aranges.GetNumEntries(); + log->Printf ("DWARFDebugAranges::Sort(minimize = %u) with %zu entries", minimize, orig_arange_size); } - // Size of one? If so, no sorting is needed - if (orig_arange_size <= 1) - return; - // Sort our address range entries - std::stable_sort (m_aranges.begin(), m_aranges.end(), RangeLessThan); - - - if (!minimize) - return; - - // Most address ranges are contiguous from function to function - // so our new ranges will likely be smaller. We calculate the size - // of the new ranges since although std::vector objects can be resized, - // the will never reduce their allocated block size and free any excesss - // memory, so we might as well start a brand new collection so it is as - // small as possible. - - // First calculate the size of the new minimal arange vector - // so we don't have to do a bunch of re-allocations as we - // copy the new minimal stuff over to the new collection - size_t minimal_size = 1; - size_t i; - for (i=1; iPrintf ("DWARFDebugAranges::Sort() %zu entries after minimizing (%zu entries combined for %zu bytes saved)", + new_arange_size, delta, delta * sizeof(Range)); } - } - assert (j+1 == minimal_size); - - // Now swap our new minimal aranges into place. The local - // minimal_aranges will then contian the old big collection - // which will get freed. - minimal_aranges.swap(m_aranges); - - if (log) - { - size_t delta = orig_arange_size - m_aranges.size(); - log->Printf ("DWARFDebugAranges::Sort() %zu entries after minimizing (%zu entries combined for %zu bytes saved)", - m_aranges.size(), delta, delta * sizeof(Range)); Dump (log.get()); } } @@ -342,64 +167,8 @@ dw_offset_t DWARFDebugAranges::FindAddress(dw_addr_t address) const { - if ( !m_aranges.empty() ) - { - DWARFDebugAranges::Range range(address); - DWARFDebugAranges::RangeCollIterator begin = m_aranges.begin(); - DWARFDebugAranges::RangeCollIterator end = m_aranges.end(); - DWARFDebugAranges::RangeCollIterator pos = lower_bound(begin, end, range, RangeLessThan); - - if ((pos != end) && (pos->lo_pc <= address && address < pos->hi_pc())) - { - // printf("FindAddress(1) found 0x%8.8x in compile unit: 0x%8.8x\n", address, pos->offset); - return pos->offset; - } - else if (pos != begin) - { - --pos; - if ((pos->lo_pc <= address) && (address < pos->hi_pc())) - { - // printf("FindAddress(2) found 0x%8.8x in compile unit: 0x%8.8x\n", address, pos->offset); - return (*pos).offset; - } - } - } + const RangeToDIE::Entry *entry = m_aranges.FindEntryThatContains(address); + if (entry) + return entry->data; return DW_INVALID_OFFSET; } - -//---------------------------------------------------------------------- -// AllRangesAreContiguous -//---------------------------------------------------------------------- -bool -DWARFDebugAranges::AllRangesAreContiguous(dw_addr_t& lo_pc, dw_addr_t& hi_pc) const -{ - if (m_aranges.empty()) - return false; - - DWARFDebugAranges::RangeCollIterator begin = m_aranges.begin(); - DWARFDebugAranges::RangeCollIterator end = m_aranges.end(); - DWARFDebugAranges::RangeCollIterator pos; - dw_addr_t next_addr = 0; - - for (pos = begin; pos != end; ++pos) - { - if ((pos != begin) && (pos->lo_pc != next_addr)) - return false; - next_addr = pos->hi_pc(); - } - lo_pc = m_aranges.front().lo_pc; // We checked for empty at the start of function so front() will be valid - hi_pc = m_aranges.back().hi_pc(); // We checked for empty at the start of function so back() will be valid - return true; -} - -bool -DWARFDebugAranges::GetMaxRange(dw_addr_t& lo_pc, dw_addr_t& hi_pc) const -{ - if (m_aranges.empty()) - return false; - - lo_pc = m_aranges.front().lo_pc; // We checked for empty at the start of function so front() will be valid - hi_pc = m_aranges.back().hi_pc(); // We checked for empty at the start of function so back() will be valid - return true; -} - Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h?rev=141352&r1=141351&r2=141352&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Thu Oct 6 22:58:56 2011 @@ -13,113 +13,81 @@ #include "DWARFDebugArangeSet.h" #include +#include "lldb/Core/RangeMap.h" + class SymbolFileDWARF; class DWARFDebugAranges { +protected: + typedef lldb_private::RangeMap RangeToDIE; + public: - struct Range + typedef RangeToDIE::Entry Range; + typedef std::vector RangeColl; + + DWARFDebugAranges(); + + void + Clear() { - explicit - Range (dw_addr_t lo = DW_INVALID_ADDRESS, - dw_addr_t hi = DW_INVALID_ADDRESS, - dw_offset_t off = DW_INVALID_OFFSET) : - lo_pc (lo), - length (hi-lo), - offset (off) - { - } - - void Clear() - { - lo_pc = DW_INVALID_ADDRESS; - length = 0; - offset = DW_INVALID_OFFSET; - } - - void - set_hi_pc (dw_addr_t hi_pc) - { - if (hi_pc == DW_INVALID_ADDRESS || hi_pc <= lo_pc) - length = 0; - else - length = hi_pc - lo_pc; - } - dw_addr_t - hi_pc() const - { - if (length) - return lo_pc + length; - return DW_INVALID_ADDRESS; - } - bool - ValidRange() const - { - return length > 0; - } - - static bool - SortedOverlapCheck (const Range& curr_range, const Range& next_range, uint32_t n) - { - if (curr_range.offset != next_range.offset) - return false; - return curr_range.hi_pc() + n >= next_range.lo_pc; - } - - bool Contains(const Range& range) const - { - return lo_pc <= range.lo_pc && range.hi_pc() <= hi_pc(); - } - - void Dump(lldb_private::Stream *s) const; - dw_addr_t lo_pc; // Start of address range - uint32_t length; // End of address range (not including this address) - dw_offset_t offset; // Offset of the compile unit or die - }; - - DWARFDebugAranges(); - - void Clear() { m_aranges.clear(); } - bool AllRangesAreContiguous(dw_addr_t& lo_pc, dw_addr_t& hi_pc) const; - bool GetMaxRange(dw_addr_t& lo_pc, dw_addr_t& hi_pc) const; - bool Extract(const lldb_private::DataExtractor &debug_aranges_data); - bool Generate(SymbolFileDWARF* dwarf2Data); + m_aranges.Clear(); + } + + bool + Extract(const lldb_private::DataExtractor &debug_aranges_data); + + bool + Generate(SymbolFileDWARF* dwarf2Data); // Use append range multiple times and then call sort - void AppendRange (dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc); - void Sort (bool minimize, uint32_t n); + void + AppendRange (dw_offset_t cu_offset, + dw_addr_t low_pc, + dw_addr_t high_pc); + + void + Sort (bool minimize); - const Range* RangeAtIndex(uint32_t idx) const - { - if (idx < m_aranges.size()) - return &m_aranges[idx]; - return NULL; - } - void Dump (lldb_private::Log *log) const; - dw_offset_t FindAddress(dw_addr_t address) const; - bool IsEmpty() const { return m_aranges.empty(); } -// void Dump(lldb_private::Stream *s); - uint32_t NumRanges() const - { - return m_aranges.size(); - } - - dw_offset_t OffsetAtIndex(uint32_t idx) const - { - if (idx < m_aranges.size()) - return m_aranges[idx].offset; - return DW_INVALID_OFFSET; - } -// void AppendDebugRanges(BinaryStreamBuf& debug_ranges, dw_addr_t cu_base_addr, uint32_t addr_size) const; + const Range* + RangeAtIndex(uint32_t idx) const + { + return m_aranges.GetEntryAtIndex (idx); + } + + void + Dump (lldb_private::Log *log) const; + + dw_offset_t + FindAddress(dw_addr_t address) const; - static void Dump(SymbolFileDWARF* dwarf2Data, lldb_private::Stream *s); + bool + IsEmpty() const + { + return m_aranges.IsEmpty(); + } + uint32_t + GetNumRanges() const + { + return m_aranges.GetNumEntries(); + } - typedef std::vector RangeColl; - typedef RangeColl::const_iterator RangeCollIterator; + dw_offset_t + OffsetAtIndex(uint32_t idx) const + { + const Range *range = m_aranges.GetEntryAtIndex (idx); + if (range) + return range->data; + return DW_INVALID_OFFSET; + } + static void + Dump(SymbolFileDWARF* dwarf2Data, lldb_private::Stream *s); + protected: - RangeColl m_aranges; + + RangeToDIE m_aranges; }; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=141352&r1=141351&r2=141352&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Thu Oct 6 22:58:56 2011 @@ -84,19 +84,8 @@ } } - // Sort with a fudge factor of 16 to make sure if we have a lot - // of functions in the compile unit whose end address if followed - // a start address that is "fudge_size" bytes close, it will combine - // the arange entries. This currently happens a lot on x86_64. This - // will help reduce the size of the aranges since sort will sort all - // of them and combine aranges that are consecutive for ranges in the - // same compile unit and we really don't need it to be all that - // accurate since we will get exact accuracy when we search the - // actual compile unit aranges which point to the exact range and - // the exact DIE offset of the function. const bool minimize = true; - const uint32_t fudge_factor = 16; - m_cu_aranges_ap->Sort (minimize, fudge_factor); + m_cu_aranges_ap->Sort (minimize); } return *m_cu_aranges_ap.get(); } @@ -447,461 +436,6 @@ } } -/* -typedef struct AddressRangeTag -{ - dw_addr_t lo_pc; - dw_addr_t hi_pc; - dw_offset_t die_offset; -} AddressRange; -*/ -struct DIERange -{ - DIERange() : - range(), - lo_die_offset(), - hi_die_offset() - { - } - - DWARFDebugAranges::Range range; - dw_offset_t lo_die_offset; - dw_offset_t hi_die_offset; -}; - -typedef struct DwarfStat -{ - DwarfStat() : count(0), byte_size(0) {} - uint32_t count; - uint32_t byte_size; -} DwarfStat; - -typedef map DwarfAttrStatMap; - -typedef struct DIEStat -{ - DIEStat() : count(0), byte_size(0), attr_stats() {} - uint32_t count; - uint32_t byte_size; - DwarfAttrStatMap attr_stats; -} DIEStat; - -typedef map DIEStatMap; -struct VerifyInfo -{ - VerifyInfo(Stream* the_strm) : - strm(the_strm), - die_ranges(), - addr_range_errors(0), - sibling_errors(0), - die_stats() - { - } - - Stream* strm; - vector die_ranges; - uint32_t addr_range_errors; - uint32_t sibling_errors; - DIEStatMap die_stats; - - DISALLOW_COPY_AND_ASSIGN(VerifyInfo); - -}; - - -//---------------------------------------------------------------------- -// VerifyCallback -// -// A callback function for the static DWARFDebugInfo::Parse() function -// that gets called each time a compile unit header or debug information -// entry is successfully parsed. -// -// This function will verify the DWARF information is well formed by -// making sure that any DW_TAG_compile_unit tags that have valid address -// ranges (DW_AT_low_pc and DW_AT_high_pc) have no gaps in the address -// ranges of it contained DW_TAG_subprogram tags. Also the sibling chain -// and relationships are verified to make sure nothing gets hosed up -// when dead stripping occurs. -//---------------------------------------------------------------------- - -static dw_offset_t -VerifyCallback -( - SymbolFileDWARF* dwarf2Data, - DWARFCompileUnitSP& cu_sp, - DWARFDebugInfoEntry* die, - const dw_offset_t next_offset, - const uint32_t curr_depth, - void* userData -) -{ - VerifyInfo* verifyInfo = (VerifyInfo*)userData; - - const DWARFCompileUnit* cu = cu_sp.get(); - Stream *s = verifyInfo->strm; - bool verbose = s->GetVerbose(); - if (die) - { - // die->Dump(dwarf2Data, cu, f); - const DWARFAbbreviationDeclaration* abbrevDecl = die->GetAbbreviationDeclarationPtr(); - // We have a DIE entry - if (abbrevDecl) - { - const dw_offset_t die_offset = die->GetOffset(); - const dw_offset_t sibling = die->GetAttributeValueAsReference(dwarf2Data, cu, DW_AT_sibling, DW_INVALID_OFFSET); - - if (sibling != DW_INVALID_OFFSET) - { - if (sibling <= next_offset) - { - if (verifyInfo->sibling_errors++ == 0) - s->Printf("ERROR\n"); - s->Printf(" 0x%8.8x: sibling attribute (0x%8.8x) in this die is not valid: it is less than this DIE or some of its contents.\n", die->GetOffset(), sibling); - } - else if (sibling > verifyInfo->die_ranges.back().hi_die_offset) - { - if (verifyInfo->sibling_errors++ == 0) - s->Printf("ERROR\n"); - s->Printf(" 0x%8.8x: sibling attribute (0x%8.8x) in this DIE is not valid: it is greater than the end of the parent scope.\n", die->GetOffset(), sibling); - } - } - - if ((die_offset < verifyInfo->die_ranges.back().lo_die_offset) || (die_offset >= verifyInfo->die_ranges.back().hi_die_offset)) - { - if (verifyInfo->sibling_errors++ == 0) - s->Printf("ERROR\n"); - s->Printf(" 0x%8.8x: DIE offset is not within the parent DIE range {0x%8.8x}: (0x%8.8x - 0x%8.8x)\n", - die->GetOffset(), - verifyInfo->die_ranges.back().range.offset, - verifyInfo->die_ranges.back().lo_die_offset, - verifyInfo->die_ranges.back().hi_die_offset); - - } - - dw_tag_t tag = abbrevDecl->Tag(); - - // Keep some stats on this DWARF file - verifyInfo->die_stats[tag].count++; - verifyInfo->die_stats[tag].byte_size += (next_offset - die->GetOffset()); - - if (verbose) - { - DIEStat& tag_stat = verifyInfo->die_stats[tag]; - - const DataExtractor& debug_info = dwarf2Data->get_debug_info_data(); - - dw_offset_t offset = die->GetOffset(); - // Skip the abbreviation code so we are at the data for the attributes - debug_info.Skip_LEB128(&offset); - - const uint32_t numAttributes = abbrevDecl->NumAttributes(); - dw_attr_t attr; - dw_form_t form; - for (uint32_t idx = 0; idx < numAttributes; ++idx) - { - dw_offset_t start_offset = offset; - abbrevDecl->GetAttrAndFormByIndexUnchecked(idx, attr, form); - DWARFFormValue::SkipValue(form, debug_info, &offset, cu); - - if (tag_stat.attr_stats.find(attr) == tag_stat.attr_stats.end()) - { - tag_stat.attr_stats[attr].count = 0; - tag_stat.attr_stats[attr].byte_size = 0; - } - - tag_stat.attr_stats[attr].count++; - tag_stat.attr_stats[attr].byte_size += offset - start_offset; - } - } - - DWARFDebugAranges::Range range; - range.offset = die->GetOffset(); - - switch (tag) - { - case DW_TAG_compile_unit: - // Check for previous subroutines that were within a previous - // - // VerifyAddressRangesForCU(verifyInfo); - // Remember which compile unit we are dealing with so we can verify - // the address ranges within it (if any) are contiguous. The DWARF - // spec states that if a compile unit TAG has high and low PC - // attributes, there must be no gaps in the address ranges of it's - // contained subroutines. If there are gaps, the high and low PC - // must not be in the DW_TAG_compile_unit's attributes. Errors like - // this can crop up when optimized code is dead stripped and the debug - // information isn't properly fixed up for output. - range.lo_pc = die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, DW_INVALID_ADDRESS); - if (range.lo_pc != DW_INVALID_ADDRESS) - { - range.set_hi_pc (die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_high_pc, DW_INVALID_ADDRESS)); - if (s->GetVerbose()) - { - s->Printf("\n CU "); - range.Dump(s); - } - } - else - { - range.lo_pc = die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_entry_pc, DW_INVALID_ADDRESS); - } - break; - - case DW_TAG_subprogram: - // If the DW_TAG_compile_unit that contained this function had a - // valid address range, add all of the valid subroutine address - // ranges to a collection of addresses which will be sorted - // and verified right before the next DW_TAG_compile_unit is - // processed to make sure that there are no gaps in the address - // range. - range.lo_pc = die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, DW_INVALID_ADDRESS); - if (range.lo_pc != DW_INVALID_ADDRESS) - { - range.set_hi_pc (die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_high_pc, DW_INVALID_ADDRESS)); - if (range.hi_pc() != DW_INVALID_ADDRESS) - { - range.offset = die->GetOffset(); - bool valid = range.ValidRange(); - if (!valid || s->GetVerbose()) - { - s->Printf("\n FUNC "); - range.Dump(s); - if (!valid) - { - ++verifyInfo->addr_range_errors; - s->Printf(" ERROR: Invalid address range for function."); - } - } - } - } - break; - - case DW_TAG_lexical_block: - case DW_TAG_inlined_subroutine: - { - range.lo_pc = die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, DW_INVALID_ADDRESS); - if (range.lo_pc != DW_INVALID_ADDRESS) - { - range.set_hi_pc (die->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_high_pc, DW_INVALID_ADDRESS)); - if (range.hi_pc() != DW_INVALID_ADDRESS) - { - range.offset = die->GetOffset(); - bool valid = range.ValidRange(); - if (!valid || s->GetVerbose()) - { - s->Printf("\n BLCK "); - range.Dump(s); - if (!valid) - { - ++verifyInfo->addr_range_errors; - s->Printf(" ERROR: Invalid address range for block or inlined subroutine."); - } - } - } - } - } - break; - } - - if (range.ValidRange() && verifyInfo->die_ranges.back().range.ValidRange()) - { - if (!verifyInfo->die_ranges.back().range.Contains(range)) - { - ++verifyInfo->addr_range_errors; - s->Printf("\n "); - range.Dump(s); - s->Printf(" ERROR: Range is not in parent"); - verifyInfo->die_ranges.back().range.Dump(s); - } - } - - if (die->HasChildren()) - { - // Keep tabs on the valid address ranges for the current item to make - // sure that it all fits (make sure the sibling offsets got fixed up - // correctly if any functions were dead stripped). - DIERange die_range; - die_range.range = range; - die_range.lo_die_offset = next_offset; - die_range.hi_die_offset = sibling; - if (die_range.hi_die_offset == DW_INVALID_OFFSET) - die_range.hi_die_offset = verifyInfo->die_ranges.back().hi_die_offset; - verifyInfo->die_ranges.push_back(die_range); - } - } - else - { - // NULL entry - verifyInfo->die_ranges.pop_back(); - } - } - else - { - // cu->Dump(ostrm_ptr); // Dump the compile unit for the DIE - // We have a new compile unit header - verifyInfo->die_ranges.clear(); - DIERange die_range; - die_range.range.offset = cu->GetOffset(); - die_range.lo_die_offset = next_offset; - die_range.hi_die_offset = cu->GetNextCompileUnitOffset(); - verifyInfo->die_ranges.push_back(die_range); - } - - // Just return the current offset to parse the next CU or DIE entry - return next_offset; -} - - -class CompareDIEStatSizes -{ -public: - bool operator() (const DIEStatMap::const_iterator& pos1, const DIEStatMap::const_iterator& pos2) const - { - return pos1->second.byte_size <= pos2->second.byte_size; - } -}; - -class CompareAttrDIEStatSizes -{ -public: - bool operator() (const DwarfAttrStatMap::const_iterator& pos1, const DwarfAttrStatMap::const_iterator& pos2) const - { - return pos1->second.byte_size <= pos2->second.byte_size; - } -}; - -//---------------------------------------------------------------------- -// Verify -// -// Verifies the DWARF information is valid. -//---------------------------------------------------------------------- -void -DWARFDebugInfo::Verify(Stream *s, SymbolFileDWARF* dwarf2Data) -{ - s->Printf("Verifying Compile Unit Header chain....."); - VerifyInfo verifyInfo(s); - verifyInfo.addr_range_errors = 0; - verifyInfo.sibling_errors = 0; - - bool verbose = s->GetVerbose(); - - uint32_t offset = 0; - if (verbose) - s->EOL(); -// vector valid_cu_offsets; - DWARFCompileUnit cu (dwarf2Data); - bool success = true; - while ( success && dwarf2Data->get_debug_info_data().ValidOffset(offset+cu.Size()) ) - { - success = cu.Extract (dwarf2Data->get_debug_info_data(), &offset); - if (!success) - s->Printf("ERROR\n"); - // else - // valid_cu_offsets.push_back(cu.GetOffset()); - - cu.Verify(verifyInfo.strm); - offset = cu.GetNextCompileUnitOffset(); - } - - if (success) - s->Printf("OK\n"); - - s->Printf("Verifying address ranges and siblings..."); - if (verbose) - s->EOL(); - DWARFDebugInfo::Parse(dwarf2Data, VerifyCallback, &verifyInfo); - -// VerifyAddressRangesForCU(&verifyInfo); - - if (verifyInfo.addr_range_errors > 0) - s->Printf("\nERRORS - %u error(s) were found.\n", verifyInfo.addr_range_errors); - else - s->Printf("OK\n"); - - uint32_t total_category_sizes[kNumTagCategories] = {0}; - uint32_t total_category_count[kNumTagCategories] = {0}; - uint32_t total_die_count = 0; - uint32_t total_die_size = 0; - - typedef set DIEStatBySizeMap; - - s->PutCString( "\n" - "DWARF Statistics\n" - "Count Size Size % Tag\n" - "-------- -------- -------- -------------------------------------------\n"); - DIEStatBySizeMap statBySizeMap; - DIEStatMap::const_iterator pos; - DIEStatMap::const_iterator end_pos = verifyInfo.die_stats.end(); - for (pos = verifyInfo.die_stats.begin(); pos != end_pos; ++pos) - { - const uint32_t die_count = pos->second.count; - const uint32_t die_size = pos->second.byte_size; - - statBySizeMap.insert(pos); - total_die_count += die_count; - total_die_size += die_size; - DW_TAG_CategoryEnum category = get_tag_category(pos->first); - total_category_sizes[category] += die_size; - total_category_count[category] += die_count; - } - - float total_die_size_float = total_die_size; - - DIEStatBySizeMap::const_reverse_iterator size_pos; - DIEStatBySizeMap::const_reverse_iterator size_pos_end = statBySizeMap.rend(); - float percentage; - for (size_pos = statBySizeMap.rbegin(); size_pos != size_pos_end; ++size_pos) - { - pos = *size_pos; - - const DIEStat& tag_stat = pos->second; - - const uint32_t die_count = tag_stat.count; - const uint32_t die_size = tag_stat.byte_size; - percentage = ((float)die_size/total_die_size_float)*100.0; - s->Printf("%7u %8u %2.2f%% %s\n", die_count, die_size, percentage, DW_TAG_value_to_name(pos->first)); - - const DwarfAttrStatMap& attr_stats = tag_stat.attr_stats; - if (!attr_stats.empty()) - { - typedef set DwarfAttrStatBySizeMap; - DwarfAttrStatBySizeMap attrStatBySizeMap; - DwarfAttrStatMap::const_iterator attr_stat_pos; - DwarfAttrStatMap::const_iterator attr_stat_pos_end = attr_stats.end(); - for (attr_stat_pos = attr_stats.begin(); attr_stat_pos != attr_stat_pos_end; ++attr_stat_pos) - { - attrStatBySizeMap.insert(attr_stat_pos); - } - - DwarfAttrStatBySizeMap::const_reverse_iterator attr_size_pos; - DwarfAttrStatBySizeMap::const_reverse_iterator attr_size_pos_end = attrStatBySizeMap.rend(); - for (attr_size_pos = attrStatBySizeMap.rbegin(); attr_size_pos != attr_size_pos_end; ++attr_size_pos) - { - attr_stat_pos = *attr_size_pos; - percentage = ((float)attr_stat_pos->second.byte_size/die_size)*100.0; - s->Printf("%7u %8u %2.2f%% %s\n", attr_stat_pos->second.count, attr_stat_pos->second.byte_size, percentage, DW_AT_value_to_name(attr_stat_pos->first)); - } - s->EOL(); - } - } - - s->Printf("-------- -------- -------- -------------------------------------------\n"); - s->Printf("%7u %8u 100.00%% Total for all DIEs\n", total_die_count, total_die_size); - - float total_category_percentages[kNumTagCategories] = - { - ((float)total_category_sizes[TagCategoryVariable]/total_die_size_float)*100.0, - ((float)total_category_sizes[TagCategoryType]/total_die_size_float)*100.0, - ((float)total_category_sizes[TagCategoryProgram]/total_die_size_float)*100.0 - }; - - s->EOL(); - s->Printf("%7u %8u %2.2f%% %s\n", total_category_count[TagCategoryVariable], total_category_sizes[TagCategoryVariable], total_category_percentages[TagCategoryVariable], "Total for variable related DIEs"); - s->Printf("%7u %8u %2.2f%% %s\n", total_category_count[TagCategoryType], total_category_sizes[TagCategoryType], total_category_percentages[TagCategoryType], "Total for type related DIEs"); - s->Printf("%7u %8u %2.2f%% %s\n", total_category_count[TagCategoryProgram], total_category_sizes[TagCategoryProgram], total_category_percentages[TagCategoryProgram], "Total for program related DIEs"); - s->Printf("\n\n"); -} - typedef struct DumpInfo { DumpInfo(Stream* init_strm, uint32_t off, uint32_t depth) : From jingham at apple.com Fri Oct 7 13:02:54 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 07 Oct 2011 18:02:54 -0000 Subject: [Lldb-commits] [lldb] r141375 - in /lldb/trunk/test/lang: cpp/dynamic-value/TestDynamicValue.py objc/objc-dynamic-value/TestObjCDynamicValue.py Message-ID: <20111007180254.5BBDD312800A@llvm.org> Author: jingham Date: Fri Oct 7 13:02:54 2011 New Revision: 141375 URL: http://llvm.org/viewvc/llvm-project?rev=141375&view=rev Log: Turn the EvaluateExpression (..., True) tests back on. Modified: lldb/trunk/test/lang/cpp/dynamic-value/TestDynamicValue.py lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py Modified: lldb/trunk/test/lang/cpp/dynamic-value/TestDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/dynamic-value/TestDynamicValue.py?rev=141375&r1=141374&r2=141375&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/dynamic-value/TestDynamicValue.py (original) +++ lldb/trunk/test/lang/cpp/dynamic-value/TestDynamicValue.py Fri Oct 7 13:02:54 2011 @@ -159,10 +159,9 @@ self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) # Get "this" using the EvaluateExpression: - # These tests fail for now because EvaluateExpression doesn't currently support dynamic typing... - #this_static = frame.EvaluateExpression ('this', False) - #this_dynamic = frame.EvaluateExpression ('this', True) - #self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) + this_static = frame.EvaluateExpression ('this', False) + this_dynamic = frame.EvaluateExpression ('this', True) + self.examine_value_object_of_this_ptr (this_static, this_dynamic, myB_loc) # The "frame var" code uses another path to get into children, so let's # make sure that works as well: Modified: lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py?rev=141375&r1=141374&r2=141375&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py (original) +++ lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py Fri Oct 7 13:02:54 2011 @@ -147,10 +147,10 @@ self.examine_SourceDerived_ptr (object_dynamic) # Get "this" using the EvaluateExpression: - # These tests fail for now because EvaluateExpression doesn't currently support dynamic typing... - #object_static = frame.EvaluateExpression ('object', noDynamic) - #object_dynamic = frame.EvaluateExpression ('object', useDynamic) - #self.examine_value_object_of_object_ptr (object_static, object_dynamic, myB_loc) + object_static = frame.EvaluateExpression ('object', noDynamic) + object_dynamic = frame.EvaluateExpression ('object', useDynamic) + del (object_static) + self.examine_SourceDerived_ptr (object_dynamic) # Continue again to the handle_SourceBase and make sure we get the correct dynamic value. # This one looks exactly the same, but in fact this is an "un-KVO'ed" version of SourceBase, so From gclayton at apple.com Fri Oct 7 13:58:12 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 07 Oct 2011 18:58:12 -0000 Subject: [Lldb-commits] [lldb] r141382 - in /lldb/trunk: include/lldb/Core/RangeMap.h include/lldb/Interpreter/Args.h source/Commands/CommandObjectBreakpointCommand.cpp source/Commands/CommandObjectTarget.cpp source/Commands/CommandObjectThread.cpp source/Core/UserSettingsController.cpp source/Interpreter/Args.cpp source/Interpreter/OptionGroupValueObjectDisplay.cpp source/Interpreter/OptionGroupWatchpoint.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Message-ID: <20111007185812.9CBD7312800A@llvm.org> Author: gclayton Date: Fri Oct 7 13:58:12 2011 New Revision: 141382 URL: http://llvm.org/viewvc/llvm-project?rev=141382&view=rev Log: Re-organized the contents of RangeMap.h to be more concise and also allow for a Range, RangeArray, RangeData (range + data), or a RangeDataArray. We have many range implementations in LLDB and I will be converting over to using the classes in RangeMap.h so we can have one set of code that does ranges and searching of ranges. Fixed up DWARFDebugAranges to use the new range classes. Fixed the enumeration parsing to take a lldb_private::Error to avoid a lot of duplicated code. Now when an invalid enumeration is supplied, an error will be returned and that error will contain a list of the valid enumeration values. Modified: lldb/trunk/include/lldb/Core/RangeMap.h lldb/trunk/include/lldb/Interpreter/Args.h lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Interpreter/Args.cpp lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Modified: lldb/trunk/include/lldb/Core/RangeMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RangeMap.h (original) +++ lldb/trunk/include/lldb/Core/RangeMap.h Fri Oct 7 13:58:12 2011 @@ -15,22 +15,24 @@ namespace lldb_private { -//---------------------------------------------------------------------- -// A vm address range. These can represent offsets ranges or actual -// addresses. -//---------------------------------------------------------------------- -template -class RangeMap -{ -public: - typedef B RangeBaseType; - typedef S RangeSizeType; - typedef T EntryDataType; - + //---------------------------------------------------------------------- + // Templatized classes for dealing with generic ranges and also + // collections of ranges, or collections of ranges that have associated + // data. + //---------------------------------------------------------------------- + + //---------------------------------------------------------------------- + // A simple range class where you get to define the type of the range + // base "B", and the type used for the range byte size "S". + //---------------------------------------------------------------------- + template struct Range { - RangeBaseType base; - RangeSizeType size; + typedef B BaseType; + typedef S SizeType; + + BaseType base; + SizeType size; Range () : base (0), @@ -38,33 +40,33 @@ { } - Range (RangeBaseType b, RangeSizeType s) : + Range (BaseType b, SizeType s) : base (b), size (s) { } // Set the start value for the range, and keep the same size - RangeBaseType - GetBase () const + BaseType + GetRangeBase () const { return base; } void - SetBase (RangeBaseType b) + SetRangeBase (BaseType b) { base = b; } - RangeBaseType - GetEnd () const + BaseType + GetRangeEnd () const { return base + size; } void - SetEnd (RangeBaseType end) + SetRangeEnd (BaseType end) { if (end > base) size = end - base; @@ -72,14 +74,14 @@ size = 0; } - RangeSizeType - GetSize () const + SizeType + GetByteSize () const { return size; } void - SetSize (RangeSizeType s) + SetByteSize (SizeType s) { size = s; } @@ -91,21 +93,21 @@ } bool - Contains (RangeBaseType r) const + Contains (BaseType r) const { - return (GetBase() <= r) && (r < GetEnd()); + return (GetRangeBase() <= r) && (r < GetRangeEnd()); } bool - ContainsEndInclusive (RangeBaseType r) const + ContainsEndInclusive (BaseType r) const { - return (GetBase() <= r) && (r <= GetEnd()); + return (GetRangeBase() <= r) && (r <= GetRangeEnd()); } bool Contains (const Range& range) const { - return Contains(range.GetBase()) && ContainsEndInclusive(range.GetEnd()); + return Contains(range.GetRangeBase()) && ContainsEndInclusive(range.GetRangeEnd()); } bool @@ -128,179 +130,318 @@ return base != rhs.base || size != rhs.size; } }; + + //---------------------------------------------------------------------- + // A range array class where you get to define the type of the ranges + // that the collection contains. + //---------------------------------------------------------------------- - struct Entry + template + class RangeArray { - Range range; - EntryDataType data; + typedef Range Entry; + + RangeArray () + { + } + + ~RangeArray() + { + } + + void + Append (const Entry &entry) + { + m_entries.push_back (entry); + } + + void + Sort () + { + if (m_entries.size() > 1) + std::stable_sort (m_entries.begin(), m_entries.end()); + } + + void + CombineConsecutiveEntriesWithEqualData () + { + typename std::vector::iterator pos; + typename std::vector::iterator end; + typename std::vector::iterator prev; + bool can_combine = false; + // First we determine if we can combine any of the Entry objects so we + // don't end up allocating and making a new collection for no reason + for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + { + if (prev != end && prev->data == pos->data) + { + can_combine = true; + break; + } + } + + // We we can combine at least one entry, then we make a new collection + // and populate it accordingly, and then swap it into place. + if (can_combine) + { + std::vector minimal_ranges; + for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + { + if (prev != end && prev->data == pos->data) + minimal_ranges.back().range.SetEnd (pos->range.GetRangeEnd()); + else + minimal_ranges.push_back (*pos); + } + // Use the swap technique in case our new vector is much smaller. + // We must swap when using the STL because std::vector objects never + // release or reduce the memory once it has been allocated/reserved. + m_entries.swap (minimal_ranges); + } + } + + void + Clear () + { + m_entries.clear(); + } + + bool + IsEmpty () const + { + return m_entries.empty(); + } + + size_t + GetNumEntries () const + { + return m_entries.size(); + } + + const Entry * + GetEntryAtIndex (uint32_t i) const + { + if (i::const_iterator begin = m_entries.begin(); + typename std::vector::const_iterator end = m_entries.end(); + typename std::vector::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + + if (pos != end && pos->Contains(addr)) + { + return &(*pos); + } + else if (pos != begin) + { + --pos; + if (pos->Contains(addr)) + { + return &(*pos); + } + } + } + return NULL; + } + + protected: + std::vector m_entries; + }; - Entry () : - range (), + //---------------------------------------------------------------------- + // A simple range with data class where you get to define the type of + // the range base "B", the type used for the range byte size "S", and + // the type for the associated data "T". + //---------------------------------------------------------------------- + template + struct RangeData : public Range + { + typedef T DataType; + + DataType data; + + RangeData () : + Range (), data () { } - - Entry (RangeBaseType base, RangeSizeType size, EntryDataType d) : - range (base, size), + + RangeData (B base, S size, DataType d) : + Range (base, size), data (d) { } - + bool - operator < (const Entry &rhs) const + operator < (const RangeData &rhs) const { - const RangeBaseType lhs_base = range.GetBase(); - const RangeBaseType rhs_base = rhs.range.GetBase(); - if (lhs_base == rhs_base) + if (this->base == rhs.base) { - const RangeBaseType lhs_size = range.GetSize(); - const RangeBaseType rhs_size = rhs.range.GetSize(); - if (lhs_size == rhs_size) - return data < rhs.data; + if (this->size == rhs.size) + return this->data < rhs.data; else - return lhs_size < rhs_size; + return this->size < rhs.size; } - return lhs_base < rhs_base; + return this->base < rhs.base; } - + bool - operator == (const Entry &rhs) const + operator == (const RangeData &rhs) const { - return range.GetBase() == rhs.range.GetBase() && - range.GetSize() == rhs.range.GetSize() && - data == rhs.data; + return this->GetRangeBase() == rhs.GetRangeBase() && + this->GetByteSize() == rhs.GetByteSize() && + this->data == rhs.data; } - + bool - operator != (const Entry &rhs) const + operator != (const RangeData &rhs) const { - return range.GetBase() != rhs.range.GetBase() || - range.GetSize() != rhs.range.GetSize() || - data != rhs.data; + return this->GetRangeBase() != rhs.GetRangeBase() || + this->GetByteSize() != rhs.GetByteSize() || + this->data != rhs.data; } }; - - RangeMap () - { - } - - ~RangeMap() - { - } - - void - Append (const Entry &entry) - { - m_entries.push_back (entry); - } - - void - Sort () - { - if (m_entries.size() > 1) - std::stable_sort (m_entries.begin(), m_entries.end()); - } - void - CombineConsecutiveEntriesWithEqualData () + template + class RangeDataArray { - typename std::vector::iterator pos; - typename std::vector::iterator end; - typename std::vector::iterator prev; - bool can_combine = false; - // First we determine if we can combine any of the Entry objects so we - // don't end up allocating and making a new collection for no reason - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + public: + typedef RangeData Entry; + + RangeDataArray () { - if (prev != end && prev->data == pos->data) - { - can_combine = true; - break; - } } - // We we can combine at least one entry, then we make a new collection - // and populate it accordingly, and then swap it into place. - if (can_combine) + ~RangeDataArray() { - std::vector minimal_ranges; + } + + void + Append (const Entry &entry) + { + m_entries.push_back (entry); + } + + void + Sort () + { + if (m_entries.size() > 1) + std::stable_sort (m_entries.begin(), m_entries.end()); + } + + void + CombineConsecutiveEntriesWithEqualData () + { + typename std::vector::iterator pos; + typename std::vector::iterator end; + typename std::vector::iterator prev; + bool can_combine = false; + // First we determine if we can combine any of the Entry objects so we + // don't end up allocating and making a new collection for no reason for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) { if (prev != end && prev->data == pos->data) - minimal_ranges.back().range.SetEnd (pos->range.GetEnd()); - else - minimal_ranges.push_back (*pos); + { + can_combine = true; + break; + } } - // Use the swap technique in case our new vector is much smaller. - // We must swap when using the STL because std::vector objects never - // release or reduce the memory once it has been allocated/reserved. - m_entries.swap (minimal_ranges); - } - } - - void - Clear () - { - m_entries.clear(); - } - - bool - IsEmpty () const - { - return m_entries.empty(); - } - - size_t - GetNumEntries () const - { - return m_entries.size(); - } - - const Entry * - GetEntryAtIndex (uint32_t i) const - { - if (i::const_iterator begin = m_entries.begin(); - typename std::vector::const_iterator end = m_entries.end(); - typename std::vector::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); - if ((pos != end) && (pos->range.GetBase() <= addr && addr < pos->range.GetEnd())) + // We we can combine at least one entry, then we make a new collection + // and populate it accordingly, and then swap it into place. + if (can_combine) { - return &(*pos); + std::vector minimal_ranges; + for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + { + if (prev != end && prev->data == pos->data) + minimal_ranges.back().SetRangeEnd (pos->GetRangeEnd()); + else + minimal_ranges.push_back (*pos); + } + // Use the swap technique in case our new vector is much smaller. + // We must swap when using the STL because std::vector objects never + // release or reduce the memory once it has been allocated/reserved. + m_entries.swap (minimal_ranges); } - else if (pos != begin) + } + + void + Clear () + { + m_entries.clear(); + } + + bool + IsEmpty () const + { + return m_entries.empty(); + } + + size_t + GetNumEntries () const + { + return m_entries.size(); + } + + const Entry * + GetEntryAtIndex (uint32_t i) const + { + if (irange.GetBase() <= addr) && (addr < pos->range.GetEnd())) + Entry entry; + entry.SetRangeBase(addr); + entry.SetByteSize(1); + typename std::vector::const_iterator begin = m_entries.begin(); + typename std::vector::const_iterator end = m_entries.end(); + typename std::vector::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + + if (pos != end && pos->Contains(addr)) { return &(*pos); } + else if (pos != begin) + { + --pos; + if (pos->Contains(addr)) + { + return &(*pos); + } + } } + return NULL; } - return NULL; - } - -protected: - std::vector m_entries; -}; - + + protected: + std::vector m_entries; + }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Interpreter/Args.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Args.h (original) +++ lldb/trunk/include/lldb/Interpreter/Args.h Fri Oct 7 13:58:12 2011 @@ -381,7 +381,7 @@ StringToBoolean (const char *s, bool fail_value, bool *success_ptr); static int32_t - StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, int32_t fail_value, bool *success_ptr); + StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, int32_t fail_value, Error &error); static lldb::ScriptLanguage StringToScriptLanguage (const char *s, lldb::ScriptLanguage fail_value, bool *success_ptr); Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Oct 7 13:58:12 2011 @@ -91,45 +91,42 @@ char short_option = (char) m_getopt_table[option_idx].val; switch (short_option) - { - case 'o': - m_use_one_liner = true; - m_one_liner = option_arg; - break; - break; - case 's': - { - bool found_one = false; - m_script_language = (lldb::ScriptLanguage) Args::StringToOptionEnum (option_arg, - g_option_table[option_idx].enum_values, - eScriptLanguageNone, - &found_one); - if (!found_one) - error.SetErrorStringWithFormat("Invalid enumeration value '%s' for option '%c'.\n", - option_arg, - short_option); - - if (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault) - { - m_use_commands = false; - m_use_script_language = true; - } - else - { - m_use_commands = true; - m_use_script_language = false; - } - } - break; - case 'e': - bool success_ptr; - m_stop_on_error = Args::StringToBoolean(option_arg, false, &success_ptr); - if (!success_ptr) - error.SetErrorStringWithFormat("Invalid value for stop-on-error: \"%s\".\n", option_arg); - break; - default: - break; - } + { + case 'o': + m_use_one_liner = true; + m_one_liner = option_arg; + break; + + case 's': + m_script_language = (lldb::ScriptLanguage) Args::StringToOptionEnum (option_arg, + g_option_table[option_idx].enum_values, + eScriptLanguageNone, + error); + + if (m_script_language == eScriptLanguagePython || m_script_language == eScriptLanguageDefault) + { + m_use_commands = false; + m_use_script_language = true; + } + else + { + m_use_commands = true; + m_use_script_language = false; + } + break; + + case 'e': + { + bool success = false; + m_stop_on_error = Args::StringToBoolean(option_arg, false, &success); + if (!success) + error.SetErrorStringWithFormat("Invalid value for stop-on-error: \"%s\".\n", option_arg); + } + break; + + default: + break; + } return error; } Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Oct 7 13:58:12 2011 @@ -1876,17 +1876,10 @@ switch (short_option) { case 's': - { - bool found_one = false; m_sort_order = (SortOrder) Args::StringToOptionEnum (option_arg, g_option_table[option_idx].enum_values, eSortOrderNone, - &found_one); - if (!found_one) - error.SetErrorStringWithFormat("Invalid enumeration value '%s' for option '%c'.\n", - option_arg, - short_option); - } + error); break; default: Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Oct 7 13:58:12 2011 @@ -307,11 +307,8 @@ case 'm': { - bool found_one = false; OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; - m_run_mode = (lldb::RunMode) Args::StringToOptionEnum(option_arg, enum_values, eOnlyDuringStepping, &found_one); - if (!found_one) - error.SetErrorStringWithFormat("Invalid enumeration value for option '%c'.\n", short_option); + m_run_mode = (lldb::RunMode) Args::StringToOptionEnum(option_arg, enum_values, eOnlyDuringStepping, error); } break; @@ -807,17 +804,16 @@ break; case 'm': { - bool found_one = false; OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; - lldb::RunMode run_mode = (lldb::RunMode) Args::StringToOptionEnum(option_arg, enum_values, eOnlyDuringStepping, &found_one); + lldb::RunMode run_mode = (lldb::RunMode) Args::StringToOptionEnum(option_arg, enum_values, eOnlyDuringStepping, error); - if (!found_one) - error.SetErrorStringWithFormat("Invalid enumeration value for option '%c'.\n", short_option); - else if (run_mode == eAllThreads) - m_stop_others = false; - else - m_stop_others = true; - + if (error.Success()) + { + if (run_mode == eAllThreads) + m_stop_others = false; + else + m_stop_others = true; + } } break; default: Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Fri Oct 7 13:58:12 2011 @@ -2381,14 +2381,9 @@ UserSettingsController::UpdateEnumVariable (OptionEnumValueElement *enum_values, int *enum_var, const char *new_value, - Error &err) + Error &error) { - bool found_one; - - *enum_var = Args::StringToOptionEnum (new_value, enum_values, enum_values[0].value, &found_one); - - if (!found_one) - err.SetErrorString ("Invalid enumeration value; cannot update variable.\n"); + *enum_var = Args::StringToOptionEnum (new_value, enum_values, enum_values[0].value, error); } void Modified: lldb/trunk/source/Interpreter/Args.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Args.cpp (original) +++ lldb/trunk/source/Interpreter/Args.cpp Fri Oct 7 13:58:12 2011 @@ -834,21 +834,36 @@ int32_t -Args::StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, int32_t fail_value, bool *success_ptr) +Args::StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, int32_t fail_value, Error &error) { - if (enum_values && s && s[0]) + if (enum_values) { - for (int i = 0; enum_values[i].string_value != NULL ; i++) + if (s && s[0]) { - if (strstr(enum_values[i].string_value, s) == enum_values[i].string_value) + for (int i = 0; enum_values[i].string_value != NULL ; i++) { - if (success_ptr) *success_ptr = true; - return enum_values[i].value; + if (strstr(enum_values[i].string_value, s) == enum_values[i].string_value) + { + error.Clear(); + return enum_values[i].value; + } } } + + StreamString strm; + strm.PutCString ("invalid enumeration value, valid values are: "); + for (int i = 0; enum_values[i].string_value != NULL; i++) + { + strm.Printf ("%s\"%s\"", + i > 0 ? ", " : "", + enum_values[i].string_value); + } + error.SetErrorString(strm.GetData()); + } + else + { + error.SetErrorString ("invalid enumeration argument"); } - if (success_ptr) *success_ptr = false; - return fail_value; } Modified: lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Fri Oct 7 13:58:12 2011 @@ -72,12 +72,9 @@ { case 'd': { - bool success; int32_t result; - result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, &success); - if (!success) - error.SetErrorStringWithFormat("Invalid dynamic value setting: \"%s\".\n", option_arg); - else + result = Args::StringToOptionEnum (option_arg, TargetInstanceSettings::g_dynamic_value_types, 2, error); + if (error.Success()) use_dynamic = (lldb::DynamicValueType) result; } break; Modified: lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Fri Oct 7 13:58:12 2011 @@ -64,21 +64,16 @@ char short_option = (char) g_option_table[option_idx].short_option; switch (short_option) { - case 'w': { - OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; - watch_type = (WatchType) Args::StringToOptionEnum(option_arg, enum_values, 0, &watch_variable); - if (!watch_variable) - error.SetErrorStringWithFormat("Invalid option arg for '-w': '%s'.\n", option_arg); + case 'w': + watch_type = (WatchType) Args::StringToOptionEnum(option_arg, g_option_table[option_idx].enum_values, 0, error); + if (error.Success()) + watch_variable = true; break; - } - case 'x': { - bool success = false; - OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; - watch_size = (WatchType) Args::StringToOptionEnum(option_arg, enum_values, 0, &success); - if (!success) - error.SetErrorStringWithFormat("Invalid option arg for '-x': '%s'.\n", option_arg); + + case 'x': + watch_size = (WatchType) Args::StringToOptionEnum(option_arg, g_option_table[option_idx].enum_values, 0, error); break; - } + default: error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); break; @@ -91,8 +86,8 @@ OptionGroupWatchpoint::OptionParsingStarting (CommandInterpreter &interpreter) { watch_variable = false; - watch_type = eWatchInvalid; - watch_size = 0; + watch_type = eWatchInvalid; + watch_size = 0; } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Fri Oct 7 13:58:12 2011 @@ -119,8 +119,8 @@ const RangeToDIE::Entry *entry = m_aranges.GetEntryAtIndex(i); log->Printf ("0x%8.8x: [0x%llx - 0x%llx)", entry->data, - entry->range.GetBase(), - entry->range.GetEnd()); + entry->GetRangeBase(), + entry->GetRangeEnd()); } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h?rev=141382&r1=141381&r2=141382&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Fri Oct 7 13:58:12 2011 @@ -20,7 +20,7 @@ class DWARFDebugAranges { protected: - typedef lldb_private::RangeMap RangeToDIE; + typedef lldb_private::RangeDataArray RangeToDIE; public: typedef RangeToDIE::Entry Range; From johnny.chen at apple.com Fri Oct 7 14:21:09 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 07 Oct 2011 19:21:09 -0000 Subject: [Lldb-commits] [lldb] r141384 - in /lldb/trunk/test: benchmarks/disassembly/TestDisassembly.py benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py benchmarks/example/TestRepeatedExprs.py functionalities/command_regex/TestCommandRegex.py functionalities/embedded_interpreter/TestConvenienceVariables.py functionalities/stop-hook/TestStopHookMechanism.py functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py lldbtest.py Message-ID: <20111007192109.70F313128018@llvm.org> Author: johnny Date: Fri Oct 7 14:21:09 2011 New Revision: 141384 URL: http://llvm.org/viewvc/llvm-project?rev=141384&view=rev Log: If we spawn an lldb process for test (via pexpect), do not load the init file unless told otherwise. Set up self.lldbOption to be "--no-lldbibit" unless env variable NO_LLDBIBIT is defined and equals "NO". Also add "-nx" to gdb spawned. Modified: lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py lldb/trunk/test/functionalities/command_regex/TestCommandRegex.py lldb/trunk/test/functionalities/embedded_interpreter/TestConvenienceVariables.py lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py lldb/trunk/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py?rev=141384&r1=141383&r2=141384&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py (original) +++ lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py Fri Oct 7 14:21:09 2011 @@ -43,7 +43,7 @@ prompt = self.child_prompt # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s' % (self.lldbExec, exe)) + self.child = pexpect.spawn('%s %s %s' % (self.lldbExec, self.lldbOption, exe)) child = self.child # Turn on logging for what the child sends back. @@ -83,7 +83,7 @@ prompt = self.child_prompt # So that the child gets torn down after the test. - self.child = pexpect.spawn('gdb %s' % exe) + self.child = pexpect.spawn('gdb --nx %s' % exe) child = self.child # Turn on logging for what the child sends back. Modified: lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py?rev=141384&r1=141383&r2=141384&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py (original) +++ lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py Fri Oct 7 14:21:09 2011 @@ -49,7 +49,7 @@ prompt = self.child_prompt # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s' % (gdb_exe_path, exe)) + self.child = pexpect.spawn('%s --nx %s' % (gdb_exe_path, exe)) child = self.child # Turn on logging for what the child sends back. Modified: lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py?rev=141384&r1=141383&r2=141384&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py (original) +++ lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py Fri Oct 7 14:21:09 2011 @@ -38,7 +38,7 @@ prompt = self.child_prompt # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s' % (self.lldbExec, exe)) + self.child = pexpect.spawn('%s %s %s' % (self.lldbExec, self.lldbOption, exe)) child = self.child # Turn on logging for what the child sends back. @@ -83,7 +83,7 @@ prompt = self.child_prompt # So that the child gets torn down after the test. - self.child = pexpect.spawn('gdb %s' % exe) + self.child = pexpect.spawn('gdb --nx %s' % exe) child = self.child # Turn on logging for what the child sends back. Modified: lldb/trunk/test/functionalities/command_regex/TestCommandRegex.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_regex/TestCommandRegex.py?rev=141384&r1=141383&r2=141384&view=diff ============================================================================== --- lldb/trunk/test/functionalities/command_regex/TestCommandRegex.py (original) +++ lldb/trunk/test/functionalities/command_regex/TestCommandRegex.py Fri Oct 7 14:21:09 2011 @@ -18,7 +18,7 @@ regex_prompt = "Enter regular expressions in the form 's///' and terminate with an empty line:\r\n" regex_prompt1 = "\r\n" - child = pexpect.spawn('%s' % self.lldbHere) + child = pexpect.spawn('%s %s' % (self.lldbHere, self.lldbOption)) # Turn on logging for what the child sends back. if self.TraceOn(): child.logfile_read = sys.stdout Modified: lldb/trunk/test/functionalities/embedded_interpreter/TestConvenienceVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/embedded_interpreter/TestConvenienceVariables.py?rev=141384&r1=141383&r2=141384&view=diff ============================================================================== --- lldb/trunk/test/functionalities/embedded_interpreter/TestConvenienceVariables.py (original) +++ lldb/trunk/test/functionalities/embedded_interpreter/TestConvenienceVariables.py Fri Oct 7 14:21:09 2011 @@ -34,7 +34,7 @@ python_prompt = ">>> " # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s' % (self.lldbHere, exe)) + self.child = pexpect.spawn('%s %s %s' % (self.lldbHere, self.lldbOption, exe)) child = self.child # Turn on logging for what the child sends back. if self.TraceOn(): Modified: lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py?rev=141384&r1=141383&r2=141384&view=diff ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py (original) +++ lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py Fri Oct 7 14:21:09 2011 @@ -40,7 +40,7 @@ add_prompt1 = "\r\n> " # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s' % (self.lldbHere, exe)) + self.child = pexpect.spawn('%s %s %s' % (self.lldbHere, self.lldbOption, exe)) child = self.child # Turn on logging for what the child sends back. if self.TraceOn(): Modified: lldb/trunk/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py?rev=141384&r1=141383&r2=141384&view=diff ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py (original) +++ lldb/trunk/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py Fri Oct 7 14:21:09 2011 @@ -43,7 +43,7 @@ prompt = "(lldb) " # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s' % (self.lldbHere, exe)) + self.child = pexpect.spawn('%s %s %s' % (self.lldbHere, self.lldbOption, exe)) child = self.child # Turn on logging for what the child sends back. if self.TraceOn(): Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=141384&r1=141383&r2=141384&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Oct 7 14:21:09 2011 @@ -484,6 +484,12 @@ self.lldbHere = os.environ["LLDB_HERE"] else: self.lldbHere = None + # If we spawn an lldb process for test (via pexpect), do not load the + # init file unless told otherwise. + if "NO_LLDBINIT" in os.environ and "NO" == os.environ["NO_LLDBINIT"]: + self.lldbOption = "" + else: + self.lldbOption = "--no-lldbinit" # Assign the test method name to self.testMethodName. # From gclayton at apple.com Fri Oct 7 14:26:25 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 07 Oct 2011 19:26:25 -0000 Subject: [Lldb-commits] [lldb] r141387 - /lldb/trunk/source/Symbol/SymbolContext.cpp Message-ID: <20111007192625.BA572312800A@llvm.org> Author: gclayton Date: Fri Oct 7 14:26:25 2011 New Revision: 141387 URL: http://llvm.org/viewvc/llvm-project?rev=141387&view=rev Log: Removed code that was left in during testing and debugging of an issue. Modified: lldb/trunk/source/Symbol/SymbolContext.cpp Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=141387&r1=141386&r2=141387&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Fri Oct 7 14:26:25 2011 @@ -584,8 +584,6 @@ curr_frame_pc.GetFileAddress(), objfile->GetFileSpec().GetDirectory().GetCString(), objfile->GetFileSpec().GetFilename().GetCString()); - - curr_inlined_block->GetRangeContainingAddress (curr_frame_pc, range); // REMOVE THIS!!! } else { From dawn at burble.org Fri Oct 7 16:44:15 2011 From: dawn at burble.org (dawn at burble.org) Date: Fri, 7 Oct 2011 14:44:15 -0700 Subject: [Lldb-commits] [PATCH] bring lldb up to llvm and clang revs 140618 Message-ID: <20111007214415.GA26958@bloodbath.burble.org> This patch allows lldb (now at rev 141350) to build with rev 140618 of clang and llvm. When lldb is ready to move to newer versions of clang and llvm, I hope this patch will save you some time. -Dawn -------------- next part -------------- Index: include/lldb/Core/ClangForward.h =================================================================== --- include/lldb/Core/ClangForward.h (revision 141350) +++ include/lldb/Core/ClangForward.h (working copy) @@ -52,7 +52,8 @@ class DeclStmt; class DependencyOutputOptions; class Diagnostic; - class DiagnosticClient; + class DiagnosticsEngine; + class DiagnosticConsumer; class DiagnosticOptions; class EnumDecl; class Expr; Index: include/lldb/Symbol/ClangASTContext.h =================================================================== --- include/lldb/Symbol/ClangASTContext.h (revision 141350) +++ include/lldb/Symbol/ClangASTContext.h (working copy) @@ -84,10 +84,10 @@ clang::SourceManager * getSourceManager(); - clang::Diagnostic * - getDiagnostic(); + clang::DiagnosticsEngine * + getDiagnostics(); - clang::DiagnosticClient * + clang::DiagnosticConsumer * getDiagnosticClient(); clang::TargetOptions * @@ -754,22 +754,22 @@ //------------------------------------------------------------------ // Classes that inherit from ClangASTContext can see and modify these //------------------------------------------------------------------ - std::string m_target_triple; - std::auto_ptr m_ast_ap; - std::auto_ptr m_language_options_ap; - std::auto_ptr m_file_manager_ap; - std::auto_ptr m_file_system_options_ap; - std::auto_ptr m_source_manager_ap; - std::auto_ptr m_diagnostic_ap; - std::auto_ptr m_diagnostic_client_ap; - std::auto_ptr m_target_options_ap; - std::auto_ptr m_target_info_ap; - std::auto_ptr m_identifier_table_ap; - std::auto_ptr m_selector_table_ap; - std::auto_ptr m_builtins_ap; - CompleteTagDeclCallback m_callback_tag_decl; - CompleteObjCInterfaceDeclCallback m_callback_objc_decl; - void * m_callback_baton; + std::string m_target_triple; + std::auto_ptr m_ast_ap; + std::auto_ptr m_language_options_ap; + std::auto_ptr m_file_manager_ap; + std::auto_ptr m_file_system_options_ap; + std::auto_ptr m_source_manager_ap; + std::auto_ptr m_diagnostic_ap; + std::auto_ptr m_diagnostic_client_ap; + std::auto_ptr m_target_options_ap; + std::auto_ptr m_target_info_ap; + std::auto_ptr m_identifier_table_ap; + std::auto_ptr m_selector_table_ap; + std::auto_ptr m_builtins_ap; + CompleteTagDeclCallback m_callback_tag_decl; + CompleteObjCInterfaceDeclCallback m_callback_objc_decl; + void * m_callback_baton; private: //------------------------------------------------------------------ // For ClangASTContext only Index: source/Expression/ASTDumper.cpp =================================================================== --- source/Expression/ASTDumper.cpp (revision 141350) +++ source/Expression/ASTDumper.cpp (working copy) @@ -416,7 +416,11 @@ switch (type->getScalarTypeKind()) { default: m_stream.Printf("~\n"); break; - case clang::Type::STK_Pointer: m_stream.Printf("STK_Pointer\n"); break; + case clang::Type::STK_CPointer: m_stream.Printf("STK_CPointer\n"); break; + case clang::Type::STK_BlockPointer: m_stream.Printf("STK_BlockPointer\n"); break; + case clang::Type::STK_ObjCObjectPointer: + m_stream.Printf("STK_ObjCObjectPointer\n"); + break; case clang::Type::STK_MemberPointer: m_stream.Printf("STK_MemberPointer\n"); break; case clang::Type::STK_Bool: m_stream.Printf("STK_Bool\n"); break; case clang::Type::STK_Integral: m_stream.Printf("STK_Integral\n"); break; Index: source/Expression/ClangASTSource.cpp =================================================================== --- source/Expression/ClangASTSource.cpp (revision 141350) +++ source/Expression/ClangASTSource.cpp (working copy) @@ -197,27 +197,27 @@ unsigned NumArgs = func_proto_type->getNumArgs(); unsigned ArgIndex; - ParmVarDecl **param_var_decls = new ParmVarDecl*[NumArgs]; + SmallVector param_var_decls; + param_var_decls.reserve(NumArgs); for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex) { QualType arg_qual_type (func_proto_type->getArgType(ArgIndex)); - param_var_decls[ArgIndex] = ParmVarDecl::Create (m_ast_source.m_ast_context, - const_cast(m_decl_context), - SourceLocation(), - SourceLocation(), - NULL, - arg_qual_type, - NULL, - SC_Static, - SC_Static, - NULL); + ParmVarDecl *NewDecl = ParmVarDecl::Create (m_ast_source.m_ast_context, + const_cast(m_decl_context), + SourceLocation(), + SourceLocation(), + NULL, + arg_qual_type, + NULL, + SC_Static, + SC_Static, + NULL); + param_var_decls.push_back(NewDecl); } - func_decl->setParams(param_var_decls, NumArgs); - - delete [] param_var_decls; + func_decl->setParams(param_var_decls); } m_decls.push_back(func_decl); Index: source/Expression/ClangExpressionParser.cpp =================================================================== --- source/Expression/ClangExpressionParser.cpp (revision 141350) +++ source/Expression/ClangExpressionParser.cpp (working copy) @@ -41,7 +41,7 @@ #include "clang/Frontend/FrontendPluginRegistry.h" #include "clang/Frontend/TextDiagnosticBuffer.h" #include "clang/Frontend/TextDiagnosticPrinter.h" -#include "clang/Frontend/VerifyDiagnosticsClient.h" +#include "clang/Frontend/VerifyDiagnosticConsumer.h" #include "clang/Lex/Preprocessor.h" #include "clang/Parse/ParseAST.h" #include "clang/Rewrite/FrontendActions.h" @@ -67,8 +67,8 @@ #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Host.h" #include "llvm/Support/Signals.h" -#include "llvm/Target/TargetRegistry.h" -#include "llvm/Target/TargetSelect.h" +#include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/TargetSelect.h" using namespace clang; using namespace llvm; @@ -103,7 +103,7 @@ //===----------------------------------------------------------------------===// static void LLVMErrorHandler(void *UserData, const std::string &Message) { - Diagnostic &Diags = *static_cast(UserData); + DiagnosticsEngine &Diags = *static_cast(UserData); Diags.Report(diag::err_fe_error_backend) << Message; @@ -132,7 +132,7 @@ case EmitCodeGenOnly: return new EmitCodeGenOnlyAction(); case EmitObj: return new EmitObjAction(); case FixIt: return new FixItAction(); - case GeneratePCH: return new GeneratePCHAction(); + case GeneratePCH: return new GeneratePCHAction(false); case GeneratePTH: return new GeneratePTHAction(); case InitOnly: return new InitOnlyAction(); case ParseSyntaxOnly: return new SyntaxOnlyAction(); @@ -307,16 +307,21 @@ // 6. Most of this we get from the CompilerInstance, but we // also want to give the context an ExternalASTSource. + m_selector_table.reset(new SelectorTable()); - m_builtin_context.reset(new Builtin::Context(m_compiler->getTarget())); + + Builtin::Context* NewContext = new Builtin::Context(); + NewContext->InitializeTarget(m_compiler->getTarget()); + m_builtin_context.reset(NewContext); std::auto_ptr ast_context(new ASTContext(m_compiler->getLangOpts(), m_compiler->getSourceManager(), - m_compiler->getTarget(), + &(m_compiler->getTarget()), m_compiler->getPreprocessor().getIdentifierTable(), *m_selector_table.get(), *m_builtin_context.get(), - 0)); + 0, + false)); ClangExpressionDeclMap *decl_map = m_expr.DeclMap(); Index: source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp (revision 141350) +++ source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp (working copy) @@ -112,7 +112,7 @@ executable = m_process->GetTarget().GetExecutableModule(); load_offset = ComputeLoadOffset(); - if (!executable.empty() && load_offset != LLDB_INVALID_ADDRESS) + if (executable.get() && load_offset != LLDB_INVALID_ADDRESS) { ModuleList module_list; module_list.Append(executable); @@ -132,7 +132,7 @@ executable = m_process->GetTarget().GetExecutableModule(); load_offset = ComputeLoadOffset(); - if (!executable.empty() && load_offset != LLDB_INVALID_ADDRESS) + if (executable.get() && load_offset != LLDB_INVALID_ADDRESS) { ModuleList module_list; module_list.Append(executable); @@ -264,7 +264,7 @@ { FileSpec file(I->path.c_str(), true); ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr); - if (!module_sp.empty()) + if (module_sp.get()) new_modules.Append(module_sp); } m_process->GetTarget().ModulesDidLoad(new_modules); @@ -280,7 +280,7 @@ FileSpec file(I->path.c_str(), true); ModuleSP module_sp = loaded_modules.FindFirstModuleForFileSpec(file, NULL, NULL); - if (!module_sp.empty()) + if (module_sp.get()) old_modules.Append(module_sp); } m_process->GetTarget().ModulesDidUnload(old_modules); @@ -355,7 +355,7 @@ { FileSpec file(I->path.c_str(), false); ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr); - if (!module_sp.empty()) + if (module_sp.get()) module_list.Append(module_sp); } Index: source/Plugins/Process/Linux/ProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessLinux.cpp (revision 141350) +++ source/Plugins/Process/Linux/ProcessLinux.cpp (working copy) @@ -437,6 +437,13 @@ return m_thread_list.GetSize(false); } +uint32_t +ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) +{ + // FIXME: Should this be implemented? + return 0; +} + ByteOrder ProcessLinux::GetByteOrder() const { Index: source/Plugins/Process/Linux/ProcessLinux.h =================================================================== --- source/Plugins/Process/Linux/ProcessLinux.h (revision 141350) +++ source/Plugins/Process/Linux/ProcessLinux.h (working copy) @@ -129,6 +129,10 @@ virtual uint32_t UpdateThreadListIfNeeded(); + uint32_t + UpdateThreadList(lldb_private::ThreadList &old_thread_list, + lldb_private::ThreadList &new_thread_list); + virtual lldb::ByteOrder GetByteOrder() const; Index: source/Plugins/Process/Linux/ProcessMonitor.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessMonitor.cpp (revision 141350) +++ source/Plugins/Process/Linux/ProcessMonitor.cpp (working copy) @@ -241,7 +241,7 @@ // Set errno to zero so that we can detect a failed peek. errno = 0; - unsigned long data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL); + uint32_t data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL); if (data == -1UL && errno) m_result = false; Index: source/Symbol/ClangASTContext.cpp =================================================================== --- source/Symbol/ClangASTContext.cpp (revision 141350) +++ source/Symbol/ClangASTContext.cpp (working copy) @@ -468,11 +468,12 @@ { m_ast_ap.reset(new ASTContext (*getLanguageOptions(), *getSourceManager(), - *getTargetInfo(), + getTargetInfo(), *getIdentifierTable(), *getSelectorTable(), *getBuiltinContext(), - 0)); + 0, + false)); if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton) { @@ -489,7 +490,11 @@ ClangASTContext::getBuiltinContext() { if (m_builtins_ap.get() == NULL) - m_builtins_ap.reset (new Builtin::Context(*getTargetInfo())); + { + Builtin::Context* NewContext = new Builtin::Context(); + NewContext->InitializeTarget(*getTargetInfo()); + m_builtins_ap.reset(NewContext); + } return m_builtins_ap.get(); } @@ -536,22 +541,23 @@ ClangASTContext::getSourceManager() { if (m_source_manager_ap.get() == NULL) - m_source_manager_ap.reset(new clang::SourceManager(*getDiagnostic(), *getFileManager())); + m_source_manager_ap.reset( + new clang::SourceManager(*getDiagnostics(), *getFileManager())); return m_source_manager_ap.get(); } -Diagnostic * -ClangASTContext::getDiagnostic() +DiagnosticsEngine * +ClangASTContext::getDiagnostics() { if (m_diagnostic_ap.get() == NULL) { llvm::IntrusiveRefCntPtr diag_id_sp(new DiagnosticIDs()); - m_diagnostic_ap.reset(new Diagnostic(diag_id_sp)); + m_diagnostic_ap.reset(new DiagnosticsEngine(diag_id_sp)); } return m_diagnostic_ap.get(); } -class NullDiagnosticClient : public DiagnosticClient +class NullDiagnosticClient : public DiagnosticConsumer { public: NullDiagnosticClient () @@ -559,7 +565,7 @@ m_log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); } - void HandleDiagnostic (Diagnostic::Level DiagLevel, const DiagnosticInfo &info) + void HandleDiagnostic (DiagnosticsEngine::Level DiagLevel, const Diagnostic &info) { if (m_log) { @@ -573,7 +579,7 @@ LogSP m_log; }; -DiagnosticClient * +DiagnosticConsumer * ClangASTContext::getDiagnosticClient() { if (m_diagnostic_client_ap.get() == NULL) @@ -600,7 +606,7 @@ { // target_triple should be something like "x86_64-apple-darwin10" if (m_target_info_ap.get() == NULL && !m_target_triple.empty()) - m_target_info_ap.reset (TargetInfo::CreateTargetInfo(*getDiagnostic(), *getTargetOptions())); + m_target_info_ap.reset (TargetInfo::CreateTargetInfo(*getDiagnostics(), *getTargetOptions())); return m_target_info_ap.get(); } @@ -1466,7 +1472,8 @@ NULL, // TypeSourceInfo * is_explicit, is_inline, - is_implicitly_declared); + is_implicitly_declared, + false); // isConstexpr } else { @@ -1492,6 +1499,7 @@ is_static, SC_None, is_inline, + false, // isConstexpr SourceLocation()); } else if (num_params == 0) @@ -1505,6 +1513,7 @@ NULL, // TypeSourceInfo * is_inline, is_explicit, + false, // isConstexpr SourceLocation()); } } @@ -1520,6 +1529,7 @@ is_static, SC_None, is_inline, + false, // isConstexpr SourceLocation()); } } @@ -1549,7 +1559,7 @@ NULL)); } - cxx_method_decl->setParams (params.data(), num_params); + cxx_method_decl->setParams (params); cxx_record_decl->addDecl (cxx_method_decl); @@ -2020,8 +2030,10 @@ name[0] == '-', is_variadic, is_synthesized, + false, // isImplicitlyDeclared is_defined, imp_control, + false, // HasRelatedResultType num_args); @@ -4208,7 +4220,17 @@ ClangASTContext::SetFunctionParameters (FunctionDecl *function_decl, ParmVarDecl **params, unsigned num_params) { if (function_decl) - function_decl->setParams (params, num_params); + { + llvm::SmallVector param_var_decls; + param_var_decls.reserve(num_params); + + for (int param_index = 0; param_index < num_params; ++param_index) + { + param_var_decls.push_back (params[param_index]); + } + + function_decl->setParams (param_var_decls); + } } Index: source/lldb.cpp =================================================================== --- source/lldb.cpp (revision 141350) +++ source/lldb.cpp (working copy) @@ -94,7 +94,9 @@ UnwindAssemblyInstEmulation::Initialize(); UnwindAssembly_x86::Initialize(); EmulateInstructionARM::Initialize (); +#if !defined (__linux__) ObjectFilePECOFF::Initialize (); +#endif #if defined (__APPLE__) //---------------------------------------------------------------------- // Apple/Darwin hosted plugins @@ -166,7 +168,9 @@ UnwindAssembly_x86::Terminate(); UnwindAssemblyInstEmulation::Terminate(); EmulateInstructionARM::Terminate (); +#if !defined (__linux__) ObjectFilePECOFF::Terminate (); +#endif #if defined (__APPLE__) DynamicLoaderMacOSXDYLD::Terminate(); From jingham at apple.com Fri Oct 7 17:16:04 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 07 Oct 2011 22:16:04 -0000 Subject: [Lldb-commits] [lldb] r141422 - in /lldb/trunk: include/lldb/Core/SourceManager.h source/Core/SourceManager.cpp source/Target/Target.cpp Message-ID: <20111007221604.C97AA2A6C12D@llvm.org> Author: jingham Date: Fri Oct 7 17:16:04 2011 New Revision: 141422 URL: http://llvm.org/viewvc/llvm-project?rev=141422&view=rev Log: Don't look up main to find the default source file till somebody actually asks for it. Modified: lldb/trunk/include/lldb/Core/SourceManager.h lldb/trunk/source/Core/SourceManager.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Core/SourceManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SourceManager.h?rev=141422&r1=141421&r2=141422&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/SourceManager.h (original) +++ lldb/trunk/include/lldb/Core/SourceManager.h Fri Oct 7 17:16:04 2011 @@ -178,6 +178,7 @@ uint32_t m_last_file_line; uint32_t m_last_file_context_before; uint32_t m_last_file_context_after; + bool m_default_set; Target *m_target; Debugger *m_debugger; Modified: lldb/trunk/source/Core/SourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SourceManager.cpp?rev=141422&r1=141421&r2=141422&view=diff ============================================================================== --- lldb/trunk/source/Core/SourceManager.cpp (original) +++ lldb/trunk/source/Core/SourceManager.cpp Fri Oct 7 17:16:04 2011 @@ -35,6 +35,7 @@ m_last_file_line (0), m_last_file_context_before (0), m_last_file_context_after (10), + m_default_set(false), m_target (&target), m_debugger(NULL) { @@ -46,6 +47,7 @@ m_last_file_line (0), m_last_file_context_before (0), m_last_file_context_after (10), + m_default_set(false), m_target (NULL), m_debugger (&debugger) { @@ -206,6 +208,8 @@ { FileSP old_file_sp = m_last_file_sp; m_last_file_sp = GetFile (file_spec); + + m_default_set = true; if (m_last_file_sp) { m_last_file_line = line; @@ -227,6 +231,35 @@ line = m_last_file_line; return true; } + else if (!m_default_set) + { + // If nobody has set the default file and line then try here. If there's no executable, then we + // will try again later when there is one. Otherwise, if we can't find it we won't look again, + // somebody will have to set it (for instance when we stop somewhere...) + Module *executable_ptr = m_target->GetExecutableModulePointer(); + if (executable_ptr) + { + SymbolContextList sc_list; + uint32_t num_matches; + ConstString main_name("main"); + bool symbols_okay = false; // Force it to be a debug symbol. + bool append = false; + num_matches = executable_ptr->FindFunctions (main_name, lldb::eFunctionNameTypeBase, symbols_okay, append, sc_list); + for (uint32_t idx = 0; idx < num_matches; idx++) + { + SymbolContext sc; + sc_list.GetContextAtIndex(idx, sc); + if (sc.line_entry.file) + { + SetDefaultFileAndLine(sc.line_entry.file, sc.line_entry.line); + break; + } + } + return GetDefaultFileAndLine (file_spec, line); + } + else + return false; + } else return false; } Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=141422&r1=141421&r2=141422&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Fri Oct 7 17:16:04 2011 @@ -811,26 +811,6 @@ FileSpecList dependent_files; ObjectFile *executable_objfile = executable_sp->GetObjectFile(); - // Let's find the file & line for main and set the default source file from there. - if (!m_source_manager.DefaultFileAndLineSet()) - { - SymbolContextList sc_list; - uint32_t num_matches; - ConstString main_name("main"); - bool symbols_okay = false; // Force it to be a debug symbol. - bool append = false; - num_matches = executable_sp->FindFunctions (main_name, eFunctionNameTypeBase, symbols_okay, append, sc_list); - for (uint32_t idx = 0; idx < num_matches; idx++) - { - SymbolContext sc; - sc_list.GetContextAtIndex(idx, sc); - if (sc.line_entry.file) - { - m_source_manager.SetDefaultFileAndLine(sc.line_entry.file, sc.line_entry.line); - break; - } - } - } if (executable_objfile && get_dependent_files) { From jingham at apple.com Fri Oct 7 17:17:16 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 07 Oct 2011 22:17:16 -0000 Subject: [Lldb-commits] [lldb] r141423 - /lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Message-ID: <20111007221716.B9F2F2A6C12D@llvm.org> Author: jingham Date: Fri Oct 7 17:17:16 2011 New Revision: 141423 URL: http://llvm.org/viewvc/llvm-project?rev=141423&view=rev Log: Fix the option lists that "--file" belongs to so the help won't come out whonky. Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=141423&r1=141422&r2=141423&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Oct 7 17:17:16 2011 @@ -71,7 +71,7 @@ { } -#define LLDB_OPT_FILE (LLDB_OPT_SET_ALL & ~(LLDB_OPT_SET_2)) +#define LLDB_OPT_FILE (LLDB_OPT_SET_1 | LLDB_OPT_SET_3 | LLDB_OPT_SET_4 | LLDB_OPT_SET_5 | LLDB_OPT_SET_6 | LLDB_OPT_SET_7 | LLDB_OPT_SET_8 | LLDB_OPT_SET_9 ) OptionDefinition CommandObjectBreakpointSet::CommandOptions::g_option_table[] = From jingham at apple.com Fri Oct 7 17:20:35 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 07 Oct 2011 22:20:35 -0000 Subject: [Lldb-commits] [lldb] r141424 - /lldb/trunk/source/Symbol/Function.cpp Message-ID: <20111007222035.816512A6C12D@llvm.org> Author: jingham Date: Fri Oct 7 17:20:35 2011 New Revision: 141424 URL: http://llvm.org/viewvc/llvm-project?rev=141424&view=rev Log: When a function calculates its module, make sure it returns the "real" module, not the linked .o file. Modified: lldb/trunk/source/Symbol/Function.cpp Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=141424&r1=141423&r2=141424&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Fri Oct 7 17:20:35 2011 @@ -387,6 +387,16 @@ Module * Function::CalculateSymbolContextModule () { + const Section *section = m_range.GetBaseAddress().GetSection(); + if (section) + { + const Section *linked_section = section->GetLinkedSection(); + if (linked_section) + return linked_section->GetModule(); + else + return section->GetModule(); + } + return this->GetCompileUnit()->GetModule(); } From jingham at apple.com Fri Oct 7 17:23:45 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 07 Oct 2011 22:23:45 -0000 Subject: [Lldb-commits] [lldb] r141428 - in /lldb/trunk: include/lldb/Breakpoint/BreakpointResolverName.h include/lldb/Target/CPPLanguageRuntime.h include/lldb/Target/ObjCLanguageRuntime.h source/API/SBTarget.cpp source/Breakpoint/BreakpointResolverName.cpp source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Target/CPPLanguageRuntime.cpp test/python_api/target/TestTargetAPI.py Message-ID: <20111007222346.0209A3128018@llvm.org> Author: jingham Date: Fri Oct 7 17:23:45 2011 New Revision: 141428 URL: http://llvm.org/viewvc/llvm-project?rev=141428&view=rev Log: Move the responsibility for translating the various eFunctionNameType lookups to the SymbolFIle (it was done mostly in the BreakpointResolverName resolver before.) Then tailor our searches to the way the indexed maps are laid out. This removes a bunch of test case failures using indexed dSYM's. Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Target/CPPLanguageRuntime.cpp lldb/trunk/test/python_api/target/TestTargetAPI.py Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h?rev=141428&r1=141427&r2=141428&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverName.h Fri Oct 7 17:23:45 2011 @@ -72,14 +72,6 @@ protected: ConstString m_func_name; - // "m_basename_filter" is used to filter results after searching for - // "m_func_name" first. This is used when we are asked to set a breakpoint - // at "foo::bar::baz" (C++ function in namespace or in a class). For - // "foo::bar::baz" we will place "baz" into m_func_name and search for all - // matching basename and methods that match "baz", then we will filter the - // results by checking if the demangled name contains "m_basename_filter" - // which would be set to "foo::bar::baz". - std::string m_basename_filter; uint32_t m_func_name_type_mask; // See FunctionNameType ConstString m_class_name; // FIXME: Not used yet. The idea would be to stop on methods of this class. RegularExpression m_regex; Modified: lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h?rev=141428&r1=141427&r2=141428&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h Fri Oct 7 17:23:45 2011 @@ -42,6 +42,15 @@ virtual bool GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope); + static bool + IsCPPMangledName(const char *name); + + static bool + IsPossibleCPPCall (const char *name, const char *&base_name_start, const char *&base_name_end); + + static bool + StripNamespacesFromVariableName (const char *name, const char *&base_name_start, const char *&base_name_end); + protected: //------------------------------------------------------------------ // Classes that inherit from CPPLanguageRuntime can see and modify these Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=141428&r1=141427&r2=141428&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Fri Oct 7 17:23:45 2011 @@ -102,7 +102,25 @@ static bool IsPossibleObjCMethodName (const char *name) { - return (name && (name[0] == '+' || name[0] == '-') && name[1] == '['); + if (!name) + return false; + bool starts_right = (name[0] == '+' || name[0] == '-') && name[1] == '['; + bool ends_right = (name[strlen(name) - 1] == ']'); + return (starts_right && ends_right); + } + + static bool + IsPossibleObjCSelector (const char *name) + { + if (!name) + return false; + + if (strchr(name, ':') == NULL) + return true; + else if (name[strlen(name) - 1] == ':') + return true; + else + return false; } protected: Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=141428&r1=141427&r2=141428&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Fri Oct 7 17:23:45 2011 @@ -588,11 +588,11 @@ { FileSpecList module_spec_list; module_spec_list.Append (FileSpec (module_name, false)); - *sb_bp = m_opaque_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, false); } else { - *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, false); } } Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=141428&r1=141427&r2=141428&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Fri Oct 7 17:23:45 2011 @@ -30,55 +30,14 @@ bool skip_prologue ) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), - m_func_name (), - m_basename_filter (), + m_func_name (func_name), m_func_name_type_mask (func_name_type_mask), m_class_name (), m_regex (), m_match_type (type), m_skip_prologue (skip_prologue) { - if (func_name_type_mask == eFunctionNameTypeAuto) - { - if ((::strchr (func_name, '(' ) != NULL) || - (::strstr (func_name, "-[") == func_name) || - (::strstr (func_name, "+[") == func_name)) - { - // We have a name that contains an open parens, or starts with - // "+[" or "-[", so this looks like a complete function prototype - m_func_name_type_mask = eFunctionNameTypeFull; - } - else - { - // We don't have a full function name, but we might have a partial - // function basename with namespaces or classes - if (::strstr (func_name, "::") != NULL) - { - // Keep the full name in "m_basename_filter" - m_basename_filter = func_name; - // Now set "m_func_name" to just the function basename - m_func_name.SetCString(m_basename_filter.c_str() + m_basename_filter.rfind("::") + 2); - // We have a name with a double colon which means we have a - // function name that is a C++ method or a function in a C++ - // namespace - m_func_name_type_mask = eFunctionNameTypeBase | eFunctionNameTypeMethod; - } - else if (::strstr (func_name, ":") != NULL) - { - // Single colon => selector - m_func_name_type_mask = eFunctionNameTypeSelector; - } - else - { - // just a basename by default - m_func_name_type_mask = eFunctionNameTypeBase; - } - } - } - if (!m_func_name) - m_func_name.SetCString(func_name); - if (m_match_type == Breakpoint::Regexp) { if (!m_regex.Compile (m_func_name.AsCString())) @@ -178,7 +137,7 @@ if (num_functions == 0 && !filter_by_cu) { - if (m_func_name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull)) + if (m_func_name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeAuto)) context.module_sp->FindSymbolsWithNameAndType (m_func_name, eSymbolTypeCode, sym_list); } } @@ -217,68 +176,7 @@ } } } - - - if (!m_basename_filter.empty()) - { - // Filter out any matches whose names don't contain the basename filter - const char *basename_filter = m_basename_filter.c_str(); - if (func_list.GetSize()) - { - bool remove = false; - for (i = 0; i < func_list.GetSize(); remove = false) - { - if (func_list.GetContextAtIndex(i, sc) == false) - remove = true; - else if (sc.function == NULL) - remove = true; - else - { - const InlineFunctionInfo* inlined_info = NULL; - - if (sc.block) - inlined_info = sc.block->GetInlinedFunctionInfo(); - if (inlined_info) - { - if (::strstr (inlined_info->GetName().AsCString(), basename_filter) == NULL) - remove = true; - } - else if (::strstr (sc.function->GetName().AsCString(), basename_filter) == NULL) - remove = true; - } - - if (remove) - { - func_list.RemoveContextAtIndex(i); - continue; - } - i++; - } - } - - if (sym_list.GetSize()) - { - bool remove = false; - for (i = 0; i < sym_list.GetSize(); remove = false) - { - if (sym_list.GetContextAtIndex(i, sc) == false) - remove = true; - else if (sc.symbol == NULL) - remove = true; - else if (::strstr (sc.symbol->GetName().AsCString(), basename_filter) == NULL) - remove = true; - - if (remove) - { - sym_list.RemoveContextAtIndex(i); - continue; - } - i++; - } - } - } - // Remove any duplicates between the funcion list and the symbol list if (func_list.GetSize()) { @@ -395,10 +293,8 @@ { if (m_match_type == Breakpoint::Regexp) s->Printf("regex = '%s'", m_regex.GetText()); - else if (m_basename_filter.empty()) - s->Printf("name = '%s'", m_func_name.AsCString()); else - s->Printf("name = '%s'", m_basename_filter.c_str()); + s->Printf("name = '%s'", m_func_name.AsCString()); } void Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h?rev=141428&r1=141427&r2=141428&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Fri Oct 7 17:23:45 2011 @@ -652,6 +652,19 @@ return die_offsets.size(); } + size_t + FindByName (const char *name, DIEArray &die_offsets) + { + Pair kv_pair; + size_t old_size = die_offsets.size(); + if (Find (name, kv_pair)) + { + die_offsets.swap(kv_pair.value); + return die_offsets.size() - old_size; + } + return 0; + } + protected: const lldb_private::DataExtractor &m_data; const lldb_private::DataExtractor &m_string_table; 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=141428&r1=141427&r2=141428&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Oct 7 17:23:45 2011 @@ -43,6 +43,7 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ObjCLanguageRuntime.h" +#include "lldb/Target/CPPLanguageRuntime.h" #include "DWARFCompileUnit.h" #include "DWARFDebugAbbrev.h" @@ -1655,14 +1656,19 @@ { sc.Clear(); // Check if the symbol vendor already knows about this compile unit? - sc.module_sp = m_obj_file->GetModule(); sc.comp_unit = GetCompUnitForDWARFCompUnit(curr_cu, UINT32_MAX); sc.function = sc.comp_unit->FindFunctionByUID (func_die->GetOffset()).get(); if (sc.function == NULL) sc.function = ParseCompileUnitFunction(sc, curr_cu, func_die); - - return sc.function != NULL; + + if (sc.function) + { + sc.module_sp = sc.function->CalculateSymbolContextModule(); + return true; + } + + return false; } uint32_t @@ -1969,11 +1975,13 @@ if (m_apple_names_ap.get()) { const char *name_cstr = name.GetCString(); - DWARFMappedHash::MemoryTable::Pair kv_pair; - if (m_apple_names_ap->Find (name_cstr, kv_pair)) - { - die_offsets.swap(kv_pair.value); - } + const char *base_name_start; + const char *base_name_end = NULL; + + if (!CPPLanguageRuntime::StripNamespacesFromVariableName(name_cstr, base_name_start, base_name_end)) + base_name_start = name_cstr; + + m_apple_names_ap->FindByName (base_name_start, die_offsets); } else { @@ -2080,96 +2088,76 @@ return variables.GetSize() - original_size; } - -uint32_t -SymbolFileDWARF::ResolveFunctions (const DIEArray &die_offsets, - SymbolContextList& sc_list, - const ConstString &name, - uint32_t name_type_mask) +bool +SymbolFileDWARF::ResolveFunction (dw_offset_t die_offset, + DWARFCompileUnit *&dwarf_cu, + SymbolContextList& sc_list) { + SymbolContext sc; + DWARFDebugInfo* info = DebugInfo(); + bool resolved_it = false; + if (info == NULL) - return 0; + return resolved_it; + + DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); - const uint32_t sc_list_initial_size = sc_list.GetSize(); - SymbolContext sc; - sc.module_sp = m_obj_file->GetModule(); - assert (sc.module_sp); + // If we were passed a die that is not a function, just return false... + if (die->Tag() != DW_TAG_subprogram && die->Tag() != DW_TAG_inlined_subroutine) + return false; - DWARFCompileUnit* dwarf_cu = NULL; - const size_t num_matches = die_offsets.size(); - for (size_t i=0; iTag() == DW_TAG_inlined_subroutine) { - const dw_offset_t die_offset = die_offsets[i]; - const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); + inlined_die = die; - // If we aren't doing full names, - if ((name_type_mask & eFunctionNameTypeFull) == 0) + while ((die = die->GetParent()) != NULL) { - const char *name_cstr = name.GetCString(); - if (ObjCLanguageRuntime::IsPossibleObjCMethodName(name_cstr)) - continue; + if (die->Tag() == DW_TAG_subprogram) + break; } - - - const DWARFDebugInfoEntry* inlined_die = NULL; - if (die->Tag() == DW_TAG_inlined_subroutine) + } + assert (die->Tag() == DW_TAG_subprogram); + if (GetFunction (dwarf_cu, die, sc)) + { + Address addr; + // Parse all blocks if needed + if (inlined_die) { - // We only are looking for selectors, which disallows anything inlined - if (name_type_mask == eFunctionNameTypeSelector) - continue; - - inlined_die = die; - - while ((die = die->GetParent()) != NULL) - { - if (die->Tag() == DW_TAG_subprogram) - break; - } + sc.block = sc.function->GetBlock (true).FindBlockByID (inlined_die->GetOffset()); + assert (sc.block != NULL); + if (sc.block->GetStartAddress (addr) == false) + addr.Clear(); } - if (die->Tag() == DW_TAG_subprogram) + else + { + sc.block = NULL; + addr = sc.function->GetAddressRange().GetBaseAddress(); + } + + if (addr.IsValid()) { - if (GetFunction (dwarf_cu, die, sc)) + + // We found the function, so we should find the line table + // and line table entry as well + LineTable *line_table = sc.comp_unit->GetLineTable(); + if (line_table == NULL) { - Address addr; - // Parse all blocks if needed - if (inlined_die) - { - sc.block = sc.function->GetBlock (true).FindBlockByID (inlined_die->GetOffset()); - assert (sc.block != NULL); - if (sc.block->GetStartAddress (addr) == false) - addr.Clear(); - } - else - { - sc.block = NULL; - addr = sc.function->GetAddressRange().GetBaseAddress(); - } - - if (addr.IsValid()) - { - - // We found the function, so we should find the line table - // and line table entry as well - LineTable *line_table = sc.comp_unit->GetLineTable(); - if (line_table == NULL) - { - if (ParseCompileUnitLineTable(sc)) - line_table = sc.comp_unit->GetLineTable(); - } - if (line_table != NULL) - line_table->FindLineEntryByAddress (addr, sc.line_entry); - - sc_list.Append(sc); - } + if (ParseCompileUnitLineTable(sc)) + line_table = sc.comp_unit->GetLineTable(); } + if (line_table != NULL) + line_table->FindLineEntryByAddress (addr, sc.line_entry); + + sc_list.Append(sc); + resolved_it = true; } } - return sc_list.GetSize() - sc_list_initial_size; + + return resolved_it; } - - void SymbolFileDWARF::FindFunctions (const ConstString &name, const NameToDIE &name_to_die, @@ -2216,66 +2204,79 @@ if (num_matches) { SymbolContext sc; - sc.module_sp = m_obj_file->GetModule(); DWARFCompileUnit* dwarf_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; - DWARFDebugInfo* debug_info = DebugInfo(); for (size_t i=0; iGetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu); - const DWARFDebugInfoEntry* inlined_die = NULL; - if (die->Tag() == DW_TAG_inlined_subroutine) - { - inlined_die = die; + ResolveFunction (die_offset, dwarf_cu, sc_list); + } + } +} + +bool +SymbolFileDWARF::FunctionDieMatchesPartialName (const DWARFDebugInfoEntry* die, + const DWARFCompileUnit *dwarf_cu, + uint32_t name_type_mask, + const char *partial_name, + const char *base_name_start, + const char *base_name_end) +{ + // If we are looking only for methods, throw away all the ones that aren't in C++ classes: + if (name_type_mask == eFunctionNameTypeMethod + || name_type_mask == eFunctionNameTypeBase) + { + clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIEOffset(die->GetOffset()); + if (!containing_decl_ctx) + return false; - while ((die = die->GetParent()) != NULL) - { - if (die->Tag() == DW_TAG_subprogram) - break; - } - } - assert (die->Tag() == DW_TAG_subprogram); - if (GetFunction (dwarf_cu, die, sc)) + bool is_cxx_method = (containing_decl_ctx->getDeclKind() == clang::Decl::CXXRecord); + + if (!is_cxx_method && name_type_mask == eFunctionNameTypeMethod) + return false; + if (is_cxx_method && name_type_mask == eFunctionNameTypeBase) + return false; + } + + // Now we need to check whether the name we got back for this type matches the extra specifications + // that were in the name we're looking up: + if (base_name_start != partial_name || *base_name_end != '\0') + { + // First see if the stuff to the left matches the full name. To do that let's see if + // we can pull out the mips linkage name attribute: + + Mangled best_name; + + DWARFDebugInfoEntry::Attributes attributes; + die->GetAttributes(this, dwarf_cu, NULL, attributes); + uint32_t idx = attributes.FindAttributeIndex(DW_AT_MIPS_linkage_name); + if (idx != UINT32_MAX) + { + DWARFFormValue form_value; + if (attributes.ExtractFormValueAtIndex(this, idx, form_value)) { - Address addr; - // Parse all blocks if needed - if (inlined_die) - { - sc.block = sc.function->GetBlock (true).FindBlockByID (inlined_die->GetOffset()); - assert (sc.block != NULL); - if (sc.block->GetStartAddress (addr) == false) - addr.Clear(); - } - else - { - sc.block = NULL; - addr = sc.function->GetAddressRange().GetBaseAddress(); - } - - if (addr.IsValid()) + const char *name = form_value.AsCString(&get_debug_str_data()); + best_name.SetValue (name, true); + } + } + if (best_name) + { + const char *demangled = best_name.GetDemangledName().GetCString(); + if (demangled) + { + std::string name_no_parens(partial_name, base_name_end - partial_name); + if (strstr (demangled, name_no_parens.c_str()) == NULL) { - - // We found the function, so we should find the line table - // and line table entry as well - LineTable *line_table = sc.comp_unit->GetLineTable(); - if (line_table == NULL) - { - if (ParseCompileUnitLineTable(sc)) - line_table = sc.comp_unit->GetLineTable(); - } - if (line_table != NULL) - line_table->FindLineEntryByAddress (addr, sc.line_entry); - - sc_list.Append(sc); + printf ("name: \"%s\" didn't match full name: \"%s\".\n", partial_name, demangled); + return false; } } } } + + return true; } - uint32_t SymbolFileDWARF::FindFunctions (const ConstString &name, uint32_t name_type_mask, @@ -2299,18 +2300,134 @@ // If we aren't appending the results to this list, then clear the list if (!append) sc_list.Clear(); + + // If name is empty then we won't find anything. + if (name.IsEmpty()) + return 0; // Remember how many sc_list are in the list before we search in case // we are appending the results to a variable list. const uint32_t original_size = sc_list.GetSize(); + const char *name_cstr = name.GetCString(); + uint32_t effective_name_type_mask = eFunctionNameTypeNone; + const char *base_name_start = name_cstr; + const char *base_name_end = name_cstr + strlen(name_cstr); + + if (name_type_mask & eFunctionNameTypeAuto) + { + if (CPPLanguageRuntime::IsCPPMangledName (name_cstr)) + effective_name_type_mask = eFunctionNameTypeFull; + else if (ObjCLanguageRuntime::IsPossibleObjCMethodName (name_cstr)) + effective_name_type_mask = eFunctionNameTypeFull; + else + { + if (ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr)) + effective_name_type_mask |= eFunctionNameTypeSelector; + + if (CPPLanguageRuntime::IsPossibleCPPCall(name_cstr, base_name_start, base_name_end)) + effective_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase); + } + } + else + { + effective_name_type_mask = name_type_mask; + if (effective_name_type_mask & eFunctionNameTypeMethod || name_type_mask & eFunctionNameTypeBase) + { + // If they've asked for a CPP method or function name and it can't be that, we don't + // even need to search for CPP methods or names. + if (!CPPLanguageRuntime::IsPossibleCPPCall(name_cstr, base_name_start, base_name_end)) + { + effective_name_type_mask &= ~(eFunctionNameTypeMethod | eFunctionNameTypeBase); + if (effective_name_type_mask == eFunctionNameTypeNone) + return 0; + } + } + + if (effective_name_type_mask & eFunctionNameTypeSelector) + { + if (!ObjCLanguageRuntime::IsPossibleObjCSelector(name_cstr)) + { + effective_name_type_mask &= ~(eFunctionNameTypeSelector); + if (effective_name_type_mask == eFunctionNameTypeNone) + return 0; + } + } + } + + DWARFDebugInfo* info = DebugInfo(); + if (info == NULL) + return 0; + if (m_apple_names_ap.get()) { - const char *name_cstr = name.GetCString(); - DWARFMappedHash::MemoryTable::Pair kv_pair; - if (m_apple_names_ap->Find (name_cstr, kv_pair)) - ResolveFunctions (kv_pair.value, sc_list, name, name_type_mask); + DIEArray die_offsets; + + uint32_t num_matches = 0; + + if (effective_name_type_mask & eFunctionNameTypeFull) + { + // If they asked for the full name, match what they typed. At some point we may + // want to canonicalize this (strip double spaces, etc. For now, we just add all the + // dies that we find by exact match. + DWARFCompileUnit *dwarf_cu = NULL; + num_matches = m_apple_names_ap->FindByName (name_cstr, die_offsets); + for (uint32_t i = 0; i < num_matches; i++) + ResolveFunction (die_offsets[i], dwarf_cu, sc_list); + } + else + { + DWARFCompileUnit* dwarf_cu = NULL; + + if (effective_name_type_mask & eFunctionNameTypeSelector) + { + num_matches = m_apple_names_ap->FindByName (name_cstr, die_offsets); + // Now make sure these are actually ObjC methods. In this case we can simply look up the name, + // and if it is an ObjC method name, we're good. + + for (uint32_t i = 0; i < num_matches; i++) + { + const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu); + assert (die); + + const char *die_name = die->GetName(this, dwarf_cu); + if (ObjCLanguageRuntime::IsPossibleObjCMethodName(die_name)) + ResolveFunction (die_offsets[i], dwarf_cu, sc_list); + } + die_offsets.clear(); + } + + if (effective_name_type_mask & eFunctionNameTypeMethod + || effective_name_type_mask & eFunctionNameTypeBase) + { + // The apple_names table stores just the "base name" of C++ methods in the table. So we have to + // extract the base name, look that up, and if there is any other information in the name we were + // passed in we have to post-filter based on that. + + // FIXME: Arrange the logic above so that we don't calculate the base name twice: + std::string base_name(base_name_start, base_name_end - base_name_start); + num_matches = m_apple_names_ap->FindByName (base_name.c_str(), die_offsets); + + for (uint32_t i = 0; i < num_matches; i++) + { + dw_offset_t offset = die_offsets[i]; + const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (offset, &dwarf_cu); + assert (die); + if (!FunctionDieMatchesPartialName(die, + dwarf_cu, + effective_name_type_mask, + name_cstr, + base_name_start, + base_name_end)) + continue; + + // If we get to here, the die is good, and we should add it: + ResolveFunction (offset, dwarf_cu, sc_list); + } + die_offsets.clear(); + } + } } else { @@ -2319,24 +2436,73 @@ if (!m_indexed) Index (); - if (name_type_mask & eFunctionNameTypeBase) - FindFunctions (name, m_function_basename_index, sc_list); - if (name_type_mask & eFunctionNameTypeFull) FindFunctions (name, m_function_fullname_index, sc_list); + std::string base_name(base_name_start, base_name_end - base_name_start); + ConstString base_name_const(base_name.c_str()); + DIEArray die_offsets; + DWARFCompileUnit *dwarf_cu = NULL; + + if (effective_name_type_mask & eFunctionNameTypeBase) + { + uint32_t num_base = m_function_basename_index.Find(base_name_const, die_offsets); + { + for (uint32_t i = 0; i < num_base; i++) + { + dw_offset_t offset = die_offsets[i]; + const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (offset, &dwarf_cu); + assert (die); + if (!FunctionDieMatchesPartialName(die, + dwarf_cu, + effective_name_type_mask, + name_cstr, + base_name_start, + base_name_end)) + continue; + + // If we get to here, the die is good, and we should add it: + ResolveFunction (offset, dwarf_cu, sc_list); + } + } + die_offsets.clear(); + } + if (name_type_mask & eFunctionNameTypeMethod) - FindFunctions (name, m_function_method_index, sc_list); + { + uint32_t num_base = m_function_method_index.Find(base_name_const, die_offsets); + { + for (uint32_t i = 0; i < num_base; i++) + { + dw_offset_t offset = die_offsets[i]; + const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (offset, &dwarf_cu); + assert (die); + if (!FunctionDieMatchesPartialName(die, + dwarf_cu, + effective_name_type_mask, + name_cstr, + base_name_start, + base_name_end)) + continue; + + // If we get to here, the die is good, and we should add it: + ResolveFunction (offset, dwarf_cu, sc_list); + } + } + die_offsets.clear(); + } if (name_type_mask & eFunctionNameTypeSelector) + { FindFunctions (name, m_function_selector_index, sc_list); + } + } // Return the number of variable that were appended to the list return sc_list.GetSize() - original_size; } - uint32_t SymbolFileDWARF::FindFunctions(const RegularExpression& regex, bool append, SymbolContextList& sc_list) { @@ -2363,13 +2529,13 @@ // we are appending the results to a variable list. uint32_t original_size = sc_list.GetSize(); - // Index the DWARF if we haven't already if (m_apple_names_ap.get()) { FindFunctions (regex, *m_apple_names_ap, sc_list); } else { + // Index the DWARF if we haven't already if (!m_indexed) Index (); @@ -2442,11 +2608,7 @@ if (m_apple_types_ap.get()) { const char *name_cstr = name.GetCString(); - DWARFMappedHash::MemoryTable::Pair kv_pair; - if (m_apple_types_ap->Find (name_cstr, kv_pair)) - { - die_offsets.swap(kv_pair.value); - } + m_apple_types_ap->FindByName (name_cstr, die_offsets); } else { @@ -2518,11 +2680,7 @@ if (m_apple_namespaces_ap.get()) { const char *name_cstr = name.GetCString(); - DWARFMappedHash::MemoryTable::Pair kv_pair; - if (m_apple_namespaces_ap->Find (name_cstr, kv_pair)) - { - die_offsets.swap(kv_pair.value); - } + m_apple_namespaces_ap->FindByName (name_cstr, die_offsets); } else { @@ -3192,11 +3350,7 @@ if (m_apple_types_ap.get()) { const char *name_cstr = type_name.GetCString(); - DWARFMappedHash::MemoryTable::Pair kv_pair; - if (m_apple_types_ap->Find (name_cstr, kv_pair)) - { - die_offsets.swap(kv_pair.value); - } + m_apple_types_ap->FindByName (name_cstr, die_offsets); } else { 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=141428&r1=141427&r2=141428&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Oct 7 17:23:45 2011 @@ -322,11 +322,19 @@ uint32_t& byte_stride, uint32_t& bit_stride); - uint32_t ResolveFunctions ( - const DIEArray &die_offsets, - lldb_private::SymbolContextList& sc_list, - const lldb_private::ConstString &name, - uint32_t name_type_mask); + // Given a die_offset, figure out the symbol context representing that die. + bool ResolveFunction ( + dw_offset_t offset, + DWARFCompileUnit *&dwarf_cu, + lldb_private::SymbolContextList& sc_list); + + bool FunctionDieMatchesPartialName ( + const DWARFDebugInfoEntry* die, + const DWARFCompileUnit *dwarf_cu, + uint32_t name_type_mask, + const char *partial_name, + const char *base_name_start, + const char *base_name_end); void FindFunctions( const lldb_private::ConstString &name, Modified: lldb/trunk/source/Target/CPPLanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/CPPLanguageRuntime.cpp?rev=141428&r1=141427&r2=141428&view=diff ============================================================================== --- lldb/trunk/source/Target/CPPLanguageRuntime.cpp (original) +++ lldb/trunk/source/Target/CPPLanguageRuntime.cpp Fri Oct 7 17:23:45 2011 @@ -40,3 +40,81 @@ // C++ has no generic way to do this. return false; } + +bool +CPPLanguageRuntime::IsCPPMangledName (const char *name) +{ + // FIXME, we should really run through all the known C++ Language plugins and ask each one if + // this is a C++ mangled name, but we can put that off till there is actually more than one + // we care about. + + if (name && name[0] == '_' && name[1] == 'Z') + return true; + else + return false; +} + +bool +CPPLanguageRuntime::StripNamespacesFromVariableName (const char *name, const char *&base_name_start, const char *&base_name_end) +{ + if (base_name_end == NULL) + base_name_end = name + strlen (name); + + const char *last_colon = NULL; + for (const char *ptr = base_name_end; ptr != name; ptr--) + { + if (*ptr == ':') + { + last_colon = ptr; + break; + } + } + + if (last_colon == NULL) + { + base_name_start = name; + return true; + } + + // Can't have a C++ name that begins with a single ':', nor contains an internal single ':' + if (last_colon == name) + return false; + else if (last_colon[-1] != ':') + return false; + else + { + // FIXME: should check if there is + base_name_start = last_colon + 1; + return true; + } +} +bool +CPPLanguageRuntime::IsPossibleCPPCall (const char *name, const char *&base_name_start, const char *&base_name_end) +{ + if (!name) + return false; + // For now, I really can't handle taking template names apart, so if you + // have < or > I'll say "could be CPP but leave the base_name empty which + // means I couldn't figure out what to use for that. + // FIXME: Do I need to do more sanity checking here? + + if (strchr(name, '>') != NULL || strchr (name, '>') != NULL) + return true; + + size_t name_len = strlen (name); + + if (name[name_len - 1] == ')') + { + // We've got arguments. + base_name_end = strchr (name, '('); + if (base_name_end == NULL) + return false; + + // FIXME: should check that this parenthesis isn't a template specialized + // on a function type or something gross like that... + } + else + base_name_end = name + strlen (name); + + return StripNamespacesFromVariableName (name, base_name_start, base_name_end); +} Modified: lldb/trunk/test/python_api/target/TestTargetAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/TestTargetAPI.py?rev=141428&r1=141427&r2=141428&view=diff ============================================================================== --- lldb/trunk/test/python_api/target/TestTargetAPI.py (original) +++ lldb/trunk/test/python_api/target/TestTargetAPI.py Fri Oct 7 17:23:45 2011 @@ -120,6 +120,9 @@ # Now launch the process, and do not stop at entry point. process = target.LaunchSimple(None, None, os.getcwd()) self.assertTrue(process, PROCESS_IS_VALID) + # Make sure we hit our breakpoint: + thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint) + self.assertTrue (len(thread_list) == 1) value_list = target.FindGlobalVariables('my_global_var_of_char_type', 3) self.assertTrue(value_list.GetSize() == 1) From jingham at apple.com Fri Oct 7 17:27:25 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 07 Oct 2011 22:27:25 -0000 Subject: [Lldb-commits] [lldb] r141429 - /lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i Message-ID: <20111007222725.4B6612A6C12D@llvm.org> Author: jingham Date: Fri Oct 7 17:27:25 2011 New Revision: 141429 URL: http://llvm.org/viewvc/llvm-project?rev=141429&view=rev Log: Mention SBBreakpointLocation::GetAddress in the Python .i file. Modified: lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i Modified: lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i?rev=141429&r1=141428&r2=141429&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i (original) +++ lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i Fri Oct 7 17:27:25 2011 @@ -32,6 +32,9 @@ bool IsValid() const; + lldb::SBAddress + GetAddress(); + lldb::addr_t GetLoadAddress (); From jingham at apple.com Fri Oct 7 17:28:30 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 07 Oct 2011 22:28:30 -0000 Subject: [Lldb-commits] [lldb] r141430 - in /lldb/trunk/include/lldb/Core: Module.h ModuleList.h Message-ID: <20111007222830.0F0732A6C12D@llvm.org> Author: jingham Date: Fri Oct 7 17:28:29 2011 New Revision: 141430 URL: http://llvm.org/viewvc/llvm-project?rev=141430&view=rev Log: Clean up some documentation. Modified: lldb/trunk/include/lldb/Core/Module.h lldb/trunk/include/lldb/Core/ModuleList.h Modified: lldb/trunk/include/lldb/Core/Module.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=141430&r1=141429&r2=141430&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Module.h (original) +++ lldb/trunk/include/lldb/Core/Module.h Fri Oct 7 17:28:29 2011 @@ -199,6 +199,11 @@ //------------------------------------------------------------------ /// Find functions by name. /// + /// If the function is an inlined function, it will have a block, + /// representing the inlined function, and the function will be the + /// containing function. If it is not inlined, then the block will + /// be NULL. + /// /// @param[in] name /// The name of the compile unit we are looking for. /// @@ -229,6 +234,11 @@ //------------------------------------------------------------------ /// Find functions by name. /// + /// If the function is an inlined function, it will have a block, + /// representing the inlined function, and the function will be the + /// containing function. If it is not inlined, then the block will + /// be NULL. + /// /// @param[in] regex /// A regular expression to use when matching the name. /// Modified: lldb/trunk/include/lldb/Core/ModuleList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=141430&r1=141429&r2=141430&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ModuleList.h (original) +++ lldb/trunk/include/lldb/Core/ModuleList.h Fri Oct 7 17:28:29 2011 @@ -166,26 +166,7 @@ SymbolContextList &sc_list); //------------------------------------------------------------------ - /// Find functions by name. - /// - /// Finds all functions that match \a name in all of the modules and - /// returns the results in \a sc_list. - /// - /// @param[in] name - /// The name of the function we are looking for. - /// - /// @param[in] name_type_mask - /// A bit mask of bits that indicate what kind of names should - /// be used when doing the lookup. Bits include fully qualified - /// names, base names, C++ methods, or ObjC selectors. - /// See FunctionNameType for more details. - /// - /// @param[out] sc_list - /// A symbol context list that gets filled in with all of the - /// matches. - /// - /// @return - /// The number of matches added to \a sc_list. + /// @see Module::FindFunctions () //------------------------------------------------------------------ uint32_t FindFunctions (const ConstString &name, From jingham at apple.com Fri Oct 7 17:28:49 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 07 Oct 2011 22:28:49 -0000 Subject: [Lldb-commits] [lldb] r141431 - /lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h Message-ID: <20111007222849.B7B522A6C12D@llvm.org> Author: jingham Date: Fri Oct 7 17:28:49 2011 New Revision: 141431 URL: http://llvm.org/viewvc/llvm-project?rev=141431&view=rev Log: Remove some commented out code. Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h?rev=141431&r1=141430&r2=141431&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h Fri Oct 7 17:28:49 2011 @@ -61,11 +61,6 @@ bool m_first_run_event; // We want to broadcast only one running event, our first. private: - - // friend ThreadPlan * - // Thread::QueueThreadPlanForStepRange (bool abort_other_plans, StepType type, const AddressRange &range, SymbolContext *addr_context, bool stop_others); - - DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepRange); }; From johnny.chen at apple.com Fri Oct 7 18:54:04 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 07 Oct 2011 23:54:04 -0000 Subject: [Lldb-commits] [lldb] r141443 - /lldb/trunk/test/python_api/default-constructor/sb_breakpointlocation.py Message-ID: <20111007235404.A53E92A6C12D@llvm.org> Author: johnny Date: Fri Oct 7 18:54:04 2011 New Revision: 141443 URL: http://llvm.org/viewvc/llvm-project?rev=141443&view=rev Log: Add fuzz call for SBBreakpointLocation.GetAddress(). Modified: lldb/trunk/test/python_api/default-constructor/sb_breakpointlocation.py Modified: lldb/trunk/test/python_api/default-constructor/sb_breakpointlocation.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_breakpointlocation.py?rev=141443&r1=141442&r2=141443&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_breakpointlocation.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_breakpointlocation.py Fri Oct 7 18:54:04 2011 @@ -6,6 +6,7 @@ import lldb def fuzz_obj(obj): + obj.GetAddress() obj.GetLoadAddress() obj.SetEnabled(True) obj.IsEnabled() From scallanan at apple.com Fri Oct 7 19:21:35 2011 From: scallanan at apple.com (Sean Callanan) Date: Sat, 08 Oct 2011 00:21:35 -0000 Subject: [Lldb-commits] [lldb] r141452 - in /lldb/trunk: include/lldb/Expression/ClangUserExpression.h include/lldb/lldb-forward.h source/Expression/ClangUserExpression.cpp Message-ID: <20111008002135.9353C3128018@llvm.org> Author: spyffe Date: Fri Oct 7 19:21:35 2011 New Revision: 141452 URL: http://llvm.org/viewvc/llvm-project?rev=141452&view=rev Log: Fixed a memory leak of ASTResultSynthesizers, by attaching them to the ClangExpressionParser. Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=141452&r1=141451&r2=141452&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Fri Oct 7 19:21:35 2011 @@ -325,6 +325,8 @@ std::auto_ptr m_local_variables; ///< The local expression variables, if the expression is DWARF. std::auto_ptr m_data_allocator; ///< The allocator that the parser uses to place strings for use by JIT-compiled code. + std::auto_ptr m_result_synthesizer; ///< The result synthesizer, if one is needed. + bool m_cplusplus; ///< True if the expression is compiled as a C++ member function (true if it was parsed when exe_ctx was in a C++ method). bool m_objectivec; ///< True if the expression is compiled as an Objective-C method (true if it was parsed when exe_ctx was in an Objective-C method). bool m_needs_object_ptr; ///< True if "this" or "self" must be looked up and passed in. False if the expression doesn't really use them and they can be NULL. Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=141452&r1=141451&r2=141452&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Fri Oct 7 19:21:35 2011 @@ -24,6 +24,7 @@ class AddressResolver; class ArchSpec; class Args; +class ASTResultSynthesizer; class Baton; class Block; class Breakpoint; Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=141452&r1=141451&r2=141452&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Fri Oct 7 19:21:35 2011 @@ -72,10 +72,13 @@ if (!clang_ast_context) return NULL; - return new ASTResultSynthesizer(passthrough, - m_desired_type, - *m_target->GetScratchClangASTContext()->getASTContext(), - m_target->GetPersistentVariables()); + if (!m_result_synthesizer.get()) + m_result_synthesizer.reset(new ASTResultSynthesizer(passthrough, + m_desired_type, + *m_target->GetScratchClangASTContext()->getASTContext(), + m_target->GetPersistentVariables())); + + return m_result_synthesizer.get(); } void From gclayton at apple.com Fri Oct 7 19:49:16 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 08 Oct 2011 00:49:16 -0000 Subject: [Lldb-commits] [lldb] r141460 - in /lldb/trunk: include/lldb/Core/ include/lldb/Symbol/ source/API/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ Message-ID: <20111008004916.338F83128018@llvm.org> Author: gclayton Date: Fri Oct 7 19:49:15 2011 New Revision: 141460 URL: http://llvm.org/viewvc/llvm-project?rev=141460&view=rev Log: Added more functionality to Range template classes in RangeMap.h and converted remaining DWARF areas that were using ranges over to this class. Also converted lldb_private::Block to use it. Modified: lldb/trunk/include/lldb/Core/RangeMap.h lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/source/API/SBBlock.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/include/lldb/Core/RangeMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RangeMap.h (original) +++ lldb/trunk/include/lldb/Core/RangeMap.h Fri Oct 7 19:49:15 2011 @@ -46,6 +46,13 @@ { } + void + Clear (BaseType b = 0) + { + base = b; + size = 0; + } + // Set the start value for the range, and keep the same size BaseType GetRangeBase () const @@ -59,6 +66,12 @@ base = b; } + void + Slide (BaseType slide) + { + base += slide; + } + BaseType GetRangeEnd () const { @@ -111,7 +124,18 @@ } bool - operator < (const Range &rhs) + Overlap (const Range &rhs) const + { + const BaseType lhs_base = this->GetRangeBase(); + const BaseType rhs_base = rhs.GetRangeBase(); + const BaseType lhs_end = this->GetRangeEnd(); + const BaseType rhs_end = rhs.GetRangeEnd(); + bool result = (lhs_base <= rhs_end) && (lhs_end >= rhs_base); + return result; + } + + bool + operator < (const Range &rhs) const { if (base == rhs.base) return size < rhs.size; @@ -119,13 +143,13 @@ } bool - operator == (const Range &rhs) + operator == (const Range &rhs) const { return base == rhs.base && size == rhs.size; } bool - operator != (const Range &rhs) + operator != (const Range &rhs) const { return base != rhs.base || size != rhs.size; } @@ -139,9 +163,13 @@ template class RangeArray { + public: + typedef B BaseType; + typedef S SizeType; typedef Range Entry; - RangeArray () + RangeArray () : + m_entries () { } @@ -163,41 +191,75 @@ } void - CombineConsecutiveEntriesWithEqualData () + CombineConsecutiveRanges () { - typename std::vector::iterator pos; - typename std::vector::iterator end; - typename std::vector::iterator prev; - bool can_combine = false; - // First we determine if we can combine any of the Entry objects so we - // don't end up allocating and making a new collection for no reason - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + // Can't combine if ranges if we have zero or one range + if (m_entries.size() > 1) { - if (prev != end && prev->data == pos->data) + // The list should be sorted prior to calling this function + typename std::vector::iterator pos; + typename std::vector::iterator end; + typename std::vector::iterator prev; + bool can_combine = false; + // First we determine if we can combine any of the Entry objects so we + // don't end up allocating and making a new collection for no reason + for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) { - can_combine = true; - break; + if (prev != end && prev->Overlap(*pos)) + { + can_combine = true; + break; + } } - } - - // We we can combine at least one entry, then we make a new collection - // and populate it accordingly, and then swap it into place. - if (can_combine) - { - std::vector minimal_ranges; - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + + // We we can combine at least one entry, then we make a new collection + // and populate it accordingly, and then swap it into place. + if (can_combine) { - if (prev != end && prev->data == pos->data) - minimal_ranges.back().range.SetEnd (pos->range.GetRangeEnd()); - else - minimal_ranges.push_back (*pos); + std::vector minimal_ranges; + for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + { + if (prev != end && prev->Overlap(*pos)) + minimal_ranges.back().SetRangeEnd (std::max(prev->GetRangeEnd(), pos->GetRangeEnd())); + else + minimal_ranges.push_back (*pos); + } + // Use the swap technique in case our new vector is much smaller. + // We must swap when using the STL because std::vector objects never + // release or reduce the memory once it has been allocated/reserved. + m_entries.swap (minimal_ranges); } - // Use the swap technique in case our new vector is much smaller. - // We must swap when using the STL because std::vector objects never - // release or reduce the memory once it has been allocated/reserved. - m_entries.swap (minimal_ranges); } } + + + BaseType + GetMinRangeBase (BaseType fail_value) const + { + if (m_entries.empty()) + return fail_value; + // m_entries must be sorted, so if we aren't empty, we grab the + // first range's base + return m_entries.front().GetRangeBase(); + } + + BaseType + GetMaxRangeEnd (BaseType fail_value) const + { + if (m_entries.empty()) + return fail_value; + // m_entries must be sorted, so if we aren't empty, we grab the + // last range's end + return m_entries.back().GetRangeEnd(); + } + + void + Slide (BaseType slide) + { + typename std::vector::iterator pos, end; + for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos) + pos->Slide (slide); + } void Clear () @@ -212,25 +274,56 @@ } size_t - GetNumEntries () const + GetSize () const { return m_entries.size(); } const Entry * - GetEntryAtIndex (uint32_t i) const + GetEntryAtIndex (size_t i) const { if (i::const_iterator begin = m_entries.begin(); + typename std::vector::const_iterator end = m_entries.end(); + typename std::vector::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + + if (pos != end && pos->Contains(addr)) + { + return std::distance (begin, pos); + } + else if (pos != begin) + { + --pos; + if (pos->Contains(addr)) + return std::distance (begin, pos); + } + } + return UINT32_MAX; + } + const Entry * FindEntryThatContains (B addr) const { @@ -256,7 +349,32 @@ } return NULL; } - + + const Entry * + FindEntryThatContains (const Entry &range) const + { + if ( !m_entries.empty() ) + { + typename std::vector::const_iterator begin = m_entries.begin(); + typename std::vector::const_iterator end = m_entries.end(); + typename std::vector::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); + + if (pos != end && pos->Contains(range)) + { + return &(*pos); + } + else if (pos != begin) + { + --pos; + if (pos->Contains(range)) + { + return &(*pos); + } + } + } + return NULL; + } + protected: std::vector m_entries; }; @@ -392,25 +510,56 @@ } size_t - GetNumEntries () const + GetSize () const { return m_entries.size(); } const Entry * - GetEntryAtIndex (uint32_t i) const + GetEntryAtIndex (size_t i) const { if (i::const_iterator begin = m_entries.begin(); + typename std::vector::const_iterator end = m_entries.end(); + typename std::vector::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + + if (pos != end && pos->Contains(addr)) + { + return std::distance (begin, pos); + } + else if (pos != begin) + { + --pos; + if (pos->Contains(addr)) + return std::distance (begin, pos); + } + } + return UINT32_MAX; + } + const Entry * FindEntryThatContains (B addr) const { @@ -439,6 +588,32 @@ return NULL; } + const Entry * + FindEntryThatContains (const Entry &range) const + { + if ( !m_entries.empty() ) + { + typename std::vector::const_iterator begin = m_entries.begin(); + typename std::vector::const_iterator end = m_entries.end(); + typename std::vector::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); + + if (pos != end && pos->Contains(range)) + { + return &(*pos); + } + else if (pos != begin) + { + --pos; + if (pos->Contains(range)) + { + return &(*pos); + } + } + } + return NULL; + } + + protected: std::vector m_entries; }; Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Fri Oct 7 19:49:15 2011 @@ -12,9 +12,9 @@ #include "lldb/lldb-private.h" #include "lldb/Core/AddressRange.h" +#include "lldb/Core/RangeMap.h" #include "lldb/Core/Stream.h" #include "lldb/Core/UserID.h" -#include "lldb/Core/VMRange.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/SymbolContext.h" @@ -43,6 +43,8 @@ public SymbolContextScope { public: + typedef RangeArray RangeArray; + typedef RangeArray::Entry Range; //------------------------------------------------------------------ /// Construct with a User ID \a uid, \a depth. @@ -97,7 +99,10 @@ /// describes the end address of a range for this block. //------------------------------------------------------------------ void - AddRange (const VMRange& range); + AddRange (const Range& range); + + void + FinalizeRanges (); //------------------------------------------------------------------ /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) @@ -143,7 +148,7 @@ /// block's ranges, \b false otherwise. //------------------------------------------------------------------ bool - Contains (const VMRange& range) const; + Contains (const Range& range) const; //------------------------------------------------------------------ /// Check if this object contains "block" as a child block at any @@ -421,14 +426,17 @@ uint32_t GetNumRanges () const { - return m_ranges.size(); + return m_ranges.GetSize(); } bool - GetRangeContainingOffset (const lldb::addr_t offset, VMRange &range); + GetRangeContainingOffset (const lldb::addr_t offset, Range &range); bool - GetRangeContainingAddress (const Address& addr, AddressRange &range, uint32_t *range_idx_ptr = NULL); + GetRangeContainingAddress (const Address& addr, AddressRange &range); + + uint32_t + GetRangeIndexContainingAddress (const Address& addr); //------------------------------------------------------------------ // Since blocks might have multiple discontiguous addresss ranges, @@ -451,7 +459,7 @@ //------------------------------------------------------------------ SymbolContextScope *m_parent_scope; collection m_children; - VMRange::collection m_ranges; ///< A list of address offset ranges relative to the function's section/offset address. + RangeArray m_ranges; lldb::InlineFunctionInfoSP m_inlineInfoSP; ///< Inlined function information. lldb::VariableListSP m_variable_list_sp; ///< The variable list for all local, static and paramter variables scoped to this block. bool m_parsed_block_info:1, ///< Set to true if this block and it's children have all been parsed Modified: lldb/trunk/source/API/SBBlock.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBlock.cpp?rev=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/source/API/SBBlock.cpp (original) +++ lldb/trunk/source/API/SBBlock.cpp Fri Oct 7 19:49:15 2011 @@ -237,12 +237,7 @@ { if (m_opaque_ptr && block_addr.IsValid()) { - uint32_t range_idx = UINT32_MAX; - AddressRange range; - if (m_opaque_ptr->GetRangeContainingAddress (block_addr.ref(), range, &range_idx)) - { - return range_idx; - } + return m_opaque_ptr->GetRangeIndexContainingAddress (block_addr.ref()); } return UINT32_MAX; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Fri Oct 7 19:49:15 2011 @@ -113,7 +113,7 @@ if (log == NULL) return; - const size_t num_entries = m_aranges.GetNumEntries(); + const size_t num_entries = m_aranges.GetSize(); for (size_t i=0; iPrintf ("DWARFDebugAranges::Sort(minimize = %u) with %zu entries", minimize, orig_arange_size); } @@ -152,7 +152,7 @@ { if (minimize) { - const size_t new_arange_size = m_aranges.GetNumEntries(); + const size_t new_arange_size = m_aranges.GetSize(); const size_t delta = orig_arange_size - new_arange_size; log->Printf ("DWARFDebugAranges::Sort() %zu entries after minimizing (%zu entries combined for %zu bytes saved)", new_arange_size, delta, delta * sizeof(Range)); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h?rev=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Fri Oct 7 19:49:15 2011 @@ -69,7 +69,7 @@ uint32_t GetNumRanges() const { - return m_aranges.GetNumEntries(); + return m_aranges.GetSize(); } dw_offset_t 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=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Fri Oct 7 19:49:15 2011 @@ -933,7 +933,7 @@ // All DW_AT_ranges are relative to the base address of the // compile unit. We add the compile unit base address to make // sure all the addresses are properly fixed up. - ranges.AddOffset(cu->GetBaseAddress()); + ranges.Slide(cu->GetBaseAddress()); } break; @@ -1024,26 +1024,25 @@ } } - size_t numRanges = ranges.Size(); - - if (numRanges == 0) + if (ranges.IsEmpty()) { if (lo_pc != DW_INVALID_ADDRESS) { - if (hi_pc != DW_INVALID_ADDRESS) - ranges.AddRange(lo_pc, hi_pc); + if (hi_pc != DW_INVALID_ADDRESS && hi_pc > lo_pc) + ranges.Append(DWARFDebugRanges::Range (lo_pc, hi_pc - lo_pc)); else - ranges.AddRange(lo_pc, lo_pc); + ranges.Append(DWARFDebugRanges::Range (lo_pc, 0)); } } if (set_frame_base_loclist_addr) { - assert (ranges.LowestAddress(0) >= cu->GetBaseAddress()); - frame_base->SetLocationListSlide(ranges.LowestAddress(0) - cu->GetBaseAddress()); + dw_addr_t lowest_range_pc = ranges.GetMinRangeBase(0); + assert (lowest_range_pc >= cu->GetBaseAddress()); + frame_base->SetLocationListSlide (lowest_range_pc - cu->GetBaseAddress()); } - if (ranges.Size() == 0 || (name == NULL) || (mangled == NULL)) + if (ranges.IsEmpty() || name == NULL || mangled == NULL) { std::vector::const_iterator pos; std::vector::const_iterator end = die_offsets.end(); @@ -1060,7 +1059,7 @@ } } } - return ranges.Size() > 0; + return !ranges.IsEmpty(); } //---------------------------------------------------------------------- @@ -2038,8 +2037,8 @@ // All DW_AT_ranges are relative to the base address of the // compile unit. We add the compile unit base address to make // sure all the addresses are properly fixed up. - ranges.AddOffset(cu->GetBaseAddress()); - if (ranges.Lookup(address)) + ranges.Slide (cu->GetBaseAddress()); + if (ranges.FindEntryThatContains(address)) { found_address = true; // puts("***MATCH***"); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp?rev=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp Fri Oct 7 19:49:15 2011 @@ -30,94 +30,62 @@ RangeList range_list; dw_offset_t offset = 0; dw_offset_t debug_ranges_offset = offset; - while (range_list.Extract(dwarf2Data, &offset)) + while (Extract(dwarf2Data, &offset, range_list)) { m_range_map[debug_ranges_offset] = range_list; debug_ranges_offset = offset; } } -bool -DWARFDebugRanges::RangeList::AddRange(dw_addr_t lo_addr, dw_addr_t hi_addr) -{ - if (lo_addr <= hi_addr) - { - Range range(lo_addr, hi_addr); - ranges.push_back(range); - return true; - } - return false; -} - -const DWARFDebugRanges::Range* -DWARFDebugRanges::RangeList::Lookup(dw_addr_t offset) const -{ - Range::const_iterator pos = ranges.begin(); - Range::const_iterator end_pos = ranges.end(); - for (pos = ranges.begin(); pos != end_pos; ++pos) - { - if (pos->begin_offset <= offset && offset < pos->end_offset) - { - return &(*pos); - } - } - return NULL; -} - -size_t -DWARFDebugRanges::RangeList::Size() const -{ - return ranges.size(); -} - -void -DWARFDebugRanges::RangeList::AddOffset(dw_addr_t offset) -{ - if (!ranges.empty()) - { - Range::iterator pos = ranges.begin(); - Range::iterator end_pos = ranges.end(); - for (pos = ranges.begin(); pos != end_pos; ++pos) - { - // assert for unsigned overflows - assert (~pos->begin_offset >= offset); - assert (~pos->end_offset >= offset); - pos->begin_offset += offset; - pos->end_offset += offset; - } - } -} - -void -DWARFDebugRanges::RangeList::SubtractOffset(dw_addr_t offset) -{ - if (!ranges.empty()) - { - Range::iterator pos = ranges.begin(); - Range::iterator end_pos = ranges.end(); - for (pos = ranges.begin(); pos != end_pos; ++pos) - { - assert (pos->begin_offset >= offset); - assert (pos->end_offset >= offset); - pos->begin_offset -= offset; - pos->end_offset -= offset; - } - } -} - - -const DWARFDebugRanges::Range* -DWARFDebugRanges::RangeList::RangeAtIndex(size_t i) const -{ - if (i < ranges.size()) - return &ranges[i]; - return NULL; -} +//void +//DWARFDebugRanges::RangeList::AddOffset(dw_addr_t offset) +//{ +// if (!ranges.empty()) +// { +// Range::iterator pos = ranges.begin(); +// Range::iterator end_pos = ranges.end(); +// for (pos = ranges.begin(); pos != end_pos; ++pos) +// { +// // assert for unsigned overflows +// assert (~pos->begin_offset >= offset); +// assert (~pos->end_offset >= offset); +// pos->begin_offset += offset; +// pos->end_offset += offset; +// } +// } +//} +// +//void +//DWARFDebugRanges::RangeList::SubtractOffset(dw_addr_t offset) +//{ +// if (!ranges.empty()) +// { +// Range::iterator pos = ranges.begin(); +// Range::iterator end_pos = ranges.end(); +// for (pos = ranges.begin(); pos != end_pos; ++pos) +// { +// assert (pos->begin_offset >= offset); +// assert (pos->end_offset >= offset); +// pos->begin_offset -= offset; +// pos->end_offset -= offset; +// } +// } +//} +// +// +//const DWARFDebugRanges::Range* +//DWARFDebugRanges::RangeList::RangeAtIndex(size_t i) const +//{ +// if (i < ranges.size()) +// return &ranges[i]; +// return NULL; +//} bool -DWARFDebugRanges::RangeList::Extract(SymbolFileDWARF* dwarf2Data, uint32_t* offset_ptr) +DWARFDebugRanges::Extract(SymbolFileDWARF* dwarf2Data, uint32_t* offset_ptr, RangeList &range_list) { - Clear(); + range_list.Clear(); + uint32_t range_offset = *offset_ptr; const DataExtractor& debug_ranges_data = dwarf2Data->get_debug_ranges_data(); uint32_t addr_size = debug_ranges_data.GetAddressByteSize(); @@ -154,65 +122,65 @@ } // Filter out empty ranges - if (begin != end) - ranges.push_back(Range(begin, end)); + if (begin < end) + range_list.Append(Range(begin, end - begin)); } // Make sure we consumed at least something return range_offset != *offset_ptr; } - -dw_addr_t -DWARFDebugRanges::RangeList::LowestAddress(const dw_addr_t cu_base_addr) const -{ - dw_addr_t addr = DW_INVALID_ADDRESS; - dw_addr_t curr_base_addr = cu_base_addr; - if (!ranges.empty()) - { - Range::const_iterator pos = ranges.begin(); - Range::const_iterator end_pos = ranges.end(); - for (pos = ranges.begin(); pos != end_pos; ++pos) - { - if (pos->begin_offset == DW_INVALID_ADDRESS) - curr_base_addr = pos->end_offset; - else if (curr_base_addr != DW_INVALID_ADDRESS) - { - dw_addr_t curr_addr = curr_base_addr + pos->begin_offset; - if (addr > curr_addr) - addr = curr_addr; - } - } - } - return addr; -} - -dw_addr_t -DWARFDebugRanges::RangeList::HighestAddress(const dw_addr_t cu_base_addr) const -{ - dw_addr_t addr = 0; - dw_addr_t curr_base_addr = cu_base_addr; - if (!ranges.empty()) - { - Range::const_iterator pos = ranges.begin(); - Range::const_iterator end_pos = ranges.end(); - for (pos = ranges.begin(); pos != end_pos; ++pos) - { - if (pos->begin_offset == DW_INVALID_ADDRESS) - curr_base_addr = pos->end_offset; - else if (curr_base_addr != DW_INVALID_ADDRESS) - { - dw_addr_t curr_addr = curr_base_addr + pos->end_offset; - if (addr < curr_addr) - addr = curr_addr; - } - } - } - if (addr != 0) - return addr; - return DW_INVALID_ADDRESS; -} - +// +//dw_addr_t +//DWARFDebugRanges::RangeList::LowestAddress(const dw_addr_t cu_base_addr) const +//{ +// dw_addr_t addr = DW_INVALID_ADDRESS; +// dw_addr_t curr_base_addr = cu_base_addr; +// if (!ranges.empty()) +// { +// Range::const_iterator pos = ranges.begin(); +// Range::const_iterator end_pos = ranges.end(); +// for (pos = ranges.begin(); pos != end_pos; ++pos) +// { +// if (pos->begin_offset == DW_INVALID_ADDRESS) +// curr_base_addr = pos->end_offset; +// else if (curr_base_addr != DW_INVALID_ADDRESS) +// { +// dw_addr_t curr_addr = curr_base_addr + pos->begin_offset; +// if (addr > curr_addr) +// addr = curr_addr; +// } +// } +// } +// return addr; +//} +// +//dw_addr_t +//DWARFDebugRanges::RangeList::HighestAddress(const dw_addr_t cu_base_addr) const +//{ +// dw_addr_t addr = 0; +// dw_addr_t curr_base_addr = cu_base_addr; +// if (!ranges.empty()) +// { +// Range::const_iterator pos = ranges.begin(); +// Range::const_iterator end_pos = ranges.end(); +// for (pos = ranges.begin(); pos != end_pos; ++pos) +// { +// if (pos->begin_offset == DW_INVALID_ADDRESS) +// curr_base_addr = pos->end_offset; +// else if (curr_base_addr != DW_INVALID_ADDRESS) +// { +// dw_addr_t curr_addr = curr_base_addr + pos->end_offset; +// if (addr < curr_addr) +// addr = curr_addr; +// } +// } +// } +// if (addr != 0) +// return addr; +// return DW_INVALID_ADDRESS; +//} +// void DWARFDebugRanges::Dump(Stream &s, const DataExtractor& debug_ranges_data, uint32_t* offset_ptr, dw_addr_t cu_base_addr) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h?rev=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h Fri Oct 7 19:49:15 2011 @@ -11,66 +11,17 @@ #define SymbolFileDWARF_DWARFDebugRanges_h_ #include "SymbolFileDWARF.h" + #include #include +#include "lldb/Core/RangeMap.h" class DWARFDebugRanges { public: - - //------------------------------------------------------------------ - // Address range - //------------------------------------------------------------------ - struct Range - { - Range(dw_addr_t begin = DW_INVALID_ADDRESS, dw_addr_t end = DW_INVALID_ADDRESS) : - begin_offset(begin), - end_offset(end) - { - } - - void Clear() - { - begin_offset = DW_INVALID_ADDRESS; - end_offset = DW_INVALID_ADDRESS; - } - - dw_addr_t begin_offset; - dw_addr_t end_offset; - - typedef std::vector collection; - typedef collection::iterator iterator; - typedef collection::const_iterator const_iterator; - - }; - - //------------------------------------------------------------------ - // Collection of ranges - //------------------------------------------------------------------ - struct RangeList - { - RangeList() : - ranges() - { - } - - bool Extract(SymbolFileDWARF* dwarf2Data, uint32_t* offset_ptr); - bool AddRange(dw_addr_t lo_addr, dw_addr_t hi_addr); - void Clear() - { - ranges.clear(); - } - - dw_addr_t LowestAddress(const dw_addr_t base_addr) const; - dw_addr_t HighestAddress(const dw_addr_t base_addr) const; - void AddOffset(dw_addr_t offset); - void SubtractOffset(dw_addr_t offset); - size_t Size() const; - const Range* RangeAtIndex(size_t i) const; - const Range* Lookup(dw_addr_t offset) const; - Range::collection ranges; - }; + typedef lldb_private::RangeArray RangeList; + typedef RangeList::Entry Range; DWARFDebugRanges(); ~DWARFDebugRanges(); @@ -79,6 +30,12 @@ bool FindRanges(dw_offset_t debug_ranges_offset, DWARFDebugRanges::RangeList& range_list) const; protected: + + bool + Extract (SymbolFileDWARF* dwarf2Data, + uint32_t* offset_ptr, + RangeList &range_list); + typedef std::map range_map; typedef range_map::iterator range_map_iterator; typedef range_map::const_iterator range_map_const_iterator; 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=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Oct 7 19:49:15 2011 @@ -650,20 +650,19 @@ } static void -AddRangesToBlock -( - Block& block, - DWARFDebugRanges::RangeList& ranges, - addr_t block_base_addr -) -{ - ranges.SubtractOffset (block_base_addr); - size_t range_idx = 0; - const DWARFDebugRanges::Range *debug_range; - for (range_idx = 0; (debug_range = ranges.RangeAtIndex(range_idx)) != NULL; range_idx++) - { - block.AddRange(VMRange (debug_range->begin_offset, debug_range->end_offset)); +AddRangesToBlock (Block& block, + DWARFDebugRanges::RangeList& ranges, + addr_t block_base_addr) +{ + const size_t num_ranges = ranges.GetSize(); + for (size_t i = 0; i= block_base_addr); + block.AddRange(Block::Range (range_base - block_base_addr, range.GetByteSize()));; } + block.FinalizeRanges (); } @@ -690,8 +689,8 @@ { // Union of all ranges in the function DIE (if the function is discontiguous) AddressRange func_range; - lldb::addr_t lowest_func_addr = func_ranges.LowestAddress(0); - lldb::addr_t highest_func_addr = func_ranges.HighestAddress(0); + lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase (0); + lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd (0); if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr) { func_range.GetBaseAddress().ResolveAddressUsingFileSections (lowest_func_addr, m_obj_file->GetSectionList()); @@ -1054,7 +1053,7 @@ if (tag == DW_TAG_subprogram) { assert (subprogram_low_pc == LLDB_INVALID_ADDRESS); - subprogram_low_pc = ranges.LowestAddress(0); + subprogram_low_pc = ranges.GetMinRangeBase(0); } else if (tag == DW_TAG_inlined_subroutine) { @@ -1068,7 +1067,7 @@ // function the offset will be for that function. if (subprogram_low_pc == LLDB_INVALID_ADDRESS) { - subprogram_low_pc = ranges.LowestAddress(0); + subprogram_low_pc = ranges.GetMinRangeBase(0); } } Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Fri Oct 7 19:49:15 2011 @@ -44,8 +44,8 @@ { *s << "id = " << ((const UserID&)*this); - size_t num_ranges = m_ranges.size(); - if (num_ranges) + size_t num_ranges = m_ranges.GetSize(); + if (num_ranges > 0) { addr_t base_addr = LLDB_INVALID_ADDRESS; @@ -55,9 +55,11 @@ base_addr = function->GetAddressRange().GetBaseAddress().GetFileAddress(); s->Printf(", range%s = ", num_ranges > 1 ? "s" : ""); - std::vector::const_iterator pos, end = m_ranges.end(); - for (pos = m_ranges.begin(); pos != end; ++pos) - pos->Dump(s, base_addr, 4); + for (size_t i=0; iAddressRange(base_addr + range.GetRangeBase(), base_addr + range.GetRangeEnd(), 4); + } } if (m_inlineInfoSP.get() != NULL) @@ -95,18 +97,19 @@ m_inlineInfoSP->Dump(s, show_fullpaths); } - if (!m_ranges.empty()) + if (!m_ranges.IsEmpty()) { *s << ", ranges ="; - std::vector::const_iterator pos; - std::vector::const_iterator end = m_ranges.end(); - for (pos = m_ranges.begin(); pos != end; ++pos) + + size_t num_ranges = m_ranges.GetSize(); + for (size_t i=0; iContains(*pos) == false) + const Range &range = m_ranges.GetEntryRef(i); + if (parent_block != NULL && parent_block->Contains(range) == false) *s << '!'; else *s << ' '; - pos->Dump(s, base_addr); + s->AddressRange(base_addr + range.GetRangeBase(), base_addr + range.GetRangeEnd(), 4); } } s->EOL(); @@ -197,18 +200,21 @@ void Block::DumpAddressRanges (Stream *s, lldb::addr_t base_addr) { - if (!m_ranges.empty()) + if (!m_ranges.IsEmpty()) { - std::vector::const_iterator pos, end = m_ranges.end(); - for (pos = m_ranges.begin(); pos != end; ++pos) - pos->Dump (s, base_addr); + size_t num_ranges = m_ranges.GetSize(); + for (size_t i=0; iAddressRange(base_addr + range.GetRangeBase(), base_addr + range.GetRangeEnd(), 4); + } } } bool Block::Contains (addr_t range_offset) const { - return VMRange::ContainsValue(m_ranges, range_offset); + return m_ranges.FindEntryThatContains(range_offset) != NULL; } bool @@ -230,9 +236,9 @@ } bool -Block::Contains (const VMRange& range) const +Block::Contains (const Range& range) const { - return VMRange::ContainsRange(m_ranges, range); + return m_ranges.FindEntryThatContains (range) != NULL; } Block * @@ -267,12 +273,12 @@ bool -Block::GetRangeContainingOffset (const addr_t offset, VMRange &range) +Block::GetRangeContainingOffset (const addr_t offset, Range &range) { - uint32_t range_idx = VMRange::FindRangeIndexThatContainsValue (m_ranges, offset); - if (range_idx < m_ranges.size()) + const Range *range_ptr = m_ranges.FindEntryThatContains (offset); + if (range_ptr) { - range = m_ranges[range_idx]; + range = *range_ptr; return true; } range.Clear(); @@ -281,7 +287,7 @@ bool -Block::GetRangeContainingAddress (const Address& addr, AddressRange &range, uint32_t *range_idx_ptr) +Block::GetRangeContainingAddress (const Address& addr, AddressRange &range) { Function *function = CalculateSymbolContextFunction(); if (function) @@ -295,36 +301,55 @@ { addr_t offset = addr_offset - func_offset; - uint32_t range_idx = VMRange::FindRangeIndexThatContainsValue (m_ranges, offset); - if (range_idx < m_ranges.size()) + const Range *range_ptr = m_ranges.FindEntryThatContains (offset); + + if (range_ptr) { range.GetBaseAddress() = func_range.GetBaseAddress(); - range.GetBaseAddress().SetOffset(func_offset + m_ranges[range_idx].GetBaseAddress()); - range.SetByteSize(m_ranges[range_idx].GetByteSize()); - if (range_idx_ptr) - *range_idx_ptr = range_idx; + range.GetBaseAddress().SetOffset(func_offset + range_ptr->GetRangeBase()); + range.SetByteSize(range_ptr->GetByteSize()); return true; } } } } - if (range_idx_ptr) - *range_idx_ptr = UINT32_MAX; range.Clear(); return false; } +uint32_t +Block::GetRangeIndexContainingAddress (const Address& addr) +{ + Function *function = CalculateSymbolContextFunction(); + if (function) + { + const AddressRange &func_range = function->GetAddressRange(); + if (addr.GetSection() == func_range.GetBaseAddress().GetSection()) + { + const addr_t addr_offset = addr.GetOffset(); + const addr_t func_offset = func_range.GetBaseAddress().GetOffset(); + if (addr_offset >= func_offset && addr_offset < func_offset + func_range.GetByteSize()) + { + addr_t offset = addr_offset - func_offset; + return m_ranges.FindEntryIndexThatContains (offset); + } + } + } + return UINT32_MAX; +} + bool Block::GetRangeAtIndex (uint32_t range_idx, AddressRange &range) { - if (range_idx < m_ranges.size()) + if (range_idx < m_ranges.GetSize()) { Function *function = CalculateSymbolContextFunction(); if (function) { + const Range &vm_range = m_ranges.GetEntryRef(range_idx); range.GetBaseAddress() = function->GetAddressRange().GetBaseAddress(); - range.GetBaseAddress().Slide(m_ranges[range_idx].GetBaseAddress ()); - range.SetByteSize (m_ranges[range_idx].GetByteSize()); + range.GetBaseAddress().Slide(vm_range.GetRangeBase ()); + range.SetByteSize (vm_range.GetByteSize()); return true; } } @@ -334,24 +359,31 @@ bool Block::GetStartAddress (Address &addr) { - if (m_ranges.empty()) + if (m_ranges.IsEmpty()) return false; Function *function = CalculateSymbolContextFunction(); if (function) { addr = function->GetAddressRange().GetBaseAddress(); - addr.Slide(m_ranges.front().GetBaseAddress ()); + addr.Slide(m_ranges.GetEntryRef(0).GetRangeBase ()); return true; } return false; } void -Block::AddRange (const VMRange& new_range) +Block::FinalizeRanges () +{ + m_ranges.Sort(); + m_ranges.CombineConsecutiveRanges (); +} + +void +Block::AddRange (const Range& range) { Block *parent_block = GetParent (); - if (parent_block && !parent_block->Contains(new_range)) + if (parent_block && !parent_block->Contains(range)) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYMBOLS)); if (log) @@ -359,8 +391,8 @@ Module *module = m_parent_scope->CalculateSymbolContextModule(); Function *function = m_parent_scope->CalculateSymbolContextFunction(); const addr_t function_file_addr = function->GetAddressRange().GetBaseAddress().GetFileAddress(); - const addr_t block_start_addr = function_file_addr + new_range.GetBaseAddress (); - const addr_t block_end_addr = function_file_addr + new_range.GetEndAddress (); + const addr_t block_start_addr = function_file_addr + range.GetRangeBase (); + const addr_t block_end_addr = function_file_addr + range.GetRangeEnd (); Type *func_type = function->GetType(); const Declaration &func_decl = func_type->GetDeclaration(); @@ -371,7 +403,7 @@ func_decl.GetFile().GetFilename().GetCString(), func_decl.GetLine(), GetID(), - (uint32_t)m_ranges.size(), + (uint32_t)m_ranges.GetSize(), block_start_addr, block_end_addr, parent_block->GetID(), @@ -383,7 +415,7 @@ { log->Printf ("warning: block {0x%8.8x} has range[%u] [0x%llx - 0x%llx) which is not contained in parent block {0x%8.8x} in function {0x%8.8x} from %s/%s", GetID(), - (uint32_t)m_ranges.size(), + (uint32_t)m_ranges.GetSize(), block_start_addr, block_end_addr, parent_block->GetID(), @@ -392,16 +424,16 @@ module->GetFileSpec().GetFilename().GetCString()); } } - parent_block->AddRange (new_range); + parent_block->AddRange (range); } - m_ranges.push_back(new_range); + m_ranges.Append(range); } // Return the current number of bytes that this object occupies in memory size_t Block::MemorySize() const { - size_t mem_size = sizeof(Block) + m_ranges.size() * sizeof(VMRange); + size_t mem_size = sizeof(Block) + m_ranges.GetSize() * sizeof(Range); if (m_inlineInfoSP.get()) mem_size += m_inlineInfoSP->MemorySize(); if (m_variable_list_sp.get()) Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Oct 7 19:49:15 2011 @@ -4106,6 +4106,7 @@ case clang::Type::Auto: break; case clang::Type::InjectedClassName: break; case clang::Type::DependentName: break; + case clang::Type::Atomic: break; } // No DeclContext in this type... return NULL; Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=141460&r1=141459&r2=141460&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Oct 7 19:49:15 2011 @@ -281,6 +281,7 @@ case clang::Type::TypeOf: break; case clang::Type::Decltype: break; case clang::Type::TemplateSpecialization: break; + case clang::Type::Atomic: break; } // We don't know hot to display this type... return lldb::eTypeClassOther; @@ -492,8 +493,10 @@ case clang::Type::TypeOfExpr: case clang::Type::TypeOf: case clang::Type::Decltype: -// case clang::Type::QualifiedName: - case clang::Type::TemplateSpecialization: break; + case clang::Type::TemplateSpecialization: + case clang::Type::Atomic: + break; + } count = 0; return lldb::eEncodingInvalid; @@ -607,8 +610,9 @@ case clang::Type::TypeOfExpr: case clang::Type::TypeOf: case clang::Type::Decltype: -// case clang::Type::QualifiedName: - case clang::Type::TemplateSpecialization: break; + case clang::Type::TemplateSpecialization: + case clang::Type::Atomic: + break; } // We don't know hot to display this type... return lldb::eFormatBytes; From jingham at apple.com Fri Oct 7 20:11:42 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 08 Oct 2011 01:11:42 -0000 Subject: [Lldb-commits] [lldb] r141468 - in /lldb/trunk: include/lldb/Symbol/SymbolContext.h source/Expression/ClangExpressionDeclMap.cpp source/Symbol/SymbolContext.cpp test/expression_command/formatters/TestFormatters.py Message-ID: <20111008011142.3A5D93128018@llvm.org> Author: jingham Date: Fri Oct 7 20:11:42 2011 New Revision: 141468 URL: http://llvm.org/viewvc/llvm-project?rev=141468&view=rev Log: Fix the last testsuite regression from the apple-names stuff. Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/test/expression_command/formatters/TestFormatters.py Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=141468&r1=141467&r2=141468&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Fri Oct 7 20:11:42 2011 @@ -229,8 +229,9 @@ /// The number of symbol contexts found. //------------------------------------------------------------------ size_t - FindFunctionsByName (const ConstString &name, - bool include_symbols, + FindFunctionsByName (const ConstString &name, + uint32_t name_type_mask, + bool include_symbols, bool append, SymbolContextList &sc_list) const; Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=141468&r1=141467&r2=141468&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Oct 7 20:11:42 2011 @@ -2182,7 +2182,8 @@ { const bool include_symbols = true; const bool append = false; - m_parser_vars->m_sym_ctx.FindFunctionsByName (name, + m_parser_vars->m_sym_ctx.FindFunctionsByName (name, + eFunctionNameTypeBase, include_symbols, append, sc_list); Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=141468&r1=141467&r2=141468&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Fri Oct 7 20:11:42 2011 @@ -463,12 +463,14 @@ size_t SymbolContext::FindFunctionsByName (const ConstString &name, + uint32_t name_type_mask, bool include_symbols, bool append, SymbolContextList &sc_list) const { if (!append) sc_list.Clear(); + uint32_t old_size = sc_list.GetSize(); if (function != NULL) { @@ -477,12 +479,27 @@ } if (module_sp) - module_sp->FindFunctions (name, eFunctionNameTypeBase | eFunctionNameTypeFull, include_symbols, true, sc_list); + module_sp->FindFunctions (name, name_type_mask, include_symbols, true, sc_list); if (target_sp) - target_sp->GetImages().FindFunctions (name, eFunctionNameTypeBase | eFunctionNameTypeFull, include_symbols, true, sc_list); - - return sc_list.GetSize(); + { + if (!module_sp) + { + target_sp->GetImages().FindFunctions (name, name_type_mask, include_symbols, true, sc_list); + } + else + { + ModuleList &modules = target_sp->GetImages(); + uint32_t num_modules = modules.GetSize(); + for (uint32_t i = 0; i < num_modules; i++) + { + ModuleSP iter_module_sp = modules.GetModuleAtIndex(i); + if (module_sp != iter_module_sp) + iter_module_sp->FindFunctions (name, name_type_mask, include_symbols, true, sc_list); + } + } + } + return sc_list.GetSize() - old_size; } //lldb::VariableSP Modified: lldb/trunk/test/expression_command/formatters/TestFormatters.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/formatters/TestFormatters.py?rev=141468&r1=141467&r2=141468&view=diff ============================================================================== --- lldb/trunk/test/expression_command/formatters/TestFormatters.py (original) +++ lldb/trunk/test/expression_command/formatters/TestFormatters.py Fri Oct 7 20:11:42 2011 @@ -56,29 +56,29 @@ self.runCmd("frame variable foo1.b -T") self.runCmd("frame variable foo1.b.b_ref -T") - self.expect("p *(new foo(47))", + self.expect("expression *(new foo(47))", substrs = ['(int) a = 47', '(bar) b = {', '(int) i = 94', '(baz) b = {', '(int) k = 99']) self.runCmd("type summary add -F formatters.foo_SummaryProvider foo") - self.expect("p new int(12)", + self.expect("expression new int(12)", substrs = ['(int *) $', ' = 0x']) self.runCmd("type summary add -s \"${var%pointer} -> ${*var%decimal}\" \"int *\"") - self.expect("p new int(12)", + self.expect("expression new int(12)", substrs = ['(int *) $', '= 0x', ' -> 12']) - self.expect("p foo1.a_ptr", + self.expect("expression foo1.a_ptr", substrs = ['(int *) $', '= 0x', ' -> 13']) - self.expect("p foo1", + self.expect("expression foo1", substrs = ['(foo) $', ' = a = 12, a_ptr = ', ' -> 13, i = 24, i_ptr = ', ' -> 25']) - self.expect("p new foo(47)", + self.expect("expression new foo(47)", substrs = ['(foo *) $', ' a = 47, a_ptr = ', ' -> 48, i = 94, i_ptr = ', ' -> 95']) - self.expect("p foo2", + self.expect("expression foo2", substrs = ['(foo) $', ' = a = 121, a_ptr = ', ' -> 122, i = 242, i_ptr = ', ' -> 243']) object_name = self.res.GetOutput() @@ -88,13 +88,13 @@ self.expect("frame variable foo2", substrs = ['(foo)', 'foo2', ' = a = 121, a_ptr = ', ' -> 122, i = 242, i_ptr = ', ' -> 243']) - self.expect("p $" + object_name, + self.expect("expression $" + object_name, substrs = ['(foo) $', ' = a = 121, a_ptr = ', ' -> 122, i = 242, i_ptr = ', ' -> 243', ', h = 245 , k = 247']) self.runCmd("type summary delete foo") self.runCmd("type synthetic add --python-class foosynth.FooSyntheticProvider foo") - self.expect("p $" + object_name, + self.expect("expression $" + object_name, substrs = ['(foo) $', ' = {', '(int) *i_ptr = 243']) self.runCmd("n") @@ -103,22 +103,22 @@ self.runCmd("type synthetic delete foo") self.runCmd("type summary add -F formatters.foo_SummaryProvider foo") - self.expect("p foo2", + self.expect("expression foo2", substrs = ['(foo) $', ' = a = 7777, a_ptr = ', ' -> 122, i = 242, i_ptr = ', ' -> 8888']) - self.expect("p $" + object_name + '.a', + self.expect("expression $" + object_name + '.a', substrs = ['7777']) - self.expect("p *$" + object_name + '.b.i_ptr', + self.expect("expression *$" + object_name + '.b.i_ptr', substrs = ['8888']) - self.expect("p $" + object_name, + self.expect("expression $" + object_name, substrs = ['(foo) $', ' = a = 121, a_ptr = ', ' -> 122, i = 242, i_ptr = ', ' -> 8888', 'h = 245 , k = 247']) self.runCmd("type summary delete foo") self.runCmd("type synthetic add --python-class foosynth.FooSyntheticProvider foo") - self.expect("p $" + object_name, + self.expect("expression $" + object_name, substrs = ['(foo) $', ' = {', '(int) *i_ptr = 8888']) self.runCmd("n") @@ -126,7 +126,7 @@ self.runCmd("type synthetic delete foo") self.runCmd("type summary add -F formatters.foo_SummaryProvider foo") - self.expect("p $" + object_name, + self.expect("expression $" + object_name, substrs = ['(foo) $', ' = a = 121, a_ptr = ', ' -> 122, i = 242, i_ptr = ', ' -> 8888', 'h = 9999 , k = 247']) process = self.dbg.GetSelectedTarget().GetProcess() @@ -145,7 +145,7 @@ self.expect("frame variable numbers", substrs = ['1','2','3','4','5']) - self.expect("p numbers", + self.expect("expression numbers", substrs = ['1','2','3','4','5']) frozen = frame.EvaluateExpression("&numbers") From gclayton at apple.com Fri Oct 7 20:13:27 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 08 Oct 2011 01:13:27 -0000 Subject: [Lldb-commits] [lldb] r141469 - /lldb/trunk/include/lldb/Core/MappedHash.h Message-ID: <20111008011327.CA63E3128018@llvm.org> Author: gclayton Date: Fri Oct 7 20:13:27 2011 New Revision: 141469 URL: http://llvm.org/viewvc/llvm-project?rev=141469&view=rev Log: Started on the export table for the MappedHash. Modified: lldb/trunk/include/lldb/Core/MappedHash.h Modified: lldb/trunk/include/lldb/Core/MappedHash.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/MappedHash.h?rev=141469&r1=141468&r2=141469&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/MappedHash.h (original) +++ lldb/trunk/include/lldb/Core/MappedHash.h Fri Oct 7 20:13:27 2011 @@ -7,6 +7,10 @@ #include #include + +#include +#include + #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Stream.h" @@ -55,7 +59,7 @@ { typedef T HeaderData; - uint32_t magic; // 'HASH' magic value to allow endian detection + uint32_t magic; // HASH_MAGIC or HASH_CIGAM magic value to allow endian detection uint16_t version; // Version number uint8_t addr_bytesize; // Size in bytes of an address uint8_t hash_function; // The hash function enumeration that was used @@ -65,7 +69,7 @@ HeaderData header_data; // Header () : - magic ('HASH'), + magic (HASH_MAGIC), version (1), addr_bytesize (4), hash_function (eHashFunctionDJB), @@ -119,13 +123,13 @@ Read (lldb_private::DataExtractor &data, uint32_t offset) { if (data.ValidOffsetForDataOfSize (offset, - sizeof(magic) + - sizeof(version) + - sizeof(addr_bytesize) + - sizeof(hash_function) + - sizeof(bucket_count) + - sizeof(hashes_count) + - sizeof(header_data_len))) + sizeof (magic) + + sizeof (version) + + sizeof (addr_bytesize) + + sizeof (hash_function) + + sizeof (bucket_count) + + sizeof (hashes_count) + + sizeof (header_data_len))) { magic = data.GetU32 (&offset); if (magic != HASH_MAGIC) @@ -174,6 +178,181 @@ // Write (int fd); }; + template + class ExportTable + { + public: + typedef __HeaderDataType HeaderDataType; + typedef Header HeaderType; + typedef __KeyType KeyType; + typedef __ValueType ValueType; + + struct Entry + { + uint32_t hash; + KeyType key; + ValueType value; + }; + + typedef std::vector ValueArrayType; + + typedef std::map HashData; + // Map a name hash to one or more name infos + typedef std::map HashToHashData; + + virtual KeyType + GetKeyForStringType (const char *cstr) const = 0; + + virtual size_t + GetByteSize (const HashData &key_to_key_values) = 0; + + virtual bool + WriteHashData (const HashData &hash_data, + lldb_private::Stream &ostrm) = 0; +// + void + AddEntry (const char *cstr, const ValueType &value) + { + Entry entry; + entry.hash = MappedHash::HashString (eHashFunctionDJB, cstr); + entry.key = GetKeyForStringType (cstr); + entry.value = value; + m_entries.push_back (entry); + } + + void + Save (const HeaderDataType &header_data, + lldb_private::Stream &ostrm) + { + if (m_entries.empty()) + return; + + const uint32_t num_entries = m_entries.size(); + uint32_t i = 0; + + HeaderType header; + + header.magic = HASH_MAGIC; + header.version = 1; + header.hash_function = eHashFunctionDJB; + header.bucket_count = 0; + header.hashes_count = 0; + header.prologue_length = header_data.GetByteSize(); + + // We need to figure out the number of unique hashes first before we can + // calculate the number of buckets we want to use. + typedef std::vector hash_coll; + hash_coll unique_hashes; + unique_hashes.resize (num_entries); + for (i=0; i 1024) + header.bucket_count = num_unique_hashes/4; + else if (num_unique_hashes > 16) + header.bucket_count = num_unique_hashes/2; + else + header.bucket_count = num_unique_hashes; + if (header.bucket_count == 0) + header.bucket_count = 1; + + + std::vector hash_buckets; + std::vector hash_indexes (header.bucket_count, 0); + std::vector hash_values; + std::vector hash_offsets; + hash_buckets.resize (header.bucket_count); + uint32_t bucket_entry_empties = 0; + //StreamString hash_file_data(Stream::eBinary, dwarf->GetObjectFile()->GetAddressByteSize(), dwarf->GetObjectFile()->GetByteSize()); + + // Push all of the hashes into their buckets and create all bucket + // entries all populated with data. + for (i=0; ifirst); + hash_offsets.push_back (GetByteSize (pos->second)); + ++hash_count; + } + + hash_indexes[i] = hash_value_index; + } + } + header.hashes_count = hash_values.size(); + + // Write the header out now that we have the hash_count + header.Write (ostrm); + + // Now for each bucket we write the start index of the hashes + // for the current bucket, or UINT32_MAX if the bucket is empty + for (i=0; isecond); + } + } + } + } + protected: + typedef std::vector collection; + collection m_entries; + }; // A class for reading and using a saved hash table from a block of data // in memory template From gclayton at apple.com Fri Oct 7 22:53:14 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 08 Oct 2011 03:53:14 -0000 Subject: [Lldb-commits] [lldb] r141477 - /lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Message-ID: <20111008035314.3F1D82A6C12D@llvm.org> Author: gclayton Date: Fri Oct 7 22:53:14 2011 New Revision: 141477 URL: http://llvm.org/viewvc/llvm-project?rev=141477&view=rev Log: Removed unneeded content. Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=141477&r1=141476&r2=141477&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Fri Oct 7 22:53:14 2011 @@ -99,12 +99,6 @@ ReferencedContainer = "container:lldb.xcodeproj"> - - - - Author: gclayton Date: Fri Oct 7 22:59:55 2011 New Revision: 141478 URL: http://llvm.org/viewvc/llvm-project?rev=141478&view=rev Log: Added some debug code that can verify that all RangeMap.h maps are sorted when needed since RangeArray and RangeDataArray instantiations depend on it. I ran the test suite with ASSERT_RANGEMAP_ARE_SORTED defined and I got no assertions, so I disabled it prior to checkin. Modified: lldb/trunk/include/lldb/Core/RangeMap.h Modified: lldb/trunk/include/lldb/Core/RangeMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=141478&r1=141477&r2=141478&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RangeMap.h (original) +++ lldb/trunk/include/lldb/Core/RangeMap.h Fri Oct 7 22:59:55 2011 @@ -13,6 +13,9 @@ #include "lldb/lldb-private.h" #include +// Uncomment to make sure all Range objects are sorted when needed +//#define ASSERT_RANGEMAP_ARE_SORTED + namespace lldb_private { //---------------------------------------------------------------------- @@ -190,9 +193,27 @@ std::stable_sort (m_entries.begin(), m_entries.end()); } +#ifdef ASSERT_RANGEMAP_ARE_SORTED + bool + IsSorted () const + { + typename std::vector::const_iterator pos, end, prev; + // First we determine if we can combine any of the Entry objects so we + // don't end up allocating and making a new collection for no reason + for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + { + if (prev != end && *pos < *prev) + return false; + } + return true; + } +#endif void CombineConsecutiveRanges () { +#ifdef ASSERT_RANGEMAP_ARE_SORTED + assert (IsSorted()); +#endif // Can't combine if ranges if we have zero or one range if (m_entries.size() > 1) { @@ -236,6 +257,9 @@ BaseType GetMinRangeBase (BaseType fail_value) const { +#ifdef ASSERT_RANGEMAP_ARE_SORTED + assert (IsSorted()); +#endif if (m_entries.empty()) return fail_value; // m_entries must be sorted, so if we aren't empty, we grab the @@ -246,6 +270,9 @@ BaseType GetMaxRangeEnd (BaseType fail_value) const { +#ifdef ASSERT_RANGEMAP_ARE_SORTED + assert (IsSorted()); +#endif if (m_entries.empty()) return fail_value; // m_entries must be sorted, so if we aren't empty, we grab the @@ -303,7 +330,10 @@ uint32_t FindEntryIndexThatContains (B addr) const { - if ( !m_entries.empty() ) +#ifdef ASSERT_RANGEMAP_ARE_SORTED + assert (IsSorted()); +#endif + if (!m_entries.empty()) { Entry entry (addr, 1); typename std::vector::const_iterator begin = m_entries.begin(); @@ -327,7 +357,10 @@ const Entry * FindEntryThatContains (B addr) const { - if ( !m_entries.empty() ) +#ifdef ASSERT_RANGEMAP_ARE_SORTED + assert (IsSorted()); +#endif + if (!m_entries.empty()) { Entry entry (addr, 1); typename std::vector::const_iterator begin = m_entries.begin(); @@ -353,7 +386,10 @@ const Entry * FindEntryThatContains (const Entry &range) const { - if ( !m_entries.empty() ) +#ifdef ASSERT_RANGEMAP_ARE_SORTED + assert (IsSorted()); +#endif + if (!m_entries.empty()) { typename std::vector::const_iterator begin = m_entries.begin(); typename std::vector::const_iterator end = m_entries.end(); @@ -460,9 +496,28 @@ std::stable_sort (m_entries.begin(), m_entries.end()); } +#ifdef ASSERT_RANGEMAP_ARE_SORTED + bool + IsSorted () const + { + typename std::vector::const_iterator pos, end, prev; + // First we determine if we can combine any of the Entry objects so we + // don't end up allocating and making a new collection for no reason + for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) + { + if (prev != end && *pos < *prev) + return false; + } + return true; + } +#endif + void CombineConsecutiveEntriesWithEqualData () { +#ifdef ASSERT_RANGEMAP_ARE_SORTED + assert (IsSorted()); +#endif typename std::vector::iterator pos; typename std::vector::iterator end; typename std::vector::iterator prev; @@ -539,6 +594,9 @@ uint32_t FindEntryIndexThatContains (B addr) const { +#ifdef ASSERT_RANGEMAP_ARE_SORTED + assert (IsSorted()); +#endif if ( !m_entries.empty() ) { Entry entry (addr, 1); @@ -563,6 +621,9 @@ const Entry * FindEntryThatContains (B addr) const { +#ifdef ASSERT_RANGEMAP_ARE_SORTED + assert (IsSorted()); +#endif if ( !m_entries.empty() ) { Entry entry; @@ -591,6 +652,9 @@ const Entry * FindEntryThatContains (const Entry &range) const { +#ifdef ASSERT_RANGEMAP_ARE_SORTED + assert (IsSorted()); +#endif if ( !m_entries.empty() ) { typename std::vector::const_iterator begin = m_entries.begin(); From gclayton at apple.com Sat Oct 8 01:59:54 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 08 Oct 2011 06:59:54 -0000 Subject: [Lldb-commits] [lldb] r141480 - in /lldb/trunk: include/lldb/Core/RangeMap.h include/lldb/Symbol/Block.h source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h Message-ID: <20111008065954.A5EAC3128018@llvm.org> Author: gclayton Date: Sat Oct 8 01:59:54 2011 New Revision: 141480 URL: http://llvm.org/viewvc/llvm-project?rev=141480&view=rev Log: Changed RangeMap over to use llvm::SmallVector and updated the RangeArray and the RangeDataArray to have an extra "unsigned N" template parameter. Updated the lldb_private::Block to use a RangeArray with a uint32_t for both the function base offset and block range size, and then a 1 for the small vector size since most lexical blocks in DWARF only have 1 range. Updates the DWARFDebugRanges RangeArray to use an unsigned of 2 since most blocks that have more than one range usually have 2. Also updated a DWARFDebugAranges to default their RangeArray to use a SmallVector with unsigned size of 1 since this will take care of the .o files when doing DWARF in .o files and since there really isn't any good size we can guess with. Modified: lldb/trunk/include/lldb/Core/RangeMap.h lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h Modified: lldb/trunk/include/lldb/Core/RangeMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=141480&r1=141479&r2=141480&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RangeMap.h (original) +++ lldb/trunk/include/lldb/Core/RangeMap.h Sat Oct 8 01:59:54 2011 @@ -11,7 +11,7 @@ #define liblldb_RangeMap_h_ #include "lldb/lldb-private.h" -#include +#include "llvm/ADT/SmallVector.h" // Uncomment to make sure all Range objects are sorted when needed //#define ASSERT_RANGEMAP_ARE_SORTED @@ -163,13 +163,15 @@ // that the collection contains. //---------------------------------------------------------------------- - template + template class RangeArray { public: typedef B BaseType; typedef S SizeType; typedef Range Entry; + //typedef std::vector Collection; + typedef llvm::SmallVector Collection; RangeArray () : m_entries () @@ -197,7 +199,7 @@ bool IsSorted () const { - typename std::vector::const_iterator pos, end, prev; + typename Collection::const_iterator pos, end, prev; // First we determine if we can combine any of the Entry objects so we // don't end up allocating and making a new collection for no reason for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) @@ -218,9 +220,9 @@ if (m_entries.size() > 1) { // The list should be sorted prior to calling this function - typename std::vector::iterator pos; - typename std::vector::iterator end; - typename std::vector::iterator prev; + typename Collection::iterator pos; + typename Collection::iterator end; + typename Collection::iterator prev; bool can_combine = false; // First we determine if we can combine any of the Entry objects so we // don't end up allocating and making a new collection for no reason @@ -237,7 +239,7 @@ // and populate it accordingly, and then swap it into place. if (can_combine) { - std::vector minimal_ranges; + Collection minimal_ranges; for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) { if (prev != end && prev->Overlap(*pos)) @@ -283,7 +285,7 @@ void Slide (BaseType slide) { - typename std::vector::iterator pos, end; + typename Collection::iterator pos, end; for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos) pos->Slide (slide); } @@ -336,9 +338,9 @@ if (!m_entries.empty()) { Entry entry (addr, 1); - typename std::vector::const_iterator begin = m_entries.begin(); - typename std::vector::const_iterator end = m_entries.end(); - typename std::vector::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); if (pos != end && pos->Contains(addr)) { @@ -363,9 +365,9 @@ if (!m_entries.empty()) { Entry entry (addr, 1); - typename std::vector::const_iterator begin = m_entries.begin(); - typename std::vector::const_iterator end = m_entries.end(); - typename std::vector::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); if (pos != end && pos->Contains(addr)) { @@ -391,9 +393,9 @@ #endif if (!m_entries.empty()) { - typename std::vector::const_iterator begin = m_entries.begin(); - typename std::vector::const_iterator end = m_entries.end(); - typename std::vector::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); if (pos != end && pos->Contains(range)) { @@ -412,7 +414,7 @@ } protected: - std::vector m_entries; + Collection m_entries; }; //---------------------------------------------------------------------- @@ -469,12 +471,15 @@ } }; - template + template class RangeDataArray { public: typedef RangeData Entry; - + //typedef std::vector Collection; + typedef llvm::SmallVector Collection; + + RangeDataArray () { } @@ -500,7 +505,7 @@ bool IsSorted () const { - typename std::vector::const_iterator pos, end, prev; + typename Collection::const_iterator pos, end, prev; // First we determine if we can combine any of the Entry objects so we // don't end up allocating and making a new collection for no reason for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) @@ -518,9 +523,9 @@ #ifdef ASSERT_RANGEMAP_ARE_SORTED assert (IsSorted()); #endif - typename std::vector::iterator pos; - typename std::vector::iterator end; - typename std::vector::iterator prev; + typename Collection::iterator pos; + typename Collection::iterator end; + typename Collection::iterator prev; bool can_combine = false; // First we determine if we can combine any of the Entry objects so we // don't end up allocating and making a new collection for no reason @@ -537,7 +542,7 @@ // and populate it accordingly, and then swap it into place. if (can_combine) { - std::vector minimal_ranges; + Collection minimal_ranges; for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) { if (prev != end && prev->data == pos->data) @@ -600,9 +605,9 @@ if ( !m_entries.empty() ) { Entry entry (addr, 1); - typename std::vector::const_iterator begin = m_entries.begin(); - typename std::vector::const_iterator end = m_entries.end(); - typename std::vector::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); if (pos != end && pos->Contains(addr)) { @@ -629,9 +634,9 @@ Entry entry; entry.SetRangeBase(addr); entry.SetByteSize(1); - typename std::vector::const_iterator begin = m_entries.begin(); - typename std::vector::const_iterator end = m_entries.end(); - typename std::vector::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); if (pos != end && pos->Contains(addr)) { @@ -657,9 +662,9 @@ #endif if ( !m_entries.empty() ) { - typename std::vector::const_iterator begin = m_entries.begin(); - typename std::vector::const_iterator end = m_entries.end(); - typename std::vector::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); if (pos != end && pos->Contains(range)) { @@ -679,7 +684,7 @@ protected: - std::vector m_entries; + Collection m_entries; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=141480&r1=141479&r2=141480&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Sat Oct 8 01:59:54 2011 @@ -43,7 +43,7 @@ public SymbolContextScope { public: - typedef RangeArray RangeArray; + typedef RangeArray RangeArray; typedef RangeArray::Entry Range; //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h?rev=141480&r1=141479&r2=141480&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Sat Oct 8 01:59:54 2011 @@ -20,7 +20,7 @@ class DWARFDebugAranges { protected: - typedef lldb_private::RangeDataArray RangeToDIE; + typedef lldb_private::RangeDataArray RangeToDIE; public: typedef RangeToDIE::Entry Range; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h?rev=141480&r1=141479&r2=141480&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h Sat Oct 8 01:59:54 2011 @@ -20,7 +20,7 @@ class DWARFDebugRanges { public: - typedef lldb_private::RangeArray RangeList; + typedef lldb_private::RangeArray RangeList; typedef RangeList::Entry Range; DWARFDebugRanges(); From gclayton at apple.com Sat Oct 8 16:46:23 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 08 Oct 2011 21:46:23 -0000 Subject: [Lldb-commits] [lldb] r141501 - /lldb/tags/lldb-80/ Message-ID: <20111008214623.306802A6C12C@llvm.org> Author: gclayton Date: Sat Oct 8 16:46:23 2011 New Revision: 141501 URL: http://llvm.org/viewvc/llvm-project?rev=141501&view=rev Log: Going to retag. Removed: lldb/tags/lldb-80/ From gclayton at apple.com Sat Oct 8 16:46:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 08 Oct 2011 21:46:57 -0000 Subject: [Lldb-commits] [lldb] r141502 - /lldb/tags/lldb-80/ Message-ID: <20111008214657.51AE22A6C12C@llvm.org> Author: gclayton Date: Sat Oct 8 16:46:57 2011 New Revision: 141502 URL: http://llvm.org/viewvc/llvm-project?rev=141502&view=rev Log: Retagged lldb-80. Added: lldb/tags/lldb-80/ - copied from r141501, lldb/trunk/ From gclayton at apple.com Sat Oct 8 17:26:11 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 08 Oct 2011 22:26:11 -0000 Subject: [Lldb-commits] [lldb] r141503 - /lldb/tags/lldb-80/resources/lldb-framework-exports Message-ID: <20111008222611.43CD92A6C12C@llvm.org> Author: gclayton Date: Sat Oct 8 17:26:11 2011 New Revision: 141503 URL: http://llvm.org/viewvc/llvm-project?rev=141503&view=rev Log: Remove unneeded exports. Modified: lldb/tags/lldb-80/resources/lldb-framework-exports Modified: lldb/tags/lldb-80/resources/lldb-framework-exports URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-80/resources/lldb-framework-exports?rev=141503&r1=141502&r2=141503&view=diff ============================================================================== --- lldb/tags/lldb-80/resources/lldb-framework-exports (original) +++ lldb/tags/lldb-80/resources/lldb-framework-exports Sat Oct 8 17:26:11 2011 @@ -1,5 +1,3 @@ __ZN4lldb* __ZNK4lldb* _init_lldb -*add_shared* -*release_shared* From gclayton at apple.com Sat Oct 8 17:26:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 08 Oct 2011 22:26:32 -0000 Subject: [Lldb-commits] [lldb] r141504 - /lldb/trunk/resources/lldb-framework-exports Message-ID: <20111008222632.D9AF02A6C12C@llvm.org> Author: gclayton Date: Sat Oct 8 17:26:32 2011 New Revision: 141504 URL: http://llvm.org/viewvc/llvm-project?rev=141504&view=rev Log: Remove unneeded exports. Modified: lldb/trunk/resources/lldb-framework-exports Modified: lldb/trunk/resources/lldb-framework-exports URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/lldb-framework-exports?rev=141504&r1=141503&r2=141504&view=diff ============================================================================== --- lldb/trunk/resources/lldb-framework-exports (original) +++ lldb/trunk/resources/lldb-framework-exports Sat Oct 8 17:26:32 2011 @@ -1,5 +1,3 @@ __ZN4lldb* __ZNK4lldb* _init_lldb -*add_shared* -*release_shared*