From gclayton at apple.com Mon Jun 6 15:42:27 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 06 Jun 2011 13:42:27 -0700 Subject: [Lldb-commits] [lldb] r132582 - /lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp In-Reply-To: <20110605163529.GA1543@pcc.me.uk> References: <20110603203958.357262A6C12C@llvm.org> <3571CC2D-495F-4F1B-A7F9-E84B1C4A5A77@apple.com> <333C44C2-643C-441D-B052-ED2B62C91641@apple.com> <20110605163529.GA1543@pcc.me.uk> Message-ID: <4E107F64-C22F-46FD-B7ED-006260D7371B@apple.com> On Jun 5, 2011, at 9:35 AM, Peter Collingbourne wrote: > On Fri, Jun 03, 2011 at 02:08:58PM -0700, Greg Clayton wrote: >> Another clarification I meant to initially convey, so one more time: >> >> Will the content of SHT_SYMTAB always contain the all the same symbols found in SHT_DYNSYM and more symbol (symbols that aren't required by the dynamic loader)? Or do the symbols for the dynamic loader only get put into the SHT_DYNSYM sections, and any other symbols get put into the SHT_SYMTAB sections? >> >> Shouldn't we just parse the SHT_SYMTAB sections and fall back to the SHT_DYNSYM section(s) if there are no SHT_SYMTAB sections? > > Hi Greg, > > Generally .dynsym is a subset of .symtab (if present), and this does > seem to be an implicit rule in the ELF specification [1]. However, > in practice this rule is not always adhered to (I have at least one > (shared) object file on my system in which both .dynsym and .symtab > are present but .dynsym is not a subset of .symtab). So I think > the safest thing to do is to parse both symbol tables, under the > "be lenient in what you accept" principle. > > Is it a problem to have duplicate symbols in Symtab? If we do this, > should we be filtering out duplicates somehow? In general, yes we should be filtering duplicates, just to keep the object file information as concise as possible. Some examples in the mach-o object file plug-in include compressing a linker symbol for "main" along with the STAB entries for it into a single symbol. The STAB entry for a function actually is 2 symbols since the mach-o symbol table entry doesn't have a length field where the first has the address value for "main" and the second has the function size. The STABs also include 2 symbols that delineate the start and end of a function, so each STAB entry actually has 4 symbol table entries. Dumping the raw mach-o nlist entries for a simple a.out program: ---------------------------------------------------------------------- Symbol table for: 'a.out' (i386) ---------------------------------------------------------------------- Index n_strx n_type n_sect n_desc n_value ======== -------- ------------------ ------ ------ ---------------- [ 0] 00000002 64 (N_SO ) 00 0000 0000000000000000 '/Volumes/work/gclayton/Documents/src/args/' [ 1] 0000002d 64 (N_SO ) 00 0000 0000000000000000 'main.c' [ 2] 00000034 66 (N_OSO ) 03 0001 000000004dcb3e87 '/Volumes/work/gclayton/Documents/src/args/main.o' [ 3] 00000001 2e (N_BNSYM ) 01 0000 0000000000001bb0 [ 4] 00000065 24 (N_FUN ) 01 0000 0000000000001bb0 '_main' [ 5] 00000001 24 (N_FUN ) 00 0000 00000000000002c6 [ 6] 00000001 4e (N_ENSYM ) 01 0000 00000000000002c6 [ 7] 00000001 64 (N_SO ) 01 0000 0000000000000000 [ 8] 0000006b 0e ( SECT ) 06 0000 0000000000002000 '_pvars' [ 9] 00000072 0f ( SECT EXT) 09 0000 0000000000002038 '_NXArgc' [ 10] 0000007a 0f ( SECT EXT) 09 0000 000000000000203c '_NXArgv' [ 11] 00000082 0f ( SECT EXT) 09 0000 0000000000002044 '___progname' [ 12] 0000008e 03 ( ABS EXT) 01 0010 0000000000001000 '__mh_execute_header' [ 13] 000000a2 0f ( SECT EXT) 09 0000 0000000000002040 '_environ' [ 14] 000000ab 0f ( SECT EXT) 01 0000 0000000000001bb0 '_main' [ 15] 000000b1 0f ( SECT EXT) 01 0000 0000000000001b70 'start' [ 16] 000000b7 01 ( UNDF EXT) 00 0100 0000000000000000 '___stack_chk_fail' [ 17] 000000c9 01 ( UNDF EXT) 00 0100 0000000000000000 '___stack_chk_guard' [ 18] 000000dc 01 ( UNDF EXT) 00 0100 0000000000000000 '_exit' [ 19] 000000e2 01 ( UNDF EXT) 00 0100 0000000000000000 '_getcwd' [ 20] 000000ea 01 ( UNDF EXT) 00 0100 0000000000000000 '_perror' [ 21] 000000f2 01 ( UNDF EXT) 00 0100 0000000000000000 '_printf' [ 22] 000000fa 01 ( UNDF EXT) 00 0100 0000000000000000 '_puts' [ 23] 00000100 01 ( UNDF EXT) 00 0100 0000000000000000 'dyld_stub_binder' Loading this into lldb we see: % lldb a.out Current executable set to 'a.out' (i386). (lldb) target modules dump symtab a.out Symtab, file = /Volumes/work/gclayton/Documents/src/args/a.out, num_symbols = 18: Debug symbol |Synthetic symbol ||Externally Visible ||| Index UserID DSX Type File Address/Value Size Flags Name ------- ------ --- ------------ ------------------ ------------------ ---------- ---------------------------------- [ 0] 0 D SourceFile 0x0000000000000000 Sibling -> [ 3] 0x00640000 /Volumes/work/gclayton/Documents/src/args/main.c [ 1] 2 D ObjectFile 0x000000004dcb3e87 0x0000000000000000 0x00660001 /Volumes/work/gclayton/Documents/src/args/main.o [ 2] 4 D Code 0x0000000000001bb0 0x00000000000002c6 0x000f0000 main [ 3] 8 Data 0x0000000000002000 0x0000000000000000 0x000e0000 pvars [ 4] 9 X Data 0x0000000000002038 0x0000000000000000 0x000f0000 NXArgc [ 5] 10 X Data 0x000000000000203c 0x0000000000000000 0x000f0000 NXArgv [ 6] 11 X Data 0x0000000000002044 0x0000000000000000 0x000f0000 __progname [ 7] 12 X Absolute 0x0000000000001000 0x0000000000000000 0x00030010 _mh_execute_header [ 8] 13 X Data 0x0000000000002040 0x0000000000000000 0x000f0000 environ [ 9] 15 X Code 0x0000000000001b70 0x0000000000000000 0x000f0000 start [ 10] 16 Trampoline 0x0000000000001e76 0x0000000000000006 0x00010100 __stack_chk_fail [ 11] 17 X Extern 0x0000000000000000 0x0000000000000000 0x00010100 __stack_chk_guard [ 12] 18 Trampoline 0x0000000000001e7c 0x0000000000000006 0x00010100 exit [ 13] 19 Trampoline 0x0000000000001e82 0x0000000000000006 0x00010100 getcwd [ 14] 20 Trampoline 0x0000000000001e88 0x0000000000000006 0x00010100 perror [ 15] 21 Trampoline 0x0000000000001e8e 0x0000000000000006 0x00010100 printf [ 16] 22 Trampoline 0x0000000000001e94 0x0000000000000006 0x00010100 puts [ 17] 23 X Extern 0x0000000000000000 0x0000000000000000 0x00010100 dyld_stub_binder Note that the "UserID" of a symbol maintains the original symbol table index in case any data in the object file refers to symbols by the original index. For linux, you would want to somehow encode the "UserID" to be the symbol table index + the section header index if any data in ELF would later want to dig up some info on one of the ELF symbols. Or you can just make the UserID a monotonically increasing index where you might need to remember the number of symbols in each section header that was a symbol table and map it back accordingly. So the main point is that is would be great if we can keep the LLDB symbol tables as simple as they need to be by removing duplicates and merging symols when possible. The mach-o example above merged the "_main" symbols #3-#6, and #14 in the mach-o into a single LLDB symbol table entry #2. It also repurposed the undefined external symbols (#16, #18-#23) into valid trampoline symbols -- they have been modified to point to the mach-o PLT trampoline code. So this takes symbols that are in the symbol table that are actually for the dynamic linker, and makes them into actual symbols that cover all of the code. Some debuggers throw away the undefined symbols and then make their own new trampoline entries for the PLT code, but in LLDB we reuse them since the data in mach-o actually refers to these undefined symbols via the original symbol table index ("UserID" in LLDB, or "Index" in the mach-o dump). So think about which ELF symbols are needed by the ELF object file in order to do name and address lookups, and feel free to make up new symbols for things like the PLT entries. Anytime you end up with an address query that comes from an object file that falls within the virtual file address of an object file, and that address doesn't return a valid symbol, we need to look at why and make sure there isn't a symbol we should be producing that explains some details about that address. From johnny.chen at apple.com Mon Jun 6 16:36:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 06 Jun 2011 21:36:56 -0000 Subject: [Lldb-commits] [lldb] r132692 - /lldb/trunk/test/lldbtest.py Message-ID: <20110606213656.50C002A6C12C@llvm.org> Author: johnny Date: Mon Jun 6 16:36:56 2011 New Revision: 132692 URL: http://llvm.org/viewvc/llvm-project?rev=132692&view=rev Log: Remove extra whitespace. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=132692&r1=132691&r2=132692&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Mon Jun 6 16:36:56 2011 @@ -391,7 +391,6 @@ build the binaries used during a particular test scenario. A plugin should be provided for the sys.platform running the test suite. The Mac OS X implementation is located in plugins/darwin.py. - """ @classmethod From johnny.chen at apple.com Thu Jun 9 17:04:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 09 Jun 2011 22:04:56 -0000 Subject: [Lldb-commits] [lldb] r132807 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/function_symbol/TestDisasmAPI.py Message-ID: <20110609220456.61B062A6C12C@llvm.org> Author: johnny Date: Thu Jun 9 17:04:56 2011 New Revision: 132807 URL: http://llvm.org/viewvc/llvm-project?rev=132807&view=rev Log: Add rich comparison methods for the SBAddress object. If two SBAddress's have the same module and file address, they are considered equal. Add a test snippet 'sa1 == sa2' to exercise the rich comparison methods for SBAddress. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.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=132807&r1=132806&r2=132807&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Thu Jun 9 17:04:56 2011 @@ -88,7 +88,8 @@ # # This dictionary defines a mapping from classname to equality method name(s). # -e = { 'SBBreakpoint': ['GetID'], +e = { 'SBAddress': ['GetFileAddress', 'GetModule'], + 'SBBreakpoint': ['GetID'], 'SBFileSpec': ['GetFilename', 'GetDirectory'], 'SBModule': ['GetFileSpec', 'GetUUIDString'] } Modified: lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py?rev=132807&r1=132806&r2=132807&view=diff ============================================================================== --- lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py (original) +++ lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py Thu Jun 9 17:04:56 2011 @@ -102,18 +102,23 @@ sa1 = symbol.GetStartAddress() #print "sa1:", sa1 + print "sa1.GetFileAddress():", sa1.GetFileAddress() #ea1 = symbol.GetEndAddress() #print "ea1:", ea1 + print "ea1.GetFileAddress():", sa1.GetFileAddress() sa2 = function.GetStartAddress() #print "sa2:", sa2 + print "sa2.GetFileAddress():", sa2.GetFileAddress() #ea2 = function.GetEndAddress() #print "ea2:", ea2 + self.assertTrue(sa1 and sa2 and sa1 == sa2, + "The two starting addresses should be the same") from lldbutil import get_description desc1 = get_description(sa1) desc2 = get_description(sa2) self.assertTrue(desc1 and desc2 and desc1 == desc2, - "The two starting addresses should be the same") + "SBAddress.GetDescription() API of sa1 and sa2 should return the same string") if __name__ == '__main__': From johnny.chen at apple.com Thu Jun 9 17:09:52 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 09 Jun 2011 22:09:52 -0000 Subject: [Lldb-commits] [lldb] r132808 - /lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py Message-ID: <20110609220952.7F3EB2A6C12C@llvm.org> Author: johnny Date: Thu Jun 9 17:09:52 2011 New Revision: 132808 URL: http://llvm.org/viewvc/llvm-project?rev=132808&view=rev Log: Comment out the debug stmts. Modified: lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py Modified: lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py?rev=132808&r1=132807&r2=132808&view=diff ============================================================================== --- lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py (original) +++ lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py Thu Jun 9 17:09:52 2011 @@ -102,13 +102,12 @@ sa1 = symbol.GetStartAddress() #print "sa1:", sa1 - print "sa1.GetFileAddress():", sa1.GetFileAddress() + #print "sa1.GetFileAddress():", hex(sa1.GetFileAddress()) #ea1 = symbol.GetEndAddress() #print "ea1:", ea1 - print "ea1.GetFileAddress():", sa1.GetFileAddress() sa2 = function.GetStartAddress() #print "sa2:", sa2 - print "sa2.GetFileAddress():", sa2.GetFileAddress() + #print "sa2.GetFileAddress():", hex(sa2.GetFileAddress()) #ea2 = function.GetEndAddress() #print "ea2:", ea2 self.assertTrue(sa1 and sa2 and sa1 == sa2, From gclayton at apple.com Thu Jun 9 17:34:34 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 09 Jun 2011 22:34:34 -0000 Subject: [Lldb-commits] [lldb] r132813 - in /lldb/trunk: include/lldb/Core/ConstString.h include/lldb/Core/History.h lldb.xcodeproj/project.pbxproj source/Core/ConstString.cpp source/Core/History.cpp source/Core/Mangled.cpp Message-ID: <20110609223434.661F92A6C12C@llvm.org> Author: gclayton Date: Thu Jun 9 17:34:34 2011 New Revision: 132813 URL: http://llvm.org/viewvc/llvm-project?rev=132813&view=rev Log: I modified the StringMap that was being used to unique our debugger C strings to have the value for the map be a "const char *" instead of an unused uint32_t. This allows us to store the uniqued mangled/demangled counterpart in this map for mangled names. This also speeds up the mangled/demangled counterpart lookup that used to be maintained in a STL map by having direct access to the data. If we eventually need to associate other strings to strings to more data, we can make the value of the StringMap have a more complex value. Added the start of a history source and history event class. It isn't being used by anything yet, but might be shortly. Added: lldb/trunk/include/lldb/Core/History.h lldb/trunk/source/Core/History.cpp Modified: lldb/trunk/include/lldb/Core/ConstString.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/ConstString.cpp lldb/trunk/source/Core/Mangled.cpp Modified: lldb/trunk/include/lldb/Core/ConstString.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConstString.h?rev=132813&r1=132812&r2=132813&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ConstString.h (original) +++ lldb/trunk/include/lldb/Core/ConstString.h Thu Jun 9 17:34:34 2011 @@ -338,6 +338,12 @@ void SetCString (const char *cstr); + void + SetCStringWithMangledCounterpart (const char *demangled, const ConstString &mangled); + + bool + GetMangledCounterpart (ConstString &counterpart) const; + //------------------------------------------------------------------ /// Set the C string value with length. /// Added: lldb/trunk/include/lldb/Core/History.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/History.h?rev=132813&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/History.h (added) +++ lldb/trunk/include/lldb/Core/History.h Thu Jun 9 17:34:34 2011 @@ -0,0 +1,177 @@ +//===-- History.h -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef lldb_History_h_ +#define lldb_History_h_ + +// C Includes +#include + +// C++ Includes +#include +#include + +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-public.h" +#include "lldb/Host/Mutex.h" + +namespace lldb_private { + +//---------------------------------------------------------------------- +/// @class HistorySource History.h "lldb/Core/History.h" +/// @brief A class that defines history events. +//---------------------------------------------------------------------- + +class HistorySource +{ +public: + typedef const void * HistoryEvent; + + HistorySource () : + m_mutex (Mutex::eMutexTypeRecursive), + m_events () + { + } + + virtual + ~HistorySource() + { + } + + // Create a new history event. Subclasses should use any data or members + // in the subclass of this class to produce a history event and push it + // onto the end of the history stack. + + virtual HistoryEvent + CreateHistoryEvent () = 0; + + virtual void + DeleteHistoryEvent (HistoryEvent event) = 0; + + virtual void + DumpHistoryEvent (Stream &strm, HistoryEvent event) = 0; + + virtual size_t + GetHistoryEventCount() = 0; + + virtual HistoryEvent + GetHistoryEventAtIndex (uint32_t idx) = 0; + + virtual HistoryEvent + GetCurrentHistoryEvent () = 0; + + // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs. + virtual int + CompareHistoryEvents (const HistoryEvent lhs, + const HistoryEvent rhs); + + virtual bool + IsCurrentHistoryEvent (const HistoryEvent event); + +private: + typedef std::stack collection; + + Mutex m_mutex; + collection m_events; + + DISALLOW_COPY_AND_ASSIGN (HistorySource); + +}; + +//---------------------------------------------------------------------- +/// @class HistorySourceUInt History.h "lldb/Core/History.h" +/// @brief A class that defines history events that are represented by +/// unsigned integers. +/// +/// Any history event that is defined by a unique monotonically +/// increasing unsigned integer +//---------------------------------------------------------------------- + +class HistorySourceUInt : public HistorySource +{ + HistorySourceUInt (const char *id_name, uintptr_t start_value = 0u) : + HistorySource(), + m_name (id_name), + m_curr_id (start_value) + { + } + + virtual + ~HistorySourceUInt() + { + } + + // Create a new history event. Subclasses should use any data or members + // in the subclass of this class to produce a history event and push it + // onto the end of the history stack. + + virtual HistoryEvent + CreateHistoryEvent () + { + ++m_curr_id; + return (HistoryEvent)m_curr_id; + } + + virtual void + DeleteHistoryEvent (HistoryEvent event) + { + // Nothing to delete, the event contains the integer + } + + virtual void + DumpHistoryEvent (Stream &strm, HistoryEvent event); + + virtual size_t + GetHistoryEventCount() + { + return m_curr_id; + } + + virtual HistoryEvent + GetHistoryEventAtIndex (uint32_t idx) + { + return (HistoryEvent)((uintptr_t)idx); + } + + virtual HistoryEvent + GetCurrentHistoryEvent () + { + return (HistoryEvent)m_curr_id; + } + + // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs. + virtual int + CompareHistoryEvents (const HistoryEvent lhs, + const HistoryEvent rhs) + { + uintptr_t lhs_uint = (uintptr_t)lhs; + uintptr_t rhs_uint = (uintptr_t)rhs; + if (lhs_uint < rhs_uint) + return -1; + if (lhs_uint > rhs_uint) + return +1; + return 0; + } + + virtual bool + IsCurrentHistoryEvent (const HistoryEvent event) + { + return (uintptr_t)event == m_curr_id; + } + +protected: + std::string m_name; // The name of the history unsigned integer + uintptr_t m_curr_id; // The current value of the history unsigned unteger +}; + + +} // namespace lldb_private + +#endif // lldb_History_h_ Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=132813&r1=132812&r2=132813&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jun 9 17:34:34 2011 @@ -393,6 +393,7 @@ 26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */; }; 26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; }; 26F5C39110F3FA26009D5894 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; + 26F73062139D8FDB00FD51C7 /* History.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F73061139D8FDB00FD51C7 /* History.cpp */; }; 49C850771384A02F007DB519 /* ProcessDataAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 49C850761384A02F007DB519 /* ProcessDataAllocator.h */; }; 49C8507C1384A786007DB519 /* ProcessDataAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C850781384A0CA007DB519 /* ProcessDataAllocator.cpp */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; @@ -1054,6 +1055,8 @@ 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libtermcap.dylib; path = /usr/lib/libtermcap.dylib; sourceTree = ""; }; 26F5C37410F3F61B009D5894 /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = ""; }; 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = ""; }; + 26F7305F139D8FC900FD51C7 /* History.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = History.h; path = include/lldb/Core/History.h; sourceTree = ""; }; + 26F73061139D8FDB00FD51C7 /* History.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = History.cpp; path = source/Core/History.cpp; sourceTree = ""; }; 26F996A7119B79C300412154 /* ARM_DWARF_Registers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARM_DWARF_Registers.h; path = source/Utility/ARM_DWARF_Registers.h; sourceTree = ""; }; 26F996A8119B79C300412154 /* ARM_GCC_Registers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARM_GCC_Registers.h; path = source/Utility/ARM_GCC_Registers.h; sourceTree = ""; }; 26FA4315130103F400E71120 /* FileSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileSpec.h; path = include/lldb/Host/FileSpec.h; sourceTree = ""; }; @@ -1896,6 +1899,8 @@ 26BC7D6310F1B77400F91463 /* FileSpecList.h */, 26BC7E7B10F1B85900F91463 /* FileSpecList.cpp */, 26BC7D6410F1B77400F91463 /* Flags.h */, + 26F7305F139D8FC900FD51C7 /* History.h */, + 26F73061139D8FDB00FD51C7 /* History.cpp */, 9AA69DBB118A029E00D753A0 /* InputReader.h */, 9AA69DB5118A027A00D753A0 /* InputReader.cpp */, 9A9E1F0013980943005AC039 /* InputReaderStack.h */, @@ -3215,6 +3220,7 @@ 2690B3711381D5C300ECFBAE /* Memory.cpp in Sources */, 9A9E1EFF1398086D005AC039 /* InputReaderStack.cpp in Sources */, B28058A1139988B0002D96D0 /* InferiorCallPOSIX.cpp in Sources */, + 26F73062139D8FDB00FD51C7 /* History.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/ConstString.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConstString.cpp?rev=132813&r1=132812&r2=132813&view=diff ============================================================================== --- lldb/trunk/source/Core/ConstString.cpp (original) +++ lldb/trunk/source/Core/ConstString.cpp Thu Jun 9 17:34:34 2011 @@ -32,6 +32,10 @@ class Pool { public: + typedef const char * StringPoolValueType; + typedef llvm::StringMap StringPool; + typedef llvm::StringMapEntry StringPoolEntryType; + //------------------------------------------------------------------ // Default constructor // @@ -51,24 +55,44 @@ } - static llvm::StringMapEntry & + static StringPoolEntryType & GetStringMapEntryFromKeyData (const char *keyData) { - char *ptr = const_cast(keyData) - sizeof (llvm::StringMapEntry); - return *reinterpret_cast*>(ptr); + char *ptr = const_cast(keyData) - sizeof (StringPoolEntryType); + return *reinterpret_cast(ptr); } size_t - GetConstCStringLength (const char *ccstr) + GetConstCStringLength (const char *ccstr) const { if (ccstr) { - llvm::StringMapEntry&entry = GetStringMapEntryFromKeyData (ccstr); + const StringPoolEntryType&entry = GetStringMapEntryFromKeyData (ccstr); return entry.getKey().size(); } return 0; } + StringPoolValueType + GetMangledCounterpart (const char *ccstr) const + { + if (ccstr) + return GetStringMapEntryFromKeyData (ccstr).getValue(); + return 0; + } + + bool + SetMangledCounterparts (const char *key_ccstr, const char *value_ccstr) + { + if (key_ccstr && value_ccstr) + { + GetStringMapEntryFromKeyData (key_ccstr).setValue(value_ccstr); + GetStringMapEntryFromKeyData (value_ccstr).setValue(key_ccstr); + return true; + } + return false; + } + const char * GetConstCString (const char *cstr) { @@ -84,13 +108,33 @@ { Mutex::Locker locker (m_mutex); llvm::StringRef string_ref (cstr, cstr_len); - llvm::StringMapEntry& entry = m_string_map.GetOrCreateValue (string_ref); + StringPoolEntryType& entry = m_string_map.GetOrCreateValue (string_ref); return entry.getKeyData(); } return NULL; } const char * + GetConstCStringAndSetMangledCounterPart (const char *demangled_cstr, const char *mangled_ccstr) + { + if (demangled_cstr) + { + Mutex::Locker locker (m_mutex); + // Make string pool entry with the mangled counterpart already set + StringPoolEntryType& entry = m_string_map.GetOrCreateValue (llvm::StringRef (demangled_cstr), mangled_ccstr); + + // Extract the const version of the demangled_cstr + const char *demangled_ccstr = entry.getKeyData(); + // Now assign the demangled const string as the counterpart of the + // mangled const string... + GetStringMapEntryFromKeyData (mangled_ccstr).setValue(demangled_ccstr); + // Return the constant demangled C string + return demangled_ccstr; + } + return NULL; + } + + const char * GetConstTrimmedCStringWithLength (const char *cstr, int cstr_len) { if (cstr) @@ -114,7 +158,7 @@ const_iterator end = m_string_map.end(); for (const_iterator pos = m_string_map.begin(); pos != end; ++pos) { - mem_size += sizeof(llvm::StringMapEntry) + pos->getKey().size(); + mem_size += sizeof(StringPoolEntryType) + pos->getKey().size(); } return mem_size; } @@ -123,7 +167,6 @@ //------------------------------------------------------------------ // Typedefs //------------------------------------------------------------------ - typedef llvm::StringMap StringPool; typedef StringPool::iterator iterator; typedef StringPool::const_iterator const_iterator; @@ -320,6 +363,19 @@ m_string = StringPool().GetConstCString (cstr); } +void +ConstString::SetCStringWithMangledCounterpart (const char *demangled, const ConstString &mangled) +{ + m_string = StringPool().GetConstCStringAndSetMangledCounterPart (demangled, mangled.m_string); +} + +bool +ConstString::GetMangledCounterpart (ConstString &counterpart) const +{ + counterpart.m_string = StringPool().GetMangledCounterpart(m_string); + return counterpart; +} + //---------------------------------------------------------------------- // Set the string value in the object by uniquing "cstr_len" bytes // starting at the "cstr" string value in our global string pool. Added: lldb/trunk/source/Core/History.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/History.cpp?rev=132813&view=auto ============================================================================== --- lldb/trunk/source/Core/History.cpp (added) +++ lldb/trunk/source/Core/History.cpp Thu Jun 9 17:34:34 2011 @@ -0,0 +1,25 @@ +//===-- History.cpp ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Core/History.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/Stream.h" + +using namespace lldb; +using namespace lldb_private; + +void +HistorySourceUInt::DumpHistoryEvent (Stream &strm, HistoryEvent event) +{ + strm.Printf ("%s %llu", m_name.c_str(), (uint64_t)((uintptr_t)event)); +} Modified: lldb/trunk/source/Core/Mangled.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=132813&r1=132812&r2=132813&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Thu Jun 9 17:34:34 2011 @@ -152,29 +152,9 @@ // lets just make sure it isn't empty... const char * mangled = m_mangled.AsCString(); // Don't bother running anything that doesn't start with _Z through the demangler - if (mangled[0] != '\0' && mangled[0] == '_' && mangled[1] == 'Z') + if (mangled[0] == '_' && mangled[1] == 'Z') { - // Since demangling can be a costly, and since all names that go - // into a ConstString (like our m_mangled and m_demangled members) - // end up being unique "const char *" values, we can use a DenseMap - // to speed up our lookup. We do this because often our symbol table - // and our debug information both have the mangled names which they - // would each need to demangle. Also, with GCC we end up with the one - // definition rule where a lot of STL code produces symbols that are - // in multiple compile units and the mangled names end up being in - // the same binary multiple times. The performance win isn't huge, - // but we showed a 20% improvement on darwin. - typedef llvm::DenseMap MangledToDemangledMap; - static MangledToDemangledMap g_mangled_to_demangled; - - // Check our mangled string pointer to demangled string pointer map first - MangledToDemangledMap::const_iterator pos = g_mangled_to_demangled.find (mangled); - if (pos != g_mangled_to_demangled.end()) - { - // We have already demangled this string, we can just use our saved result! - m_demangled.SetCString(pos->second); - } - else + if (!m_mangled.GetMangledCounterpart(m_demangled)) { // We didn't already mangle this name, demangle it and if all goes well // add it to our map. @@ -182,11 +162,7 @@ if (demangled_name) { - m_demangled.SetCString (demangled_name); - // Now that the name has been uniqued, add the uniqued C string - // pointer from m_mangled as the key to the uniqued C string - // pointer in m_demangled. - g_mangled_to_demangled.insert (std::make_pair (mangled, m_demangled.GetCString())); + m_demangled.SetCStringWithMangledCounterpart(demangled_name, m_mangled); free (demangled_name); } } From gclayton at apple.com Thu Jun 9 19:00:19 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 10 Jun 2011 00:00:19 -0000 Subject: [Lldb-commits] [lldb] r132823 - /lldb/trunk/source/Core/ConstString.cpp Message-ID: <20110610000019.59A542A6C12C@llvm.org> Author: gclayton Date: Thu Jun 9 19:00:19 2011 New Revision: 132823 URL: http://llvm.org/viewvc/llvm-project?rev=132823&view=rev Log: Explicitly set the value to NULL when adding a string map entry. Modified: lldb/trunk/source/Core/ConstString.cpp Modified: lldb/trunk/source/Core/ConstString.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConstString.cpp?rev=132823&r1=132822&r2=132823&view=diff ============================================================================== --- lldb/trunk/source/Core/ConstString.cpp (original) +++ lldb/trunk/source/Core/ConstString.cpp Thu Jun 9 19:00:19 2011 @@ -108,7 +108,7 @@ { Mutex::Locker locker (m_mutex); llvm::StringRef string_ref (cstr, cstr_len); - StringPoolEntryType& entry = m_string_map.GetOrCreateValue (string_ref); + StringPoolEntryType& entry = m_string_map.GetOrCreateValue (string_ref, (StringPoolValueType)NULL); return entry.getKeyData(); } return NULL; From gclayton at apple.com Thu Jun 9 20:32:06 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 10 Jun 2011 01:32:06 -0000 Subject: [Lldb-commits] [lldb] r132827 - /lldb/trunk/include/lldb/Core/ConstString.h Message-ID: <20110610013206.DD21C2A6C12C@llvm.org> Author: gclayton Date: Thu Jun 9 20:32:06 2011 New Revision: 132827 URL: http://llvm.org/viewvc/llvm-project?rev=132827&view=rev Log: Added an llvm::StringRef accessor. Modified: lldb/trunk/include/lldb/Core/ConstString.h Modified: lldb/trunk/include/lldb/Core/ConstString.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConstString.h?rev=132827&r1=132826&r2=132827&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ConstString.h (original) +++ lldb/trunk/include/lldb/Core/ConstString.h Thu Jun 9 20:32:06 2011 @@ -14,6 +14,8 @@ #include #include "lldb/lldb-private.h" +#include "llvm/ADT/StringRef.h" + namespace lldb_private { @@ -232,6 +234,12 @@ return m_string; } + llvm::StringRef + GetStringRef () const + { + return llvm::StringRef (m_string, GetLength()); + } + const char * GetCString () const { From gclayton at apple.com Thu Jun 9 20:37:29 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 10 Jun 2011 01:37:29 -0000 Subject: [Lldb-commits] [lldb] r132828 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: NameToDIE.cpp NameToDIE.h Message-ID: <20110610013729.456BA2A6C12C@llvm.org> Author: gclayton Date: Thu Jun 9 20:37:29 2011 New Revision: 132828 URL: http://llvm.org/viewvc/llvm-project?rev=132828&view=rev Log: Header file cleanup and moved an inline to the implementation file. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp?rev=132828&r1=132827&r2=132828&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp Thu Jun 9 20:37:29 2011 @@ -8,7 +8,15 @@ //===----------------------------------------------------------------------===// #include "NameToDIE.h" +#include "lldb/Core/ConstString.h" #include "lldb/Core/Stream.h" +#include "lldb/Core/RegularExpression.h" + +void +NameToDIE::Insert (const lldb_private::ConstString& name, const Info &info) +{ + m_collection.insert (std::make_pair(name.AsCString(), info)); +} size_t NameToDIE::Find (const lldb_private::ConstString &name, std::vector &info_array) const Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h?rev=132828&r1=132827&r2=132828&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h Thu Jun 9 20:37:29 2011 @@ -11,8 +11,8 @@ #define SymbolFileDWARF_NameToDIE_h_ #include -#include "lldb/Core/ConstString.h" -#include "lldb/Core/RegularExpression.h" +#include +#include "lldb/lldb-defines.h" class NameToDIE { @@ -37,10 +37,7 @@ Dump (lldb_private::Stream *s); void - Insert (const lldb_private::ConstString& name, const Info &info) - { - m_collection.insert (std::make_pair(name.AsCString(), info)); - } + Insert (const lldb_private::ConstString& name, const Info &info); size_t Find (const lldb_private::ConstString &name, From gclayton at apple.com Thu Jun 9 21:22:01 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 10 Jun 2011 02:22:01 -0000 Subject: [Lldb-commits] [lldb] r132829 - /lldb/trunk/include/lldb/Core/UniqueCStringMap.h Message-ID: <20110610022201.87D6C2A6C12C@llvm.org> Author: gclayton Date: Thu Jun 9 21:22:01 2011 New Revision: 132829 URL: http://llvm.org/viewvc/llvm-project?rev=132829&view=rev Log: Make the size accessor const. Modified: lldb/trunk/include/lldb/Core/UniqueCStringMap.h Modified: lldb/trunk/include/lldb/Core/UniqueCStringMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UniqueCStringMap.h?rev=132829&r1=132828&r2=132829&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UniqueCStringMap.h (original) +++ lldb/trunk/include/lldb/Core/UniqueCStringMap.h Thu Jun 9 21:22:01 2011 @@ -175,7 +175,7 @@ // Get the total number of entries in this map. //------------------------------------------------------------------ size_t - GetSize () + GetSize () const { return m_map.size(); } From vasil.georgiev.vasilev at cern.ch Fri Jun 10 09:49:32 2011 From: vasil.georgiev.vasilev at cern.ch (Vassil Vassilev) Date: Fri, 10 Jun 2011 16:49:32 +0200 Subject: [Lldb-commits] Hi All! Message-ID: <4DF22EFC.3040307@cern.ch> Hi, Can I say Hi to lldb community with the attached patch. I saw that lldb didn't have doxygen documentation on the website and decided to see what I could do. Recently I did that for cling so I've made few changes to adapt it for lldb. It is customization of clang's approach of generating documentation. Be careful it's slow and space consuming ;) There are few warnings given by doxygen parser (it claims that it doesn't recognize the tags /bfalse and /btrue) If you want you can give it a try and if it needs some more tweaking I can do it. Vassil -------------- next part -------------- A non-text attachment was scrubbed... Name: lldb_doxygen.diff Type: text/x-patch Size: 100874 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110610/d6b5ef7b/attachment-0001.bin