From johnny.chen at apple.com Mon Jan 9 13:19:23 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 09 Jan 2012 19:19:23 -0000 Subject: [Lldb-commits] [lldb] r147789 - /lldb/trunk/test/types/AbstractBase.py Message-ID: <20120109191923.5D8BD1BE003@llvm.org> Author: johnny Date: Mon Jan 9 13:19:23 2012 New Revision: 147789 URL: http://llvm.org/viewvc/llvm-project?rev=147789&view=rev Log: Fix comment. Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=147789&r1=147788&r2=147789&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Mon Jan 9 13:19:23 2012 @@ -148,7 +148,7 @@ self.runCmd("expression %s" % var) output = self.res.GetOutput() - # The input type is in a canonical form as a set named atoms. + # The input type is in a canonical form as a set of named atoms. # The display type string must conatin each and every element. # # Example: From gclayton at apple.com Mon Jan 9 13:23:34 2012 From: gclayton at apple.com (Greg Clayton) Date: Mon, 09 Jan 2012 19:23:34 -0000 Subject: [Lldb-commits] [lldb] r147790 - in /lldb/trunk: include/lldb/Target/ABI.h source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h Message-ID: <20120109192334.ECC231BE003@llvm.org> Author: gclayton Date: Mon Jan 9 13:23:34 2012 New Revision: 147790 URL: http://llvm.org/viewvc/llvm-project?rev=147790&view=rev Log: Fixed a return value problem with the new ABI::FixCodeAddress () function: it was checked in as: virtual bool ABI::FixCodeAddress (lldb::addr_t pc); when it should have been: virtual lldb::addr_t ABI::FixCodeAddress (lldb::addr_t pc); Modified: lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=147790&r1=147789&r2=147790&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Mon Jan 9 13:23:34 2012 @@ -76,7 +76,7 @@ virtual bool CodeAddressIsValid (lldb::addr_t pc) = 0; - virtual bool + virtual lldb::addr_t FixCodeAddress (lldb::addr_t pc) { // Some targets might use bits in a code address to indicate Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h?rev=147790&r1=147789&r2=147790&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h Mon Jan 9 13:23:34 2012 @@ -82,7 +82,7 @@ return pc <= UINT32_MAX; } - virtual bool + virtual lldb::addr_t FixCodeAddress (lldb::addr_t pc) { // ARM uses bit zero to signify a code address is thumb, so we must From scallanan at apple.com Mon Jan 9 13:41:29 2012 From: scallanan at apple.com (Sean Callanan) Date: Mon, 09 Jan 2012 19:41:29 -0000 Subject: [Lldb-commits] [lldb] r147794 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20120109194129.2716C1BE003@llvm.org> Author: spyffe Date: Mon Jan 9 13:41:28 2012 New Revision: 147794 URL: http://llvm.org/viewvc/llvm-project?rev=147794&view=rev Log: Updating Xcode project version numbers for lldb-102 and debugserver-161 Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=147794&r1=147793&r2=147794&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Jan 9 13:41:28 2012 @@ -3733,9 +3733,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 101; + DYLIB_CURRENT_VERSION = 102; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3793,10 +3793,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 101; + DYLIB_CURRENT_VERSION = 102; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3852,8 +3852,8 @@ 2689FFD513353D7A00698AC0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 101; - DYLIB_CURRENT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; + DYLIB_CURRENT_VERSION = 102; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3881,8 +3881,8 @@ 2689FFD613353D7A00698AC0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 101; - DYLIB_CURRENT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; + DYLIB_CURRENT_VERSION = 102; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3910,8 +3910,8 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 101; - DYLIB_CURRENT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; + DYLIB_CURRENT_VERSION = 102; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3991,7 +3991,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4022,10 +4022,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 101; + DYLIB_CURRENT_VERSION = 102; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4269,7 +4269,7 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4299,7 +4299,7 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=147794&r1=147793&r2=147794&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Mon Jan 9 13:41:28 2012 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 101 + 102 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=147794&r1=147793&r2=147794&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Mon Jan 9 13:41:28 2012 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 160; + CURRENT_PROJECT_VERSION = 161; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = ""; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 160; + CURRENT_PROJECT_VERSION = 161; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 160; + CURRENT_PROJECT_VERSION = 161; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -534,7 +534,7 @@ "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 160; + CURRENT_PROJECT_VERSION = 161; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -577,7 +577,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 160; + CURRENT_PROJECT_VERSION = 161; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -620,7 +620,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 160; + CURRENT_PROJECT_VERSION = 161; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From scallanan at apple.com Mon Jan 9 13:42:16 2012 From: scallanan at apple.com (Sean Callanan) Date: Mon, 09 Jan 2012 19:42:16 -0000 Subject: [Lldb-commits] [lldb] r147795 - /lldb/tags/lldb-102/ Message-ID: <20120109194216.6E7941BE003@llvm.org> Author: spyffe Date: Mon Jan 9 13:42:16 2012 New Revision: 147795 URL: http://llvm.org/viewvc/llvm-project?rev=147795&view=rev Log: lldb-102 Added: lldb/tags/lldb-102/ - copied from r147794, lldb/trunk/ From gclayton at apple.com Mon Jan 9 17:59:30 2012 From: gclayton at apple.com (Greg Clayton) Date: Mon, 09 Jan 2012 23:59:30 -0000 Subject: [Lldb-commits] [lldb] r147813 - /lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Message-ID: <20120109235930.415E31BE003@llvm.org> Author: gclayton Date: Mon Jan 9 17:59:30 2012 New Revision: 147813 URL: http://llvm.org/viewvc/llvm-project?rev=147813&view=rev Log: Make a log timer for the BSD archive creation so we can track the time it takes to open and index BSD archives. Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp?rev=147813&r1=147812&r2=147813&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (original) +++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Mon Jan 9 17:59:30 2012 @@ -16,6 +16,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/RegularExpression.h" +#include "lldb/Core/Timer.h" #include "lldb/Host/Mutex.h" #include "lldb/Symbol/ObjectFile.h" @@ -265,31 +266,39 @@ Module* module, DataBufferSP& data_sp, const FileSpec *file, - addr_t offset, - addr_t length) + addr_t file_offset, + addr_t file_size) { if (file && data_sp && ObjectContainerBSDArchive::MagicBytesMatch(data_sp)) { - Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, module->GetArchitecture(), module->GetModificationTime())); - - if (archive_sp) + Timer scoped_timer (__PRETTY_FUNCTION__, + "ObjectContainerBSDArchive::CreateInstance (module = %s/%s, file = %p, file_offset = 0x%z8.8x, file_size = 0x%z8.8x)", + module->GetFileSpec().GetDirectory().AsCString(), + module->GetFileSpec().GetFilename().AsCString(), + file, file_offset, file_size); + + std::auto_ptr container_ap(new ObjectContainerBSDArchive (module, data_sp, file, file_offset, file_size)); + + if (container_ap.get()) { - // We already have this archive in our cache, use it - std::auto_ptr container_ap(new ObjectContainerBSDArchive (module, data_sp, file, offset, length)); - if (container_ap.get()) + Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, module->GetArchitecture(), module->GetModificationTime())); + + if (archive_sp) { + // We already have this archive in our cache, use it container_ap->SetArchive (archive_sp); return container_ap.release(); } + else + { + // Read everything since we need that in order to index all the + // objects in the archive + data_sp = file->MemoryMapFileContents (file_offset, file_size); + + if (container_ap->ParseHeader()) + return container_ap.release(); + } } - - // Read everything since we need that in order to index all the - // objects in the archive - data_sp = file->MemoryMapFileContents (offset, length); - - std::auto_ptr container_ap(new ObjectContainerBSDArchive (module, data_sp, file, offset, length)); - if (container_ap->ParseHeader()) - return container_ap.release(); } return NULL; } From gclayton at apple.com Mon Jan 9 18:00:16 2012 From: gclayton at apple.com (Greg Clayton) Date: Tue, 10 Jan 2012 00:00:16 -0000 Subject: [Lldb-commits] [lldb] r147814 - /lldb/trunk/test/make/Makefile.rules Message-ID: <20120110000016.20C4A1BE003@llvm.org> Author: gclayton Date: Mon Jan 9 18:00:15 2012 New Revision: 147814 URL: http://llvm.org/viewvc/llvm-project?rev=147814&view=rev Log: Update makefile rules to support C++ files in shared libraries and fix how the linker driver is found. Modified: lldb/trunk/test/make/Makefile.rules Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=147814&r1=147813&r2=147814&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Mon Jan 9 18:00:15 2012 @@ -69,7 +69,7 @@ cxx_compiler = $(if $(findstring clang,$(1)), $(subst clang,clang++,$(1)), $(if $(findstring llvm-gcc,$(1)), $(subst llvm-gcc,llvm-g++,$(1)), $(subst gcc,g++,$(1)))) # Function that returns the C++ linker, given $(CC) as arg. -cxx_linker = $(if $(findstring clang,$(1)), $(subst clang,g++,$(1)), $(if $(findstring llvm-gcc,$(1)), $(subst llvm-gcc,g++,$(1)), $(subst gcc,g++,$(1)))) +cxx_linker = $(if $(findstring clang,$(1)), $(subst clang,clang++,$(1)), $(if $(findstring llvm-gcc,$(1)), $(subst llvm-gcc,llvm-g++,$(1)), $(subst gcc,g++,$(1)))) #---------------------------------------------------------------------- # dylib settings @@ -78,6 +78,11 @@ DYLIB_OBJECTS +=$(strip $(DYLIB_C_SOURCES:.c=.o)) endif +ifneq "$(strip $(DYLIB_CXX_SOURCES))" "" + DYLIB_OBJECTS +=$(strip $(DYLIB_CXX_SOURCES:.cpp=.o)) + CXX = $(call cxx_compiler,$(CC)) + LD = $(call cxx_linker,$(CC)) +endif #---------------------------------------------------------------------- # Check if we have any C source files From gclayton at apple.com Mon Jan 9 18:25:18 2012 From: gclayton at apple.com (Greg Clayton) Date: Tue, 10 Jan 2012 00:25:18 -0000 Subject: [Lldb-commits] [lldb] r147815 - /lldb/trunk/source/Commands/CommandObjectTarget.cpp Message-ID: <20120110002518.F3E361BE003@llvm.org> Author: gclayton Date: Mon Jan 9 18:25:18 2012 New Revision: 147815 URL: http://llvm.org/viewvc/llvm-project?rev=147815&view=rev Log: When doing a "target modules lookup --address ", show the file address in the module when dumping the information in addition to all info that we were previously showing. 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=147815&r1=147814&r2=147815&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Mon Jan 9 18:25:18 2012 @@ -1337,15 +1337,13 @@ return false; } - // If an offset was given, print out the address we ended up looking up - if (offset) - strm.Printf("File Address: 0x%llx\n", addr); - ExecutionContextScope *exe_scope = interpreter.GetExecutionContext().GetBestExecutionContextScope(); strm.IndentMore(); strm.Indent (" Address: "); + so_addr.Dump (&strm, exe_scope, Address::DumpStyleModuleWithFileAddress); + strm.PutCString (" ("); so_addr.Dump (&strm, exe_scope, Address::DumpStyleSectionNameOffset); - strm.EOL(); + strm.PutCString (")\n"); strm.Indent (" Summary: "); const uint32_t save_indent = strm.GetIndentLevel (); strm.SetIndentLevel (save_indent + 13); From gclayton at apple.com Mon Jan 9 18:29:37 2012 From: gclayton at apple.com (Greg Clayton) Date: Tue, 10 Jan 2012 00:29:37 -0000 Subject: [Lldb-commits] [lldb] r147816 - in /lldb/trunk/examples/interposing: ./ darwin/ darwin/fd_interposing/ darwin/fd_interposing/FDInterposing.cpp darwin/fd_interposing/Makefile Message-ID: <20120110002937.269F81BE003@llvm.org> Author: gclayton Date: Mon Jan 9 18:29:36 2012 New Revision: 147816 URL: http://llvm.org/viewvc/llvm-project?rev=147816&view=rev Log: Added a file descriptor interposing library for darwin. This can catch all functions that can create file descriptors and close them. It will warn when there close file descriptor call that returns with EBADF and show the corresponding stack backtraces that caused the issue. It will also log all file descriptor create and delete calls. See the comments at the top of FDInterposing.cpp for all of the details. Added: lldb/trunk/examples/interposing/ lldb/trunk/examples/interposing/darwin/ lldb/trunk/examples/interposing/darwin/fd_interposing/ lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile Added: lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp?rev=147816&view=auto ============================================================================== --- lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp (added) +++ lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp Mon Jan 9 18:29:36 2012 @@ -0,0 +1,972 @@ +//===-- FDInterposing.cpp ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file helps with catching double close calls on unix integer file +// descriptors by interposing functions for all file descriptor create and +// close operations. A stack backtrace for every create and close function is +// maintained, and every create and close operation is logged. When a double +// file descriptor close is encountered, it will be logged. +// +// To enable the interposing in a darwin program, set the DYLD_INSERT_LIBRARIES +// environment variable as follows: +// For sh: +// DYLD_INSERT_LIBRARIES=/path/to/FDInterposing.dylib /path/to/executable +// For tcsh: +// (setenv DYLD_INSERT_LIBRARIES=/path/to/FDInterposing.dylib ; /path/to/executable) +// +// Other environment variables that can alter the default actions of this +// interposing shared library include: +// +// "FileDescriptorStackLoggingNoCompact" +// +// With this environment variable set, all file descriptor create and +// delete operations will be permanantly maintained in the event map. +// The default action is to compact the create/delete events by removing +// any previous file descriptor create events that are matched with a +// corresponding file descriptor delete event when the next valid file +// descriptor create event is detected. +// +// "FileDescriptorMinimalLogging" +// +// By default every file descriptor create and delete operation is logged +// (to STDOUT by default, see the "FileDescriptorLogFile"). This can be +// suppressed to only show errors and warnings by setting this environment +// variable (the value in not important). +// +// "FileDescriptorLogFile=" +// +// By default logging goes to STDOUT_FILENO, but this can be changed by +// setting FileDescriptorLogFile. The value is a path to a file that +// will be opened and used for logging. +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // for std::tr1::shared_ptr +#include +#include +#include +#include + +//---------------------------------------------------------------------- +/// @def DISALLOW_COPY_AND_ASSIGN(TypeName) +/// Macro definition for easily disallowing copy constructor and +/// assignment operators in C++ classes. +//---------------------------------------------------------------------- +#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ +TypeName(const TypeName&); \ +const TypeName& operator=(const TypeName&) + +namespace fd_interposing { + +//---------------------------------------------------------------------- +// String class so we can get formatted strings without having to worry +// about the memory storage since it will allocate the memory it needs. +//---------------------------------------------------------------------- +class String +{ +public: + String () : + m_str (NULL) + {} + + String (const char *format, ...) : + m_str (NULL) + { + va_list args; + va_start (args, format); + vprintf (format, args); + va_end (args); + } + + ~String() + { + reset(); + } + + void + reset (char *s = NULL) + { + if (m_str) + ::free (m_str); + m_str = s; + } + + const char * + c_str () const + { + return m_str; + } + + void + printf (const char *format, ...) + { + va_list args; + va_start (args, format); + vprintf (format, args); + va_end (args); + } + void + vprintf (const char *format, va_list args) + { + reset(); + ::vasprintf (&m_str, format, args); + } + + void + log (int log_fd) + { + if (m_str && log_fd >= 0) + { + const int len = strlen(m_str); + if (len > 0) + { + write (log_fd, m_str, len); + const char last_char = m_str[len-1]; + if (!(last_char == '\n' || last_char == '\r')) + write (log_fd, "\n", 1); + } + } + } +protected: + char *m_str; + +private: + DISALLOW_COPY_AND_ASSIGN (String); +}; + +//---------------------------------------------------------------------- +// Type definitions +//---------------------------------------------------------------------- +typedef std::vector Frames; +class FDEvent; +typedef std::vector Frames; +typedef std::tr1::shared_ptr FDEventSP; +typedef std::tr1::shared_ptr StringSP; + + +//---------------------------------------------------------------------- +// FDEvent +// +// A class that describes a file desciptor event. +// +// File descriptor events fall into one of two categories: create events +// and delete events. +//---------------------------------------------------------------------- +class FDEvent +{ +public: + FDEvent (int fd, int err, const StringSP &string_sp, bool is_create, const Frames& frames) : + m_string_sp (string_sp), + m_frames (frames.begin(), frames.end()), + m_fd (fd), + m_err (err), + m_is_create (is_create) + {} + + ~FDEvent () {} + + bool + IsCreateEvent() const + { + return m_is_create; + } + + bool + IsDeleteEvent() const + { + return !m_is_create; + } + + Frames & + GetFrames () + { + return m_frames; + } + + const Frames & + GetFrames () const + { + return m_frames; + } + + int + GetFD () const + { + return m_fd; + } + + int + GetError () const + { + return m_err; + } + + void + Dump (int log_fd) const; + + void + SetCreateEvent (FDEventSP &create_event_sp) + { + m_create_event_sp = create_event_sp; + } + +private: + // A shared pointer to a String that describes this event in + // detail (all args and return and error values) + StringSP m_string_sp; + // The frames for the stack backtrace for this event + Frames m_frames; + // If this is a file descriptor delete event, this might contain + // the correspoding file descriptor create event + FDEventSP m_create_event_sp; + // The file descriptor for this event + int m_fd; + // The error code (if any) for this event + int m_err; + // True if this event is a file descriptor create event, false + // if it is a file descriptor delete event + bool m_is_create; +}; + +//---------------------------------------------------------------------- +// Templatized class that will save errno only if the "value" it is +// constructed with is equal to INVALID. When the class goes out of +// scope, it will restore errno if it was saved. +//---------------------------------------------------------------------- +template +class Errno +{ +public: + // Save errno only if we are supposed to + Errno (int value) : + m_saved_errno ((value == INVALID) ? errno : 0), + m_restore (value == INVALID) + { + } + + // Restore errno only if we are supposed to + ~Errno() + { + if (m_restore) + errno = m_saved_errno; + } + + // Accessor for the saved value of errno + int + get_errno() const + { + return m_saved_errno; + } + +protected: + const int m_saved_errno; + const bool m_restore; +}; + +typedef Errno<-1> InvalidFDErrno; +typedef Errno<-1> NegativeErrorErrno; +typedef std::vector FDEventArray; +typedef std::map FDEventMap; + +//---------------------------------------------------------------------- +// Globals +//---------------------------------------------------------------------- +// Global event map that contains all file descriptor events. As file +// descriptor create and close events come in, they will get filled +// into this map (protected by g_mutex). When a file descriptor close +// event is detected, the open event will be removed and placed into +// the close event so if something tries to double close a file +// descriptor we can show the previous close event and the file +// desctiptor event that created it. When a new file descriptor create +// event comes in, we will remove the previous one for that file +// desctiptor unless the environment variable "FileDescriptorStackLoggingNoCompact" +// is set. The file desctiptor history can be accessed using the +// get_fd_history() function. +static FDEventMap g_fd_event_map; +// A mutex to protect access to our data structures in g_fd_event_map +// and also our logging messages +static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; +// Log all file descriptor create and close events by default. Only log +// warnings and erros if the "FileDescriptorMinimalLogging" environment +// variable is set. +static int g_log_all_calls = 1; +// We compact the file descriptor events by default. Set the environment +// varible "FileDescriptorStackLoggingNoCompact" to keep a full history. +static int g_compact = 1; + +//---------------------------------------------------------------------- +// Mutex class that will lock a mutex when it is constructed, and unlock +// it when is goes out of scope +//---------------------------------------------------------------------- +class Locker +{ +public: + Locker (pthread_mutex_t *mutex_ptr) : + m_mutex_ptr(mutex_ptr) + { + ::pthread_mutex_lock (m_mutex_ptr); + } + + // This allows clients to test try and acquire the mutex... + Locker (pthread_mutex_t *mutex_ptr, bool &lock_acquired) : + m_mutex_ptr(NULL) + { + lock_acquired = ::pthread_mutex_trylock(mutex_ptr) == 0; + if (lock_acquired) + m_mutex_ptr = mutex_ptr; + } + + ~Locker () + { + if (m_mutex_ptr) + ::pthread_mutex_unlock (m_mutex_ptr); + } +protected: + pthread_mutex_t *m_mutex_ptr; +}; + +static void +log (const char *format, ...) __attribute__ ((format (printf, 1, 2))); + +static void +log (int log_fd, const FDEvent *event, const char *format, ...) __attribute__ ((format (printf, 3, 4))); + +static void +backtrace_log (const char *format, ...) __attribute__ ((format (printf, 1, 2))); + +static void +log_to_fd (int log_fd, const char *format, ...) __attribute__ ((format (printf, 2, 3))); + +static inline size_t +get_backtrace (Frames &frame_buffer, size_t frames_to_remove) +{ + void *frames[2048]; + int count = ::backtrace (&frames[0], sizeof(frames)/sizeof(void*)); + if (count > frames_to_remove) + frame_buffer.assign (&frames[frames_to_remove], &frames[count]); + else + frame_buffer.assign (&frames[0], &frames[count]); + while (frame_buffer.back() < (void *)1024) + frame_buffer.pop_back(); + return frame_buffer.size(); +} + +static int +get_logging_fd () +{ + static int g_log_fd = STDOUT_FILENO; + static char program_fullpath[PATH_MAX]; + static int initialized = 0; + + const int pid = getpid(); + + if (!initialized) + { + initialized = 1; + + // Keep all stack info around for all fd create and delete calls. + // Otherwise we will remove the fd create call when a corresponding + // fd delete call is received + if (getenv("FileDescriptorStackLoggingNoCompact")) + g_compact = 0; + + if (getenv("FileDescriptorMinimalLogging")) + g_log_all_calls = 0; + + char program_basename[PATH_MAX]; + // If DST is NULL, then return the number of bytes needed. + uint32_t len = sizeof(program_fullpath); + if (_NSGetExecutablePath (program_fullpath, &len) == 0) + { + strncpy (program_basename, program_fullpath, sizeof(program_basename)); + const char *program_basename_cstr = basename(program_basename); + if (program_basename_cstr) + { + // Only let this interposing happen on the first time this matches + // and stop this from happening so any child processes don't also + // log their file descriptors + ::unsetenv ("DYLD_INSERT_LIBRARIES"); + const char *log_path = getenv ("FileDescriptorLogFile"); + if (log_path) + g_log_fd = ::creat (log_path, 0660); + if (g_log_fd >= 0) + log ("Logging file descriptor functions process '%s' (pid = %i)\n", program_fullpath, pid); + } + } + } + return g_log_fd; +} + +void +log_to_fd (int log_fd, const char *format, va_list args) +{ + if (format && format[0] && log_fd >= 0) + { + char buffer[PATH_MAX]; + const int count = ::vsnprintf (buffer, sizeof(buffer), format, args); + if (count > 0) + write (log_fd, buffer, count); + } +} + +void +log_to_fd (int log_fd, const char *format, ...) +{ + if (format && format[0]) + { + va_list args; + va_start (args, format); + log_to_fd (log_fd, format, args); + va_end (args); + } +} + +void +log (const char *format, va_list args) +{ + log_to_fd (get_logging_fd (), format, args); +} + +void +log (const char *format, ...) +{ + if (format && format[0]) + { + va_list args; + va_start (args, format); + log (format, args); + va_end (args); + } +} + +void +log (int log_fd, const FDEvent *event, const char *format, ...) +{ + if (format && format[0]) + { + va_list args; + va_start (args, format); + log_to_fd (log_fd, format, args); + va_end (args); + } + if (event) + event->Dump(log_fd); +} + +void +FDEvent::Dump (int log_fd) const +{ + if (log_fd >= 0) + { + log_to_fd (log_fd, "%s\n", m_string_sp->c_str()); + if (!m_frames.empty()) + ::backtrace_symbols_fd (m_frames.data(), m_frames.size(), log_fd); + + if (m_create_event_sp) + { + log_to_fd (log_fd, "\nfd=%i was created with this event:\n", m_fd); + m_create_event_sp->Dump (log_fd); + log_to_fd (log_fd, "\n"); + } + } +} + + +void +backtrace_log (const char *format, ...) +{ + const int log_fd = get_logging_fd (); + if (log_fd >= 0) + { + if (format && format[0]) + { + va_list args; + va_start (args, format); + log (format, args); + va_end (args); + } + + Frames frames; + if (get_backtrace(frames, 3)) + ::backtrace_symbols_fd (frames.data(), frames.size(), log_fd); + } + +} + +void +save_backtrace (int fd, int err, const StringSP &string_sp, bool is_create); + +void +save_backtrace (int fd, int err, const StringSP &string_sp, bool is_create) +{ + Frames frames; + get_backtrace(frames, 2); + + FDEventSP fd_event_sp (new FDEvent (fd, err, string_sp, is_create, frames)); + + FDEventMap::iterator pos = g_fd_event_map.find (fd); + + if (pos != g_fd_event_map.end()) + { + // We have history for this fd... + + FDEventArray &event_array = g_fd_event_map[fd]; + if (fd_event_sp->IsCreateEvent()) + { + // The current fd event is a function that creates + // a descriptor, check in case last event was + // a create event. + if (event_array.back()->IsCreateEvent()) + { + const int log_fd = get_logging_fd(); + // Two fd create functions in a row, we missed + // a function that closes a fd... + log (log_fd, fd_event_sp.get(), "\nwarning: unmatched file descriptor create event fd=%i (we missed a file descriptor close event):\n", fd); + } + else if (g_compact) + { + // We are compacting so we remove previous create event + // when we get the correspinding delete event + event_array.pop_back(); + } + } + else + { + // The current fd event is a function that deletes + // a descriptor, check in case last event for this + // fd was a delete event (double close!) + if (event_array.back()->IsDeleteEvent()) + { + const int log_fd = get_logging_fd(); + // Two fd delete functions in a row, we must + // have missed some function that opened a descriptor + log (log_fd, fd_event_sp.get(), "\nwarning: unmatched file descriptor close event for fd=%d (we missed the file descriptor create event):\n", fd); + } + else if (g_compact) + { + // Since this is a close event, we want to remember the open event + // that this close if for... + fd_event_sp->SetCreateEvent(event_array.back()); + // We are compacting so we remove previous create event + // when we get the correspinding delete event + event_array.pop_back(); + } + } + + event_array.push_back(fd_event_sp); + } + else + { + g_fd_event_map[fd].push_back(fd_event_sp); + } +} + +//---------------------------------------------------------------------- +// socket() interpose function +//---------------------------------------------------------------------- +extern "C" int +socket$__interposed__ (int domain, int type, int protocol) +{ + Locker locker (&g_mutex); + const int fd = ::socket (domain, type, protocol); + InvalidFDErrno fd_errno(fd); + StringSP description_sp(new String); + if (fd == -1) + description_sp->printf("socket (domain = %i, type = %i, protocol = %i) => fd=%i errno = %i", domain, type, protocol, fd, fd_errno.get_errno()); + else + description_sp->printf("socket (domain = %i, type = %i, protocol = %i) => fd=%i", domain, type, protocol, fd); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fd >= 0) + save_backtrace (fd, fd_errno.get_errno(), description_sp, true); + return fd; +} + +//---------------------------------------------------------------------- +// socketpair() interpose function +//---------------------------------------------------------------------- +extern "C" int +socketpair$__interposed__ (int domain, int type, int protocol, int fds[2]) +{ + Locker locker (&g_mutex); + fds[0] = -1; + fds[1] = -1; + const int err = socketpair (domain, type, protocol, fds); + NegativeErrorErrno err_errno(err); + StringSP description_sp(new String ("socketpair (domain=%i, type=%i, protocol=%i, {fd=%i, fd=%i}) -> err=%i", domain, type, protocol, fds[0], fds[1], err)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fds[0] >= 0) + save_backtrace (fds[0], err_errno.get_errno(), description_sp, true); + if (fds[1] >= 0) + save_backtrace (fds[1], err_errno.get_errno(), description_sp, true); + return err; +} + +//---------------------------------------------------------------------- +// open() interpose function +//---------------------------------------------------------------------- +extern "C" int +open$__interposed__ (const char *path, int oflag, int mode) +{ + Locker locker (&g_mutex); + int fd = -2; + StringSP description_sp(new String); + if (oflag & O_CREAT) + { + fd = open (path, oflag, mode); + description_sp->printf("open (path = '%s', oflag = %i, mode = %i) -> fd=%i", path, oflag, mode, fd); + } + else + { + fd = open (path, oflag); + description_sp->printf("open (path = '%s', oflag = %i) -> fd=%i", path, oflag, fd); + } + + InvalidFDErrno fd_errno(fd); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fd >= 0) + save_backtrace (fd, fd_errno.get_errno(), description_sp, true); + return fd; +} + +//---------------------------------------------------------------------- +// open$NOCANCEL() interpose function +//---------------------------------------------------------------------- +extern "C" int open$NOCANCEL(const char *, int, ...); +extern "C" int __open_nocancel(const char *, int, ...); +extern "C" int +open$NOCANCEL$__interposed__ (const char *path, int oflag, int mode) +{ + Locker locker (&g_mutex); + const int fd = open$NOCANCEL (path, oflag, mode); + InvalidFDErrno fd_errno(fd); + StringSP description_sp(new String ("open$NOCANCEL (path = '%s', oflag = %i, mode = %i) -> fd=%i", path, oflag, mode, fd)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fd >= 0) + save_backtrace (fd, fd_errno.get_errno(), description_sp, true); + return fd; +} + +extern "C" int __open_extended(const char *, int, uid_t, gid_t, int, struct kauth_filesec *); + +//---------------------------------------------------------------------- +// __open_extended() interpose function +//---------------------------------------------------------------------- +extern "C" int +__open_extended$__interposed__ (const char *path, int oflag, uid_t uid, gid_t gid, int mode, struct kauth_filesec *fsacl) +{ + Locker locker (&g_mutex); + const int fd = __open_extended (path, oflag, uid, gid, mode, fsacl); + InvalidFDErrno fd_errno(fd); + StringSP description_sp(new String ("__open_extended (path='%s', oflag=%i, uid=%i, gid=%i, mode=%i, fsacl=%p) -> fd=%i", path, oflag, uid, gid, mode, fsacl, fd)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fd >= 0) + save_backtrace (fd, fd_errno.get_errno(), description_sp, true); + return fd; +} + +//---------------------------------------------------------------------- +// kqueue() interpose function +//---------------------------------------------------------------------- +extern "C" int +kqueue$__interposed__ (void) +{ + Locker locker (&g_mutex); + const int fd = ::kqueue (); + InvalidFDErrno fd_errno(fd); + StringSP description_sp(new String ("kqueue () -> fd=%i", fd)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fd >= 0) + save_backtrace (fd, fd_errno.get_errno(), description_sp, true); + return fd; + +} + +//---------------------------------------------------------------------- +// shm_open() interpose function +//---------------------------------------------------------------------- +extern "C" int +shm_open$__interposed__ (const char *path, int oflag, int mode) +{ + Locker locker (&g_mutex); + const int fd = shm_open (path, oflag, mode); + InvalidFDErrno fd_errno(fd); + StringSP description_sp(new String ("shm_open (path = '%s', oflag = %i, mode = %i) -> fd=%i", path, oflag, mode, fd)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fd >= 0) + save_backtrace (fd, fd_errno.get_errno(), description_sp, true); + return fd; +} + +//---------------------------------------------------------------------- +// accept() interpose function +//---------------------------------------------------------------------- +extern "C" int +accept$__interposed__ (int socket, struct sockaddr *address, socklen_t *address_len) +{ + Locker locker (&g_mutex); + const int fd = accept (socket, address, address_len); + InvalidFDErrno fd_errno(fd); + StringSP description_sp(new String ("accept (socket=%i, ...) -> fd=%i", socket, fd)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fd >= 0) + save_backtrace (fd, fd_errno.get_errno(), description_sp, true); + return fd; +} + + +//---------------------------------------------------------------------- +// accept$NOCANCEL() interpose function +//---------------------------------------------------------------------- +extern "C" int accept$NOCANCEL (int, struct sockaddr * __restrict, socklen_t * __restrict); +extern "C" int +accept$NOCANCEL$__interposed__ (int socket, struct sockaddr *address, socklen_t *address_len) +{ + Locker locker (&g_mutex); + const int fd = accept$NOCANCEL (socket, address, address_len); + InvalidFDErrno fd_errno(fd); + StringSP description_sp(new String ("accept$NOCANCEL (socket=%i, ...) -> fd=%i", socket, fd)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fd >= 0) + save_backtrace (fd, fd_errno.get_errno(), description_sp, true); + return fd; +} + +//---------------------------------------------------------------------- +// dup() interpose function +//---------------------------------------------------------------------- +extern "C" int +dup$__interposed__ (int fd2) +{ + Locker locker (&g_mutex); + const int fd = dup (fd2); + InvalidFDErrno fd_errno(fd); + StringSP description_sp(new String ("dup (fd2=%i) -> fd=%i", fd2, fd)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fd >= 0) + save_backtrace (fd, fd_errno.get_errno(), description_sp, true); + return fd; +} + +//---------------------------------------------------------------------- +// dup2() interpose function +//---------------------------------------------------------------------- +extern "C" int +dup2$__interposed__ (int fd1, int fd2) +{ + Locker locker (&g_mutex); + + const int fd = dup2(fd1, fd2); + InvalidFDErrno fd_errno(fd); + StringSP description_sp(new String ("dup2 fd1=%i, fd2=%i) -> fd=%i", fd1, fd2, fd)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + // If "fd2" is already opened, it will be closed during the + // dup2 call below, so we need to see if we have fd2 in our + // open map and treat it as a close(fd2) + FDEventMap::iterator pos = g_fd_event_map.find (fd2); + if (pos != g_fd_event_map.end() && pos->second.back()->IsCreateEvent()) + save_backtrace (fd2, 0, description_sp, false); + + if (fd >= 0) + save_backtrace (fd, fd_errno.get_errno(), description_sp, true); + return fd; +} + +//---------------------------------------------------------------------- +// close() interpose function +//---------------------------------------------------------------------- +extern "C" int +close$__interposed__ (int fd) +{ + Locker locker (&g_mutex); + const int err = close(fd); + NegativeErrorErrno err_errno(err); + StringSP description_sp (new String); + if (err == -1) + description_sp->printf("close (fd=%i) => %i errno = %i (%s))", fd, err, err_errno.get_errno(), strerror(err_errno.get_errno())); + else + description_sp->printf("close (fd=%i) => %i", fd, err); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + + if (err == 0) + { + if (fd >= 0) + save_backtrace (fd, err, description_sp, false); + } + else if (err == -1) + { + if (err_errno.get_errno() == EBADF && fd != -1) + { + backtrace_log ("\nerror: close on fd=%d resulted in EBADF in process %i\n", fd, getpid()); + + FDEventMap::iterator pos = g_fd_event_map.find (fd); + if (pos != g_fd_event_map.end()) + { + log (get_logging_fd(), pos->second.back().get(), "\nfd=%d was previously closed with this event:\n", fd); + } + } + } + return err; +} + +//---------------------------------------------------------------------- +// close$NOCANCEL() interpose function +//---------------------------------------------------------------------- +extern "C" int close$NOCANCEL(int); +extern "C" int +close$NOCANCEL$__interposed__ (int fd) +{ + Locker locker (&g_mutex); + const int err = close$NOCANCEL(fd); + NegativeErrorErrno err_errno(err); + StringSP description_sp (new String); + if (err == -1) + description_sp->printf("close$NOCANCEL (fd=%i) => %i errno = %i (%s))", fd, err, err_errno.get_errno(), strerror(err_errno.get_errno())); + else + description_sp->printf("close$NOCANCEL (fd=%i) => %i", fd, err); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + + if (err == 0) + { + if (fd >= 0) + save_backtrace (fd, err, description_sp, false); + } + else if (err == -1) + { + if (err_errno.get_errno() == EBADF && fd != -1) + { + backtrace_log ("\nInvoking close$NOCANCEL (fd=%d) in process %i resulted in %i %s\n", fd, getpid(), err_errno.get_errno(), err_errno.get_errno() ? strerror (err_errno.get_errno()) : ""); + + FDEventMap::iterator pos = g_fd_event_map.find (fd); + if (pos != g_fd_event_map.end()) + { + log (get_logging_fd(), pos->second.back().get(), "\nPrevious close(fd=%d) was done here:\n", fd); + } + } + } + return err; + +} + +//---------------------------------------------------------------------- +// pipe() interpose function +//---------------------------------------------------------------------- +extern "C" int +pipe$__interposed__ (int fds[2]) +{ + Locker locker (&g_mutex); + fds[0] = -1; + fds[1] = -1; + const int err = pipe (fds); + const int saved_errno = errno; + StringSP description_sp(new String ("pipe ({fd=%i, fd=%i}) -> err=%i", fds[0], fds[1], err)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); + if (fds[0] >= 0) + save_backtrace (fds[0], saved_errno, description_sp, true); + if (fds[1] >= 0) + save_backtrace (fds[1], saved_errno, description_sp, true); + errno = saved_errno; + return err; +} + +//---------------------------------------------------------------------- +// get_fd_history() +// +// This function allows runtime access to the file descriptor history. +// +// @param[in] log_fd +// The file descriptor to log to +// +// @param[in] fd +// The file descriptor whose history should be dumped +//---------------------------------------------------------------------- +extern "C" void +get_fd_history (int log_fd, int fd) +{ + // "create" below needs to be outside of the mutex locker scope + if (log_fd >= 0) + { + bool got_lock = false; + Locker locker (&g_mutex, got_lock); + if (got_lock) + { + FDEventMap::iterator pos = g_fd_event_map.find (fd); + log_to_fd (log_fd, "Dumping file descriptor history for fd=%i:\n", fd); + if (pos != g_fd_event_map.end()) + { + FDEventArray &event_array = g_fd_event_map[fd]; + const size_t num_events = event_array.size(); + for (size_t i=0; iDump (log_fd); + } + else + { + log_to_fd (log_fd, "error: no file descriptor events found for fd=%i\n", fd); + } + } + else + { + log_to_fd (log_fd, "error: fd event mutex is locked...\n"); + } + } +} + +//---------------------------------------------------------------------- +// Interposing +//---------------------------------------------------------------------- +// FD creation routines +DYLD_INTERPOSE(accept$__interposed__, accept); +DYLD_INTERPOSE(accept$NOCANCEL$__interposed__, accept$NOCANCEL); +DYLD_INTERPOSE(dup$__interposed__, dup); +DYLD_INTERPOSE(dup2$__interposed__, dup2); +DYLD_INTERPOSE(kqueue$__interposed__, kqueue); +DYLD_INTERPOSE(open$__interposed__, open); +DYLD_INTERPOSE(open$NOCANCEL$__interposed__, open$NOCANCEL); +DYLD_INTERPOSE(open$NOCANCEL$__interposed__, __open_nocancel); +DYLD_INTERPOSE(__open_extended$__interposed__, __open_extended); +DYLD_INTERPOSE(pipe$__interposed__, pipe); +DYLD_INTERPOSE(shm_open$__interposed__, shm_open); +DYLD_INTERPOSE(socket$__interposed__, socket); +DYLD_INTERPOSE(socketpair$__interposed__, socketpair); + +// FD deleting routines +DYLD_INTERPOSE(close$__interposed__, close); +DYLD_INTERPOSE(close$NOCANCEL$__interposed__, close$NOCANCEL); + +} // namespace fd_interposing + + Added: lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile?rev=147816&view=auto ============================================================================== --- lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile (added) +++ lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile Mon Jan 9 18:29:36 2012 @@ -0,0 +1,7 @@ +LEVEL = ../../../../test/make + +DYLIB_NO_EXECUTABLE := YES +DYLIB_NAME := FDInterposing +DYLIB_CXX_SOURCES := FDInterposing.cpp + +include $(LEVEL)/Makefile.rules From johnny.chen at apple.com Mon Jan 9 18:41:11 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 Jan 2012 00:41:11 -0000 Subject: [Lldb-commits] [lldb] r147821 - /lldb/trunk/test/make/Makefile.rules Message-ID: <20120110004111.D7C0C1BE003@llvm.org> Author: johnny Date: Mon Jan 9 18:41:11 2012 New Revision: 147821 URL: http://llvm.org/viewvc/llvm-project?rev=147821&view=rev Log: Add a CFLAGS_EXTRAS make variable to be able to pass things (like '-DTEST_BLOCK_CAPTURED_VARS') to the compile phase. Plus add a DYLIB_ONLY make variable that can be used to turn off compilation/building of a.out. Example: [16:39:21] johnny:/Volumes/data/lldb/svn/trunk/test/lang/c/global_variables $ make clean rm -rf "a.out" "a.out.dSYM" main.o main.d a.o a.d liba.dylib liba.dylib.dSYM [16:39:24] johnny:/Volumes/data/lldb/svn/trunk/test/lang/c/global_variables $ make DYLIB_ONLY=YES clang -gdwarf-2 -O0 -arch x86_64 -c -o a.o a.c clang -gdwarf-2 -O0 -arch x86_64 a.o -install_name "@executable_path/liba.dylib" -dynamiclib -o "liba.dylib" [16:39:30] johnny:/Volumes/data/lldb/svn/trunk/test/lang/c/global_variables $ Modified: lldb/trunk/test/make/Makefile.rules Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=147821&r1=147820&r2=147821&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Mon Jan 9 18:41:11 2012 @@ -42,7 +42,7 @@ # Change any build/tool options needed #---------------------------------------------------------------------- CFLAGS ?= -gdwarf-2 -O0 -CFLAGS += $(FRAMEWORK_INCLUDES) +CFLAGS += $(FRAMEWORK_INCLUDES) $(CFLAGS_EXTRAS) ifeq "$(OS)" "Darwin" CFLAGS += -arch $(ARCH) DS := dsymutil @@ -122,24 +122,36 @@ #---------------------------------------------------------------------- +# DYLIB_ONLY variable can be used to skip the building of a.out. +# See the sections below regarding dSYM file as well as the building of +# EXE from all the objects. +#---------------------------------------------------------------------- + +#---------------------------------------------------------------------- # Make the dSYM file from the executable if $(MAKE_DSYM) != "NO" #---------------------------------------------------------------------- ifeq "$(OS)" "Darwin" ifneq "$(MAKE_DSYM)" "NO" +ifeq "$(DYLIB_ONLY)" "" $(DSYM) : $(EXE) $(DS) $(DSFLAGS) -o "$(DSYM)" "$(EXE)" endif endif +endif #---------------------------------------------------------------------- # Compile the executable from all the objects. #---------------------------------------------------------------------- -ifeq "$(DYLIB_NAME)" "" -$(EXE) : $(OBJECTS) - $(LD) $(LDFLAGS) $(OBJECTS) -o "$(EXE)" -else +ifneq "$(DYLIB_NAME)" "" +ifeq "$(DYLIB_ONLY)" "" $(EXE) : $(OBJECTS) $(DYLIB_FILENAME) $(LD) $(LDFLAGS) $(OBJECTS) -L. -l$(DYLIB_NAME) -o "$(EXE)" +else +EXE = $(DYLIB_FILENAME) +endif +else +$(EXE) : $(OBJECTS) + $(LD) $(LDFLAGS) $(OBJECTS) -o "$(EXE)" endif #---------------------------------------------------------------------- From johnny.chen at apple.com Mon Jan 9 19:29:35 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 Jan 2012 01:29:35 -0000 Subject: [Lldb-commits] [lldb] r147823 - /lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile Message-ID: <20120110012935.9008B1BE003@llvm.org> Author: johnny Date: Mon Jan 9 19:29:35 2012 New Revision: 147823 URL: http://llvm.org/viewvc/llvm-project?rev=147823&view=rev Log: Fix make errors (define the DYLIB_ONLY make variable). Modified: lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile Modified: lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile?rev=147823&r1=147822&r2=147823&view=diff ============================================================================== --- lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile (original) +++ lldb/trunk/examples/interposing/darwin/fd_interposing/Makefile Mon Jan 9 19:29:35 2012 @@ -1,7 +1,7 @@ LEVEL = ../../../../test/make -DYLIB_NO_EXECUTABLE := YES DYLIB_NAME := FDInterposing +DYLIB_ONLY := YES DYLIB_CXX_SOURCES := FDInterposing.cpp include $(LEVEL)/Makefile.rules From johnny.chen at apple.com Mon Jan 9 20:04:05 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 Jan 2012 02:04:05 -0000 Subject: [Lldb-commits] [lldb] r147828 - in /lldb/trunk/test/types: AbstractBase.py TestFloatTypes.py TestFloatTypesExpr.py TestIntegerTypes.py TestIntegerTypesExpr.py basic_type.cpp Message-ID: <20120110020405.2B2121BE003@llvm.org> Author: johnny Date: Mon Jan 9 20:04:04 2012 New Revision: 147828 URL: http://llvm.org/viewvc/llvm-project?rev=147828&view=rev Log: Refactor the test/types directory to reduce some stupid reduant code. Also add test cases to the test suite to exercise displaying of variables captured inside a block (Darwin-only). Modified: lldb/trunk/test/types/AbstractBase.py lldb/trunk/test/types/TestFloatTypes.py lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypes.py lldb/trunk/test/types/TestIntegerTypesExpr.py lldb/trunk/test/types/basic_type.cpp Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=147828&r1=147827&r2=147828&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Mon Jan 9 20:04:04 2012 @@ -29,7 +29,31 @@ # used for all the test cases. self.exe_name = self.testMethodName - def generic_type_tester(self, exe_name, atoms, quotedDisplay=False): + # bc -> blockCaptured + # qd -> quotedDisplay + + def build_and_run(self, source, atoms, dsym=True, bc=False, qd=False): + self.build_and_run_with_source_atoms_expr(source, atoms, expr=False, dsym=dsym, bc=bc, qd=qd) + + def build_and_run_expr(self, source, atoms, dsym=True, bc=False, qd=False): + self.build_and_run_with_source_atoms_expr(source, atoms, expr=True, dsym=dsym, bc=bc, qd=qd) + + def build_and_run_with_source_atoms_expr(self, source, atoms, expr, dsym=True, bc=False, qd=False): + if bc: + d = {'CXX_SOURCES': source, 'EXE': self.exe_name, 'CFLAGS_EXTRAS': '-DTEST_BLOCK_CAPTURED_VARS'} + else: + d = {'CXX_SOURCES': source, 'EXE': self.exe_name} + if dsym: + self.buildDsym(dictionary=d) + else: + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + if expr: + self.generic_type_expr_tester(self.exe_name, atoms, blockCaptured=bc, quotedDisplay=qd) + else: + self.generic_type_tester(self.exe_name, atoms, blockCaptured=bc, quotedDisplay=qd) + + def generic_type_tester(self, exe_name, atoms, quotedDisplay=False, blockCaptured=False): """Test that variables with basic types are displayed correctly.""" # First, capture the golden output emitted by the oracle, i.e., the @@ -44,6 +68,9 @@ # variable = 'value' # for line in go.split(os.linesep): + # We'll ignore variables of array types from inside a block. + if blockCaptured and '[' in line: + continue match = self.pattern.search(line) if match: var, val = match.group(1), match.group(2) @@ -53,15 +80,18 @@ # Bring the program to the point where we can issue a series of # 'frame variable -T' command. self.runCmd("file %s" % exe_name, CURRENT_EXECUTABLE_SET) - puts_line = line_number ("basic_type.cpp", "// Here is the line we will break on to check variables") - self.expect("breakpoint set -f basic_type.cpp -l %d" % puts_line, + if blockCaptured: + break_line = line_number ("basic_type.cpp", "// Break here to test block captured variables.") + else: + break_line = line_number ("basic_type.cpp", "// Here is the line we will break on to check variables.") + self.expect("breakpoint set -f basic_type.cpp -l %d" % break_line, BREAKPOINT_CREATED, startstr = "Breakpoint created: 1: file ='basic_type.cpp', line = %d, locations = 1" % - puts_line) + break_line) self.runCmd("run", RUN_SUCCEEDED) self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, - substrs = [" at basic_type.cpp:%d" % puts_line, + substrs = [" at basic_type.cpp:%d" % break_line, "stop reason = breakpoint"]) #self.runCmd("frame variable -T") @@ -96,7 +126,7 @@ self.expect(output, Msg(var, val, True), exe=False, substrs = [nv]) - def generic_type_expr_tester(self, exe_name, atoms, quotedDisplay=False): + def generic_type_expr_tester(self, exe_name, atoms, quotedDisplay=False, blockCaptured=False): """Test that variable expressions with basic types are evaluated correctly.""" # First, capture the golden output emitted by the oracle, i.e., the @@ -111,6 +141,9 @@ # variable = 'value' # for line in go.split(os.linesep): + # We'll ignore variables of array types from inside a block. + if blockCaptured and '[' in line: + continue match = self.pattern.search(line) if match: var, val = match.group(1), match.group(2) @@ -120,14 +153,17 @@ # Bring the program to the point where we can issue a series of # 'expr' command. self.runCmd("file %s" % exe_name, CURRENT_EXECUTABLE_SET) - puts_line = line_number ("basic_type.cpp", "// Here is the line we will break on to check variables.") - self.expect("breakpoint set -f basic_type.cpp -l %d" % puts_line, + if blockCaptured: + break_line = line_number ("basic_type.cpp", "// Break here to test block captured variables.") + else: + break_line = line_number ("basic_type.cpp", "// Here is the line we will break on to check variables.") + self.expect("breakpoint set -f basic_type.cpp -l %d" % break_line, BREAKPOINT_CREATED, startstr = "Breakpoint created: 1: file ='basic_type.cpp', line = %d, locations = 1" % - puts_line) + break_line) self.runCmd("run", RUN_SUCCEEDED) self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, - substrs = [" at basic_type.cpp:%d" % puts_line, + substrs = [" at basic_type.cpp:%d" % break_line, "stop reason = breakpoint"]) #self.runCmd("frame variable -T") Modified: lldb/trunk/test/types/TestFloatTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypes.py?rev=147828&r1=147827&r2=147828&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypes.py (original) +++ lldb/trunk/test/types/TestFloatTypes.py Mon Jan 9 20:04:04 2012 @@ -14,40 +14,30 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_float_type_with_dsym(self): """Test that float-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'float.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.float_type(self.exe_name) + self.build_and_run('float.cpp', set(['float'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_float_type_from_block_with_dsym(self): + """Test that float-type variables are displayed correctly from a block.""" + self.build_and_run('float.cpp', set(['float']), bc=True) def test_float_type_with_dwarf(self): """Test that float-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'float.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.float_type(self.exe_name) + self.build_and_run('float.cpp', set(['float']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_double_type_with_dsym(self): """Test that double-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'double.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.double_type(self.exe_name) - - def test_double_type_with_dwarf(self): - """Test that double-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'double.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.double_type(self.exe_name) + self.build_and_run('double.cpp', set(['double'])) - def float_type(self, exe_name): - """Test that float-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['float'])) + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_double_type_from_block_with_dsym(self): + """Test that double-type variables are displayed correctly from a block.""" + self.build_and_run('double.cpp', set(['double']), bc=True) - def double_type(self, exe_name): + def test_double_type_with_dwarf(self): """Test that double-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['double'])) + self.build_and_run('double.cpp', set(['double']), dsym=False) if __name__ == '__main__': Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=147828&r1=147827&r2=147828&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Mon Jan 9 20:04:04 2012 @@ -17,40 +17,30 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_float_type_with_dsym(self): """Test that float-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'float.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.float_type_expr(self.exe_name) + self.build_and_run_expr('float.cpp', set(['float'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_float_type_from_block_with_dsym(self): + """Test that float-type variables are displayed correctly from a block.""" + self.build_and_run_expr('float.cpp', set(['float']), bc=True) def test_float_type_with_dwarf(self): """Test that float-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'float.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.float_type_expr(self.exe_name) + self.build_and_run_expr('float.cpp', set(['float']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_double_type_with_dsym(self): """Test that double-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'double.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.double_type_expr(self.exe_name) - - def test_double_type_with_dwarf(self): - """Test that double-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'double.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.double_type_expr(self.exe_name) + self.build_and_run_expr('double.cpp', set(['double'])) - def float_type_expr(self, exe_name): - """Test that float-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['float'])) + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_double_type_from_block_with_dsym(self): + """Test that double-type variables are displayed correctly from a block.""" + self.build_and_run_expr('double.cpp', set(['double']), bc=True) - def double_type_expr(self, exe_name): + def test_double_type_with_dwarf(self): """Test that double-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['double'])) + self.build_and_run_expr('double.cpp', set(['double']), dsym=False) if __name__ == '__main__': Modified: lldb/trunk/test/types/TestIntegerTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypes.py?rev=147828&r1=147827&r2=147828&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypes.py (original) +++ lldb/trunk/test/types/TestIntegerTypes.py Mon Jan 9 20:04:04 2012 @@ -14,122 +14,114 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_char_type_with_dsym(self): """Test that char-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'char.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.char_type(self.exe_name) + self.build_and_run('char.cpp', set(['char']), qd=True) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_char_type_from_block_with_dsym(self): + """Test that char-type variables are displayed correctly from a block.""" + self.build_and_run('char.cpp', set(['char']), bc=True, qd=True) def test_char_type_with_dwarf(self): """Test that char-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'char.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.char_type(self.exe_name) + self.build_and_run('char.cpp', set(['char']), dsym=False, qd=True) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_char_type_with_dsym(self): """Test that 'unsigned_char'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_char.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_char_type(self.exe_name) + self.build_and_run('unsigned_char.cpp', set(['unsigned', 'char']), qd=True) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_char_type_from_block_with_dsym(self): + """Test that 'unsigned char'-type variables are displayed correctly from a block.""" + self.build_and_run('unsigned_char.cpp', set(['unsigned', 'char']), bc=True, qd=True) def test_unsigned_char_type_with_dwarf(self): """Test that 'unsigned char'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_char.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_char_type(self.exe_name) + self.build_and_run('unsigned_char.cpp', set(['unsigned', 'char']), dsym=False, qd=True) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_short_type_with_dsym(self): """Test that short-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'short.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.short_type(self.exe_name) + self.build_and_run('short.cpp', set(['short'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_short_type_from_block_with_dsym(self): + """Test that short-type variables are displayed correctly from a block.""" + self.build_and_run('short.cpp', set(['short']), bc=True) def test_short_type_with_dwarf(self): """Test that short-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'short.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.short_type(self.exe_name) + self.build_and_run('short.cpp', set(['short']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_short_type_with_dsym(self): """Test that 'unsigned_short'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_short.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_short_type(self.exe_name) + self.build_and_run('unsigned_short.cpp', set(['unsigned', 'short'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_short_type_from_block_with_dsym(self): + """Test that 'unsigned short'-type variables are displayed correctly from a block.""" + self.build_and_run('unsigned_short.cpp', set(['unsigned', 'short']), bc=True) def test_unsigned_short_type_with_dwarf(self): """Test that 'unsigned short'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_short.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_short_type(self.exe_name) + self.build_and_run('unsigned_short.cpp', set(['unsigned', 'short']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_int_type_with_dsym(self): """Test that int-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'int.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type(self.exe_name) + self.build_and_run('int.cpp', set(['int'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_int_type_from_block_with_dsym(self): + """Test that int-type variables are displayed correctly from a block.""" + self.build_and_run('int.cpp', set(['int']), dsym=False) def test_int_type_with_dwarf(self): """Test that int-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'int.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type(self.exe_name) + self.build_and_run('int.cpp', set(['int']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_int_type_with_dsym(self): """Test that 'unsigned_int'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type(self.exe_name) + self.build_and_run('unsigned_int.cpp', set(['unsigned', 'int'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_int_type_from_block_with_dsym(self): + """Test that 'unsigned int'-type variables are displayed correctly from a block.""" + self.build_and_run('unsigned_int.cpp', set(['unsigned', 'int']), bc=True) def test_unsigned_int_type_with_dwarf(self): """Test that 'unsigned int'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type(self.exe_name) + self.build_and_run('unsigned_int.cpp', set(['unsigned', 'int']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_type_with_dsym(self): """Test that long-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type(self.exe_name) + self.build_and_run('long.cpp', set(['long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_long_type_from_block_with_dsym(self): + """Test that long-type variables are displayed correctly from a block.""" + self.build_and_run('long.cpp', set(['long']), bc=True) def test_long_type_with_dwarf(self): """Test that long-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type(self.exe_name) + self.build_and_run('long.cpp', set(['long']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_long_type_with_dsym(self): """Test that 'unsigned long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type(self.exe_name) + self.build_and_run('unsigned_long.cpp', set(['unsigned', 'long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_long_type_from_block_with_dsym(self): + """Test that 'unsigned_long'-type variables are displayed correctly from a block.""" + self.build_and_run('unsigned_long.cpp', set(['unsigned', 'long']), bc=True) def test_unsigned_long_type_with_dwarf(self): """Test that 'unsigned long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type(self.exe_name) + self.build_and_run('unsigned_long.cpp', set(['unsigned', 'long']), dsym=False) # rdar://problem/8482903 # test suite failure for types dir -- "long long" and "unsigned long long" @@ -137,72 +129,30 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_long_type_with_dsym(self): """Test that 'long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type(self.exe_name) + self.build_and_run('long_long.cpp', set(['long long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_long_long_type_from_block_with_dsym(self): + """Test that 'long_long'-type variables are displayed correctly from a block.""" + self.build_and_run('long_long.cpp', set(['long long']), bc=True) def test_long_long_type_with_dwarf(self): """Test that 'long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type(self.exe_name) + self.build_and_run('long_long.cpp', set(['long long']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_long_long_type_with_dsym(self): """Test that 'unsigned long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long_long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type(self.exe_name) + self.build_and_run('unsigned_long_long.cpp', set(['unsigned', 'long long'])) - def test_unsigned_long_long_type_with_dwarf(self): - """Test that 'unsigned long long'-type variables are displayed correctly.""" - d = {'CXX_SOURCES': 'unsigned_long_long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type(self.exe_name) - - def char_type(self, exe_name): - """Test that char-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['char']), quotedDisplay=True) - - def unsigned_char_type(self, exe_name): - """Test that 'unsigned char'-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['unsigned', 'char']), quotedDisplay=True) - - def short_type(self, exe_name): - """Test that short-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['short'])) - - def unsigned_short_type(self, exe_name): - """Test that 'unsigned short'-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['unsigned', 'short'])) - - def int_type(self, exe_name): - """Test that int-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['int'])) - - def unsigned_int_type(self, exe_name): - """Test that 'unsigned int'-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['unsigned', 'int'])) - - def long_type(self, exe_name): - """Test that long-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['long'])) - - def unsigned_long_type(self, exe_name): - """Test that 'unsigned long'-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['unsigned', 'long'])) - - def long_long_type(self, exe_name): - """Test that long long-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['long long'])) + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_long_long_type_from_block_with_dsym(self): + """Test that 'unsigned_long_long'-type variables are displayed correctly from a block.""" + self.build_and_run('unsigned_long_long.cpp', set(['unsigned', 'long long']), bc=True) - def unsigned_long_long_type(self, exe_name): + def test_unsigned_long_long_type_with_dwarf(self): """Test that 'unsigned long long'-type variables are displayed correctly.""" - self.generic_type_tester(exe_name, set(['unsigned', 'long long'])) + self.build_and_run('unsigned_long_long.cpp', set(['unsigned', 'long long']), dsym=False) if __name__ == '__main__': Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=147828&r1=147827&r2=147828&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Mon Jan 9 20:04:04 2012 @@ -14,122 +14,114 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_char_type_with_dsym(self): """Test that char-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'char.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.char_type_expr(self.exe_name) + self.build_and_run_expr('char.cpp', set(['char']), qd=True) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_char_type_from_block_with_dsym(self): + """Test that char-type variables are displayed correctly from a block.""" + self.build_and_run_expr('char.cpp', set(['char']), bc=True, qd=True) def test_char_type_with_dwarf(self): """Test that char-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'char.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.char_type_expr(self.exe_name) + self.build_and_run_expr('char.cpp', set(['char']), dsym=False, qd=True) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_char_type_with_dsym(self): """Test that 'unsigned_char'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_char.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_char_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_char.cpp', set(['unsigned', 'char']), qd=True) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_char_type_from_block_with_dsym(self): + """Test that 'unsigned char'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('unsigned_char.cpp', set(['unsigned', 'char']), bc=True, qd=True) def test_unsigned_char_type_with_dwarf(self): """Test that 'unsigned char'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_char.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_char_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_char.cpp', set(['unsigned', 'char']), dsym=False, qd=True) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_short_type_with_dsym(self): """Test that short-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'short.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.short_type_expr(self.exe_name) + self.build_and_run_expr('short.cpp', set(['short'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_short_type_from_block_with_dsym(self): + """Test that short-type variables are displayed correctly from a block.""" + self.build_and_run_expr('short.cpp', set(['short']), bc=True) def test_short_type_with_dwarf(self): """Test that short-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'short.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.short_type_expr(self.exe_name) + self.build_and_run_expr('short.cpp', set(['short']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_short_type_with_dsym(self): """Test that 'unsigned_short'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_short.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_short_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_short.cpp', set(['unsigned', 'short'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_short_type_from_block_with_dsym(self): + """Test that 'unsigned short'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('unsigned_short.cpp', set(['unsigned', 'short']), bc=True) def test_unsigned_short_type_with_dwarf(self): """Test that 'unsigned short'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_short.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_short_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_short.cpp', set(['unsigned', 'short']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_int_type_with_dsym(self): """Test that int-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'int.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type_expr(self.exe_name) + self.build_and_run_expr('int.cpp', set(['int'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_int_type_from_block_with_dsym(self): + """Test that int-type variables are displayed correctly from a block.""" + self.build_and_run_expr('int.cpp', set(['int']), dsym=False) def test_int_type_with_dwarf(self): """Test that int-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'int.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.int_type_expr(self.exe_name) + self.build_and_run_expr('int.cpp', set(['int']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_int_type_with_dsym(self): """Test that 'unsigned_int'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_int.cpp', set(['unsigned', 'int'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_int_type_from_block_with_dsym(self): + """Test that 'unsigned int'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('unsigned_int.cpp', set(['unsigned', 'int']), bc=True) def test_unsigned_int_type_with_dwarf(self): """Test that 'unsigned int'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_int.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_int_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_int.cpp', set(['unsigned', 'int']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_type_with_dsym(self): """Test that long-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type_expr(self.exe_name) + self.build_and_run_expr('long.cpp', set(['long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_long_type_from_block_with_dsym(self): + """Test that long-type variables are displayed correctly from a block.""" + self.build_and_run_expr('long.cpp', set(['long']), bc=True) def test_long_type_with_dwarf(self): """Test that long-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_type_expr(self.exe_name) + self.build_and_run_expr('long.cpp', set(['long']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_long_type_with_dsym(self): """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_long.cpp', set(['unsigned', 'long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_long_type_from_block_with_dsym(self): + """Test that 'unsigned_long'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('unsigned_long.cpp', set(['unsigned', 'long']), bc=True) def test_unsigned_long_type_with_dwarf(self): """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_long.cpp', set(['unsigned', 'long']), dsym=False) # rdar://problem/8482903 # test suite failure for types dir -- "long long" and "unsigned long long" @@ -137,72 +129,30 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_long_long_type_with_dsym(self): """Test that 'long long'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type_expr(self.exe_name) + self.build_and_run_expr('long_long.cpp', set(['long long'])) + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_long_long_type_from_block_with_dsym(self): + """Test that 'long_long'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('long_long.cpp', set(['long long']), bc=True) def test_long_long_type_with_dwarf(self): """Test that 'long long'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'long_long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.long_long_type_expr(self.exe_name) + self.build_and_run_expr('long_long.cpp', set(['long long']), dsym=False) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_unsigned_long_long_type_with_dsym(self): """Test that 'unsigned long long'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_long_long.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type_expr(self.exe_name) + self.build_and_run_expr('unsigned_long_long.cpp', set(['unsigned', 'long long'])) - def test_unsigned_long_long_type_with_dwarf(self): - """Test that 'unsigned long long'-type variable expressions are evaluated correctly.""" - d = {'CXX_SOURCES': 'unsigned_long_long.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.unsigned_long_long_type_expr(self.exe_name) - - def char_type_expr(self, exe_name): - """Test that char-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['char']), quotedDisplay=True) - - def unsigned_char_type_expr(self, exe_name): - """Test that 'unsigned char'-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['unsigned', 'char']), quotedDisplay=True) - - def short_type_expr(self, exe_name): - """Test that short-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['short'])) - - def unsigned_short_type_expr(self, exe_name): - """Test that 'unsigned short'-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['unsigned', 'short'])) - - def int_type_expr(self, exe_name): - """Test that int-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['int'])) - - def unsigned_int_type_expr(self, exe_name): - """Test that 'unsigned int'-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['unsigned', 'int'])) - - def long_type_expr(self, exe_name): - """Test that long-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['long'])) - - def unsigned_long_type_expr(self, exe_name): - """Test that 'unsigned long'-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['unsigned', 'long'])) - - def long_long_type_expr(self, exe_name): - """Test that long long-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['long long'])) + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_unsigned_long_long_type_from_block_with_dsym(self): + """Test that 'unsigned_long_long'-type variables are displayed correctly from a block.""" + self.build_and_run_expr('unsigned_long_long.cpp', set(['unsigned', 'long long']), bc=True) - def unsigned_long_long_type_expr(self, exe_name): + def test_unsigned_long_long_type_with_dwarf(self): """Test that 'unsigned long long'-type variable expressions are evaluated correctly.""" - self.generic_type_expr_tester(exe_name, set(['unsigned', 'long long'])) + self.build_and_run_expr('unsigned_long_long.cpp', set(['unsigned', 'long long']), dsym=False) if __name__ == '__main__': Modified: lldb/trunk/test/types/basic_type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/basic_type.cpp?rev=147828&r1=147827&r2=147828&view=diff ============================================================================== --- lldb/trunk/test/types/basic_type.cpp (original) +++ lldb/trunk/test/types/basic_type.cpp Mon Jan 9 20:04:04 2012 @@ -20,6 +20,10 @@ #endif +#ifdef TEST_BLOCK_CAPTURED_VARS +#include +#endif + class a_class { public: @@ -34,7 +38,7 @@ } const T& - get_a() + get_a() const { return m_a; } @@ -46,7 +50,7 @@ } const T& - get_b() + get_b() const { return m_b; } @@ -169,5 +173,41 @@ #endif puts("About to exit, break here to check values..."); // Here is the line we will break on to check variables. + +#ifdef TEST_BLOCK_CAPTURED_VARS +#include + + void (^myBlock)() = ^() { + printf ("%s: a = '" T_PRINTF_FORMAT "'\n", T_CSTR, a); + printf ("%s*: %p => *a_ptr = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_ptr, *a_ptr); + printf ("%s&: @%p => a_ref = '" T_PRINTF_FORMAT "'\n", T_CSTR, &a_ref, a_ref); + + printf ("(a_class) a_class_instance.m_a = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_a()); + printf ("(a_class) a_class_instance.m_b = '" T_PRINTF_FORMAT "'\n", a_class_instance.get_b()); + printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_a = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_a()); + printf ("(a_class*) a_class_ptr = %p, a_class_ptr->m_b = '" T_PRINTF_FORMAT "'\n", a_class_ptr, a_class_ptr->get_b()); + printf ("(a_class&) a_class_ref = %p, a_class_ref.m_a = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_a()); + printf ("(a_class&) a_class_ref = %p, a_class_ref.m_b = '" T_PRINTF_FORMAT "'\n", &a_class_ref, a_class_ref.get_b()); + + printf ("(a_struct_t) a_struct.a = '" T_PRINTF_FORMAT "'\n", a_struct.a); + printf ("(a_struct_t) a_struct.b = '" T_PRINTF_FORMAT "'\n", a_struct.b); + printf ("(a_struct_t*) a_struct_ptr = %p, a_struct_ptr->a = '" T_PRINTF_FORMAT "'\n", a_struct_ptr, a_struct_ptr->a); + printf ("(a_struct_t*) a_struct_ptr = %p, a_struct_ptr->b = '" T_PRINTF_FORMAT "'\n", a_struct_ptr, a_struct_ptr->b); + printf ("(a_struct_t&) a_struct_ref = %p, a_struct_ref.a = '" T_PRINTF_FORMAT "'\n", &a_struct_ref, a_struct_ref.a); + printf ("(a_struct_t&) a_struct_ref = %p, a_struct_ref.b = '" T_PRINTF_FORMAT "'\n", &a_struct_ref, a_struct_ref.b); + + printf ("(a_union_zero_t) a_union_zero.a = '" T_PRINTF_FORMAT "'\n", a_union_zero.a); + printf ("(a_union_zero_t*) a_union_zero_ptr = %p, a_union_zero_ptr->a = '" T_PRINTF_FORMAT "'\n", a_union_zero_ptr, a_union_zero_ptr->a); + printf ("(a_union_zero_t&) a_union_zero_ref = %p, a_union_zero_ref.a = '" T_PRINTF_FORMAT "'\n", &a_union_zero_ref, a_union_zero_ref.a); + + printf ("(a_union_nonzero_t) a_union_nonzero.u.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero.u.a); + printf ("(a_union_nonzero_t*) a_union_nonzero_ptr = %p, a_union_nonzero_ptr->u.a = '" T_PRINTF_FORMAT "'\n", a_union_nonzero_ptr, a_union_nonzero_ptr->u.a); + printf ("(a_union_nonzero_t&) a_union_nonzero_ref = %p, a_union_nonzero_ref.u.a = '" T_PRINTF_FORMAT "'\n", &a_union_nonzero_ref, a_union_nonzero_ref.u.a); + + printf ("That's All Folks!\n"); // Break here to test block captured variables. + }; + + myBlock(); +#endif return 0; } From jingham at apple.com Mon Jan 9 20:14:47 2012 From: jingham at apple.com (Jim Ingham) Date: Tue, 10 Jan 2012 02:14:47 -0000 Subject: [Lldb-commits] [lldb] r147829 - /lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Message-ID: <20120110021447.6D36A1BE003@llvm.org> Author: jingham Date: Mon Jan 9 20:14:47 2012 New Revision: 147829 URL: http://llvm.org/viewvc/llvm-project?rev=147829&view=rev Log: Don't call lldb_private::Process::GetLoadAddressPermissions to sanity check the unwind addresses when you already know that the address is contained in a bona fide function. This can be a slow call. Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=147829&r1=147828&r2=147829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Jan 9 20:14:47 2012 @@ -95,7 +95,11 @@ return; } m_sym_ctx = frame_sp->GetSymbolContext (eSymbolContextFunction | eSymbolContextSymbol); - m_sym_ctx_valid = true; + + // We require that eSymbolContextSymbol be successfully filled in or this context is of no use to us. + if ((m_sym_ctx.GetResolvedMask() & eSymbolContextSymbol) == eSymbolContextSymbol) + m_sym_ctx_valid = true; + AddressRange addr_range; m_sym_ctx.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, 0, false, addr_range); @@ -276,32 +280,6 @@ if (abi) pc = abi->FixCodeAddress(pc); - // Test the pc value to see if we know it's in an unmapped/non-executable region of memory. - uint32_t permissions; - if (m_thread.GetProcess().GetLoadAddressPermissions(pc, permissions) - && (permissions & ePermissionsExecutable) == 0) - { - // If this is the second frame off the stack, we may have unwound the first frame - // incorrectly. But using the architecture default unwind plan may get us back on - // track -- albeit possibly skipping a real frame. Give this frame a clearly-invalid - // pc and see if we can get any further. - if (GetNextFrame().get() && GetNextFrame()->IsValid() && GetNextFrame()->IsFrameZero()) - { - if (log) - { - log->Printf("%*sFrame %u had a pc of 0x%llx which is not in executable memory but on frame 1 -- allowing it once.", - m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, (uint64_t) pc); - } - m_frame_type = eSkipFrame; - } - else - { - // anywhere other than the second frame, a non-executable pc means we're off in the weeds -- stop now. - m_frame_type = eNotAValidFrame; - return; - } - } - m_thread.GetProcess().GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, m_current_pc); // If we don't have a Module for some reason, we're not going to find symbol/function information - just @@ -313,6 +291,33 @@ log->Printf("%*sFrame %u using architectural default unwind method", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); } + + // Test the pc value to see if we know it's in an unmapped/non-executable region of memory. + uint32_t permissions; + if (m_thread.GetProcess().GetLoadAddressPermissions(pc, permissions) + && (permissions & ePermissionsExecutable) == 0) + { + // If this is the second frame off the stack, we may have unwound the first frame + // incorrectly. But using the architecture default unwind plan may get us back on + // track -- albeit possibly skipping a real frame. Give this frame a clearly-invalid + // pc and see if we can get any further. + if (GetNextFrame().get() && GetNextFrame()->IsValid() && GetNextFrame()->IsFrameZero()) + { + if (log) + { + log->Printf("%*sFrame %u had a pc of 0x%llx which is not in executable memory but on frame 1 -- allowing it once.", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, (uint64_t) pc); + } + m_frame_type = eSkipFrame; + } + else + { + // anywhere other than the second frame, a non-executable pc means we're off in the weeds -- stop now. + m_frame_type = eNotAValidFrame; + return; + } + } + if (abi) { m_fast_unwind_plan_sp.reset (); @@ -689,8 +694,9 @@ // in the zeroth frame, we need to use the "unwind at first instruction" arch default UnwindPlan // Also, if this Process can report on memory region attributes, any non-executable region means // we jumped through a bad function pointer - handle the same way as 0x0. + // Note, if the symbol context has a function for the symbol, then we don't need to do this check. - if (behaves_like_zeroth_frame && m_current_pc.IsValid()) + if ((!m_sym_ctx_valid || m_sym_ctx.function == NULL) && behaves_like_zeroth_frame && m_current_pc.IsValid()) { uint32_t permissions; addr_t current_pc_addr = m_current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()); From gclayton at apple.com Mon Jan 9 20:52:22 2012 From: gclayton at apple.com (Greg Clayton) Date: Tue, 10 Jan 2012 02:52:22 -0000 Subject: [Lldb-commits] [lldb] r147834 - /lldb/trunk/include/lldb/Host/Host.h Message-ID: <20120110025222.2229D1BE003@llvm.org> Author: gclayton Date: Mon Jan 9 20:52:21 2012 New Revision: 147834 URL: http://llvm.org/viewvc/llvm-project?rev=147834&view=rev Log: Fix for linux build. Modified: lldb/trunk/include/lldb/Host/Host.h Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=147834&r1=147833&r2=147834&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Mon Jan 9 20:52:21 2012 @@ -11,6 +11,7 @@ #define liblldb_Host_h_ #if defined(__cplusplus) +#include #include "lldb/lldb-private.h" #include "lldb/Core/StringList.h" From gclayton at apple.com Mon Jan 9 20:53:13 2012 From: gclayton at apple.com (Greg Clayton) Date: Tue, 10 Jan 2012 02:53:13 -0000 Subject: [Lldb-commits] [lldb] r147835 - /lldb/trunk/source/Core/DataBufferMemoryMap.cpp Message-ID: <20120110025313.42DBB1BE003@llvm.org> Author: gclayton Date: Mon Jan 9 20:53:13 2012 New Revision: 147835 URL: http://llvm.org/viewvc/llvm-project?rev=147835&view=rev Log: Since clang modifies .o files in place, use MAP_PRIVATE as it seems to fix the issues we run into on darwin even though the docs don't seems to say it will. Modified: lldb/trunk/source/Core/DataBufferMemoryMap.cpp Modified: lldb/trunk/source/Core/DataBufferMemoryMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataBufferMemoryMap.cpp?rev=147835&r1=147834&r2=147835&view=diff ============================================================================== --- lldb/trunk/source/Core/DataBufferMemoryMap.cpp (original) +++ lldb/trunk/source/Core/DataBufferMemoryMap.cpp Mon Jan 9 20:53:13 2012 @@ -171,7 +171,7 @@ if (writeable) prot |= PROT_WRITE; - int flags = MAP_SHARED; + int flags = MAP_PRIVATE; if (fd_is_file) flags |= MAP_FILE; From jingham at apple.com Mon Jan 9 21:58:23 2012 From: jingham at apple.com (Jim Ingham) Date: Tue, 10 Jan 2012 03:58:23 -0000 Subject: [Lldb-commits] [lldb] r147838 - /lldb/trunk/include/lldb/Core/FormatNavigator.h Message-ID: <20120110035823.995A31BE003@llvm.org> Author: jingham Date: Mon Jan 9 21:58:23 2012 New Revision: 147838 URL: http://llvm.org/viewvc/llvm-project?rev=147838&view=rev Log: As we are grubbing through memory chasing down the hierarchy of an ObjC object, protect against the possibility that that object might be just random memory with loops. Modified: lldb/trunk/include/lldb/Core/FormatNavigator.h Modified: lldb/trunk/include/lldb/Core/FormatNavigator.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatNavigator.h?rev=147838&r1=147837&r2=147838&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatNavigator.h (original) +++ lldb/trunk/include/lldb/Core/FormatNavigator.h Mon Jan 9 21:58:23 2012 @@ -375,8 +375,11 @@ return Get_Impl(type, entry, Types()); } + #define LLDB_MAX_REASONABLE_OBJC_CLASS_DEPTH 100 + bool Get_ObjC(ValueObject& valobj, ObjCLanguageRuntime::ObjCISA isa, + std::set &found_values, MapValueType& entry, uint32_t& reason) { @@ -397,6 +400,7 @@ log->Printf("invalid ISA, bailing out"); return false; } + ConstString name = runtime->GetActualTypeName(isa); if (log) log->Printf("looking for formatter for %s", name.GetCString()); @@ -415,13 +419,29 @@ log->Printf("invalid parent ISA, bailing out"); return false; } - if (parent == isa) + + // Put the isa value in our map. Then check the new_value, if it was already there, we've got a + // loop in the inheritance hierarchy, and should bag out. + std::pair::iterator, bool> new_value = found_values.insert (isa); + if (new_value.second == false) + { + //Our value already existed in the map. + if (log) + log->Printf ("ISA: 0x%llx already found in inheritance chain.", isa); + return false; + } + + if (found_values.size() > LLDB_MAX_REASONABLE_OBJC_CLASS_DEPTH) { + // ObjC hierarchies are usually pretty shallow, if we've gone this far, we are probably chasing + // uninitialized memory. if (log) - log->Printf("parent-child loop, bailing out"); + log->Printf("Parent-child depth of %d, we are probably off in the weeds, bailing out.", + LLDB_MAX_REASONABLE_OBJC_CLASS_DEPTH); return false; } - if (Get_ObjC(valobj, parent, entry, reason)) + + if (Get_ObjC(valobj, parent, found_values, entry, reason)) { reason |= lldb_private::eFormatterChoiceCriterionNavigatedBaseClasses; return true; @@ -512,7 +532,8 @@ } else { - if (Get_ObjC(valobj, runtime->GetISA(valobj), entry, reason)) + std::set found_values; + if (Get_ObjC(valobj, runtime->GetISA(valobj), found_values, entry, reason)) { reason |= lldb_private::eFormatterChoiceCriterionDynamicObjCHierarchy; return true; @@ -555,7 +576,8 @@ } else { - if (Get_ObjC(valobj, runtime->GetISA(valobj), entry, reason)) + std::set found_values; + if (Get_ObjC(valobj, runtime->GetISA(valobj), found_values, entry, reason)) { reason |= lldb_private::eFormatterChoiceCriterionDynamicObjCHierarchy; return true; From scallanan at apple.com Tue Jan 10 12:37:33 2012 From: scallanan at apple.com (Sean Callanan) Date: Tue, 10 Jan 2012 18:37:33 -0000 Subject: [Lldb-commits] [lldb] r147865 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20120110183733.274222A6C12C@llvm.org> Author: spyffe Date: Tue Jan 10 12:37:32 2012 New Revision: 147865 URL: http://llvm.org/viewvc/llvm-project?rev=147865&view=rev Log: Updating Xcode project version numbers for lldb-103 and debugserver-162 Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=147865&r1=147864&r2=147865&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Jan 10 12:37:32 2012 @@ -3733,9 +3733,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 102; + DYLIB_CURRENT_VERSION = 103; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3793,10 +3793,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 102; + DYLIB_CURRENT_VERSION = 103; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3852,8 +3852,8 @@ 2689FFD513353D7A00698AC0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 102; - DYLIB_CURRENT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; + DYLIB_CURRENT_VERSION = 103; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3881,8 +3881,8 @@ 2689FFD613353D7A00698AC0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 102; - DYLIB_CURRENT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; + DYLIB_CURRENT_VERSION = 103; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3910,8 +3910,8 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 102; - DYLIB_CURRENT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; + DYLIB_CURRENT_VERSION = 103; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3991,7 +3991,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4022,10 +4022,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 102; + DYLIB_CURRENT_VERSION = 103; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4269,7 +4269,7 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4299,7 +4299,7 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=147865&r1=147864&r2=147865&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Tue Jan 10 12:37:32 2012 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 102 + 103 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=147865&r1=147864&r2=147865&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Tue Jan 10 12:37:32 2012 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 161; + CURRENT_PROJECT_VERSION = 162; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = ""; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 161; + CURRENT_PROJECT_VERSION = 162; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 161; + CURRENT_PROJECT_VERSION = 162; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -534,7 +534,7 @@ "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 161; + CURRENT_PROJECT_VERSION = 162; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -577,7 +577,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 161; + CURRENT_PROJECT_VERSION = 162; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -620,7 +620,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 161; + CURRENT_PROJECT_VERSION = 162; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From scallanan at apple.com Tue Jan 10 12:38:17 2012 From: scallanan at apple.com (Sean Callanan) Date: Tue, 10 Jan 2012 18:38:17 -0000 Subject: [Lldb-commits] [lldb] r147866 - /lldb/tags/lldb-103/ Message-ID: <20120110183817.A19692A6C12C@llvm.org> Author: spyffe Date: Tue Jan 10 12:38:17 2012 New Revision: 147866 URL: http://llvm.org/viewvc/llvm-project?rev=147866&view=rev Log: lldb-103 Added: lldb/tags/lldb-103/ - copied from r147865, lldb/trunk/ From jingham at apple.com Tue Jan 10 16:21:42 2012 From: jingham at apple.com (Jim Ingham) Date: Tue, 10 Jan 2012 22:21:42 -0000 Subject: [Lldb-commits] [lldb] r147883 - /lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Message-ID: <20120110222142.5F0A02A6C12C@llvm.org> Author: jingham Date: Tue Jan 10 16:21:42 2012 New Revision: 147883 URL: http://llvm.org/viewvc/llvm-project?rev=147883&view=rev Log: Check the return value of GetBasicInfo before dereferencing it. Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp?rev=147883&r1=147882&r2=147883&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Tue Jan 10 16:21:42 2012 @@ -95,8 +95,13 @@ if (others_stopped) { - times_to_resume = GetBasicInfo()->suspend_count; - m_suspend_count = - (times_to_resume - m_suspend_count); + if (GetBasicInfo()) + { + times_to_resume = m_basic_info.suspend_count; + m_suspend_count = - (times_to_resume - m_suspend_count); + } + else + times_to_resume = 0; } else { From gclayton at apple.com Tue Jan 10 16:33:56 2012 From: gclayton at apple.com (Greg Clayton) Date: Tue, 10 Jan 2012 22:33:56 -0000 Subject: [Lldb-commits] [lldb] r147886 - in /lldb/trunk/tools/debugserver: debugserver.xcodeproj/project.pbxproj source/MacOSX/arm/DNBArchImpl.cpp source/MacOSX/arm/DNBArchImpl.h Message-ID: <20120110223356.C23942A6C12C@llvm.org> Author: gclayton Date: Tue Jan 10 16:33:56 2012 New Revision: 147886 URL: http://llvm.org/viewvc/llvm-project?rev=147886&view=rev Log: Disable ARMDisassembler.framework support which was used for software single stepping. Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=147886&r1=147885&r2=147886&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Tue Jan 10 16:33:56 2012 @@ -557,8 +557,6 @@ "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = ( "-framework", SpringBoardServices, - "-framework", - ARMDisassembler, "-llockdown", ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; @@ -600,8 +598,6 @@ "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = ( "-framework", SpringBoardServices, - "-framework", - ARMDisassembler, "-llockdown", ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; @@ -643,8 +639,6 @@ "OTHER_LDFLAGS[sdk=iphoneos*][arch=*]" = ( "-framework", SpringBoardServices, - "-framework", - ARMDisassembler, "-llockdown", ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp?rev=147886&r1=147885&r2=147886&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp Tue Jan 10 16:33:56 2012 @@ -423,10 +423,13 @@ } m_sw_single_step_itblock_break_count = 0; +#if defined (USE_ARM_DISASSEMBLER_FRAMEWORK) + // Decode instructions up to the current PC to ensure the internal decoder state is valid for the IT block // The decoder has to decode each instruction in the IT block even if it is not executed so that // the fields are correctly updated DecodeITBlockInstructions(m_state.context.gpr.__pc); +#endif } } @@ -466,6 +469,8 @@ } +#if defined (USE_ARM_DISASSEMBLER_FRAMEWORK) + void DNBArchMachARM::DecodeITBlockInstructions(nub_addr_t curr_pc) @@ -520,7 +525,7 @@ DNBLogThreadedIf(LOG_STEP | LOG_VERBOSE, "%s: next_pc_in_itblock=0x%8.8x", __FUNCTION__, next_pc_in_itblock); } } - +#endif // Set the single step bit in the processor status register. kern_return_t @@ -685,6 +690,8 @@ return false; } +#if defined (USE_ARM_DISASSEMBLER_FRAMEWORK) + bool DNBArchMachARM::ComputeNextPC(nub_addr_t currentPC, arm_decoded_instruction_t decodedInstruction, bool currentPCIsThumb, nub_addr_t *targetPC) { @@ -1830,6 +1837,8 @@ return decodeReturnCode; } +#endif + nub_bool_t DNBArchMachARM::BreakpointHit (nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *baton) { @@ -1847,6 +1856,8 @@ DNBArchMachARM::SetSingleStepSoftwareBreakpoints() { DNBError err; + +#if defined (USE_ARM_DISASSEMBLER_FRAMEWORK) err = GetGPRState(false); if (err.Fail()) @@ -2043,7 +2054,9 @@ } #endif } - +#else + err.LogThreaded("%s: ARMDisassembler.framework support is disabled", __FUNCTION__); +#endif return err.Error(); } Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h?rev=147886&r1=147885&r2=147886&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h Tue Jan 10 16:33:56 2012 @@ -17,7 +17,9 @@ #if defined (__arm__) #include "DNBArch.h" +#if defined (USE_ARM_DISASSEMBLER_FRAMEWORK) #include +#endif class MachThread; @@ -36,7 +38,9 @@ m_last_decode_pc(INVALID_NUB_ADDRESS) { memset(&m_dbg_save, 0, sizeof(m_dbg_save)); +#if defined (USE_ARM_DISASSEMBLER_FRAMEWORK) ThumbStaticsInit(&m_last_decode_thumb); +#endif for (int i = 0; i < kMaxNumThumbITBreakpoints; i++) m_sw_single_step_itblock_break_id[i] = INVALID_NUB_BREAK_ID; } @@ -85,10 +89,12 @@ kern_return_t SetSingleStepSoftwareBreakpoints (); bool ConditionPassed(uint8_t condition, uint32_t cpsr); +#if defined (USE_ARM_DISASSEMBLER_FRAMEWORK) bool ComputeNextPC(nub_addr_t currentPC, arm_decoded_instruction_t decodedInstruction, bool currentPCIsThumb, nub_addr_t *targetPC); - void EvaluateNextInstructionForSoftwareBreakpointSetup(nub_addr_t currentPC, uint32_t cpsr, bool currentPCIsThumb, nub_addr_t *nextPC, bool *nextPCIsThumb); - void DecodeITBlockInstructions(nub_addr_t curr_pc); arm_error_t DecodeInstructionUsingDisassembler(nub_addr_t curr_pc, uint32_t curr_cpsr, arm_decoded_instruction_t *decodedInstruction, thumb_static_data_t *thumbStaticData, nub_addr_t *next_pc); + void DecodeITBlockInstructions(nub_addr_t curr_pc); +#endif + void EvaluateNextInstructionForSoftwareBreakpointSetup(nub_addr_t currentPC, uint32_t cpsr, bool currentPCIsThumb, nub_addr_t *nextPC, bool *nextPCIsThumb); static nub_bool_t BreakpointHit (nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *baton); typedef enum RegisterSetTag @@ -233,8 +239,10 @@ nub_break_t m_sw_single_step_itblock_break_id[kMaxNumThumbITBreakpoints]; nub_addr_t m_sw_single_step_itblock_break_count; // Disassembler state +#if defined (USE_ARM_DISASSEMBLER_FRAMEWORK) thumb_static_data_t m_last_decode_thumb; arm_decoded_instruction_t m_last_decode_arm; +#endif nub_addr_t m_last_decode_pc; }; From johnny.chen at apple.com Tue Jan 10 17:22:57 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 Jan 2012 23:22:57 -0000 Subject: [Lldb-commits] [lldb] r147893 - /lldb/trunk/test/types/AbstractBase.py Message-ID: <20120110232257.5EF132A6C12C@llvm.org> Author: johnny Date: Tue Jan 10 17:22:57 2012 New Revision: 147893 URL: http://llvm.org/viewvc/llvm-project?rev=147893&view=rev Log: Add documentation for the generic functions build_and_run() and build_and_run_expr() called from the Test*Types*.py test cases. Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=147893&r1=147892&r2=147893&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Tue Jan 10 17:22:57 2012 @@ -29,8 +29,26 @@ # used for all the test cases. self.exe_name = self.testMethodName - # bc -> blockCaptured - # qd -> quotedDisplay + #==========================================================================# + # Functions build_and_run() and build_and_run_expr() are generic functions # + # which are called from the Test*Types*.py test cases. The API client is # + # responsible for supplying two mandatory arguments: the source file, e.g.,# + # 'int.cpp', and the atoms, e.g., set(['unsigned', 'long long']) to the # + # functions. There are also three optional keyword arguments of interest, # + # as follows: # + # # + # dsym -> build for dSYM (defaulted to True) # + # True: build dSYM file # + # False: build DWARF map # + # bc -> blockCaptured (defaulted to False) # + # True: testing vars of various basic types from isnide a block # + # False: testing vars of various basic types from a function # + # qd -> quotedDisplay (defaulted to False) # + # True: the output from 'frame var' or 'expr var' contains a pair # + # of single quotes around the value # + # False: no single quotes are to be found around the value of # + # variable # + #==========================================================================# def build_and_run(self, source, atoms, dsym=True, bc=False, qd=False): self.build_and_run_with_source_atoms_expr(source, atoms, expr=False, dsym=dsym, bc=bc, qd=qd) @@ -101,7 +119,7 @@ for var, val in gl: self.runCmd("frame variable -T %s" % var) output = self.res.GetOutput() - + # The input type is in a canonical form as a set of named atoms. # The display type string must conatin each and every element. # @@ -183,7 +201,7 @@ self.runCmd("expression %s" % var) output = self.res.GetOutput() - + # The input type is in a canonical form as a set of named atoms. # The display type string must conatin each and every element. # From johnny.chen at apple.com Tue Jan 10 17:36:06 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 10 Jan 2012 23:36:06 -0000 Subject: [Lldb-commits] [lldb] r147895 - in /lldb/trunk/test/types: AbstractBase.py basic_type.cpp Message-ID: <20120110233606.66A572A6C12C@llvm.org> Author: johnny Date: Tue Jan 10 17:36:06 2012 New Revision: 147895 URL: http://llvm.org/viewvc/llvm-project?rev=147895&view=rev Log: Add comment for build_and_run_with_source_atoms_expr() and remove redundant #include from basic_type.cpp. Modified: lldb/trunk/test/types/AbstractBase.py lldb/trunk/test/types/basic_type.cpp Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=147895&r1=147894&r2=147895&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Tue Jan 10 17:36:06 2012 @@ -57,6 +57,7 @@ self.build_and_run_with_source_atoms_expr(source, atoms, expr=True, dsym=dsym, bc=bc, qd=qd) def build_and_run_with_source_atoms_expr(self, source, atoms, expr, dsym=True, bc=False, qd=False): + # See also Makefile and basic_type.cpp:177. if bc: d = {'CXX_SOURCES': source, 'EXE': self.exe_name, 'CFLAGS_EXTRAS': '-DTEST_BLOCK_CAPTURED_VARS'} else: Modified: lldb/trunk/test/types/basic_type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/basic_type.cpp?rev=147895&r1=147894&r2=147895&view=diff ============================================================================== --- lldb/trunk/test/types/basic_type.cpp (original) +++ lldb/trunk/test/types/basic_type.cpp Tue Jan 10 17:36:06 2012 @@ -175,8 +175,6 @@ puts("About to exit, break here to check values..."); // Here is the line we will break on to check variables. #ifdef TEST_BLOCK_CAPTURED_VARS -#include - void (^myBlock)() = ^() { printf ("%s: a = '" T_PRINTF_FORMAT "'\n", T_CSTR, a); printf ("%s*: %p => *a_ptr = '" T_PRINTF_FORMAT "'\n", T_CSTR, a_ptr, *a_ptr); From johnny.chen at apple.com Tue Jan 10 18:35:13 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 11 Jan 2012 00:35:13 -0000 Subject: [Lldb-commits] [lldb] r147901 - in /lldb/trunk/tools/debugserver/source/MacOSX/arm: DNBArchImpl.cpp DNBArchImpl.h Message-ID: <20120111003513.C19CC2A6C12C@llvm.org> Author: johnny Date: Tue Jan 10 18:35:13 2012 New Revision: 147901 URL: http://llvm.org/viewvc/llvm-project?rev=147901&view=rev Log: Snapshot of initial work for ARM watchpoint support on the debugserver. It is incomplete and untested; passes the compilation only. Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp?rev=147901&r1=147900&r2=147901&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp Tue Jan 10 18:35:13 2012 @@ -448,6 +448,36 @@ } bool +DNBArchMachARM::NotifyException(MachException::Data& exc) +{ + switch (exc.exc_type) + { + default: + break; + case EXC_BREAKPOINT: + if (exc.exc_data.size() >= 2 && exc.exc_data[0] == 1) + { + // exc_code = EXC_ARM_WATCHPOINT + // + // Check whether this corresponds to a watchpoint hit event. + // If yes, set the exc_sub_code to the data break address. + nub_addr_t addr = 0; + uint32_t hw_index = GetHardwareWatchpointHit(addr); + if (hw_index != INVALID_NUB_HW_INDEX) + { + exc.exc_data[1] = addr; + // Piggyback the hw_index in the exc.data. + exc.exc_data.push_back(hw_index); + } + + return true; + } + break; + } + return false; +} + +bool DNBArchMachARM::StepNotComplete () { if (m_hw_single_chained_step_addr != INVALID_NUB_ADDRESS) @@ -2375,6 +2405,91 @@ return false; } +// {0} -> __bvr[16], {0} -> __bcr[16], {0} --> __wvr[16], {0} -> __wcr{16} +DNBArchMachARM::DBG DNBArchMachARM::Global_Debug_State = {{0},{0},{0},{0}}; +bool DNBArchMachARM::Valid_Global_Debug_State = false; + +// Use this callback from MachThread, which in turn was called from MachThreadList, to update +// the global view of the hardware watchpoint state, so that when new thread comes along, they +// get to inherit the existing hardware watchpoint state. +void +DNBArchMachARM::HardwareWatchpointStateChanged () +{ + Global_Debug_State = m_state.dbg; + Valid_Global_Debug_State = true; +} + +// Iterate through the debug status register; return the index of the first hit. +uint32_t +DNBArchMachARM::GetHardwareWatchpointHit(nub_addr_t &addr) +{ + // Read the debug state + kern_return_t kret = GetDBGState(true); + DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchMachARM::GetHardwareWatchpointHit() GetDBGState() => 0x%8.8x.", kret); + if (kret == KERN_SUCCESS) + { + DBG &debug_state = m_state.dbg; + uint32_t i, num = NumSupportedHardwareWatchpoints(); + for (i = 0; i < num; ++i) + { + // FIXME: IsWatchpointHit() currently returns the first enabled watchpoint, + // instead of finding the watchpoint that actually triggered. + if (IsWatchpointHit(debug_state, i)) + { + addr = GetWatchAddress(debug_state, i); + DNBLogThreadedIf(LOG_WATCHPOINTS, + "DNBArchMachARM::GetHardwareWatchpointHit() found => %u (addr = 0x%llx).", + i, + (uint64_t)addr); + return i; + } + } + } + return INVALID_NUB_HW_INDEX; +} + +// ThreadWillResume() calls this to clear bits[5:2] (Method of entry bits) of +// the Debug Status and Control Register (DSCR). +// +// b0010 = a watchpoint occurred +// b0000 is the reset value +void +DNBArchMachARM::ClearWatchpointOccurred() +{ + // See also IsWatchpointHit(). + uint32_t register_DBGDSCR; + asm("mrc p14, 0, %0, c0, c1, 0" : "=r" (register_DBGDSCR)); + if (bits(register_DBGDSCR, 5, 2) == 0x2) + { + uint32_t mask = ~(0xF << 2); + register_DBGDSCR &= mask; + asm("mcr p14, 0, %0, c0, c1, 0" : "=r" (register_DBGDSCR)); + } + return; +} + +// FIXME: IsWatchpointHit() currently returns the first enabled watchpoint, +// instead of finding the watchpoint that actually triggered. +bool +DNBArchMachARM::IsWatchpointHit(const DBG &debug_state, uint32_t hw_index) +{ + // Watchpoint Control Registers, bitfield definitions + // ... + // Bits Value Description + // [0] 0 Watchpoint disabled + // 1 Watchpoint enabled. + return (debug_state.__wcr[hw_index] & 1u); +} + +nub_addr_t +DNBArchMachARM::GetWatchAddress(const DBG &debug_state, uint32_t hw_index) +{ + // Watchpoint Value Registers, bitfield definitions + // Bits Description + // [31:2] Watchpoint address + return bits(debug_state.__wvr[hw_index], 31, 2); +} + //---------------------------------------------------------------------- // Register information defintions for 32 bit ARMV6. //---------------------------------------------------------------------- Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h?rev=147901&r1=147900&r2=147901&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.h Tue Jan 10 18:35:13 2012 @@ -67,6 +67,7 @@ virtual uint64_t GetSP(uint64_t failValue); // Get stack pointer virtual void ThreadWillResume(); virtual bool ThreadDidStop(); + virtual bool NotifyException(MachException::Data& exc); static DNBArchProtocol *Create (MachThread *thread); static const uint8_t * const SoftwareBreakpointOpcode (nub_size_t byte_size); @@ -79,6 +80,8 @@ virtual bool DisableHardwareBreakpoint (uint32_t hw_break_index); virtual bool DisableHardwareWatchpoint (uint32_t hw_break_index); virtual bool StepNotComplete (); + virtual void HardwareWatchpointStateChanged (); + virtual uint32_t GetHardwareWatchpointHit(nub_addr_t &addr); typedef arm_debug_state_t DBG; @@ -136,6 +139,10 @@ EXC exc; }; + // See also HardwareWatchpointStateChanged() which updates this class-wide variable. + static DBG Global_Debug_State; + static bool Valid_Global_Debug_State; + struct State { Context context; @@ -228,10 +235,16 @@ kern_return_t SetVFPState (); kern_return_t SetEXCState (); kern_return_t SetDBGState (); + + // Helper functions for watchpoint implementaions. + static void ClearWatchpointOccurred(); + static bool IsWatchpointHit(const DBG &debug_state, uint32_t hw_index); + static nub_addr_t GetWatchAddress(const DBG &debug_state, uint32_t hw_index); + protected: MachThread * m_thread; State m_state; - arm_debug_state_t m_dbg_save; + DBG m_dbg_save; nub_addr_t m_hw_single_chained_step_addr; // Software single stepping support nub_addr_t m_sw_single_step_next_pc; From scallanan at apple.com Tue Jan 10 19:36:21 2012 From: scallanan at apple.com (Sean Callanan) Date: Wed, 11 Jan 2012 01:36:21 -0000 Subject: [Lldb-commits] [lldb] r147906 - /lldb/trunk/source/Expression/IRInterpreter.cpp Message-ID: <20120111013621.DCC312A6C12C@llvm.org> Author: spyffe Date: Tue Jan 10 19:36:21 2012 New Revision: 147906 URL: http://llvm.org/viewvc/llvm-project?rev=147906&view=rev Log: If the size of a type can't be determined, default to assume it's of pointer size. Modified: lldb/trunk/source/Expression/IRInterpreter.cpp Modified: lldb/trunk/source/Expression/IRInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=147906&r1=147905&r2=147906&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRInterpreter.cpp (original) +++ lldb/trunk/source/Expression/IRInterpreter.cpp Tue Jan 10 19:36:21 2012 @@ -277,7 +277,7 @@ if (i == m_memory.end()) return Region(); - size_t size = m_target_data.getTypeStoreSize(type); + size_t size = (type->isSized() ? m_target_data.getTypeStoreSize(type) : m_target_data.getPointerSize()); return Region(*i, addr, size); } From johnny.chen at apple.com Tue Jan 10 19:42:59 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 11 Jan 2012 01:42:59 -0000 Subject: [Lldb-commits] [lldb] r147907 - /lldb/trunk/test/make/Makefile.rules Message-ID: <20120111014259.41D622A6C12C@llvm.org> Author: johnny Date: Tue Jan 10 19:42:58 2012 New Revision: 147907 URL: http://llvm.org/viewvc/llvm-project?rev=147907&view=rev Log: Add usage examples of recently added functionality. Modified: lldb/trunk/test/make/Makefile.rules Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=147907&r1=147906&r2=147907&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Tue Jan 10 19:42:58 2012 @@ -6,6 +6,12 @@ # OBJC_SOURCES := # OBJCXX_SOURCES := # DYLIB_C_SOURCES := +# DYLIB_CXX_SOURCES := +# +# Specifying DYLIB_ONLY has the effect of building dylib only, skipping +# the building of the a.out executable program. For example, +# DYLIB_ONLY := YES +# # Uncomment line below for debugging shell commands # SHELL = /bin/sh -x From gclayton at apple.com Tue Jan 10 19:59:18 2012 From: gclayton at apple.com (Greg Clayton) Date: Wed, 11 Jan 2012 01:59:18 -0000 Subject: [Lldb-commits] [lldb] r147908 - /lldb/trunk/source/Core/Module.cpp Message-ID: <20120111015918.764542A6C12C@llvm.org> Author: gclayton Date: Tue Jan 10 19:59:18 2012 New Revision: 147908 URL: http://llvm.org/viewvc/llvm-project?rev=147908&view=rev Log: Fixed a missing space when reporting errors and warning through the module and also print out the full path and architecture. Modified: lldb/trunk/source/Core/Module.cpp Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=147908&r1=147907&r2=147908&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Tue Jan 10 19:59:18 2012 @@ -620,7 +620,7 @@ StreamString strm; strm.PutCString("error: "); GetDescription(&strm, lldb::eDescriptionLevelBrief); - + strm.PutChar (' '); va_list args; va_start (args, format); strm.PrintfVarArg(format, args); @@ -675,7 +675,8 @@ { StreamString strm; strm.PutCString("warning: "); - GetDescription(&strm, lldb::eDescriptionLevelBrief); + GetDescription(&strm, lldb::eDescriptionLevelFull); + strm.PutChar (' '); va_list args; va_start (args, format); @@ -699,7 +700,7 @@ if (log) { StreamString log_message; - GetDescription(&log_message, lldb::eDescriptionLevelBrief); + GetDescription(&log_message, lldb::eDescriptionLevelFull); log_message.PutCString (": "); va_list args; va_start (args, format); From johnny.chen at apple.com Tue Jan 10 19:59:55 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 11 Jan 2012 01:59:55 -0000 Subject: [Lldb-commits] [lldb] r147909 - /lldb/trunk/test/make/Makefile.rules Message-ID: <20120111015955.46F822A6C12C@llvm.org> Author: johnny Date: Tue Jan 10 19:59:55 2012 New Revision: 147909 URL: http://llvm.org/viewvc/llvm-project?rev=147909&view=rev Log: Add more usage examples. Modified: lldb/trunk/test/make/Makefile.rules Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=147909&r1=147908&r2=147909&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Tue Jan 10 19:59:55 2012 @@ -12,6 +12,10 @@ # the building of the a.out executable program. For example, # DYLIB_ONLY := YES # +# And also might be of interest: +# FRAMEWORK_INCLUDES (Darwin only) := +# CFLAGS_EXTRAS := +# LD_EXTRAS := # Uncomment line below for debugging shell commands # SHELL = /bin/sh -x From jingham at apple.com Tue Jan 10 20:21:12 2012 From: jingham at apple.com (Jim Ingham) Date: Wed, 11 Jan 2012 02:21:12 -0000 Subject: [Lldb-commits] [lldb] r147914 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20120111022112.986382A6C12C@llvm.org> Author: jingham Date: Tue Jan 10 20:21:12 2012 New Revision: 147914 URL: http://llvm.org/viewvc/llvm-project?rev=147914&view=rev Log: Don't assert but report & return a NULL type if we end up parsing a type we are in the middle of parsing. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.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=147914&r1=147913&r2=147914&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Jan 10 20:21:12 2012 @@ -1916,8 +1916,18 @@ type = GetTypeForDIE (curr_cu, type_die).get(); if (assert_not_being_parsed) - assert (type != DIE_IS_BEING_PARSED); - return type; + { + if (type != DIE_IS_BEING_PARSED) + return type; + + GetObjectFile()->GetModule()->ReportError ("Parsing a die that is being parsed die: 0x%8.8x: %s %s", + type_die->GetOffset(), + DW_TAG_value_to_name(type_die->Tag()), + type_die->GetName(this, curr_cu)); + + } + else + return type; } return NULL; } From scallanan at apple.com Tue Jan 10 20:23:25 2012 From: scallanan at apple.com (Sean Callanan) Date: Wed, 11 Jan 2012 02:23:25 -0000 Subject: [Lldb-commits] [lldb] r147915 - /lldb/trunk/source/Expression/IRInterpreter.cpp Message-ID: <20120111022325.7BCB02A6C12C@llvm.org> Author: spyffe Date: Tue Jan 10 20:23:25 2012 New Revision: 147915 URL: http://llvm.org/viewvc/llvm-project?rev=147915&view=rev Log: After thinking about it, it doesn't seem right to make assumptions if the type is unsized. We just give up (and let the JIT handle it) instead. Modified: lldb/trunk/source/Expression/IRInterpreter.cpp Modified: lldb/trunk/source/Expression/IRInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=147915&r1=147914&r2=147915&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRInterpreter.cpp (original) +++ lldb/trunk/source/Expression/IRInterpreter.cpp Tue Jan 10 20:23:25 2012 @@ -274,10 +274,10 @@ { MemoryMap::iterator i = LookupInternal(addr); - if (i == m_memory.end()) + if (i == m_memory.end() || !type->isSized()) return Region(); - - size_t size = (type->isSized() ? m_target_data.getTypeStoreSize(type) : m_target_data.getPointerSize()); + + size_t size = m_target_data.getTypeStoreSize(type); return Region(*i, addr, size); } From johnny.chen at apple.com Wed Jan 11 18:29:46 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 12 Jan 2012 00:29:46 -0000 Subject: [Lldb-commits] [lldb] r147983 - in /lldb/trunk/test/python_api/process/io: TestProcessIO.py main.c Message-ID: <20120112002946.48CCD2A6C12C@llvm.org> Author: johnny Date: Wed Jan 11 18:29:46 2012 New Revision: 147983 URL: http://llvm.org/viewvc/llvm-project?rev=147983&view=rev Log: rdar://problem/10492827 SBProcess.GetSTDERR() not getting stderr of the launched process Since we are launch the inferior with: process = target.LaunchSimple(None, None, os.getcwd()) i.e., without specifying stdin/out/err. A pseudo terminal is used for handling the process I/O, and we are satisfied once the expected output appears in process.GetSTDOUT(). Modified: lldb/trunk/test/python_api/process/io/TestProcessIO.py lldb/trunk/test/python_api/process/io/main.c Modified: lldb/trunk/test/python_api/process/io/TestProcessIO.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/io/TestProcessIO.py?rev=147983&r1=147982&r2=147983&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/io/TestProcessIO.py (original) +++ lldb/trunk/test/python_api/process/io/TestProcessIO.py Wed Jan 11 18:29:46 2012 @@ -49,10 +49,10 @@ error = process.GetSTDERR(500) if self.TraceOn(): print "output->|%s|" % output - print "error->|%s|" % error - # We are satisfied once "input line=>1" appears in stderr. + # Since we launched the process without specifying stdin/out/err, + # a pseudo terminal is used for stdout/err, and we are satisfied + # once "input line=>1" appears in stdout. # See also main.c. - #if "input line=>1" in error: if "input line=>1" in output: return time.sleep(5) Modified: lldb/trunk/test/python_api/process/io/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/io/main.c?rev=147983&r1=147982&r2=147983&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/io/main.c (original) +++ lldb/trunk/test/python_api/process/io/main.c Wed Jan 11 18:29:46 2012 @@ -6,6 +6,8 @@ int count = 1; while (fgets(line, sizeof(line), stdin)) { // Reading from stdin... fprintf(stderr, "input line=>%d\n", count++); + if (count > 3) + break; } printf("Exiting now\n"); From gclayton at apple.com Wed Jan 11 19:21:32 2012 From: gclayton at apple.com (Greg Clayton) Date: Thu, 12 Jan 2012 01:21:32 -0000 Subject: [Lldb-commits] [lldb] r147987 - /lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Message-ID: <20120112012132.23F852A6C12C@llvm.org> Author: gclayton Date: Wed Jan 11 19:21:31 2012 New Revision: 147987 URL: http://llvm.org/viewvc/llvm-project?rev=147987&view=rev Log: Revert some changes I did for logging that affected the ability to load .o files in BSD archive parsing. Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp?rev=147987&r1=147986&r2=147987&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (original) +++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Wed Jan 11 19:21:31 2012 @@ -266,8 +266,8 @@ Module* module, DataBufferSP& data_sp, const FileSpec *file, - addr_t file_offset, - addr_t file_size) + addr_t offset, + addr_t length) { if (file && data_sp && ObjectContainerBSDArchive::MagicBytesMatch(data_sp)) { @@ -275,30 +275,28 @@ "ObjectContainerBSDArchive::CreateInstance (module = %s/%s, file = %p, file_offset = 0x%z8.8x, file_size = 0x%z8.8x)", module->GetFileSpec().GetDirectory().AsCString(), module->GetFileSpec().GetFilename().AsCString(), - file, file_offset, file_size); + file, offset, length); - std::auto_ptr container_ap(new ObjectContainerBSDArchive (module, data_sp, file, file_offset, file_size)); - - if (container_ap.get()) + Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, module->GetArchitecture(), module->GetModificationTime())); + + if (archive_sp) { - Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, module->GetArchitecture(), module->GetModificationTime())); - - if (archive_sp) + // We already have this archive in our cache, use it + std::auto_ptr container_ap(new ObjectContainerBSDArchive (module, data_sp, file, offset, length)); + if (container_ap.get()) { - // We already have this archive in our cache, use it container_ap->SetArchive (archive_sp); return container_ap.release(); } - else - { - // Read everything since we need that in order to index all the - // objects in the archive - data_sp = file->MemoryMapFileContents (file_offset, file_size); - - if (container_ap->ParseHeader()) - return container_ap.release(); - } } + + // Read everything since we need that in order to index all the + // objects in the archive + data_sp = file->MemoryMapFileContents (offset, length); + + std::auto_ptr container_ap(new ObjectContainerBSDArchive (module, data_sp, file, offset, length)); + if (container_ap->ParseHeader()) + return container_ap.release(); } return NULL; } From jingham at apple.com Wed Jan 11 19:45:53 2012 From: jingham at apple.com (Jim Ingham) Date: Thu, 12 Jan 2012 01:45:53 -0000 Subject: [Lldb-commits] [lldb] r148005 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Message-ID: <20120112014553.CED9B2A6C12C@llvm.org> Author: jingham Date: Wed Jan 11 19:45:53 2012 New Revision: 148005 URL: http://llvm.org/viewvc/llvm-project?rev=148005&view=rev Log: Don't dereference the oso_dwarf without checking for NULL. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=148005&r1=148004&r2=148005&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Wed Jan 11 19:45:53 2012 @@ -651,8 +651,8 @@ if (FileSpec::Compare (file_spec, so_file_spec, false) == 0) { SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (i); - - oso_dwarf->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list); + if (oso_dwarf) + oso_dwarf->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list); } } } From gclayton at apple.com Wed Jan 11 22:33:28 2012 From: gclayton at apple.com (Greg Clayton) Date: Thu, 12 Jan 2012 04:33:28 -0000 Subject: [Lldb-commits] [lldb] r148016 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: DWARFCompileUnit.cpp DWARFCompileUnit.h SymbolFileDWARF.cpp SymbolFileDWARF.h SymbolFileDWARFDebugMap.cpp SymbolFileDWARFDebugMap.h Message-ID: <20120112043329.08D722A6C12C@llvm.org> Author: gclayton Date: Wed Jan 11 22:33:28 2012 New Revision: 148016 URL: http://llvm.org/viewvc/llvm-project?rev=148016&view=rev Log: Fix DWARF parsing issue we can run into when using llvm-gcc based dSYM files. Also fix the parsing of objective C built-in types (Class, id and SEL) so they don't parse more information that is not needed due to the way they are represented in DWARF. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h 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=148016&r1=148015&r2=148016&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Wed Jan 11 22:33:28 2012 @@ -42,7 +42,8 @@ m_offset (DW_INVALID_OFFSET), m_length (0), m_version (0), - m_addr_size (DWARFCompileUnit::GetDefaultAddressSize()) + m_addr_size (DWARFCompileUnit::GetDefaultAddressSize()), + m_producer (eProducerInvalid) { } @@ -58,6 +59,7 @@ m_die_array.clear(); m_func_aranges_ap.reset(); m_user_data = NULL; + m_producer = eProducerInvalid; } bool @@ -876,4 +878,47 @@ } } +bool +DWARFCompileUnit::Supports_DW_AT_APPLE_objc_complete_type () +{ + if (GetProducer() == eProcucerLLVMGCC) + return false; + return true; +} + +bool +DWARFCompileUnit::DW_AT_decl_file_attributes_are_invalid() +{ + // llvm-gcc makes completely invalid decl file attributes and won't ever + // be fixed, so we need to know to ignore these. + return GetProducer() == eProcucerLLVMGCC; +} + +DWARFCompileUnit::Producer +DWARFCompileUnit::GetProducer () +{ + if (m_producer == eProducerInvalid) + { + const DWARFDebugInfoEntry *die = GetCompileUnitDIEOnly(); + if (die) + { + const char *producer_cstr = die->GetAttributeValueAsString(m_dwarf2Data, this, DW_AT_producer, NULL); + if (producer_cstr) + { + RegularExpression g_llvm_gcc_regex("^4\\.[012]\\.[01] \\(Based on Apple Inc\\. build [0-9]+\\) \\(LLVM build [\\.0-9]+\\)$"); + if (g_llvm_gcc_regex.Execute (producer_cstr)) + m_producer = eProcucerLLVMGCC; + else if (strstr(producer_cstr, "clang")) + m_producer = eProducerClang; + else if (strstr(producer_cstr, "GNU")) + m_producer = eProducerGCC; + } + } + if (m_producer == eProducerInvalid) + m_producer = eProcucerOther; + } + return m_producer; +} + + Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=148016&r1=148015&r2=148016&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Wed Jan 11 22:33:28 2012 @@ -18,6 +18,15 @@ class DWARFCompileUnit { public: + enum Producer + { + eProducerInvalid = 0, + eProducerClang, + eProducerGCC, + eProcucerLLVMGCC, + eProcucerOther + }; + DWARFCompileUnit(SymbolFileDWARF* dwarf2Data); bool Extract(const lldb_private::DataExtractor &debug_info, uint32_t* offset_ptr); @@ -129,6 +138,11 @@ m_user_data = d; } + bool + Supports_DW_AT_APPLE_objc_complete_type (); + + bool + DW_AT_decl_file_attributes_are_invalid(); // void // AddGlobalDIEByIndex (uint32_t die_idx); @@ -155,6 +169,10 @@ { return m_dwarf2Data; } + + Producer + GetProducer (); + protected: SymbolFileDWARF* m_dwarf2Data; @@ -167,6 +185,7 @@ uint32_t m_length; uint16_t m_version; uint8_t m_addr_size; + Producer m_producer; private: DISALLOW_COPY_AND_ASSIGN (DWARFCompileUnit); }; 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=148016&r1=148015&r2=148016&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Jan 11 22:33:28 2012 @@ -202,6 +202,7 @@ m_indexed (false), m_is_external_ast_source (false), m_using_apple_tables (false), + m_supports_DW_AT_APPLE_objc_complete_type (eLazyBoolCalculate), m_ranges(), m_unique_ast_type_map () { @@ -3852,18 +3853,50 @@ return objc_class_symbol; } +// Some compilers don't emit the DW_AT_APPLE_objc_complete_type attribute. If they don't +// then we can end up looking through all class types for a complete type and never find +// the full definition. We need to know if this attribute is supported, so we determine +// this here and cache th result. We also need to worry about the debug map DWARF file +// if we are doing darwin DWARF in .o file debugging. +bool +SymbolFileDWARF::Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu) +{ + if (m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolCalculate) + { + m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolNo; + if (cu && cu->Supports_DW_AT_APPLE_objc_complete_type()) + m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes; + else + { + DWARFDebugInfo* debug_info = DebugInfo(); + const uint32_t num_compile_units = GetNumCompileUnits(); + for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) + { + DWARFCompileUnit* curr_cu = debug_info->GetCompileUnitAtIndex(cu_idx); + if (curr_cu != cu && curr_cu->Supports_DW_AT_APPLE_objc_complete_type()) + { + m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes; + break; + } + } + } + if (m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolNo && m_debug_map_symfile) + return m_debug_map_symfile->Supports_DW_AT_APPLE_objc_complete_type (this); + } + return m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolYes; +} // 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::FindCompleteObjCDefinitionTypeForDIE (DWARFCompileUnit* cu, - const DWARFDebugInfoEntry *die, - const ConstString &type_name) +SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, + const ConstString &type_name, + bool must_be_implementation) { TypeSP type_sp; - if (cu == NULL || die == NULL || !type_name || !GetObjCClassSymbol (type_name)) + if (!type_name || (must_be_implementation && !GetObjCClassSymbol (type_name))) return type_sp; DIEArray die_offsets; @@ -3886,8 +3919,6 @@ const size_t num_matches = die_offsets.size(); - const dw_tag_t die_tag = die->Tag(); - DWARFCompileUnit* type_cu = NULL; const DWARFDebugInfoEntry* type_die = NULL; if (num_matches) @@ -3905,40 +3936,21 @@ // Don't try and resolve the DIE we are looking for with the DIE itself! if (type_die != die) { - const dw_tag_t type_die_tag = type_die->Tag(); - // Make sure the tags match - if (type_die_tag == die_tag) + switch (type_die->Tag()) { - // The tags match, lets try resolving this type - try_resolving_type = true; - } - else - { - // The tags don't match, but we need to watch our for a - // forward declaration for a struct and ("struct foo") - // ends up being a class ("class foo { ... };") or - // vice versa. - switch (type_die_tag) - { - case DW_TAG_class_type: - // We had a "class foo", see if we ended up with a "struct foo { ... };" - try_resolving_type = (die_tag == DW_TAG_structure_type); - break; - case DW_TAG_structure_type: - // We had a "struct foo", see if we ended up with a "class foo { ... };" - try_resolving_type = (die_tag == DW_TAG_class_type); - break; - default: - // Tags don't match, don't event try to resolve - // using this type whose name matches.... - break; - } + case DW_TAG_class_type: + case DW_TAG_structure_type: + try_resolving_type = true; + break; + default: + break; } } if (try_resolving_type) { - try_resolving_type = type_die->GetAttributeValueAsUnsigned (this, type_cu, DW_AT_APPLE_objc_complete_type, 0); + if (type_cu->Supports_DW_AT_APPLE_objc_complete_type()) + try_resolving_type = type_die->GetAttributeValueAsUnsigned (this, type_cu, DW_AT_APPLE_objc_complete_type, 0); if (try_resolving_type) { @@ -3952,7 +3964,8 @@ MakeUserID(type_die->GetOffset()), MakeUserID(type_cu->GetOffset())); - m_die_to_type[die] = resolved_type; + if (die) + m_die_to_type[die] = resolved_type; type_sp = resolved_type; break; } @@ -4232,28 +4245,52 @@ case DW_TAG_volatile_type: encoding_data_type = Type::eEncodingIsVolatileUID; break; } - if (type_name_cstr != NULL && sc.comp_unit != NULL && - (sc.comp_unit->GetLanguage() == eLanguageTypeObjC || sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus)) + if (clang_type == NULL && (encoding_data_type == Type::eEncodingIsPointerUID || encoding_data_type == Type::eEncodingIsTypedefUID)) { - static ConstString g_objc_type_name_id("id"); - static ConstString g_objc_type_name_Class("Class"); - static ConstString g_objc_type_name_selector("SEL"); - - if (type_name_const_str == g_objc_type_name_id) + if (type_name_cstr != NULL && sc.comp_unit != NULL && + (sc.comp_unit->GetLanguage() == eLanguageTypeObjC || sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus)) { - clang_type = ast.GetBuiltInType_objc_id(); - resolve_state = Type::eResolveStateFull; + static ConstString g_objc_type_name_id("id"); + static ConstString g_objc_type_name_Class("Class"); + static ConstString g_objc_type_name_selector("SEL"); + + if (type_name_const_str == g_objc_type_name_id) + { + if (log) + GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'id' built-in type.", + die->GetOffset(), + DW_TAG_value_to_name(die->Tag()), + die->GetName(this, dwarf_cu)); + clang_type = ast.GetBuiltInType_objc_id(); + encoding_data_type = Type::eEncodingIsUID; + encoding_uid = LLDB_INVALID_UID; + resolve_state = Type::eResolveStateFull; - } - else if (type_name_const_str == g_objc_type_name_Class) - { - clang_type = ast.GetBuiltInType_objc_Class(); - resolve_state = Type::eResolveStateFull; - } - else if (type_name_const_str == g_objc_type_name_selector) - { - clang_type = ast.GetBuiltInType_objc_selector(); - resolve_state = Type::eResolveStateFull; + } + else if (type_name_const_str == g_objc_type_name_Class) + { + if (log) + GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'Class' built-in type.", + die->GetOffset(), + DW_TAG_value_to_name(die->Tag()), + die->GetName(this, dwarf_cu)); + clang_type = ast.GetBuiltInType_objc_Class(); + encoding_data_type = Type::eEncodingIsUID; + encoding_uid = LLDB_INVALID_UID; + resolve_state = Type::eResolveStateFull; + } + else if (type_name_const_str == g_objc_type_name_selector) + { + if (log) + GetObjectFile()->GetModule()->LogMessage (log.get(), "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'selector' built-in type.", + die->GetOffset(), + DW_TAG_value_to_name(die->Tag()), + die->GetName(this, dwarf_cu)); + clang_type = ast.GetBuiltInType_objc_selector(); + encoding_data_type = Type::eEncodingIsUID; + encoding_uid = LLDB_INVALID_UID; + resolve_state = Type::eResolveStateFull; + } } } @@ -4304,7 +4341,15 @@ switch (attr) { case DW_AT_decl_file: - decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); + if (dwarf_cu->DW_AT_decl_file_attributes_are_invalid()) + { + // llvm-gcc outputs invalid DW_AT_decl_file attributes that always + // point to the compile unit file, so we clear this invalid value + // so that we can still unique types efficiently. + decl.SetFile(FileSpec ("", false)); + } + else + decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; case DW_AT_decl_line: @@ -4420,21 +4465,21 @@ if (class_language == eLanguageTypeObjC) { - if (!is_complete_objc_class) + if (!is_complete_objc_class && Supports_DW_AT_APPLE_objc_complete_type(dwarf_cu)) { // We have a valid eSymbolTypeObjCClass class symbol whose // name matches the current objective C class that we // are trying to find and this DIE isn't the complete // definition (we checked is_complete_objc_class above and // know it is false), so the real definition is in here somewhere - type_sp = FindCompleteObjCDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); + type_sp = FindCompleteObjCDefinitionTypeForDIE (die, type_name_const_str, true); if (!type_sp && m_debug_map_symfile) { // We weren't able to find a full declaration in // this DWARF, see if we have a declaration anywhere // else... - type_sp = m_debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); + type_sp = m_debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE (die, type_name_const_str, true); } if (type_sp) @@ -4865,19 +4910,16 @@ { ConstString class_name (class_name_start, class_name_end - class_name_start); TypeList types; - const uint32_t match_count = FindTypes (empty_sc, class_name, NULL, true, UINT32_MAX, types); - if (match_count > 0) + + TypeSP complete_objc_class_type_sp (FindCompleteObjCDefinitionTypeForDIE (NULL, class_name, true)); + if (!complete_objc_class_type_sp) + complete_objc_class_type_sp = FindCompleteObjCDefinitionTypeForDIE (NULL, class_name, false); + + if (complete_objc_class_type_sp) { - for (uint32_t i=0; iGetClangForwardType(); - if (ClangASTContext::IsObjCClassType (type_clang_forward_type)) - { - class_opaque_type = type_clang_forward_type; - break; - } - } + clang_type_t type_clang_forward_type = complete_objc_class_type_sp->GetClangForwardType(); + if (ClangASTContext::IsObjCClassType (type_clang_forward_type)) + class_opaque_type = type_clang_forward_type; } } 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=148016&r1=148015&r2=148016&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Wed Jan 11 22:33:28 2012 @@ -22,6 +22,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" +#include "lldb/lldb-private.h" #include "lldb/Core/ClangForward.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/dwarf.h" @@ -375,9 +376,14 @@ const lldb_private::ConstString &type_name); lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE ( - DWARFCompileUnit* cu, const DWARFDebugInfoEntry *die, - const lldb_private::ConstString &type_name); + const lldb_private::ConstString &type_name, + bool must_be_implementation); + + bool Supports_DW_AT_APPLE_objc_complete_type (DWARFCompileUnit *cu); + + lldb::TypeSP FindCompleteObjCDefinitionType (const lldb_private::ConstString &type_name, + bool header_definition_ok); lldb_private::Symbol * GetObjCClassSymbol (const lldb_private::ConstString &objc_class_name); @@ -498,9 +504,10 @@ 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, - m_using_apple_tables:1; + bool m_indexed:1, + m_is_external_ast_source:1, + m_using_apple_tables:1; + lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type; std::auto_ptr m_ranges; UniqueDWARFASTTypeMap m_unique_ast_type_map; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=148016&r1=148015&r2=148016&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Wed Jan 11 22:33:28 2012 @@ -65,7 +65,8 @@ m_flags(), m_compile_unit_infos(), m_func_indexes(), - m_glob_indexes() + m_glob_indexes(), + m_supports_DW_AT_APPLE_objc_complete_type (eLazyBoolCalculate) { } @@ -952,16 +953,36 @@ } + +bool +SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWARF *skip_dwarf_oso) +{ + if (m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolCalculate) + { + m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolNo; + SymbolFileDWARF *oso_dwarf; + for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) + { + if (skip_dwarf_oso != oso_dwarf && oso_dwarf->Supports_DW_AT_APPLE_objc_complete_type(NULL)) + { + m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes; + break; + } + } + } + return m_supports_DW_AT_APPLE_objc_complete_type == eLazyBoolYes; +} + TypeSP -SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (DWARFCompileUnit* cu, - const DWARFDebugInfoEntry *die, - const ConstString &type_name) +SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, + const ConstString &type_name, + bool must_be_implementation) { TypeSP type_sp; SymbolFileDWARF *oso_dwarf; for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) { - type_sp = oso_dwarf->FindCompleteObjCDefinitionTypeForDIE (cu, die, type_name); + type_sp = oso_dwarf->FindCompleteObjCDefinitionTypeForDIE (die, type_name, must_be_implementation); if (type_sp) break; } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=148016&r1=148015&r2=148016&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Wed Jan 11 22:33:28 2012 @@ -216,10 +216,13 @@ const DWARFDebugInfoEntry *die, const lldb_private::ConstString &type_name); + bool + Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWARF *skip_dwarf_oso); + lldb::TypeSP - FindCompleteObjCDefinitionTypeForDIE (DWARFCompileUnit* cu, - const DWARFDebugInfoEntry *die, - const lldb_private::ConstString &type_name); + FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, + const lldb_private::ConstString &type_name, + bool must_be_implementation); UniqueDWARFASTTypeMap & @@ -235,6 +238,7 @@ std::vector m_func_indexes; // Sorted by address std::vector m_glob_indexes; UniqueDWARFASTTypeMap m_unique_ast_type_map; + lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type; }; #endif // #ifndef SymbolFileDWARF_SymbolFileDWARFDebugMap_h_ From gclayton at apple.com Wed Jan 11 23:25:18 2012 From: gclayton at apple.com (Greg Clayton) Date: Thu, 12 Jan 2012 05:25:18 -0000 Subject: [Lldb-commits] [lldb] r148017 - in /lldb/trunk: include/lldb/Core/ include/lldb/Symbol/ source/Core/ source/Host/macosx/ source/Plugins/ObjectContainer/BSD-Archive/ source/Plugins/ObjectContainer/Universal-Mach-O/ source/Plugins/ObjectFile/ELF/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/SymbolVendor/MacOSX/ source/Symbol/ Message-ID: <20120112052518.930DF2A6C12C@llvm.org> Author: gclayton Date: Wed Jan 11 23:25:17 2012 New Revision: 148017 URL: http://llvm.org/viewvc/llvm-project?rev=148017&view=rev Log: Big change in the way ObjectFile file contents are managed. We now mmap() the entire object file contents into memory with MAP_PRIVATE. We do this because object file contents can change on us and currently this helps alleviate this situation. It also make the code for accessing object file data much easier to manage and we don't end up opening the file, reading some data and closing the file over and over. Modified: lldb/trunk/include/lldb/Core/Section.h lldb/trunk/include/lldb/Symbol/ObjectContainer.h lldb/trunk/include/lldb/Symbol/ObjectFile.h lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Core/Section.cpp lldb/trunk/source/Host/macosx/Symbols.cpp lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp lldb/trunk/source/Symbol/ObjectFile.cpp Modified: lldb/trunk/include/lldb/Core/Section.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Section.h (original) +++ lldb/trunk/include/lldb/Core/Section.h Wed Jan 11 23:25:17 2012 @@ -199,9 +199,6 @@ m_byte_size = byte_size; } - size_t - GetSectionDataFromImage (const DataExtractor& image_data, DataExtractor& section_data) const; - bool IsFake() const { Modified: lldb/trunk/include/lldb/Symbol/ObjectContainer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectContainer.h?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ObjectContainer.h (original) +++ lldb/trunk/include/lldb/Symbol/ObjectContainer.h Wed Jan 11 23:25:17 2012 @@ -49,17 +49,19 @@ //------------------------------------------------------------------ ObjectContainer (Module* module, const FileSpec *file, - lldb::addr_t offset, - lldb::addr_t length, - lldb::DataBufferSP& headerDataSP) : + lldb::addr_t file_offset, + lldb::addr_t file_size, + lldb::DataBufferSP& file_data_sp) : ModuleChild (module), m_file (), // This file can be different than the module's file spec - m_offset (offset), - m_length (length), - m_data (headerDataSP, lldb::endian::InlHostByteOrder(), 4) + m_offset (file_offset), + m_length (file_size), + m_data () { if (file) m_file = *file; + if (file_data_sp) + m_data.SetData (file_data_sp, file_offset, file_size); } //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original) +++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Wed Jan 11 23:25:17 2012 @@ -146,7 +146,8 @@ FindPlugin (Module* module, const FileSpec* file_spec, lldb::addr_t file_offset, - lldb::addr_t file_size); + lldb::addr_t file_size, + lldb::DataBufferSP &data_sp); //------------------------------------------------------------------ /// Gets the address size in bytes for the current object file. @@ -423,7 +424,12 @@ return m_strata; } - + size_t + GetData (off_t offset, size_t length, DataExtractor &data) const; + + size_t + CopyData (off_t offset, size_t length, void *dst) const; + protected: //------------------------------------------------------------------ // Member variables. Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Wed Jan 11 23:25:17 2012 @@ -782,7 +782,8 @@ m_did_load_objfile = true; Timer scoped_timer(__PRETTY_FUNCTION__, "Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString("")); - m_objfile_sp = ObjectFile::FindPlugin(this, &m_file, m_object_offset, m_file.GetByteSize()); + DataBufferSP file_data_sp; + m_objfile_sp = ObjectFile::FindPlugin(this, &m_file, m_object_offset, m_file.GetByteSize(), file_data_sp); if (m_objfile_sp) { // Once we get the object file, update our module with the object file's Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Wed Jan 11 23:25:17 2012 @@ -878,6 +878,8 @@ if (!file_spec.Exists()) { file_spec.GetPath(path, sizeof(path)); + if (path[0] == '\0') + in_file_spec.GetPath(path, sizeof(path)); if (file_spec.Exists()) { if (uuid_ptr && uuid_ptr->IsValid()) Modified: lldb/trunk/source/Core/Section.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Core/Section.cpp (original) +++ lldb/trunk/source/Core/Section.cpp Wed Jan 11 23:25:17 2012 @@ -228,7 +228,7 @@ { // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); - s->Printf("0x%8.8llx %-14s ", GetID(), GetSectionTypeAsCString (m_type)); + s->Printf("0x%8.8llx %-16s ", GetID(), GetSectionTypeAsCString (m_type)); bool resolved = true; addr_t addr = LLDB_INVALID_ADDRESS; @@ -307,53 +307,12 @@ m_name.Dump(s); } -//---------------------------------------------------------------------- -// Get the section data from a complete contiguous copy of the -// entire executable image. -//---------------------------------------------------------------------- -size_t -Section::GetSectionDataFromImage (const DataExtractor& image_data, DataExtractor& section_data) const -{ - size_t file_size = GetByteSize(); - if (file_size > 0) - { - off_t file_offset = GetFileOffset(); - if (section_data.SetData (image_data, file_offset, file_size) == file_size) - return true; - } - return false; -} - size_t Section::ReadSectionDataFromObjectFile (const ObjectFile* objfile, off_t section_offset, void *dst, size_t dst_len) const { - if (objfile && dst && dst_len) - { - const FileSpec& file = objfile->GetFileSpec(); - - if (file) - { - size_t bytes_left = dst_len; - size_t bytes_read = 0; - const uint64_t file_size = GetFileSize(); - if (section_offset < file_size) - { - off_t section_file_offset = objfile->GetOffset() + GetFileOffset() + section_offset; - bytes_read = file.ReadFileContents (section_file_offset, dst, dst_len, NULL); - if (bytes_read >= dst_len) - return bytes_read; - bytes_left -= bytes_read; - } - - const uint64_t byte_size = GetByteSize(); - if (section_offset + bytes_read < byte_size) - { - memset ((uint8_t*)dst + bytes_read, 0, bytes_left); - bytes_read += bytes_left; - } - return bytes_read; - } - } + // The object file now contains a full mmap'ed copy of the object file data, so just use this + if (objfile) + return objfile->CopyData (GetFileOffset() + section_offset, dst_len, dst); return 0; } @@ -363,47 +322,17 @@ size_t Section::ReadSectionDataFromObjectFile(const ObjectFile* objfile, DataExtractor& section_data) const { - if (objfile == NULL) - return 0; - - const FileSpec& file = objfile->GetFileSpec(); - - if (file) - { - size_t section_file_size = GetByteSize(); - if (section_file_size > 0) - { - off_t section_file_offset = GetFileOffset() + objfile->GetOffset(); - DataBufferSP section_data_sp(file.ReadFileContents(section_file_offset, section_file_size)); - - section_data.SetByteOrder(objfile->GetByteOrder()); - section_data.SetAddressByteSize(objfile->GetAddressByteSize()); - return section_data.SetData (section_data_sp); - } - } - return 0; + // The object file now contains a full mmap'ed copy of the object file data, so just use this + return MemoryMapSectionDataFromObjectFile (objfile, section_data); } size_t Section::MemoryMapSectionDataFromObjectFile(const ObjectFile* objfile, DataExtractor& section_data) const { - if (objfile == NULL) - return 0; - - const FileSpec& file = objfile->GetFileSpec(); - - if (file) - { - size_t section_file_size = GetFileSize(); - if (section_file_size > 0) - { - off_t section_file_offset = GetFileOffset() + objfile->GetOffset(); - DataBufferSP section_data_sp(file.MemoryMapFileContents(section_file_offset, section_file_size)); - section_data.SetByteOrder(objfile->GetByteOrder()); - section_data.SetAddressByteSize(objfile->GetAddressByteSize()); - return section_data.SetData (section_data_sp); - } - } + // The object file now contains a full mmap'ed copy of the object file data, so just use this + if (objfile) + return objfile->GetData(GetFileOffset(), GetByteSize(), section_data); + section_data.Clear(); return 0; } @@ -691,16 +620,10 @@ bool target_has_loaded_sections = target && !target->GetSectionLoadList().IsEmpty(); if (show_header && !m_sections.empty()) { -// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); -// s->Indent(); -// s->PutCString( "SectionList\n"); -// s->IndentMore(); -// s->Printf("%*s", 2*(sizeof(void *) + 2), ""); s->Indent(); - s->Printf("SectID Type %s Address File Off. File Size Flags Section Name\n", target_has_loaded_sections ? "Load" : "File"); -// s->Printf("%*s", 2*(sizeof(void *) + 2), ""); + s->Printf( "SectID Type %s Address File Off. File Size Flags Section Name\n", target_has_loaded_sections ? "Load" : "File"); s->Indent(); - s->PutCString("---------- -------------- --------------------------------------- ---------- ---------- ---------- ----------------------------\n"); + s->PutCString("---------- ---------------- --------------------------------------- ---------- ---------- ---------- ----------------------------\n"); } Modified: lldb/trunk/source/Host/macosx/Symbols.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Symbols.cpp (original) +++ lldb/trunk/source/Host/macosx/Symbols.cpp Wed Jan 11 23:25:17 2012 @@ -450,7 +450,7 @@ dsym_fspec.SetFile(path, false); - if (FileAtPathContainsArchAndUUID (dsym_fspec, arch, uuid)) + if (dsym_fspec.Exists() && FileAtPathContainsArchAndUUID (dsym_fspec, arch, uuid)) { return true; } @@ -468,7 +468,7 @@ strncat(path, ".dSYM/Contents/Resources/DWARF/", sizeof(path)); strncat(path, exec_fspec->GetFilename().AsCString(), sizeof(path)); dsym_fspec.SetFile(path, false); - if (dsym_fspec.Exists()) + if (dsym_fspec.Exists() && FileAtPathContainsArchAndUUID (dsym_fspec, arch, uuid)) return true; else { Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (original) +++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Wed Jan 11 23:25:17 2012 @@ -269,7 +269,9 @@ addr_t offset, addr_t length) { - if (file && data_sp && ObjectContainerBSDArchive::MagicBytesMatch(data_sp)) + DataExtractor data; + data.SetData (data_sp, offset, length); + if (file && data_sp && ObjectContainerBSDArchive::MagicBytesMatch(data)) { Timer scoped_timer (__PRETTY_FUNCTION__, "ObjectContainerBSDArchive::CreateInstance (module = %s/%s, file = %p, file_offset = 0x%z8.8x, file_size = 0x%z8.8x)", @@ -278,25 +280,20 @@ file, offset, length); Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, module->GetArchitecture(), module->GetModificationTime())); - - if (archive_sp) + + std::auto_ptr container_ap(new ObjectContainerBSDArchive (module, data_sp, file, offset, length)); + + if (container_ap.get()) { - // We already have this archive in our cache, use it - std::auto_ptr container_ap(new ObjectContainerBSDArchive (module, data_sp, file, offset, length)); - if (container_ap.get()) + if (archive_sp) { + // We already have this archive in our cache, use it container_ap->SetArchive (archive_sp); return container_ap.release(); } + else if (container_ap->ParseHeader()) + return container_ap.release(); } - - // Read everything since we need that in order to index all the - // objects in the archive - data_sp = file->MemoryMapFileContents (offset, length); - - std::auto_ptr container_ap(new ObjectContainerBSDArchive (module, data_sp, file, offset, length)); - if (container_ap->ParseHeader()) - return container_ap.release(); } return NULL; } @@ -304,9 +301,8 @@ bool -ObjectContainerBSDArchive::MagicBytesMatch (DataBufferSP& dataSP) +ObjectContainerBSDArchive::MagicBytesMatch (const DataExtractor &data) { - DataExtractor data(dataSP, lldb::endian::InlHostByteOrder(), 4); uint32_t offset = 0; const char* armag = (const char* )data.PeekData (offset, sizeof(ar_hdr)); if (armag && ::strncmp(armag, ARMAG, SARMAG) == 0) @@ -353,11 +349,6 @@ m_module->GetArchitecture(), m_module->GetModificationTime(), m_data); - // The archive might be huge, so clear "m_data" to free up the - // memory since it will contain the entire file (possibly more than - // one architecture slice). We already have an index of all objects - // in the file, so we will be ready to serve up those objects. - m_data.Clear(); } } return m_archive_sp.get() != NULL; @@ -396,7 +387,11 @@ { Object *object = m_archive_sp->FindObject (m_module->GetObjectName()); if (object) - return ObjectFile::FindPlugin (m_module, file, m_offset + object->ar_file_offset, object->ar_file_size); + return ObjectFile::FindPlugin (m_module, + file, + object->ar_file_offset, + object->ar_file_size, + m_data.GetSharedDataBuffer()); } return ObjectFileSP(); } Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h (original) +++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h Wed Jan 11 23:25:17 2012 @@ -46,7 +46,7 @@ lldb::addr_t length); static bool - MagicBytesMatch (lldb::DataBufferSP& dataSP); + MagicBytesMatch (const lldb_private::DataExtractor &data); //------------------------------------------------------------------ // Member Functions Modified: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp Wed Jan 11 23:25:17 2012 @@ -51,15 +51,17 @@ ObjectContainerUniversalMachO::CreateInstance ( Module* module, - DataBufferSP& dataSP, + DataBufferSP& data_sp, const FileSpec *file, addr_t offset, addr_t length ) { - if (ObjectContainerUniversalMachO::MagicBytesMatch(dataSP)) + DataExtractor data; + data.SetData (data_sp, offset, length); + if (ObjectContainerUniversalMachO::MagicBytesMatch(data)) { - std::auto_ptr container_ap(new ObjectContainerUniversalMachO (module, dataSP, file, offset, length)); + std::auto_ptr container_ap(new ObjectContainerUniversalMachO (module, data_sp, file, offset, length)); if (container_ap->ParseHeader()) { return container_ap.release(); @@ -71,9 +73,8 @@ bool -ObjectContainerUniversalMachO::MagicBytesMatch (DataBufferSP& dataSP) +ObjectContainerUniversalMachO::MagicBytesMatch (const DataExtractor &data) { - DataExtractor data(dataSP, lldb::endian::InlHostByteOrder(), 4); uint32_t offset = 0; uint32_t magic = data.GetU32(&offset); return magic == UniversalMagic || magic == UniversalMagicSwapped; @@ -115,17 +116,6 @@ m_header.nfat_arch = m_data.GetU32(&offset); - const size_t nfat_arch_size = sizeof(fat_arch) * m_header.nfat_arch; - // See if the current data we have is enough for all of the fat headers? - if (!m_data.ValidOffsetForDataOfSize(offset, nfat_arch_size)) - { - // The fat headers are larger than the number of bytes we have been - // given when this class was constructed. We will read the exact number - // of bytes that we need. - DataBufferSP data_sp(m_file.ReadFileContents(m_offset, nfat_arch_size + sizeof(fat_header))); - m_data.SetData (data_sp); - } - // Now we should have enough data for all of the fat headers, so lets index // them so we know how many architectures that this universal binary contains. uint32_t arch_idx = 0; @@ -140,9 +130,6 @@ } } } - // Now that we have indexed the universal headers, we no longer need any cached data. - m_data.Clear(); - return true; } else @@ -222,7 +209,8 @@ return ObjectFile::FindPlugin (m_module, file, m_offset + m_fat_archs[arch_idx].offset, - m_fat_archs[arch_idx].size); + m_fat_archs[arch_idx].size, + m_data.GetSharedDataBuffer()); } } } Modified: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h (original) +++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h Wed Jan 11 23:25:17 2012 @@ -42,7 +42,7 @@ lldb::addr_t length); static bool - MagicBytesMatch (lldb::DataBufferSP& dataSP); + MagicBytesMatch (const lldb_private::DataExtractor &data); //------------------------------------------------------------------ // Member Functions Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Jan 11 23:25:17 2012 @@ -473,15 +473,11 @@ return 0; const size_t ph_size = m_header.e_phnum * m_header.e_phentsize; - const elf_off ph_offset = m_offset + m_header.e_phoff; - DataBufferSP buffer_sp(m_file.ReadFileContents(ph_offset, ph_size)); - - if (buffer_sp.get() == NULL || buffer_sp->GetByteSize() != ph_size) + const elf_off ph_offset = m_header.e_phoff; + DataExtractor data; + if (GetData (ph_offset, ph_size, data) != ph_size) return 0; - DataExtractor data(buffer_sp, m_data.GetByteOrder(), - m_data.GetAddressByteSize()); - uint32_t idx; uint32_t offset; for (idx = 0, offset = 0; idx < m_header.e_phnum; ++idx) @@ -515,16 +511,11 @@ return 0; const size_t sh_size = m_header.e_shnum * m_header.e_shentsize; - const elf_off sh_offset = m_offset + m_header.e_shoff; - DataBufferSP buffer_sp(m_file.ReadFileContents(sh_offset, sh_size)); - - if (buffer_sp.get() == NULL || buffer_sp->GetByteSize() != sh_size) + const elf_off sh_offset = m_header.e_shoff; + DataExtractor data; + if (GetData (sh_offset, sh_size, data) != sh_size) return 0; - DataExtractor data(buffer_sp, - m_data.GetByteOrder(), - m_data.GetAddressByteSize()); - uint32_t idx; uint32_t offset; for (idx = 0, offset = 0; idx < m_header.e_shnum; ++idx) @@ -549,13 +540,11 @@ { const ELFSectionHeader &sheader = m_section_headers[strtab_idx]; const size_t byte_size = sheader.sh_size; - const Elf64_Off offset = m_offset + sheader.sh_offset; - DataBufferSP buffer_sp(m_file.ReadFileContents(offset, byte_size)); + const Elf64_Off offset = sheader.sh_offset; + m_shstr_data.SetData (m_data, offset, byte_size); - if (buffer_sp.get() == NULL || buffer_sp->GetByteSize() != byte_size) + if (m_shstr_data.GetByteSize() != byte_size) return 0; - - m_shstr_data.SetData(buffer_sp); } } return m_shstr_data.GetByteSize(); 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=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Jan 11 23:25:17 2012 @@ -63,11 +63,11 @@ ObjectFile * -ObjectFileMachO::CreateInstance (Module* module, DataBufferSP& dataSP, const FileSpec* file, addr_t offset, addr_t length) +ObjectFileMachO::CreateInstance (Module* module, DataBufferSP& data_sp, const FileSpec* file, addr_t offset, addr_t length) { - if (ObjectFileMachO::MagicBytesMatch(dataSP)) + if (ObjectFileMachO::MagicBytesMatch(data_sp, offset, length)) { - std::auto_ptr objfile_ap(new ObjectFileMachO (module, dataSP, file, offset, length)); + std::auto_ptr objfile_ap(new ObjectFileMachO (module, data_sp, file, offset, length)); if (objfile_ap.get() && objfile_ap->ParseHeader()) return objfile_ap.release(); } @@ -97,17 +97,20 @@ bool -ObjectFileMachO::MagicBytesMatch (DataBufferSP& dataSP) +ObjectFileMachO::MagicBytesMatch (DataBufferSP& data_sp, + lldb::addr_t data_offset, + lldb::addr_t data_length) { - DataExtractor data(dataSP, lldb::endian::InlHostByteOrder(), 4); + DataExtractor data; + data.SetData (data_sp, data_offset, data_length); uint32_t offset = 0; uint32_t magic = data.GetU32(&offset); return MachHeaderSizeFromMagic(magic) != 0; } -ObjectFileMachO::ObjectFileMachO(Module* module, DataBufferSP& dataSP, const FileSpec* file, addr_t offset, addr_t length) : - ObjectFile(module, file, offset, length, dataSP), +ObjectFileMachO::ObjectFileMachO(Module* module, DataBufferSP& data_sp, const FileSpec* file, addr_t offset, addr_t length) : + ObjectFile(module, file, offset, length, data_sp), m_mutex (Mutex::eMutexTypeRecursive), m_header(), m_sections_ap(), @@ -170,12 +173,7 @@ ArchSpec mach_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype); if (SetModulesArchitecture (mach_arch)) - { - // Read in all only the load command data - DataBufferSP data_sp(m_file.ReadFileContents(m_offset, m_header.sizeofcmds + MachHeaderSizeFromMagic(m_header.magic))); - m_data.SetData (data_sp); return true; - } } else { @@ -802,37 +800,27 @@ return 0; const size_t addr_byte_size = m_data.GetAddressByteSize(); - const ByteOrder byte_order = m_data.GetByteOrder(); bool bit_width_32 = addr_byte_size == 4; const size_t nlist_byte_size = bit_width_32 ? sizeof(struct nlist) : sizeof(struct nlist_64); - DataBufferSP symtab_data_sp(m_file.ReadFileContents (m_offset + symtab_load_command.symoff, - symtab_load_command.nsyms * nlist_byte_size)); + DataExtractor nlist_data (m_data, symtab_load_command.symoff, symtab_load_command.nsyms * nlist_byte_size); - if (symtab_data_sp.get() == NULL || - symtab_data_sp->GetBytes() == NULL || - symtab_data_sp->GetByteSize() == 0) + if (nlist_data.GetByteSize() == 0) { if (log) GetModule()->LogMessage(log.get(), "failed to read nlist data"); return 0; } - DataBufferSP strtab_data_sp(m_file.ReadFileContents (m_offset + symtab_load_command.stroff, - symtab_load_command.strsize)); + DataExtractor strtab_data (m_data, symtab_load_command.stroff, symtab_load_command.strsize); - if (strtab_data_sp.get() == NULL || - strtab_data_sp->GetBytes() == NULL || - strtab_data_sp->GetByteSize() == 0) + if (strtab_data.GetByteSize() == 0) { if (log) GetModule()->LogMessage(log.get(), "failed to read strtab data"); return 0; } - const char *strtab_data = (const char *)strtab_data_sp->GetBytes(); - const size_t strtab_data_len = strtab_data_sp->GetByteSize(); - static ConstString g_segment_name_TEXT ("__TEXT"); static ConstString g_segment_name_DATA ("__DATA"); static ConstString g_segment_name_OBJC ("__OBJC"); @@ -847,11 +835,8 @@ eh_frame_section_sp = section_list->FindSectionByName (g_section_name_eh_frame); uint8_t TEXT_eh_frame_sectID = eh_frame_section_sp.get() ? eh_frame_section_sp->GetID() : NListSectionNoSection; - //uint32_t symtab_offset = 0; - assert (symtab_data_sp->GetByteSize()/nlist_byte_size >= symtab_load_command.nsyms); uint32_t nlist_data_offset = 0; - DataExtractor nlist_data (symtab_data_sp, byte_order, addr_byte_size); uint32_t N_SO_index = UINT32_MAX; @@ -889,7 +874,8 @@ nlist.n_value = nlist_data.GetAddress_unchecked (&nlist_data_offset); SymbolType type = eSymbolTypeInvalid; - if (nlist.n_strx >= strtab_data_len) + const char *symbol_name = strtab_data.PeekCStr(nlist.n_strx); + if (symbol_name == NULL) { // No symbol should be NULL, even the symbols with no // string values should have an offset zero which points @@ -902,7 +888,6 @@ m_module->GetFileSpec().GetFilename().GetCString()); continue; } - const char *symbol_name = &strtab_data[nlist.n_strx]; const char *symbol_name_non_abi_mangled = NULL; if (symbol_name[0] == '\0') @@ -1517,12 +1502,11 @@ // Now synthesize indirect symbols if (m_dysymtab.nindirectsyms != 0) { - DataBufferSP indirect_symbol_indexes_sp(m_file.ReadFileContents(m_offset + m_dysymtab.indirectsymoff, m_dysymtab.nindirectsyms * 4)); + DataExtractor indirect_symbol_index_data (m_data, m_dysymtab.indirectsymoff, m_dysymtab.nindirectsyms * 4); - if (indirect_symbol_indexes_sp && indirect_symbol_indexes_sp->GetByteSize()) + if (indirect_symbol_index_data.GetByteSize()) { NListIndexToSymbolIndexMap::const_iterator end_index_pos = m_nlist_idx_to_sym_idx.end(); - DataExtractor indirect_symbol_index_data (indirect_symbol_indexes_sp, m_data.GetByteOrder(), m_data.GetAddressByteSize()); for (uint32_t sect_idx = 1; sect_idx < m_mach_sections.size(); ++sect_idx) { Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Wed Jan 11 23:25:17 2012 @@ -48,7 +48,9 @@ lldb::addr_t length); static bool - MagicBytesMatch (lldb::DataBufferSP& dataSP); + MagicBytesMatch (lldb::DataBufferSP& dataSP, + lldb::addr_t offset, + lldb::addr_t length); //------------------------------------------------------------------ // Member Functions Modified: lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp Wed Jan 11 23:25:17 2012 @@ -148,7 +148,8 @@ if (dsym_fspec) { - dsym_objfile_sp = ObjectFile::FindPlugin(module, &dsym_fspec, 0, dsym_fspec.GetByteSize()); + DataBufferSP dsym_file_data_sp; + dsym_objfile_sp = ObjectFile::FindPlugin(module, &dsym_fspec, 0, dsym_fspec.GetByteSize(), dsym_file_data_sp); if (UUIDsMatch(module, dsym_objfile_sp.get())) { ReplaceDSYMSectionsWithExecutableSections (obj_file, dsym_objfile_sp.get()); Modified: lldb/trunk/source/Symbol/ObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=148017&r1=148016&r2=148017&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ObjectFile.cpp (original) +++ lldb/trunk/source/Symbol/ObjectFile.cpp Wed Jan 11 23:25:17 2012 @@ -9,6 +9,7 @@ #include "lldb/lldb-private.h" #include "lldb/lldb-private-log.h" +#include "lldb/Core/DataBuffer.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" @@ -22,7 +23,7 @@ using namespace lldb_private; ObjectFileSP -ObjectFile::FindPlugin (Module* module, const FileSpec* file, addr_t file_offset, addr_t file_size) +ObjectFile::FindPlugin (Module* module, const FileSpec* file, addr_t file_offset, addr_t file_size, DataBufferSP &file_data_sp) { Timer scoped_timer (__PRETTY_FUNCTION__, "ObjectFile::FindPlugin (module = %s/%s, file = %p, file_offset = 0x%z8.8x, file_size = 0x%z8.8x)", @@ -35,10 +36,14 @@ { if (file) { - if (file_size == 0) - file_size = file->GetByteSize(); + // Memory map the entire file contents + if (!file_data_sp) + { + assert (file_offset == 0); + file_data_sp = file->MemoryMapFileContents(file_offset, file_size); + } - if (file_size == 0) + if (!file_data_sp || file_data_sp->GetByteSize() == 0) { // Check for archive file with format "/path/to/archive.a(object.o)" char path_with_object[PATH_MAX*2]; @@ -56,42 +61,42 @@ archive_file.SetFile (path.c_str(), false); file_size = archive_file.GetByteSize(); if (file_size > 0) + { module->SetFileSpecAndObjectName (archive_file, ConstString(object.c_str())); + file_data_sp = archive_file.MemoryMapFileContents(file_offset, file_size); + } } } } - // No need to delegate further if (file_offset, file_size) exceeds the total file size. - // This is the base case. -// if (file_offset + file_size > file->GetByteSize()) -// return NULL; - - DataBufferSP file_header_data_sp(file->ReadFileContents(file_offset, 512)); - uint32_t idx; - - // Check if this is a normal object file by iterating through - // all object file plugin instances. - ObjectFileCreateInstance create_object_file_callback; - for (idx = 0; (create_object_file_callback = PluginManager::GetObjectFileCreateCallbackAtIndex(idx)) != NULL; ++idx) + if (file_data_sp && file_data_sp->GetByteSize() > 0) { - object_file_sp.reset (create_object_file_callback(module, file_header_data_sp, file, file_offset, file_size)); - if (object_file_sp.get()) - return object_file_sp; - } + uint32_t idx; - // Check if this is a object container by iterating through - // all object container plugin instances and then trying to get - // an object file from the container. - ObjectContainerCreateInstance create_object_container_callback; - for (idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx) - { - std::auto_ptr object_container_ap(create_object_container_callback(module, file_header_data_sp, file, file_offset, file_size)); + // Check if this is a normal object file by iterating through + // all object file plugin instances. + ObjectFileCreateInstance create_object_file_callback; + for (idx = 0; (create_object_file_callback = PluginManager::GetObjectFileCreateCallbackAtIndex(idx)) != NULL; ++idx) + { + object_file_sp.reset (create_object_file_callback(module, file_data_sp, file, file_offset, file_size)); + if (object_file_sp.get()) + return object_file_sp; + } + + // Check if this is a object container by iterating through + // all object container plugin instances and then trying to get + // an object file from the container. + ObjectContainerCreateInstance create_object_container_callback; + for (idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx) + { + std::auto_ptr object_container_ap(create_object_container_callback(module, file_data_sp, file, file_offset, file_size)); - if (object_container_ap.get()) - object_file_sp = object_container_ap->GetObjectFile(file); + if (object_container_ap.get()) + object_file_sp = object_container_ap->GetObjectFile(file); - if (object_file_sp.get()) - return object_file_sp; + if (object_file_sp.get()) + return object_file_sp; + } } } } @@ -103,20 +108,22 @@ ObjectFile::ObjectFile (Module* module, const FileSpec *file_spec_ptr, - addr_t offset, - addr_t length, - DataBufferSP& headerDataSP) : + addr_t file_offset, + addr_t file_size, + DataBufferSP& file_data_sp) : ModuleChild (module), m_file (), // This file could be different from the original module's file m_type (eTypeInvalid), m_strata (eStrataInvalid), - m_offset (offset), - m_length (length), - m_data (headerDataSP, endian::InlHostByteOrder(), 4), + m_offset (file_offset), + m_length (file_size), + m_data (), m_unwind_table (*this) { if (file_spec_ptr) m_file = *file_spec_ptr; + if (file_data_sp) + m_data.SetData (file_data_sp, file_offset, file_size); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) { @@ -277,4 +284,18 @@ return ObjectFileSP (this); } +size_t +ObjectFile::GetData (off_t offset, size_t length, DataExtractor &data) const +{ + // The entire file has already been mmap'ed into m_data, so just copy from there + // as the back mmap buffer will be shared with shared pointers. + return data.SetData (m_data, offset, length); +} + +size_t +ObjectFile::CopyData (off_t offset, size_t length, void *dst) const +{ + // The entire file has already been mmap'ed into m_data, so just copy from there + return m_data.CopyByteOrderedData (offset, length, dst, length, lldb::endian::InlHostByteOrder()); +} From gclayton at apple.com Wed Jan 11 23:29:51 2012 From: gclayton at apple.com (Greg Clayton) Date: Thu, 12 Jan 2012 05:29:51 -0000 Subject: [Lldb-commits] [lldb] r148018 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20120112052951.1341E2A6C12C@llvm.org> Author: gclayton Date: Wed Jan 11 23:29:50 2012 New Revision: 148018 URL: http://llvm.org/viewvc/llvm-project?rev=148018&view=rev Log: Bumped Xcode project versions for lldb-104 and debugserver-163. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=148018&r1=148017&r2=148018&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Jan 11 23:29:50 2012 @@ -3733,9 +3733,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 103; + DYLIB_CURRENT_VERSION = 104; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3793,10 +3793,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 103; + DYLIB_CURRENT_VERSION = 104; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3852,8 +3852,8 @@ 2689FFD513353D7A00698AC0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 103; - DYLIB_CURRENT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; + DYLIB_CURRENT_VERSION = 104; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3881,8 +3881,8 @@ 2689FFD613353D7A00698AC0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 103; - DYLIB_CURRENT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; + DYLIB_CURRENT_VERSION = 104; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3910,8 +3910,8 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 103; - DYLIB_CURRENT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; + DYLIB_CURRENT_VERSION = 104; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3991,7 +3991,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4022,10 +4022,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 103; + DYLIB_CURRENT_VERSION = 104; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4269,7 +4269,7 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4299,7 +4299,7 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 103; + CURRENT_PROJECT_VERSION = 104; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=148018&r1=148017&r2=148018&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Wed Jan 11 23:29:50 2012 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 103 + 104 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=148018&r1=148017&r2=148018&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Wed Jan 11 23:29:50 2012 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 162; + CURRENT_PROJECT_VERSION = 163; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = ""; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 162; + CURRENT_PROJECT_VERSION = 163; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 162; + CURRENT_PROJECT_VERSION = 163; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -534,7 +534,7 @@ "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 162; + CURRENT_PROJECT_VERSION = 163; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -575,7 +575,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 162; + CURRENT_PROJECT_VERSION = 163; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -616,7 +616,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 162; + CURRENT_PROJECT_VERSION = 163; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Wed Jan 11 23:30:17 2012 From: gclayton at apple.com (Greg Clayton) Date: Thu, 12 Jan 2012 05:30:17 -0000 Subject: [Lldb-commits] [lldb] r148019 - /lldb/tags/lldb-104/ Message-ID: <20120112053017.BA34E2A6C12C@llvm.org> Author: gclayton Date: Wed Jan 11 23:30:17 2012 New Revision: 148019 URL: http://llvm.org/viewvc/llvm-project?rev=148019&view=rev Log: lldb-104 Added: lldb/tags/lldb-104/ - copied from r148018, lldb/trunk/ From jingham at apple.com Thu Jan 12 16:35:30 2012 From: jingham at apple.com (Jim Ingham) Date: Thu, 12 Jan 2012 22:35:30 -0000 Subject: [Lldb-commits] [lldb] r148054 - in /lldb/trunk: include/lldb/Core/ModuleList.h source/Core/Module.cpp source/Core/ModuleList.cpp Message-ID: <20120112223530.371FB2A6C12C@llvm.org> Author: jingham Date: Thu Jan 12 16:35:29 2012 New Revision: 148054 URL: http://llvm.org/viewvc/llvm-project?rev=148054&view=rev Log: Let the Module FindType do the stripping of namespace components, that's not expensive and doing it both at the ModuleList and Module levels means we look 4 times for a negative search. Also, don't do the search for the stripped name if that is the same as the original one. Modified: lldb/trunk/include/lldb/Core/ModuleList.h lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Core/ModuleList.cpp Modified: lldb/trunk/include/lldb/Core/ModuleList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=148054&r1=148053&r2=148054&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ModuleList.h (original) +++ lldb/trunk/include/lldb/Core/ModuleList.h Thu Jan 12 16:35:29 2012 @@ -434,13 +434,6 @@ collection m_modules; ///< The collection of modules. mutable Mutex m_modules_mutex; -private: - uint32_t - FindTypes_Impl (const SymbolContext& sc, - const ConstString &name, - bool append, - uint32_t max_matches, - TypeList& types); }; } // namespace lldb_private Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=148054&r1=148053&r2=148054&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Thu Jan 12 16:35:29 2012 @@ -531,8 +531,13 @@ if (retval == 0) { - const char *stripped = StripTypeName(name.GetCString()); - return FindTypes_Impl(sc, ConstString(stripped), namespace_decl, append, max_matches, types); + const char *orig_name = name.GetCString(); + const char *stripped = StripTypeName(orig_name); + // Only do this lookup if StripTypeName has stripped the name: + if (stripped != orig_name) + return FindTypes_Impl(sc, ConstString(stripped), namespace_decl, append, max_matches, types); + else + return 0; } else return retval; Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=148054&r1=148053&r2=148054&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Thu Jan 12 16:35:29 2012 @@ -434,7 +434,7 @@ uint32_t -ModuleList::FindTypes_Impl (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) +ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) { Mutex::Locker locker(m_modules_mutex); @@ -454,41 +454,6 @@ return total_matches; } -// depending on implementation details, type lookup might fail because of -// embedded spurious namespace:: prefixes. this call strips them, paying -// attention to the fact that a type might have namespace'd type names as -// arguments to templates, and those must not be stripped off -static const char* -StripTypeName(const char* name_cstr) -{ - const char* skip_namespace = strstr(name_cstr, "::"); - const char* template_arg_char = strchr(name_cstr, '<'); - while (skip_namespace != NULL) - { - if (template_arg_char != NULL && - skip_namespace > template_arg_char) // but namespace'd template arguments are still good to go - break; - name_cstr = skip_namespace+2; - skip_namespace = strstr(name_cstr, "::"); - } - return name_cstr; -} - -uint32_t -ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) -{ - uint32_t retval = FindTypes_Impl(sc, name, append, max_matches, types); - - if (retval == 0) - { - const char *stripped = StripTypeName(name.GetCString()); - return FindTypes_Impl(sc, ConstString(stripped), append, max_matches, types); - } - else - return retval; - -} - ModuleSP ModuleList::FindFirstModuleForFileSpec (const FileSpec &file_spec, const ArchSpec *arch_ptr, From jingham at apple.com Thu Jan 12 16:42:34 2012 From: jingham at apple.com (Jim Ingham) Date: Thu, 12 Jan 2012 22:42:34 -0000 Subject: [Lldb-commits] [lldb] r148057 - /lldb/trunk/source/Core/ValueObject.cpp Message-ID: <20120112224234.F2DDA2A6C12C@llvm.org> Author: jingham Date: Thu Jan 12 16:42:34 2012 New Revision: 148057 URL: http://llvm.org/viewvc/llvm-project?rev=148057&view=rev Log: Fix a comment typo. 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=148057&r1=148056&r2=148057&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Thu Jan 12 16:42:34 2012 @@ -3594,7 +3594,7 @@ { if (m_mod_id == current_mod_id) { - // Everything is already up to date in this object, no need do + // Everything is already up to date in this object, no need to // update the execution context scope. changed = false; } From jingham at apple.com Thu Jan 12 16:45:32 2012 From: jingham at apple.com (Jim Ingham) Date: Thu, 12 Jan 2012 22:45:32 -0000 Subject: [Lldb-commits] [lldb] r148059 - in /lldb/trunk: include/lldb/Symbol/Type.h source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp source/Symbol/Type.cpp Message-ID: <20120112224532.4BA5D2A6C12C@llvm.org> Author: jingham Date: Thu Jan 12 16:45:31 2012 New Revision: 148059 URL: http://llvm.org/viewvc/llvm-project?rev=148059&view=rev Log: Discriminate between the lldb_private::Type's for ObjC Classes that come from debug info, and those that are made up from the ObjC runtime symbols. For now the latter contain nothing but the fact that the name describes an ObjC class, and so are not useful for things like dynamic types. Modified: lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=148059&r1=148058&r2=148059&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Thu Jan 12 16:45:31 2012 @@ -262,7 +262,9 @@ // For C++0x references (&&) void * CreateClangRValueReferenceType (Type *type); - + + bool + IsRealObjCClass(); protected: ConstString m_name; Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=148059&r1=148058&r2=148059&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Thu Jan 12 16:45:31 2012 @@ -332,6 +332,7 @@ class_type_or_name.SetName (class_name); TypeList class_types; + SymbolContext sc; uint32_t num_matches = target.GetImages().FindTypes (sc, class_type_or_name.GetName(), true, @@ -349,7 +350,10 @@ TypeSP this_type(class_types.GetTypeAtIndex(i)); if (this_type) { - if (ClangASTContext::IsObjCClassType(this_type->GetClangFullType())) + // Only consider "real" ObjC classes. For now this means avoiding + // the Type objects that are made up from the OBJC_CLASS_$_ symbols. + // we don't want to use them since they are empty and useless. + if (this_type->IsRealObjCClass()) { // There can only be one type with a given name, // so we've just found duplicate definitions, and this Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=148059&r1=148058&r2=148059&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Thu Jan 12 16:45:31 2012 @@ -414,7 +414,7 @@ lldb::TypeSP type(new Type (iter->second, this, name, - 0, // byte_size + 0, // byte_size - don't change this from 0, we currently use that to identify these "synthetic" ObjC class types. NULL, // SymbolContextScope* 0, // encoding_uid Type::eEncodingInvalid, Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=148059&r1=148058&r2=148059&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Thu Jan 12 16:45:31 2012 @@ -673,6 +673,18 @@ return GetClangASTContext().CreateRValueReferenceType (type->GetClangForwardType()); } +bool +Type::IsRealObjCClass() +{ + // For now we are just skipping ObjC classes that get made by hand from the runtime, because + // those don't have any information. We could extend this to only return true for "full + // definitions" if we can figure that out. + + if (ClangASTContext::IsObjCClassType(m_clang_type) && GetByteSize() != 0) + return true; + else + return false; +} TypeAndOrName::TypeAndOrName () : m_type_sp(), m_type_name() { From johnny.chen at apple.com Thu Jan 12 17:09:42 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 12 Jan 2012 23:09:42 -0000 Subject: [Lldb-commits] [lldb] r148066 - in /lldb/trunk/test: functionalities/archives/ functionalities/archives/Makefile functionalities/archives/TestBSDArchives.py functionalities/archives/a.c functionalities/archives/b.c functionalities/archives/main.c make/Makefile.rules Message-ID: <20120112230942.79E2E2A6C12C@llvm.org> Author: johnny Date: Thu Jan 12 17:09:42 2012 New Revision: 148066 URL: http://llvm.org/viewvc/llvm-project?rev=148066&view=rev Log: rdar://problem/10680957 Need a test case that tests DWARF with .o in .a files test/functionalities/archives: Produces libfoo.a from a.o and b.o. Test breaking inside functions defined inside the libfoo.a BSD Archive. test/make/makefile.rules: Some additional rules to sepcify archive building. For example: ARCHIVE_NAME := libfoo.a ARCHIVE_C_SOURCES := a.c b.c Added: lldb/trunk/test/functionalities/archives/ lldb/trunk/test/functionalities/archives/Makefile lldb/trunk/test/functionalities/archives/TestBSDArchives.py lldb/trunk/test/functionalities/archives/a.c lldb/trunk/test/functionalities/archives/b.c lldb/trunk/test/functionalities/archives/main.c Modified: lldb/trunk/test/make/Makefile.rules Added: lldb/trunk/test/functionalities/archives/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/archives/Makefile?rev=148066&view=auto ============================================================================== --- lldb/trunk/test/functionalities/archives/Makefile (added) +++ lldb/trunk/test/functionalities/archives/Makefile Thu Jan 12 17:09:42 2012 @@ -0,0 +1,9 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +MAKE_DSYM := NO +ARCHIVE_NAME := libfoo.a +ARCHIVE_C_SOURCES := a.c b.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/archives/TestBSDArchives.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/archives/TestBSDArchives.py?rev=148066&view=auto ============================================================================== --- lldb/trunk/test/functionalities/archives/TestBSDArchives.py (added) +++ lldb/trunk/test/functionalities/archives/TestBSDArchives.py Thu Jan 12 17:09:42 2012 @@ -0,0 +1,65 @@ +"""Test breaking inside functions defined within a BSD archive file libfoo.a.""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class BSDArchivesTestCase(TestBase): + + mydir = os.path.join("functionalities", "archives") + + def test_with_dwarf(self): + """Break inside a() and b() defined within libfoo.a.""" + self.buildDwarf() + self.break_inside_bsd_archives() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number in a(int) to break at. + self.line = line_number('a.c', '// Set file and line breakpoint inside a().') + + def break_inside_bsd_archives(self): + """Break inside a() and b() defined within libfoo.a.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break inside a() by file and line first. + self.expect("breakpoint set -f a.c -l %d" % self.line, BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='a.c', line = %d" % + self.line) + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # Break at a(int) first. + self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['(int) arg = 1']) + self.expect("frame variable __a_global", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['(int) __a_global = 1']) + + # Set breakpoint for b() next. + self.expect("breakpoint set -n b", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 2: name = 'b'", + substrs = ['resolved = 1']) + + # Continue the program, we should break at b(int) next. + self.runCmd("continue") + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['(int) arg = 2']) + self.expect("frame variable __b_global", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['(int) __b_global = 2']) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/archives/a.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/archives/a.c?rev=148066&view=auto ============================================================================== --- lldb/trunk/test/functionalities/archives/a.c (added) +++ lldb/trunk/test/functionalities/archives/a.c Thu Jan 12 17:09:42 2012 @@ -0,0 +1,19 @@ +//===-- a.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +int __a_global = 1; + +int a(int arg) { + int result = arg + __a_global; + return result; // Set file and line breakpoint inside a(). +} + +int aa(int arg1) { + int result1 = arg1 - __a_global; + return result1; +} Added: lldb/trunk/test/functionalities/archives/b.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/archives/b.c?rev=148066&view=auto ============================================================================== --- lldb/trunk/test/functionalities/archives/b.c (added) +++ lldb/trunk/test/functionalities/archives/b.c Thu Jan 12 17:09:42 2012 @@ -0,0 +1,19 @@ +//===-- b.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +static int __b_global = 2; + +int b(int arg) { + int result = arg + __b_global; + return result; +} + +int bb(int arg1) { + int result2 = arg1 - __b_global; + return result2; +} Added: lldb/trunk/test/functionalities/archives/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/archives/main.c?rev=148066&view=auto ============================================================================== --- lldb/trunk/test/functionalities/archives/main.c (added) +++ lldb/trunk/test/functionalities/archives/main.c Thu Jan 12 17:09:42 2012 @@ -0,0 +1,17 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +extern int a(int); +extern int b(int); +int main (int argc, char const *argv[]) +{ + printf ("a(1) returns %d\n", a(1)); + printf ("b(2) returns %d\n", b(2)); +} Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=148066&r1=148065&r2=148066&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Thu Jan 12 17:09:42 2012 @@ -58,6 +58,8 @@ DS := dsymutil DSFLAGS = DSYM = $(EXE).dSYM + AR := libtool + ARFLAGS := -static -o endif CXXFLAGS +=$(CFLAGS) @@ -130,6 +132,42 @@ endif endif +#---------------------------------------------------------------------- +# Check if we have any C source files for archive +#---------------------------------------------------------------------- +ifneq "$(strip $(ARCHIVE_C_SOURCES))" "" + ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_C_SOURCES:.c=.o)) +endif + +#---------------------------------------------------------------------- +# Check if we have any C++ source files for archive +#---------------------------------------------------------------------- +ifneq "$(strip $(ARCHIVE_CXX_SOURCES))" "" + ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_CXX_SOURCES:.cpp=.o)) + CXX = $(call cxx_compiler,$(CC)) + LD = $(call cxx_linker,$(CC)) +endif + +#---------------------------------------------------------------------- +# Check if we have any ObjC source files for archive +#---------------------------------------------------------------------- +ifneq "$(strip $(ARCHIVE_OBJC_SOURCES))" "" + ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJC_SOURCES:.m=.o)) + LDFLAGS +=-lobjc +endif + +#---------------------------------------------------------------------- +# Check if we have any ObjC++ source files for archive +#---------------------------------------------------------------------- +ifneq "$(strip $(ARCHIVE_OBJCXX_SOURCES))" "" + ARCHIVE_OBJECTS +=$(strip $(ARCHIVE_OBJCXX_SOURCES:.mm=.o)) + CXX = $(call cxx_compiler,$(CC)) + LD = $(call cxx_linker,$(CC)) + ifeq $(findstring lobjc,$(LDFLAGS)) "" + LDFLAGS +=-lobjc + endif +endif + #---------------------------------------------------------------------- # DYLIB_ONLY variable can be used to skip the building of a.out. @@ -154,14 +192,27 @@ #---------------------------------------------------------------------- ifneq "$(DYLIB_NAME)" "" ifeq "$(DYLIB_ONLY)" "" -$(EXE) : $(OBJECTS) $(DYLIB_FILENAME) - $(LD) $(LDFLAGS) $(OBJECTS) -L. -l$(DYLIB_NAME) -o "$(EXE)" +$(EXE) : $(OBJECTS) $(ARCHIVE_NAME) $(DYLIB_FILENAME) + $(LD) $(LDFLAGS) $(OBJECTS) $(ARCHIVE_NAME) -L. -l$(DYLIB_NAME) -o "$(EXE)" else EXE = $(DYLIB_FILENAME) endif else -$(EXE) : $(OBJECTS) - $(LD) $(LDFLAGS) $(OBJECTS) -o "$(EXE)" +$(EXE) : $(OBJECTS) $(ARCHIVE_NAME) + $(LD) $(LDFLAGS) $(OBJECTS) $(ARCHIVE_NAME) -o "$(EXE)" +endif + +#---------------------------------------------------------------------- +# Make the archive +#---------------------------------------------------------------------- +ifneq "$(ARCHIVE_NAME)" "" +ifeq "$(OS)" "Darwin" +$(ARCHIVE_NAME) : $(ARCHIVE_OBJECTS) + $(AR) $(ARFLAGS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) + $(RM) $(ARCHIVE_OBJECTS) +else +$(ARCHIVE_NAME) : $(foreach ar_obj,$(ARCHIVE_OBJECTS),$(ARCHIVE_NAME)($(ar_obj))) +endif endif #---------------------------------------------------------------------- @@ -228,9 +279,9 @@ all: $(EXE) $(DSYM) clean:: ifeq "$(DYLIB_NAME)" "" - rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) + rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) else - rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).dSYM + rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) $(ARCHIVE_NAME) $(ARCHIVE_OBJECTS) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).dSYM endif #---------------------------------------------------------------------- From johnny.chen at apple.com Thu Jan 12 17:50:29 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 12 Jan 2012 23:50:29 -0000 Subject: [Lldb-commits] [lldb] r148071 - in /lldb/trunk/test: functionalities/load_unload/Makefile macosx/universal/Makefile Message-ID: <20120112235029.2D7C02A6C12C@llvm.org> Author: johnny Date: Thu Jan 12 17:50:28 2012 New Revision: 148071 URL: http://llvm.org/viewvc/llvm-project?rev=148071&view=rev Log: Modify a couple of Makefiles to use clang instead of gcc, since gcc is being deprecated. Modified: lldb/trunk/test/functionalities/load_unload/Makefile lldb/trunk/test/macosx/universal/Makefile Modified: lldb/trunk/test/functionalities/load_unload/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/load_unload/Makefile?rev=148071&r1=148070&r2=148071&view=diff ============================================================================== --- lldb/trunk/test/functionalities/load_unload/Makefile (original) +++ lldb/trunk/test/functionalities/load_unload/Makefile Thu Jan 12 17:50:28 2012 @@ -1,9 +1,6 @@ all: a.out liba.dylib libb.dylib libc.dylib libd.dylib -CC ?= gcc -ifeq "$(CC)" "cc" - CC = gcc -endif +CC ?= clang CFLAGS ?=-arch x86_64 -gdwarf-2 -O0 CWD := $(shell pwd) Modified: lldb/trunk/test/macosx/universal/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/macosx/universal/Makefile?rev=148071&r1=148070&r2=148071&view=diff ============================================================================== --- lldb/trunk/test/macosx/universal/Makefile (original) +++ lldb/trunk/test/macosx/universal/Makefile Thu Jan 12 17:50:28 2012 @@ -1,7 +1,4 @@ -CC ?= gcc -ifeq "$(CC)" "cc" - CC = gcc -endif +CC ?= clang testit: testit.i386 testit.x86_64 lipo -create -o testit testit.i386 testit.x86_64 From johnny.chen at apple.com Thu Jan 12 18:02:46 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 13 Jan 2012 00:02:46 -0000 Subject: [Lldb-commits] [lldb] r148073 - /lldb/trunk/test/source-manager/hidden/ Message-ID: <20120113000246.C725F2A6C12C@llvm.org> Author: johnny Date: Thu Jan 12 18:02:46 2012 New Revision: 148073 URL: http://llvm.org/viewvc/llvm-project?rev=148073&view=rev Log: rdar://problem/10684459 test_move_and_then_display_source (TestSourceManager.py) never works in LLDB test suite Forgot to svn ci the "hidden" directory. :-( Added: lldb/trunk/test/source-manager/hidden/ From johnny.chen at apple.com Thu Jan 12 18:24:12 2012 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 13 Jan 2012 00:24:12 -0000 Subject: [Lldb-commits] [lldb] r148075 - /lldb/trunk/test/functionalities/archives/README Message-ID: <20120113002412.1775E2A6C12C@llvm.org> Author: johnny Date: Thu Jan 12 18:24:11 2012 New Revision: 148075 URL: http://llvm.org/viewvc/llvm-project?rev=148075&view=rev Log: Add some description for this test directory. Added: lldb/trunk/test/functionalities/archives/README Added: lldb/trunk/test/functionalities/archives/README URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/archives/README?rev=148075&view=auto ============================================================================== --- lldb/trunk/test/functionalities/archives/README (added) +++ lldb/trunk/test/functionalities/archives/README Thu Jan 12 18:24:11 2012 @@ -0,0 +1,62 @@ +a.out file refers to libfoo.a for a.o and b.o, which is what we want to accomplish for +this test case. + +[16:17:44] johnny:/Volumes/data/lldb/svn/latest/test/functionalities/archives $ dsymutil -s a.out +---------------------------------------------------------------------- +Symbol table for: 'a.out' (x86_64) +---------------------------------------------------------------------- +Index n_strx n_type n_sect n_desc n_value +======== -------- ------------------ ------ ------ ---------------- +[ 0] 00000002 64 (N_SO ) 00 0000 0000000000000000 '/Volumes/data/lldb/svn/latest/test/functionalities/archives/' +[ 1] 0000003f 64 (N_SO ) 00 0000 0000000000000000 'main.c' +[ 2] 00000046 66 (N_OSO ) 03 0001 000000004f0f780c '/Volumes/data/lldb/svn/latest/test/functionalities/archives/main.o' +[ 3] 00000001 2e (N_BNSYM ) 01 0000 0000000100000d70 +[ 4] 00000089 24 (N_FUN ) 01 0000 0000000100000d70 '_main' +[ 5] 00000001 24 (N_FUN ) 00 0000 000000000000005d +[ 6] 00000001 4e (N_ENSYM ) 01 0000 000000000000005d +[ 7] 00000001 64 (N_SO ) 01 0000 0000000000000000 +[ 8] 00000002 64 (N_SO ) 00 0000 0000000000000000 '/Volumes/data/lldb/svn/latest/test/functionalities/archives/' +[ 9] 0000008f 64 (N_SO ) 00 0000 0000000000000000 'a.c' +[ 10] 00000093 66 (N_OSO ) 03 0001 000000004f0f780c '/Volumes/data/lldb/svn/latest/test/functionalities/archives/libfoo.a(a.o)' +[ 11] 00000001 2e (N_BNSYM ) 01 0000 0000000100000dd0 +[ 12] 000000dd 24 (N_FUN ) 01 0000 0000000100000dd0 '_a' +[ 13] 00000001 24 (N_FUN ) 00 0000 0000000000000020 +[ 14] 00000001 4e (N_ENSYM ) 01 0000 0000000000000020 +[ 15] 00000001 2e (N_BNSYM ) 01 0000 0000000100000df0 +[ 16] 000000e0 24 (N_FUN ) 01 0000 0000000100000df0 '_aa' +[ 17] 00000001 24 (N_FUN ) 00 0000 0000000000000018 +[ 18] 00000001 4e (N_ENSYM ) 01 0000 0000000000000018 +[ 19] 000000e4 20 (N_GSYM ) 00 0000 0000000000000000 '___a_global' +[ 20] 00000001 64 (N_SO ) 01 0000 0000000000000000 +[ 21] 00000002 64 (N_SO ) 00 0000 0000000000000000 '/Volumes/data/lldb/svn/latest/test/functionalities/archives/' +[ 22] 000000f0 64 (N_SO ) 00 0000 0000000000000000 'b.c' +[ 23] 000000f4 66 (N_OSO ) 03 0001 000000004f0f780c '/Volumes/data/lldb/svn/latest/test/functionalities/archives/libfoo.a(b.o)' +[ 24] 00000001 2e (N_BNSYM ) 01 0000 0000000100000e10 +[ 25] 0000013e 24 (N_FUN ) 01 0000 0000000100000e10 '_b' +[ 26] 00000001 24 (N_FUN ) 00 0000 0000000000000020 +[ 27] 00000001 4e (N_ENSYM ) 01 0000 0000000000000020 +[ 28] 00000001 2e (N_BNSYM ) 01 0000 0000000100000e30 +[ 29] 00000141 24 (N_FUN ) 01 0000 0000000100000e30 '_bb' +[ 30] 00000001 24 (N_FUN ) 00 0000 0000000000000018 +[ 31] 00000001 4e (N_ENSYM ) 01 0000 0000000000000018 +[ 32] 00000145 26 (N_STSYM ) 0a 0000 000000010000104c '___b_global' +[ 33] 00000001 64 (N_SO ) 01 0000 0000000000000000 +[ 34] 00000151 0e ( SECT ) 07 0000 0000000100001000 '_pvars' +[ 35] 00000158 0e ( SECT ) 0a 0000 000000010000104c '___b_global' +[ 36] 00000164 0f ( SECT EXT) 0b 0000 0000000100001050 '_NXArgc' +[ 37] 0000016c 0f ( SECT EXT) 0b 0000 0000000100001058 '_NXArgv' +[ 38] 00000174 0f ( SECT EXT) 0a 0000 0000000100001048 '___a_global' +[ 39] 00000180 0f ( SECT EXT) 0b 0000 0000000100001068 '___progname' +[ 40] 0000018c 03 ( ABS EXT) 01 0010 0000000100000000 '__mh_execute_header' +[ 41] 000001a0 0f ( SECT EXT) 01 0000 0000000100000dd0 '_a' +[ 42] 000001a3 0f ( SECT EXT) 01 0000 0000000100000df0 '_aa' +[ 43] 000001a7 0f ( SECT EXT) 01 0000 0000000100000e10 '_b' +[ 44] 000001aa 0f ( SECT EXT) 01 0000 0000000100000e30 '_bb' +[ 45] 000001ae 0f ( SECT EXT) 0b 0000 0000000100001060 '_environ' +[ 46] 000001b7 0f ( SECT EXT) 01 0000 0000000100000d70 '_main' +[ 47] 000001bd 0f ( SECT EXT) 01 0000 0000000100000d30 'start' +[ 48] 000001c3 01 ( UNDF EXT) 00 0100 0000000000000000 '_exit' +[ 49] 000001c9 01 ( UNDF EXT) 00 0100 0000000000000000 '_printf' +[ 50] 000001d1 01 ( UNDF EXT) 00 0100 0000000000000000 'dyld_stub_binder' + + From jingham at apple.com Thu Jan 12 20:04:05 2012 From: jingham at apple.com (Jim Ingham) Date: Fri, 13 Jan 2012 02:04:05 -0000 Subject: [Lldb-commits] [lldb] r148087 - /lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp Message-ID: <20120113020405.814DF2A6C12C@llvm.org> Author: jingham Date: Thu Jan 12 20:04:05 2012 New Revision: 148087 URL: http://llvm.org/viewvc/llvm-project?rev=148087&view=rev Log: Don't set breakpoints independently comp unit by comp unit, but look over all the file & line matches and only pick the "best" ones. Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp?rev=148087&r1=148086&r2=148087&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp Thu Jan 12 20:04:05 2012 @@ -52,70 +52,136 @@ ) { SymbolContextList sc_list; - uint32_t sc_list_size; - CompileUnit *cu = context.comp_unit; assert (m_breakpoint != NULL); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); - - sc_list_size = cu->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything, sc_list); - for (uint32_t i = 0; i < sc_list_size; i++) + + // There is a tricky bit here. You can have two compilation units that #include the same file, and + // in one of them the function at m_line_number is used (and so code and a line entry for it is generated) but in the + // other it isn't. If we considered the CU's independently, then in the second inclusion, we'd move the breakpoint + // to the next function that actually generated code in the header file. That would end up being confusing. + // So instead, we do the CU iterations by hand here, then scan through the complete list of matches, and figure out + // the closest line number match, and only set breakpoints on that match. + + // Note also that if file_spec only had a file name and not a directory, there may be many different file spec's in + // the resultant list. The closest line match for one will not be right for some totally different file. + // So we go through the match list and pull out the sets that have the same file spec in their line_entry + // and treat each set separately. + + uint32_t num_comp_units = context.module_sp->GetNumCompileUnits(); + for (uint32_t i = 0; i < num_comp_units; i++) + { + CompUnitSP cu_sp (context.module_sp->GetCompileUnitAtIndex (i)); + if (filter.CompUnitPasses(*(cu_sp.get()))) + cu_sp->ResolveSymbolContext (m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything, sc_list); + } + + while (sc_list.GetSize() > 0) { + SymbolContextList tmp_sc_list; + int current_idx = 0; SymbolContext sc; - if (sc_list.GetContextAtIndex(i, sc)) + bool first_entry = true; + + FileSpec match_file_spec; + uint32_t closest_line_number = UINT32_MAX; + + // Pull out the first entry, and all the others that match its file spec, and stuff them in the tmp list. + while (current_idx < sc_list.GetSize()) { - Address line_start = sc.line_entry.range.GetBaseAddress(); - if (line_start.IsValid()) + bool matches; + + sc_list.GetContextAtIndex (current_idx, sc); + if (first_entry) + { + match_file_spec = sc.line_entry.file; + matches = true; + first_entry = false; + } + else + matches = (sc.line_entry.file == match_file_spec); + + if (matches) { - if (filter.AddressPasses(line_start)) + tmp_sc_list.Append (sc); + sc_list.RemoveContextAtIndex(current_idx); + + // ResolveSymbolContext will always return a number that is >= the line number you pass in. + // So the smaller line number is always better. + if (sc.line_entry.line < closest_line_number) + closest_line_number = sc.line_entry.line; + } + else + current_idx++; + } + + // Okay, we've found the closest line number match, now throw away all the others, + // and make breakpoints out of the closest line number match. + + uint32_t tmp_sc_list_size = tmp_sc_list.GetSize(); + + for (uint32_t i = 0; i < tmp_sc_list_size; i++) + { + SymbolContext sc; + if (tmp_sc_list.GetContextAtIndex(i, sc)) + { + if (sc.line_entry.line == closest_line_number) { - BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start)); - if (log && bp_loc_sp && !m_breakpoint->IsInternal()) + Address line_start = sc.line_entry.range.GetBaseAddress(); + if (line_start.IsValid()) { - StreamString s; - bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose); - log->Printf ("Added location: %s\n", s.GetData()); + if (filter.AddressPasses(line_start)) + { + BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start)); + if (log && bp_loc_sp && !m_breakpoint->IsInternal()) + { + StreamString s; + bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose); + log->Printf ("Added location: %s\n", s.GetData()); + } + } + else if (log) + { + log->Printf ("Breakpoint at file address 0x%llx for %s:%d didn't pass the filter.\n", + line_start.GetFileAddress(), + m_file_spec.GetFilename().AsCString(""), + m_line_number); + } + } + else + { + if (log) + log->Printf ("error: Unable to set breakpoint at file address 0x%llx for %s:%d\n", + line_start.GetFileAddress(), + m_file_spec.GetFilename().AsCString(""), + m_line_number); } } - else if (log) + else { - log->Printf ("Breakpoint at file address 0x%llx for %s:%d didn't pass the filter.\n", - line_start.GetFileAddress(), - m_file_spec.GetFilename().AsCString(""), - m_line_number); + #if 0 + s << "error: Breakpoint at '" << pos->c_str() << "' isn't resolved yet: \n"; + if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionNameOffset)) + s.EOL(); + if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionPointerOffset)) + s.EOL(); + if (sc.line_entry.address.Dump(&s, Address::DumpStyleFileAddress)) + s.EOL(); + if (sc.line_entry.address.Dump(&s, Address::DumpStyleLoadAddress)) + s.EOL(); + #endif } } - else - { - if (log) - log->Printf ("error: Unable to set breakpoint at file address 0x%llx for %s:%d\n", - line_start.GetFileAddress(), - m_file_spec.GetFilename().AsCString(""), - m_line_number); - } - } - else - { -#if 0 - s << "error: Breakpoint at '" << pos->c_str() << "' isn't resolved yet: \n"; - if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionNameOffset)) - s.EOL(); - if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionPointerOffset)) - s.EOL(); - if (sc.line_entry.address.Dump(&s, Address::DumpStyleFileAddress)) - s.EOL(); - if (sc.line_entry.address.Dump(&s, Address::DumpStyleLoadAddress)) - s.EOL(); -#endif } } + return Searcher::eCallbackReturnContinue; } Searcher::Depth BreakpointResolverFileLine::GetDepth() { - return Searcher::eDepthCompUnit; + return Searcher::eDepthModule; } void From gclayton at apple.com Thu Jan 12 23:38:24 2012 From: gclayton at apple.com (Greg Clayton) Date: Fri, 13 Jan 2012 05:38:24 -0000 Subject: [Lldb-commits] [lldb] r148097 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Message-ID: <20120113053824.623922A6C12C@llvm.org> Author: gclayton Date: Thu Jan 12 23:38:24 2012 New Revision: 148097 URL: http://llvm.org/viewvc/llvm-project?rev=148097&view=rev Log: Fixed the new __apple_types to be able to accept a DW_TAG_structure_type forward declaration and then find a DW_TAG_class_type definition, or vice versa. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h 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=148097&r1=148096&r2=148097&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Thu Jan 12 23:38:24 2012 @@ -85,7 +85,13 @@ for (size_t i=0; i Author: gclayton Date: Thu Jan 12 23:54:31 2012 New Revision: 148098 URL: http://llvm.org/viewvc/llvm-project?rev=148098&view=rev Log: Bumped Xcode project version for lldb-105 and debugserver-164. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=148098&r1=148097&r2=148098&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jan 12 23:54:31 2012 @@ -3733,9 +3733,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 104; + DYLIB_CURRENT_VERSION = 105; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3793,10 +3793,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 104; + DYLIB_CURRENT_VERSION = 105; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3852,8 +3852,8 @@ 2689FFD513353D7A00698AC0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 104; - DYLIB_CURRENT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; + DYLIB_CURRENT_VERSION = 105; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3881,8 +3881,8 @@ 2689FFD613353D7A00698AC0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 104; - DYLIB_CURRENT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; + DYLIB_CURRENT_VERSION = 105; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3910,8 +3910,8 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 104; - DYLIB_CURRENT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; + DYLIB_CURRENT_VERSION = 105; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3991,7 +3991,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4022,10 +4022,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 104; + DYLIB_CURRENT_VERSION = 105; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4269,7 +4269,7 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4299,7 +4299,7 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 104; + CURRENT_PROJECT_VERSION = 105; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=148098&r1=148097&r2=148098&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Thu Jan 12 23:54:31 2012 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 104 + 105 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=148098&r1=148097&r2=148098&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Thu Jan 12 23:54:31 2012 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 163; + CURRENT_PROJECT_VERSION = 164; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = ""; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 163; + CURRENT_PROJECT_VERSION = 164; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 163; + CURRENT_PROJECT_VERSION = 164; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -534,7 +534,7 @@ "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 163; + CURRENT_PROJECT_VERSION = 164; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -575,7 +575,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 163; + CURRENT_PROJECT_VERSION = 164; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -616,7 +616,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 163; + CURRENT_PROJECT_VERSION = 164; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Thu Jan 12 23:55:01 2012 From: gclayton at apple.com (Greg Clayton) Date: Fri, 13 Jan 2012 05:55:01 -0000 Subject: [Lldb-commits] [lldb] r148099 - /lldb/tags/lldb-105/ Message-ID: <20120113055501.C13042A6C12C@llvm.org> Author: gclayton Date: Thu Jan 12 23:55:01 2012 New Revision: 148099 URL: http://llvm.org/viewvc/llvm-project?rev=148099&view=rev Log: lldb-105 Added: lldb/tags/lldb-105/ - copied from r148098, lldb/trunk/ From gclayton at apple.com Fri Jan 13 02:39:16 2012 From: gclayton at apple.com (Greg Clayton) Date: Fri, 13 Jan 2012 08:39:16 -0000 Subject: [Lldb-commits] [lldb] r148110 - /lldb/trunk/source/Core/Debugger.cpp Message-ID: <20120113083916.5A2A41BE003@llvm.org> Author: gclayton Date: Fri Jan 13 02:39:16 2012 New Revision: 148110 URL: http://llvm.org/viewvc/llvm-project?rev=148110&view=rev Log: Added a new thread and frame format that can be used to display a function name + arguments when the data is available. It seems to work really well, but some more testing is needed before we make this on by default. The new function format name is: ${function.name-with-args} To see how to use these formats see the website: http://lldb.llvm.org/formats.html Here is a sample backtrace of debugging LLDB with LLDB using this new format value: (lldb) thread backtrace all * thread #1: tid = 0x2203, 0x00007fff88a17bca libsystem_kernel.dylib __psynch_cvwait + 10, stop reason = signal SIGINT, name = , queue = com.apple.main-thread frame #0: 0x00007fff88a17bca libsystem_kernel.dylib __psynch_cvwait + 10 frame #1: 0x00007fff884ae274 libsystem_c.dylib _pthread_cond_wait + 840 frame #2: 0x00000001010778ea LLDB lldb_private::Condition::Wait(this=0x0000000104846770, mutex=0x0000000104846730, abstime=0x0000000000000000, timed_out=0x00007fff5fbfdea7) + 138 at Condition.cpp:92 frame #3: 0x0000000101244c21 LLDB lldb_private::Predicate::WaitForValueEqualTo(this=0x0000000104846728, value=true, abstime=0x0000000000000000, timed_out=0x00007fff5fbfdea7) + 209 at Predicate.h:317 frame #4: 0x0000000100f6eeb2 LLDB lldb_private::Listener::WaitForEventsInternal(this=0x0000000104846660, timeout=0x0000000000000000, broadcaster=0x0000000000000000, broadcaster_names=0x0000000000000000, num_broadcaster_names=0x00000000, event_type_mask=0x00000000, event_sp=0x00007fff5fbfe030) + 386 at Listener.cpp:388 frame #5: 0x0000000100f6f231 LLDB lldb_private::Listener::WaitForEvent(this=0x0000000104846660, timeout=0x0000000000000000, event_sp=0x00007fff5fbfe030) + 81 at Listener.cpp:436 frame #6: 0x0000000100098dcd LLDB lldb::SBListener::WaitForEvent(this=0x00007fff5fbff0f0, timeout_secs=0xffffffff, event=0x00007fff5fbfe430) + 685 at SBListener.cpp:181 frame #7: 0x000000010000628c lldb Driver::MainLoop(this=0x00007fff5fbff620) + 5244 at Driver.cpp:1325 frame #8: 0x0000000100006ca3 lldb main(argc=1, argv=0x00007fff5fbff758, envp=0x00007fff5fbff768) + 419 at Driver.cpp:1460 frame #9: 0x0000000100000d54 lldb start + 52 thread #3: tid = 0x2703, 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10, name = frame #0: 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10 frame #1: 0x0000000100f3f072 LLDB lldb_private::ConnectionFileDescriptor::BytesAvailable(this=0x000000010524d040, timeout_usec=0x004c4b40, error_ptr=0x0000000105640a18) + 722 at ConnectionFileDescriptor.cpp:542 frame #2: 0x0000000100f3e6dd LLDB lldb_private::ConnectionFileDescriptor::Read(this=0x000000010524d040, dst=0x0000000105640a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x0000000105640a14, error_ptr=0x0000000105640a18) + 301 at ConnectionFileDescriptor.cpp:273 frame #3: 0x0000000100f3b8f7 LLDB lldb_private::Communication::ReadFromConnection(this=0x0000000104846270, dst=0x0000000105640a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x0000000105640a14, error_ptr=0x0000000105640a18) + 167 at Communication.cpp:317 frame #4: 0x0000000100f3b197 LLDB lldb_private::Communication::ReadThread(p=0x0000000104846270) + 327 at Communication.cpp:344 frame #5: 0x0000000101078923 LLDB ThreadCreateTrampoline(arg=0x00000001045f6650) + 227 at Host.cpp:549 frame #6: 0x00007fff884aa8bf libsystem_c.dylib _pthread_start + 335 frame #7: 0x00007fff884adb75 libsystem_c.dylib thread_start + 13 thread #4: tid = 0x2803, 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10, name = frame #0: 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10 frame #1: 0x0000000100f3f072 LLDB lldb_private::ConnectionFileDescriptor::BytesAvailable(this=0x0000000105700370, timeout_usec=0x004c4b40, error_ptr=0x00000001056c3a18) + 722 at ConnectionFileDescriptor.cpp:542 frame #2: 0x0000000100f3e6dd LLDB lldb_private::ConnectionFileDescriptor::Read(this=0x0000000105700370, dst=0x00000001056c3a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x00000001056c3a14, error_ptr=0x00000001056c3a18) + 301 at ConnectionFileDescriptor.cpp:273 frame #3: 0x0000000100f3b8f7 LLDB lldb_private::Communication::ReadFromConnection(this=0x0000000105700000, dst=0x00000001056c3a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x00000001056c3a14, error_ptr=0x00000001056c3a18) + 167 at Communication.cpp:317 frame #4: 0x0000000100f3b197 LLDB lldb_private::Communication::ReadThread(p=0x0000000105700000) + 327 at Communication.cpp:344 frame #5: 0x0000000101078923 LLDB ThreadCreateTrampoline(arg=0x0000000105700430) + 227 at Host.cpp:549 frame #6: 0x00007fff884aa8bf libsystem_c.dylib _pthread_start + 335 frame #7: 0x00007fff884adb75 libsystem_c.dylib thread_start + 13 thread #5: tid = 0x2903, 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10, name = frame #0: 0x00007fff88a17df2 libsystem_kernel.dylib select$DARWIN_EXTSN + 10 frame #1: 0x0000000100f3f072 LLDB lldb_private::ConnectionFileDescriptor::BytesAvailable(this=0x00000001057178f0, timeout_usec=0x004c4b40, error_ptr=0x0000000105980a18) + 722 at ConnectionFileDescriptor.cpp:542 frame #2: 0x0000000100f3e6dd LLDB lldb_private::ConnectionFileDescriptor::Read(this=0x00000001057178f0, dst=0x0000000105980a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x0000000105980a14, error_ptr=0x0000000105980a18) + 301 at ConnectionFileDescriptor.cpp:273 frame #3: 0x0000000100f3b8f7 LLDB lldb_private::Communication::ReadFromConnection(this=0x0000000105717580, dst=0x0000000105980a60, dst_len=1024, timeout_usec=0x004c4b40, status=0x0000000105980a14, error_ptr=0x0000000105980a18) + 167 at Communication.cpp:317 frame #4: 0x0000000100f3b197 LLDB lldb_private::Communication::ReadThread(p=0x0000000105717580) + 327 at Communication.cpp:344 frame #5: 0x0000000101078923 LLDB ThreadCreateTrampoline(arg=0x00000001057179b0) + 227 at Host.cpp:549 frame #6: 0x00007fff884aa8bf libsystem_c.dylib _pthread_start + 335 frame #7: 0x00007fff884adb75 libsystem_c.dylib thread_start + 13 thread #6: tid = 0x2a03, 0x00007fff88a18af2 libsystem_kernel.dylib read + 10, name = frame #0: 0x00007fff88a18af2 libsystem_kernel.dylib read + 10 frame #1: 0x0000000100050c3b libedit.3.dylib read_init + 247 frame #2: 0x0000000100050e96 libedit.3.dylib el_wgetc + 155 frame #3: 0x000000010005115d libedit.3.dylib el_wgets + 578 frame #4: 0x000000010005debc libedit.3.dylib el_gets + 37 frame #5: 0x000000010000d409 lldb IOChannel::LibeditGetInput(this=0x0000000105700490, new_line=0x0000000105a03db0) + 89 at IOChannel.cpp:311 frame #6: 0x000000010000d8b6 lldb IOChannel::Run(this=0x0000000105700490) + 806 at IOChannel.cpp:391 frame #7: 0x000000010000d57d lldb IOChannel::IOReadThread(ptr=0x0000000105700490) + 29 at IOChannel.cpp:345 frame #8: 0x0000000101078923 LLDB ThreadCreateTrampoline(arg=0x00000001057179f0) + 227 at Host.cpp:549 frame #9: 0x00007fff884aa8bf libsystem_c.dylib _pthread_start + 335 frame #10: 0x00007fff884adb75 libsystem_c.dylib thread_start + 13 (lldb) Modified: lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=148110&r1=148109&r2=148110&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Jan 13 02:39:16 2012 @@ -24,8 +24,10 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" #include "lldb/Core/ValueObject.h" +#include "lldb/Core/ValueObjectVariable.h" #include "lldb/Host/Terminal.h" #include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Symbol/VariableList.h" #include "lldb/Target/TargetList.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -1883,6 +1885,108 @@ var_success = true; } } + else if (::strncmp (var_name_begin, "name-with-args}", strlen("name-with-args}")) == 0) + { + // Print the function name with arguments in it + + if (sc->function) + { + var_success = true; + ExecutionContextScope *exe_scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL; + cstr = sc->function->GetName().AsCString (NULL); + if (cstr) + { + const InlineFunctionInfo *inline_info = NULL; + VariableListSP variable_list_sp; + bool get_function_vars = true; + if (sc->block) + { + Block *inline_block = sc->block->GetContainingInlinedBlock (); + + if (inline_block) + { + get_function_vars = false; + inline_info = sc->block->GetInlinedFunctionInfo(); + if (inline_info) + variable_list_sp = inline_block->GetBlockVariableList (true); + } + } + + if (get_function_vars) + { + variable_list_sp = sc->function->GetBlock(true).GetBlockVariableList (true); + } + + if (inline_info) + { + s.PutCString (cstr); + s.PutCString (" [inlined] "); + cstr = inline_info->GetName().GetCString(); + } + + VariableList args; + if (variable_list_sp) + { + const size_t num_variables = variable_list_sp->GetSize(); + for (size_t var_idx = 0; var_idx < num_variables; ++var_idx) + { + VariableSP var_sp (variable_list_sp->GetVariableAtIndex(var_idx)); + if (var_sp->GetScope() == eValueTypeVariableArgument) + args.AddVariable (var_sp); + } + + } + if (args.GetSize() > 0) + { + const char *open_paren = strchr (cstr, '('); + const char *close_paren = NULL; + if (open_paren) + close_paren = strchr (open_paren, ')'); + + if (open_paren) + s.Write(cstr, open_paren - cstr + 1); + else + { + s.PutCString (cstr); + s.PutChar ('('); + } + const size_t num_args = variable_list_sp->GetSize(); + for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx) + { + VariableSP var_sp (args.GetVariableAtIndex (arg_idx)); + ValueObjectSP var_value_sp (ValueObjectVariable::Create (exe_scope, var_sp)); + const char *var_name = var_value_sp->GetName().GetCString(); + const char *var_value = var_value_sp->GetValueAsCString(); + if (var_value_sp->GetError().Success()) + { + if (arg_idx > 0) + s.PutCString (", "); + s.Printf ("%s=%s", var_name, var_value); + } + } + + if (close_paren) + s.PutCString (close_paren); + else + s.PutChar(')'); + + } + else + { + s.PutCString(cstr); + } + } + } + else if (sc->symbol) + { + cstr = sc->symbol->GetName().AsCString (NULL); + if (cstr) + { + s.PutCString(cstr); + var_success = true; + } + } + } else if (::strncmp (var_name_begin, "addr-offset}", strlen("addr-offset}")) == 0) { var_success = addr != NULL; From gclayton at apple.com Fri Jan 13 02:41:20 2012 From: gclayton at apple.com (Greg Clayton) Date: Fri, 13 Jan 2012 08:41:20 -0000 Subject: [Lldb-commits] [lldb] r148111 - /lldb/trunk/www/formats.html Message-ID: <20120113084120.EC4802A6C12D@llvm.org> Author: gclayton Date: Fri Jan 13 02:41:20 2012 New Revision: 148111 URL: http://llvm.org/viewvc/llvm-project?rev=148111&view=rev Log: Updated HTML with info for ${function.name-with-args} Modified: lldb/trunk/www/formats.html Modified: lldb/trunk/www/formats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/formats.html?rev=148111&r1=148110&r2=148111&view=diff ============================================================================== --- lldb/trunk/www/formats.html (original) +++ lldb/trunk/www/formats.html Fri Jan 13 02:41:20 2012 @@ -79,7 +79,8 @@ frame.fpThe generic frame register for the frame pointer. frame.flagsThe generic frame register for the flags register. frame.reg.NAMEAccess to any platform specific register by name (replace NAME with the name of the desired register). - function.nameThe name of the current function or symbol + function.nameThe name of the current function or symbol. + function.name-with-argsThe name of the current function with arguments and values or the symbol name. function.pc-offsetThe program counter offset within the current function or symbol line.file.basenameThe line table entry basename to the file for the current line entry in the current frame. line.file.fullpathThe line table entry fullpath to the file for the current line entry in the current frame. @@ -254,4 +255,4 @@ - + From scallanan at apple.com Fri Jan 13 16:05:56 2012 From: scallanan at apple.com (Sean Callanan) Date: Fri, 13 Jan 2012 22:05:56 -0000 Subject: [Lldb-commits] [lldb] r148144 - /lldb/trunk/source/Expression/ClangASTSource.cpp Message-ID: <20120113220556.3752E2A6C12C@llvm.org> Author: spyffe Date: Fri Jan 13 16:05:55 2012 New Revision: 148144 URL: http://llvm.org/viewvc/llvm-project?rev=148144&view=rev Log: Fixed some logging in the AST source and added more information. Modified: lldb/trunk/source/Expression/ClangASTSource.cpp Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=148144&r1=148143&r2=148144&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Fri Jan 13 16:05:55 2012 @@ -154,9 +154,10 @@ if (log) { - log->Printf(" CompleteTagDecl[%u] on (ASTContext*)%p Completing a TagDecl named %s", - invocation_id, + log->Printf(" CompleteTagDecl[%u] on (ASTContext*)%p Completing (TagDecl*)%p named %s", + current_id, m_ast_context, + tag_decl, tag_decl->getName().str().c_str()); log->Printf(" CTD[%u] Before:", current_id); @@ -349,7 +350,7 @@ if (log) { - log->Printf(" FELD[%u] Original decl:", current_id); + log->Printf(" FELD[%u] Original decl (Decl*)%p:", current_id, original_decl); ASTDumper(original_decl).ToLog(log, " "); } @@ -407,7 +408,7 @@ if (log) { if (!context.m_decl_context) - log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] on (ASTContext*)%p for '%s' in a NULL DeclContext", current_id, m_ast_context, name.GetCString()); + log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] on (ASTContext*)%p for '%s' in a NULL DeclContext", current_id, m_ast_context, name.GetCString()); else if (const NamedDecl *context_named_decl = dyn_cast(context.m_decl_context)) log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] on (ASTContext*)%p for '%s' in '%s'", current_id, m_ast_context, name.GetCString(), context_named_decl->getNameAsString().c_str()); else From scallanan at apple.com Fri Jan 13 16:10:18 2012 From: scallanan at apple.com (Sean Callanan) Date: Fri, 13 Jan 2012 22:10:18 -0000 Subject: [Lldb-commits] [lldb] r148145 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20120113221018.636172A6C12C@llvm.org> Author: spyffe Date: Fri Jan 13 16:10:18 2012 New Revision: 148145 URL: http://llvm.org/viewvc/llvm-project?rev=148145&view=rev Log: If the name of a struct or union is NULL in the debug info, call it anonymous. This isn't perfect, because Clang actually considers the following struct not to be anonymous: ? struct { int x; int y; } g_foo; - but DWARF doesn't make the distinction. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=148145&r1=148144&r2=148145&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Jan 13 16:10:18 2012 @@ -1119,6 +1119,9 @@ SourceLocation(), SourceLocation(), name && name[0] ? &ast->Idents.get(name) : NULL); + + if (!name) + decl->setAnonymousStructOrUnion(true); if (decl_ctx) { From scallanan at apple.com Fri Jan 13 16:19:53 2012 From: scallanan at apple.com (Sean Callanan) Date: Fri, 13 Jan 2012 22:19:53 -0000 Subject: [Lldb-commits] [lldb] r148146 - /lldb/trunk/source/Target/Target.cpp Message-ID: <20120113221953.DF7732A6C12C@llvm.org> Author: spyffe Date: Fri Jan 13 16:19:53 2012 New Revision: 148146 URL: http://llvm.org/viewvc/llvm-project?rev=148146&view=rev Log: Only create new ASTImporters on demand, not proactively. Modified: lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=148146&r1=148145&r2=148146&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Fri Jan 13 16:19:53 2012 @@ -840,8 +840,6 @@ } } } - - m_ast_importer_ap.reset(new ClangASTImporter()); } UpdateInstanceName(); From scallanan at apple.com Fri Jan 13 16:55:55 2012 From: scallanan at apple.com (Sean Callanan) Date: Fri, 13 Jan 2012 22:55:55 -0000 Subject: [Lldb-commits] [lldb] r148152 - /lldb/trunk/source/Symbol/ClangASTImporter.cpp Message-ID: <20120113225555.C266E2A6C12C@llvm.org> Author: spyffe Date: Fri Jan 13 16:55:55 2012 New Revision: 148152 URL: http://llvm.org/viewvc/llvm-project?rev=148152&view=rev Log: I made two major improvements to the way the master AST importer imports types. - First, before importing the definition of a Decl from its source, notify the underlying importer of the source->destination mapping. Especially for anonymous strucutres that are otherwise hard to unique in the target AST context, this hint is very helpful. - When deporting a type or Decl from one ASTContext to another (deporting occurs in the case of moving result types from the parser's AST context to the result AST context), don't forget their origin if the origin is the original debug information. Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=148152&r1=148151&r2=148152&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Fri Jan 13 16:55:55 2012 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "clang/AST/Decl.h" +#include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" @@ -93,11 +94,15 @@ { MinionSP minion_sp (GetMinion (dst_ctx, src_ctx)); - minion_sp->ImportDefinition(tag_decl); + minion_sp->ImportDefinitionTo(result_tag_decl, tag_decl); ASTContextMetadataSP to_context_md = GetContextMetadata(dst_ctx); - to_context_md->m_origins.erase(result_tag_decl); + OriginMap::iterator oi = to_context_md->m_origins.find(result_tag_decl); + + if (oi != to_context_md->m_origins.end() && + oi->second.ctx == src_ctx) + to_context_md->m_origins.erase(oi); } } @@ -119,11 +124,15 @@ MinionSP minion_sp (GetMinion (dst_ctx, src_ctx)); if (minion_sp && isa(decl)) - minion_sp->ImportDefinition(decl); + minion_sp->ImportDefinitionTo(result, decl); ASTContextMetadataSP to_context_md = GetContextMetadata(dst_ctx); - to_context_md->m_origins.erase(result); + OriginMap::iterator oi = to_context_md->m_origins.find(decl); + + if (oi != to_context_md->m_origins.end() && + oi->second.ctx == src_ctx) + to_context_md->m_origins.erase(oi); return result; } @@ -142,8 +151,8 @@ MinionSP minion_sp (GetMinion(&decl->getASTContext(), decl_origin.ctx)); if (minion_sp) - minion_sp->ImportDefinition(decl_origin.decl); - + minion_sp->ImportDefinitionTo(decl, decl_origin.decl); + return true; } @@ -158,8 +167,8 @@ MinionSP minion_sp (GetMinion(&decl->getASTContext(), origin_ast_ctx)); if (minion_sp) - minion_sp->ImportDefinition(origin_decl); - + minion_sp->ImportDefinitionTo(decl, origin_decl); + ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext()); OriginMap &origins = context_md->m_origins; @@ -185,8 +194,8 @@ MinionSP minion_sp (GetMinion(&interface_decl->getASTContext(), decl_origin.ctx)); if (minion_sp) - minion_sp->ImportDefinition(decl_origin.decl); - + minion_sp->ImportDefinitionTo(interface_decl, decl_origin.decl); + return true; } @@ -258,6 +267,11 @@ void ClangASTImporter::ForgetDestination (clang::ASTContext *dst_ast) { + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (log) + log->Printf(" [ClangASTImporter] Forgetting destination (ASTContext*)%p", dst_ast); + m_metadata_map.erase(dst_ast); } @@ -266,6 +280,11 @@ { ASTContextMetadataSP md = MaybeGetContextMetadata (dst_ast); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (log) + log->Printf(" [ClangASTImporter] Forgetting source->dest (ASTContext*)%p->(ASTContext*)%p", src_ast, dst_ast); + if (!md) return; @@ -319,6 +338,14 @@ context_md->m_objc_interface_maps[decl] = new_map; } +void +ClangASTImporter::Minion::ImportDefinitionTo (clang::Decl *to, clang::Decl *from) +{ + ASTImporter::Imported(from, to); + + ImportDefinition(from); +} + clang::Decl *ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) { From gclayton at apple.com Sat Jan 14 11:04:19 2012 From: gclayton at apple.com (Greg Clayton) Date: Sat, 14 Jan 2012 17:04:19 -0000 Subject: [Lldb-commits] [lldb] r148189 - /lldb/trunk/source/Core/Debugger.cpp Message-ID: <20120114170419.465192A6C12C@llvm.org> Author: gclayton Date: Sat Jan 14 11:04:19 2012 New Revision: 148189 URL: http://llvm.org/viewvc/llvm-project?rev=148189&view=rev Log: When the lldb_private::Debugger goes away, it should cleanup all of its targets. Modified: lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=148189&r1=148188&r2=148189&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Sat Jan 14 11:04:19 2012 @@ -359,13 +359,16 @@ int num_targets = m_target_list.GetNumTargets(); for (int i = 0; i < num_targets; i++) { - ProcessSP process_sp (m_target_list.GetTargetAtIndex (i)->GetProcessSP()); - if (process_sp) + TargetSP target_sp (m_target_list.GetTargetAtIndex (i)); + if (target_sp) { - if (process_sp->GetShouldDetach()) - process_sp->Detach(); - else - process_sp->Destroy(); + ProcessSP process_sp (target_sp->GetProcessSP()); + if (process_sp) + { + if (process_sp->GetShouldDetach()) + process_sp->Detach(); + } + target_sp->Destroy(); } } DisconnectInput(); @@ -776,6 +779,7 @@ "{frame.reg.carp = '${frame.reg.carp}'\n}" "{function.id = '${function.id}'\n}" "{function.name = '${function.name}'\n}" + "{function.name-with-args = '${function.name-with-args}'\n}" "{function.addr-offset = '${function.addr-offset}'\n}" "{function.line-offset = '${function.line-offset}'\n}" "{function.pc-offset = '${function.pc-offset}'\n}" From gclayton at apple.com Sat Jan 14 12:18:31 2012 From: gclayton at apple.com (Greg Clayton) Date: Sat, 14 Jan 2012 18:18:31 -0000 Subject: [Lldb-commits] [lldb] r148195 - /lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp Message-ID: <20120114181831.5C51F2A6C12C@llvm.org> Author: gclayton Date: Sat Jan 14 12:18:31 2012 New Revision: 148195 URL: http://llvm.org/viewvc/llvm-project?rev=148195&view=rev Log: Added some fixes for the fd interposing dylib: - don't strip too many frames from the backtrace when logging close backtraces - cleanup some logging messages Modified: lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp Modified: lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp?rev=148195&r1=148194&r2=148195&view=diff ============================================================================== --- lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp (original) +++ lldb/trunk/examples/interposing/darwin/fd_interposing/FDInterposing.cpp Sat Jan 14 12:18:31 2012 @@ -314,7 +314,8 @@ // We compact the file descriptor events by default. Set the environment // varible "FileDescriptorStackLoggingNoCompact" to keep a full history. static int g_compact = 1; - +// The name of the process +static char g_program_path[PATH_MAX] = {0}; //---------------------------------------------------------------------- // Mutex class that will lock a mutex when it is constructed, and unlock // it when is goes out of scope @@ -376,11 +377,8 @@ get_logging_fd () { static int g_log_fd = STDOUT_FILENO; - static char program_fullpath[PATH_MAX]; static int initialized = 0; - const int pid = getpid(); - if (!initialized) { initialized = 1; @@ -396,10 +394,10 @@ char program_basename[PATH_MAX]; // If DST is NULL, then return the number of bytes needed. - uint32_t len = sizeof(program_fullpath); - if (_NSGetExecutablePath (program_fullpath, &len) == 0) + uint32_t len = sizeof(g_program_path); + if (_NSGetExecutablePath (g_program_path, &len) == 0) { - strncpy (program_basename, program_fullpath, sizeof(program_basename)); + strncpy (program_basename, g_program_path, sizeof(program_basename)); const char *program_basename_cstr = basename(program_basename); if (program_basename_cstr) { @@ -411,7 +409,7 @@ if (log_path) g_log_fd = ::creat (log_path, 0660); if (g_log_fd >= 0) - log ("Logging file descriptor functions process '%s' (pid = %i)\n", program_fullpath, pid); + log ("Logging file descriptor functions process '%s' (pid = %i)\n", g_program_path, getpid()); } } } @@ -508,7 +506,7 @@ } Frames frames; - if (get_backtrace(frames, 3)) + if (get_backtrace(frames, 2)) ::backtrace_symbols_fd (frames.data(), frames.size(), log_fd); } @@ -785,18 +783,19 @@ dup2$__interposed__ (int fd1, int fd2) { Locker locker (&g_mutex); - - const int fd = dup2(fd1, fd2); - InvalidFDErrno fd_errno(fd); - StringSP description_sp(new String ("dup2 fd1=%i, fd2=%i) -> fd=%i", fd1, fd2, fd)); - if (g_log_all_calls) - description_sp->log (get_logging_fd()); // If "fd2" is already opened, it will be closed during the // dup2 call below, so we need to see if we have fd2 in our // open map and treat it as a close(fd2) FDEventMap::iterator pos = g_fd_event_map.find (fd2); + StringSP dup2_close_description_sp(new String ("dup2 (fd1=%i, fd2=%i) -> will close (fd=%i)", fd1, fd2, fd2)); if (pos != g_fd_event_map.end() && pos->second.back()->IsCreateEvent()) - save_backtrace (fd2, 0, description_sp, false); + save_backtrace (fd2, 0, dup2_close_description_sp, false); + + const int fd = dup2(fd1, fd2); + InvalidFDErrno fd_errno(fd); + StringSP description_sp(new String ("dup2 (fd1=%i, fd2=%i) -> fd=%i", fd1, fd2, fd)); + if (g_log_all_calls) + description_sp->log (get_logging_fd()); if (fd >= 0) save_backtrace (fd, fd_errno.get_errno(), description_sp, true); @@ -829,12 +828,12 @@ { if (err_errno.get_errno() == EBADF && fd != -1) { - backtrace_log ("\nerror: close on fd=%d resulted in EBADF in process %i\n", fd, getpid()); + backtrace_log ("\nerror: close on fd=%d resulted in EBADF in process %s (pid = %i)\n", fd, g_program_path, getpid()); FDEventMap::iterator pos = g_fd_event_map.find (fd); if (pos != g_fd_event_map.end()) { - log (get_logging_fd(), pos->second.back().get(), "\nfd=%d was previously closed with this event:\n", fd); + log (get_logging_fd(), pos->second.back().get(), "\nfd=%d was previously %s with this event:\n", fd, pos->second.back()->IsCreateEvent() ? "opened" : "closed"); } } } @@ -868,12 +867,12 @@ { if (err_errno.get_errno() == EBADF && fd != -1) { - backtrace_log ("\nInvoking close$NOCANCEL (fd=%d) in process %i resulted in %i %s\n", fd, getpid(), err_errno.get_errno(), err_errno.get_errno() ? strerror (err_errno.get_errno()) : ""); + backtrace_log ("\nerror: close$NOCANCEL on fd=%d resulted in EBADF in process %s (pid = %i)\n", fd, g_program_path, getpid()); FDEventMap::iterator pos = g_fd_event_map.find (fd); if (pos != g_fd_event_map.end()) { - log (get_logging_fd(), pos->second.back().get(), "\nPrevious close(fd=%d) was done here:\n", fd); + log (get_logging_fd(), pos->second.back().get(), "\nfd=%d was previously %s with this event:\n", fd, pos->second.back()->IsCreateEvent() ? "opened" : "closed"); } } } From scallanan at apple.com Sat Jan 14 14:16:24 2012 From: scallanan at apple.com (Sean Callanan) Date: Sat, 14 Jan 2012 20:16:24 -0000 Subject: [Lldb-commits] [lldb] r148199 - /lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Message-ID: <20120114201624.C33B72A6C12C@llvm.org> Author: spyffe Date: Sat Jan 14 14:16:24 2012 New Revision: 148199 URL: http://llvm.org/viewvc/llvm-project?rev=148199&view=rev Log: I forgot to import a header file change. This should fix builds. Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=148199&r1=148198&r2=148199&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Sat Jan 14 14:16:24 2012 @@ -199,6 +199,8 @@ { } + void ImportDefinitionTo (clang::Decl *to, clang::Decl *from); + clang::Decl *Imported (clang::Decl *from, clang::Decl *to); ClangASTImporter &m_master; From gclayton at apple.com Sat Jan 14 14:47:38 2012 From: gclayton at apple.com (Greg Clayton) Date: Sat, 14 Jan 2012 20:47:38 -0000 Subject: [Lldb-commits] [lldb] r148201 - in /lldb/trunk/source/Core: ConnectionFileDescriptor.cpp Debugger.cpp Message-ID: <20120114204738.C7C112A6C12C@llvm.org> Author: gclayton Date: Sat Jan 14 14:47:38 2012 New Revision: 148201 URL: http://llvm.org/viewvc/llvm-project?rev=148201&view=rev Log: Fixed two double "int close(int fd)" issues found by our file descriptor interposing library on darwin: The first is in SBDebugger::SetInputFileHandle (FILE *file, bool transfer_ownership) where we would give our FILE * to a lldb_private::File object member variable and tell it that it owned the file descriptor if "transfer_ownership" was true, and then we would also give it to the communication plug-in that waits for stdin to come in and tell it that it owned the FILE *. They would both try and close the file. The seconds was when we use a file descriptor through ConnectionFileDescriptor where someone else is creating a connection with ConnectionFileDescriptor and a URL like: "fd://123". We were always taking ownwership of the fd 123, when we shouldn't be. There is a TODO in the comments that says we should allow URL options to be passed to be able to specify this later (something like: "fd://123?transer_ownership=1"), but we can get to this later. Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=148201&r1=148200&r2=148201&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Sat Jan 14 14:47:38 2012 @@ -174,7 +174,16 @@ bool is_socket = GetSocketOption (m_fd_send, SOL_SOCKET, SO_REUSEADDR, resuse) == 0; if (is_socket) m_fd_send_type = m_fd_recv_type = eFDTypeSocket; - m_should_close_fd = true; + // Don't take ownership of a file descriptor that gets passed + // to us since someone else opened the file descriptor and + // handed it to us. + // TODO: Since are using a URL to open connection we should + // eventually parse options using the web standard where we + // have "fd://123?opt1=value;opt2=value" and we can have an + // option be "owns=1" or "owns=0" or something like this to + // allow us to specify this. For now, we assume we must + // assume we don't own it. + m_should_close_fd = false; return eConnectionStatusSuccess; } } Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=148201&r1=148200&r2=148201&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Sat Jan 14 14:47:38 2012 @@ -410,7 +410,10 @@ // Disconnect from any old connection if we had one m_input_comm.Disconnect (); - m_input_comm.SetConnection (new ConnectionFileDescriptor (in_file.GetDescriptor(), true)); + // Pass false as the second argument to ConnectionFileDescriptor below because + // our "in_file" above will already take ownership if requested and we don't + // want to objects trying to own and close a file descriptor. + m_input_comm.SetConnection (new ConnectionFileDescriptor (in_file.GetDescriptor(), false)); m_input_comm.SetReadThreadBytesReceivedCallback (Debugger::DispatchInputCallback, this); Error error; From gclayton at apple.com Sat Jan 14 14:57:34 2012 From: gclayton at apple.com (Greg Clayton) Date: Sat, 14 Jan 2012 20:57:34 -0000 Subject: [Lldb-commits] [lldb] r148202 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20120114205734.B02552A6C12C@llvm.org> Author: gclayton Date: Sat Jan 14 14:57:34 2012 New Revision: 148202 URL: http://llvm.org/viewvc/llvm-project?rev=148202&view=rev Log: Bumped xcode project versions for lldb-106 and debugserver-165 Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=148202&r1=148201&r2=148202&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat Jan 14 14:57:34 2012 @@ -3733,9 +3733,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 105; + DYLIB_CURRENT_VERSION = 106; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3793,10 +3793,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 105; + DYLIB_CURRENT_VERSION = 106; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3852,8 +3852,8 @@ 2689FFD513353D7A00698AC0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 105; - DYLIB_CURRENT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; + DYLIB_CURRENT_VERSION = 106; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3881,8 +3881,8 @@ 2689FFD613353D7A00698AC0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 105; - DYLIB_CURRENT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; + DYLIB_CURRENT_VERSION = 106; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3910,8 +3910,8 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 105; - DYLIB_CURRENT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; + DYLIB_CURRENT_VERSION = 106; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3991,7 +3991,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4022,10 +4022,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 105; + DYLIB_CURRENT_VERSION = 106; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4269,7 +4269,7 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4299,7 +4299,7 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 105; + CURRENT_PROJECT_VERSION = 106; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=148202&r1=148201&r2=148202&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Sat Jan 14 14:57:34 2012 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 105 + 106 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=148202&r1=148201&r2=148202&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Sat Jan 14 14:57:34 2012 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 164; + CURRENT_PROJECT_VERSION = 165; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = ""; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 164; + CURRENT_PROJECT_VERSION = 165; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 164; + CURRENT_PROJECT_VERSION = 165; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -534,7 +534,7 @@ "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 164; + CURRENT_PROJECT_VERSION = 165; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -575,7 +575,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 164; + CURRENT_PROJECT_VERSION = 165; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -616,7 +616,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 164; + CURRENT_PROJECT_VERSION = 165; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Sat Jan 14 14:58:05 2012 From: gclayton at apple.com (Greg Clayton) Date: Sat, 14 Jan 2012 20:58:05 -0000 Subject: [Lldb-commits] [lldb] r148203 - /lldb/tags/lldb-106/ Message-ID: <20120114205805.8BB342A6C12C@llvm.org> Author: gclayton Date: Sat Jan 14 14:58:05 2012 New Revision: 148203 URL: http://llvm.org/viewvc/llvm-project?rev=148203&view=rev Log: lldb-106 Added: lldb/tags/lldb-106/ - copied from r148202, lldb/trunk/