[Lldb-commits] [lldb] r168494 - in /lldb/branches/windows: ./ include/lldb/API/ include/lldb/Core/ include/lldb/Expression/ include/lldb/Target/ lldb.xcodeproj/ scripts/Python/interface/ source/API/ source/Core/ source/Expression/ source/Host/common/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/ObjectContainer/BSD-Archive/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ source/Target/ test/ test/...

Carlo Kok ck at remobjects.com
Thu Nov 22 04:24:08 PST 2012


Author: carlokok
Date: Thu Nov 22 06:24:07 2012
New Revision: 168494

URL: http://llvm.org/viewvc/llvm-project?rev=168494&view=rev
Log:
Merge trunk into branches-windows

Added:
    lldb/branches/windows/test/lang/objc/objc-ivar-stripped/
      - copied from r168491, lldb/trunk/test/lang/objc/objc-ivar-stripped/
    lldb/branches/windows/test/lang/objc/rdar-12408181/
      - copied from r168491, lldb/trunk/test/lang/objc/rdar-12408181/
    lldb/branches/windows/www/symbols.html
      - copied unchanged from r168491, lldb/trunk/www/symbols.html
Modified:
    lldb/branches/windows/   (props changed)
    lldb/branches/windows/include/lldb/API/SBProcess.h
    lldb/branches/windows/include/lldb/Core/Broadcaster.h
    lldb/branches/windows/include/lldb/Core/Listener.h
    lldb/branches/windows/include/lldb/Expression/ClangExpressionDeclMap.h
    lldb/branches/windows/include/lldb/Expression/RecordingMemoryManager.h
    lldb/branches/windows/include/lldb/Target/ObjCLanguageRuntime.h
    lldb/branches/windows/include/lldb/Target/Process.h
    lldb/branches/windows/include/lldb/Target/Thread.h
    lldb/branches/windows/lldb.xcodeproj/project.pbxproj
    lldb/branches/windows/scripts/Python/interface/SBProcess.i
    lldb/branches/windows/source/API/SBProcess.cpp
    lldb/branches/windows/source/Core/Listener.cpp
    lldb/branches/windows/source/Expression/ClangExpressionDeclMap.cpp
    lldb/branches/windows/source/Expression/ClangExpressionParser.cpp
    lldb/branches/windows/source/Expression/RecordingMemoryManager.cpp
    lldb/branches/windows/source/Host/common/Host.cpp
    lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
    lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
    lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
    lldb/branches/windows/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
    lldb/branches/windows/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/branches/windows/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
    lldb/branches/windows/source/Plugins/Process/Utility/RegisterContextLLDB.h
    lldb/branches/windows/source/Plugins/Process/Utility/UnwindLLDB.cpp
    lldb/branches/windows/source/Plugins/Process/Utility/UnwindLLDB.h
    lldb/branches/windows/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/branches/windows/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/branches/windows/source/Symbol/ClangASTContext.cpp
    lldb/branches/windows/source/Target/Process.cpp
    lldb/branches/windows/source/Target/Thread.cpp
    lldb/branches/windows/source/Target/ThreadList.cpp
    lldb/branches/windows/test/dotest.py
    lldb/branches/windows/test/expression_command/call-function/TestCallStdStringFunction.py
    lldb/branches/windows/test/expression_command/formatters/TestFormatters.py
    lldb/branches/windows/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
    lldb/branches/windows/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py
    lldb/branches/windows/test/functionalities/command_script/main.cpp
    lldb/branches/windows/test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py
    lldb/branches/windows/test/lang/cpp/stl/main.cpp
    lldb/branches/windows/test/logging/TestLogging.py
    lldb/branches/windows/test/python_api/event/TestEvents.py
    lldb/branches/windows/test/types/TestFloatTypes.py
    lldb/branches/windows/test/types/TestFloatTypesExpr.py
    lldb/branches/windows/test/types/TestIntegerTypes.py
    lldb/branches/windows/test/types/TestIntegerTypesExpr.py
    lldb/branches/windows/tools/debugserver/source/DNB.cpp
    lldb/branches/windows/tools/debugserver/source/DNB.h
    lldb/branches/windows/tools/debugserver/source/DNBDefs.h
    lldb/branches/windows/tools/debugserver/source/MacOSX/MachProcess.cpp
    lldb/branches/windows/tools/debugserver/source/MacOSX/MachProcess.h
    lldb/branches/windows/tools/debugserver/source/MacOSX/MachTask.cpp
    lldb/branches/windows/tools/debugserver/source/MacOSX/MachTask.h
    lldb/branches/windows/tools/debugserver/source/MacOSX/MachVMMemory.cpp
    lldb/branches/windows/tools/debugserver/source/MacOSX/MachVMMemory.h
    lldb/branches/windows/tools/debugserver/source/RNBContext.cpp
    lldb/branches/windows/tools/debugserver/source/RNBContext.h
    lldb/branches/windows/tools/debugserver/source/RNBRemote.cpp
    lldb/branches/windows/tools/debugserver/source/RNBRemote.h
    lldb/branches/windows/tools/debugserver/source/debugserver.cpp
    lldb/branches/windows/www/lldb-gdb.html
    lldb/branches/windows/www/sidebar.incl

Propchange: lldb/branches/windows/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 22 06:24:07 2012
@@ -1,2 +1,2 @@
 /lldb/branches/apple/python-GIL:156467-162159
-/lldb/trunk:163223-167847
+/lldb/trunk:163223-168491

Modified: lldb/branches/windows/include/lldb/API/SBProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/include/lldb/API/SBProcess.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/include/lldb/API/SBProcess.h (original)
+++ lldb/branches/windows/include/lldb/API/SBProcess.h Thu Nov 22 06:24:07 2012
@@ -30,7 +30,8 @@
         eBroadcastBitStateChanged   = (1 << 0),
         eBroadcastBitInterrupt      = (1 << 1),
         eBroadcastBitSTDOUT         = (1 << 2),
-        eBroadcastBitSTDERR         = (1 << 3)
+        eBroadcastBitSTDERR         = (1 << 3),
+        eBroadcastBitProfileData    = (1 << 4)
     };
 
     SBProcess ();
@@ -74,6 +75,9 @@
     size_t
     GetSTDERR (char *dst, size_t dst_len) const;
 
+    size_t
+    GetAsyncProfileData(char *dst, size_t dst_len) const;
+    
     void
     ReportEventState (const lldb::SBEvent &event, FILE *out) const;
 

Modified: lldb/branches/windows/include/lldb/Core/Broadcaster.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/include/lldb/Core/Broadcaster.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/include/lldb/Core/Broadcaster.h (original)
+++ lldb/branches/windows/include/lldb/Core/Broadcaster.h Thu Nov 22 06:24:07 2012
@@ -233,7 +233,8 @@
 ///             eBroadcastBitStateChanged   = (1 << 0),
 ///             eBroadcastBitInterrupt      = (1 << 1),
 ///             eBroadcastBitSTDOUT         = (1 << 2),
-///             eBroadcastBitSTDERR         = (1 << 3)
+///             eBroadcastBitSTDERR         = (1 << 3),
+///             eBroadcastBitProfileData    = (1 << 4)
 ///         };
 ///     \endcode
 //----------------------------------------------------------------------

Modified: lldb/branches/windows/include/lldb/Core/Listener.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/include/lldb/Core/Listener.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/include/lldb/Core/Listener.h (original)
+++ lldb/branches/windows/include/lldb/Core/Listener.h Thu Nov 22 06:24:07 2012
@@ -117,7 +117,7 @@
     size_t
     HandleBroadcastEvent (lldb::EventSP &event_sp);
 
-protected:
+private:
 
     //------------------------------------------------------------------
     // Classes that inherit from Listener can see and modify these
@@ -177,7 +177,6 @@
     void
     BroadcasterManagerWillDestruct (BroadcasterManager *manager);
     
-private:
 
 //    broadcaster_collection::iterator
 //    FindBroadcasterWithMask (Broadcaster *broadcaster,

Modified: lldb/branches/windows/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/include/lldb/Expression/ClangExpressionDeclMap.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/branches/windows/include/lldb/Expression/ClangExpressionDeclMap.h Thu Nov 22 06:24:07 2012
@@ -328,6 +328,11 @@
     ///     The target to find the symbol in.  If not provided,
     ///     then the current parsing context's Target.
     ///
+    /// @param[in] process
+    ///     The process to use.  For Objective-C symbols, the process's
+    ///     Objective-C language runtime may be queried if the process
+    ///     is non-NULL.
+    ///
     /// @param[in] name
     ///     The name of the symbol.  
     ///
@@ -336,6 +341,7 @@
     //------------------------------------------------------------------
     lldb::addr_t 
     GetSymbolAddress (Target &target,
+                      Process *process,
                       const ConstString &name,
                       lldb::SymbolType symbol_type);
     

Modified: lldb/branches/windows/include/lldb/Expression/RecordingMemoryManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/include/lldb/Expression/RecordingMemoryManager.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/include/lldb/Expression/RecordingMemoryManager.h (original)
+++ lldb/branches/windows/include/lldb/Expression/RecordingMemoryManager.h Thu Nov 22 06:24:07 2012
@@ -184,11 +184,14 @@
     /// @param[in] SectionID
     ///     A unique identifier for the section.
     ///
+    /// @param[in] IsReadOnly
+    ///     Flag indicating the section is read-only.
+    ///
     /// @return
     ///     Allocated space.
     //------------------------------------------------------------------
     virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
-                                         unsigned SectionID);
+                                         unsigned SectionID, bool IsReadOnly);
 
     //------------------------------------------------------------------
     /// Allocate space for a global variable, and add it to the
@@ -207,6 +210,18 @@
                                     unsigned Alignment);
 
     //------------------------------------------------------------------
+    /// Called when object loading is complete and section page
+    /// permissions can be applied. Currently unimplemented for LLDB.
+    ///
+    /// @param[out] ErrMsg
+    ///     The error that prevented the page protection from succeeding.
+    ///
+    /// @return
+    ///     True in case of failure, false in case of success.
+    //------------------------------------------------------------------
+    bool applyPermissions(std::string *ErrMsg) { return false; }
+
+    //------------------------------------------------------------------
     /// Passthrough interface stub
     //------------------------------------------------------------------
     virtual void deallocateFunctionBody(void *Body);

Modified: lldb/branches/windows/include/lldb/Target/ObjCLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/include/lldb/Target/ObjCLanguageRuntime.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/include/lldb/Target/ObjCLanguageRuntime.h (original)
+++ lldb/branches/windows/include/lldb/Target/ObjCLanguageRuntime.h Thu Nov 22 06:24:07 2012
@@ -114,8 +114,9 @@
         // This should return true iff the interface could be completed
         virtual bool
         Describe (std::function <void (ObjCISA)> const &superclass_func,
-                  std::function <void (const char*, const char*)> const &instance_method_func,
-                  std::function <void (const char*, const char*)> const &class_method_func)
+                  std::function <bool (const char*, const char*)> const &instance_method_func,
+                  std::function <bool (const char*, const char*)> const &class_method_func,
+                  std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> const &ivar_func)
         {
             return false;
         }
@@ -260,7 +261,6 @@
         if (m_process && m_process->GetStopID() != m_isa_to_descriptor_cache_stop_id)
         {
             UpdateISAToDescriptorMapIfNeeded ();
-            assert (m_process->GetStopID() == m_isa_to_descriptor_cache_stop_id); // REMOVE THIS PRIOR TO CHECKIN
         }
     }
     
@@ -285,6 +285,15 @@
     virtual size_t
     GetByteOffsetForIvar (ClangASTType &parent_qual_type, const char *ivar_name);
     
+    // Given the name of an Objective-C runtime symbol (e.g., ivar offset symbol),
+    // try to determine from the runtime what the value of that symbol would be.
+    // Useful when the underlying binary is stripped.
+    virtual lldb::addr_t
+    LookupRuntimeSymbol (const ConstString &name)
+    {
+        return LLDB_INVALID_ADDRESS;
+    }
+    
     //------------------------------------------------------------------
     /// Chop up an objective C function prototype.
     ///

Modified: lldb/branches/windows/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/include/lldb/Target/Process.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/include/lldb/Target/Process.h (original)
+++ lldb/branches/windows/include/lldb/Target/Process.h Thu Nov 22 06:24:07 2012
@@ -1350,7 +1350,8 @@
         eBroadcastBitStateChanged   = (1 << 0),
         eBroadcastBitInterrupt      = (1 << 1),
         eBroadcastBitSTDOUT         = (1 << 2),
-        eBroadcastBitSTDERR         = (1 << 3)
+        eBroadcastBitSTDERR         = (1 << 3),
+        eBroadcastBitProfileData    = (1 << 4)
     };
 
     enum
@@ -2948,7 +2949,7 @@
 
     Error
     DeallocateMemory (lldb::addr_t ptr);
-
+    
     //------------------------------------------------------------------
     /// Get any available STDOUT.
     ///
@@ -3004,6 +3005,24 @@
         return 0;
     }
 
+    //------------------------------------------------------------------
+    /// Get any available profile data.
+    ///
+    /// @param[out] buf
+    ///     A buffer that will receive any profile data bytes that are
+    ///     currently available.
+    ///
+    /// @param[out] buf_size
+    ///     The size in bytes for the buffer \a buf.
+    ///
+    /// @return
+    ///     The number of bytes written into \a buf. If this value is
+    ///     equal to \a buf_size, another call to this function should
+    ///     be made to retrieve more profile data.
+    //------------------------------------------------------------------
+    virtual size_t
+    GetAsyncProfileData (char *buf, size_t buf_size, Error &error);
+    
     //----------------------------------------------------------------------
     // Process Breakpoints
     //----------------------------------------------------------------------
@@ -3124,8 +3143,7 @@
     {
     public:
         ProcessEventHijacker (Process &process, Listener *listener) :
-            m_process (process),
-            m_listener (listener)
+            m_process (process)
         {
             m_process.HijackProcessEvents (listener);
         }
@@ -3136,7 +3154,6 @@
          
     private:
         Process &m_process;
-        Listener *m_listener;
     };
     friend class ProcessEventHijacker;
     //------------------------------------------------------------------
@@ -3445,14 +3462,16 @@
     UnixSignals                 m_unix_signals;         /// This is the current signal set for this process.
     lldb::ABISP                 m_abi_sp;
     lldb::InputReaderSP         m_process_input_reader;
-    Communication 				m_stdio_communication;
-    Mutex        				m_stdio_communication_mutex;
+    Communication               m_stdio_communication;
+    Mutex                       m_stdio_communication_mutex;
     std::string                 m_stdout_data;
     std::string                 m_stderr_data;
+    Mutex                       m_profile_data_comm_mutex;
+    std::string                 m_profile_data;
     MemoryCache                 m_memory_cache;
     AllocatedMemoryCache        m_allocated_memory_cache;
     bool                        m_should_detach;   /// Should we detach if the process object goes away with an explicit call to Kill or Detach?
-    LanguageRuntimeCollection 	m_language_runtimes;
+    LanguageRuntimeCollection   m_language_runtimes;
     std::auto_ptr<NextEventAction> m_next_event_action_ap;
     std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions;
     ReadWriteLock               m_run_lock;
@@ -3524,6 +3543,9 @@
     void
     AppendSTDERR (const char *s, size_t len);
     
+    void
+    BroadcastAsyncProfileData(const char *s, size_t len);
+    
     static void
     STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len);
     

Modified: lldb/branches/windows/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/include/lldb/Target/Thread.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/include/lldb/Target/Thread.h (original)
+++ lldb/branches/windows/include/lldb/Target/Thread.h Thu Nov 22 06:24:07 2012
@@ -859,7 +859,7 @@
     GetUnwinder ();
 
     // Check to see whether the thread is still at the last breakpoint hit that stopped it.
-    virtual const bool
+    virtual bool
     IsStillAtLastBreakpointHit();
 
     lldb::StackFrameListSP

Modified: lldb/branches/windows/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/lldb.xcodeproj/project.pbxproj?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/branches/windows/lldb.xcodeproj/project.pbxproj Thu Nov 22 06:24:07 2012
@@ -153,6 +153,9 @@
 		26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */; };
 		267C012B136880DF006E963E /* OptionGroupValueObjectDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */; };
 		267C01371368C49C006E963E /* OptionGroupOutputFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC531368B3E4006DC050 /* OptionGroupOutputFile.cpp */; };
+		268648C416531BF800F04704 /* com.apple.debugserver.posix.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 268648C116531BF800F04704 /* com.apple.debugserver.posix.plist */; };
+		268648C516531BF800F04704 /* com.apple.debugserver.applist.internal.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 268648C216531BF800F04704 /* com.apple.debugserver.applist.internal.plist */; };
+		268648C616531BF800F04704 /* com.apple.debugserver.internal.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 268648C316531BF800F04704 /* com.apple.debugserver.internal.plist */; };
 		2686536C1370ACB200D186A3 /* OptionGroupBoolean.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2686536B1370ACB200D186A3 /* OptionGroupBoolean.cpp */; };
 		268653701370AE7200D186A3 /* OptionGroupUInt64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2686536F1370AE7200D186A3 /* OptionGroupUInt64.cpp */; };
 		2689000113353DB600698AC0 /* BreakpointResolverAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5310FE555900271C65 /* BreakpointResolverAddress.cpp */; };
@@ -700,6 +703,9 @@
 			dstPath = /Developer/Library/Lockdown/ServiceAgents/;
 			dstSubfolderSpec = 0;
 			files = (
+				268648C416531BF800F04704 /* com.apple.debugserver.posix.plist in CopyFiles */,
+				268648C516531BF800F04704 /* com.apple.debugserver.applist.internal.plist in CopyFiles */,
+				268648C616531BF800F04704 /* com.apple.debugserver.internal.plist in CopyFiles */,
 				AFF87C87150FF669000E1742 /* com.apple.debugserver.plist in CopyFiles */,
 				AFF87C89150FF672000E1742 /* com.apple.debugserver-secure.plist in CopyFiles */,
 				AFF87C8F150FF688000E1742 /* com.apple.debugserver.applist.plist in CopyFiles */,
@@ -971,6 +977,9 @@
 		2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PseudoTerminal.h; path = include/lldb/Utility/PseudoTerminal.h; sourceTree = "<group>"; };
 		2682F284115EF3A700CCFF99 /* SBError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBError.cpp; path = source/API/SBError.cpp; sourceTree = "<group>"; };
 		2682F286115EF3BD00CCFF99 /* SBError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBError.h; path = include/lldb/API/SBError.h; sourceTree = "<group>"; };
+		268648C116531BF800F04704 /* com.apple.debugserver.posix.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; name = com.apple.debugserver.posix.plist; path = tools/debugserver/source/com.apple.debugserver.posix.plist; sourceTree = "<group>"; };
+		268648C216531BF800F04704 /* com.apple.debugserver.applist.internal.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; name = com.apple.debugserver.applist.internal.plist; path = tools/debugserver/source/com.apple.debugserver.applist.internal.plist; sourceTree = "<group>"; };
+		268648C316531BF800F04704 /* com.apple.debugserver.internal.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; name = com.apple.debugserver.internal.plist; path = tools/debugserver/source/com.apple.debugserver.internal.plist; sourceTree = "<group>"; };
 		2686536B1370ACB200D186A3 /* OptionGroupBoolean.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupBoolean.cpp; path = source/Interpreter/OptionGroupBoolean.cpp; sourceTree = "<group>"; };
 		2686536D1370ACC600D186A3 /* OptionGroupBoolean.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupBoolean.h; path = include/lldb/Interpreter/OptionGroupBoolean.h; sourceTree = "<group>"; };
 		2686536E1370AE5A00D186A3 /* OptionGroupUInt64.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupUInt64.h; path = include/lldb/Interpreter/OptionGroupUInt64.h; sourceTree = "<group>"; };
@@ -1755,6 +1764,9 @@
 		08FB7794FE84155DC02AAC07 /* lldb */ = {
 			isa = PBXGroup;
 			children = (
+				268648C116531BF800F04704 /* com.apple.debugserver.posix.plist */,
+				268648C216531BF800F04704 /* com.apple.debugserver.applist.internal.plist */,
+				268648C316531BF800F04704 /* com.apple.debugserver.internal.plist */,
 				26F5C32810F3DF7D009D5894 /* Libraries */,
 				264E8576159BE51A00E9D7A2 /* Resources */,
 				08FB7795FE84155DC02AAC07 /* Source */,

Modified: lldb/branches/windows/scripts/Python/interface/SBProcess.i
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/scripts/Python/interface/SBProcess.i?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/scripts/Python/interface/SBProcess.i (original)
+++ lldb/branches/windows/scripts/Python/interface/SBProcess.i Thu Nov 22 06:24:07 2012
@@ -43,7 +43,8 @@
         eBroadcastBitStateChanged   = (1 << 0),
         eBroadcastBitInterrupt      = (1 << 1),
         eBroadcastBitSTDOUT         = (1 << 2),
-        eBroadcastBitSTDERR         = (1 << 3)
+        eBroadcastBitSTDERR         = (1 << 3),
+        eBroadcastBitProfileData    = (1 << 4)
     };
 
     SBProcess ();
@@ -96,6 +97,9 @@
     size_t
     GetSTDERR (char *dst, size_t dst_len) const;
 
+    size_t
+    GetAsyncProfileData(char *dst, size_t dst_len) const;
+    
     void
     ReportEventState (const lldb::SBEvent &event, FILE *out) const;
 

Modified: lldb/branches/windows/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/API/SBProcess.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/API/SBProcess.cpp (original)
+++ lldb/branches/windows/source/API/SBProcess.cpp Thu Nov 22 06:24:07 2012
@@ -366,6 +366,29 @@
     return bytes_read;
 }
 
+size_t
+SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const
+{
+    size_t bytes_read = 0;
+    ProcessSP process_sp(GetSP());
+    if (process_sp)
+    {
+        Error error;
+        bytes_read = process_sp->GetAsyncProfileData (dst, dst_len, error);
+    }
+    
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    if (log)
+        log->Printf ("SBProcess(%p)::GetProfileData (dst=\"%.*s\", dst_len=%llu) => %llu",
+                     process_sp.get(),
+                     (int) bytes_read,
+                     dst,
+                     (uint64_t)dst_len,
+                     (uint64_t)bytes_read);
+    
+    return bytes_read;
+}
+
 void
 SBProcess::ReportEventState (const SBEvent &event, FILE *out) const
 {

Modified: lldb/branches/windows/source/Core/Listener.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Core/Listener.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Core/Listener.cpp (original)
+++ lldb/branches/windows/source/Core/Listener.cpp Thu Nov 22 06:24:07 2012
@@ -312,6 +312,11 @@
                 m_cond_wait.SetValue (false, eBroadcastNever);
         }
         
+        // Unlock the event queue here.  We've removed this event and are about to return
+        // it so it should be okay to get the next event off the queue here - and it might
+        // be useful to do that in the "DoOnRemoval".
+        lock.Unlock();
+        
         // Don't call DoOnRemoval if you aren't removing the event...
         if (remove)
             event_sp->DoOnRemoval();
@@ -406,19 +411,23 @@
 
     while (1)
     {
-        // Scope for "event_locker"
-        {
-            // Don't allow new events to be added while we're checking for the
-            // one we want.  Otherwise, setting m_cond_wait to false below
-            // might cause us to miss one.
-            Mutex::Locker event_locker(m_events_mutex);
-
-            if (GetNextEventInternal (broadcaster, broadcaster_names, num_broadcaster_names, event_type_mask, event_sp))
+        // Note, we don't want to lock the m_events_mutex in the call to GetNextEventInternal, since the DoOnRemoval
+        // code might require that new events be serviced.  For instance, the Breakpoint Command's 
+        if (GetNextEventInternal (broadcaster, broadcaster_names, num_broadcaster_names, event_type_mask, event_sp))
                 return true;
 
+        {
             // Reset condition value to false, so we can wait for new events to be
             // added that might meet our current filter
-            m_cond_wait.SetValue (false, eBroadcastNever);
+            // But first poll for any new event that might satisfy our condition, and if so consume it,
+            // otherwise wait.
+            
+            Mutex::Locker event_locker(m_events_mutex);
+            const bool remove = false;
+            if (FindNextEventInternal (broadcaster, broadcaster_names, num_broadcaster_names, event_type_mask, event_sp, remove))
+                continue;
+            else
+                m_cond_wait.SetValue (false, eBroadcastNever);
         }
 
         if (m_cond_wait.WaitForValueEqualTo (true, timeout, &timed_out))

Modified: lldb/branches/windows/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/ClangExpressionDeclMap.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/branches/windows/source/Expression/ClangExpressionDeclMap.cpp Thu Nov 22 06:24:07 2012
@@ -40,6 +40,7 @@
 #include "lldb/Symbol/Variable.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StackFrame.h"
@@ -749,7 +750,7 @@
 }
 
 addr_t
-ClangExpressionDeclMap::GetSymbolAddress (Target &target, const ConstString &name, lldb::SymbolType symbol_type)
+ClangExpressionDeclMap::GetSymbolAddress (Target &target, Process *process, const ConstString &name, lldb::SymbolType symbol_type)
 {
     SymbolContextList sc_list;
     
@@ -808,6 +809,16 @@
         }
     }
     
+    if (symbol_load_addr == LLDB_INVALID_ADDRESS && process)
+    {
+        ObjCLanguageRuntime *runtime = process->GetObjCLanguageRuntime();
+        
+        if (runtime)
+        {
+            symbol_load_addr = runtime->LookupRuntimeSymbol(name);
+        }
+    }
+    
     return symbol_load_addr;
 }
 
@@ -819,7 +830,7 @@
     if (!m_parser_vars->m_exe_ctx.GetTargetPtr())
         return false;
     
-    return GetSymbolAddress(m_parser_vars->m_exe_ctx.GetTargetRef(), name, symbol_type);
+    return GetSymbolAddress(m_parser_vars->m_exe_ctx.GetTargetRef(), m_parser_vars->m_exe_ctx.GetProcessPtr(), name, symbol_type);
 }
 
 // Interface for IRInterpreter
@@ -1840,7 +1851,7 @@
     }
     else if (sym)
     {
-        addr_t location_load_addr = GetSymbolAddress(*target, name, lldb::eSymbolTypeAny);
+        addr_t location_load_addr = GetSymbolAddress(*target, process, name, lldb::eSymbolTypeAny);
         
         if (location_load_addr == LLDB_INVALID_ADDRESS)
         {

Modified: lldb/branches/windows/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/ClangExpressionParser.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/branches/windows/source/Expression/ClangExpressionParser.cpp Thu Nov 22 06:24:07 2012
@@ -246,7 +246,7 @@
     
     // Create the target instance.
     m_compiler->setTarget(TargetInfo::CreateTargetInfo(m_compiler->getDiagnostics(),
-                                                       m_compiler->getTargetOpts()));
+                                                       &m_compiler->getTargetOpts()));
     
     assert (m_compiler->hasTarget());
     

Modified: lldb/branches/windows/source/Expression/RecordingMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Expression/RecordingMemoryManager.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Expression/RecordingMemoryManager.cpp (original)
+++ lldb/branches/windows/source/Expression/RecordingMemoryManager.cpp Thu Nov 22 06:24:07 2012
@@ -124,9 +124,9 @@
 }
 
 uint8_t *
-RecordingMemoryManager::allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID)
+RecordingMemoryManager::allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, bool IsReadOnly)
 {
-    uint8_t *return_value = m_default_mm_ap->allocateDataSection(Size, Alignment, SectionID);
+    uint8_t *return_value = m_default_mm_ap->allocateDataSection(Size, Alignment, SectionID, IsReadOnly);
     
     Allocation allocation;
     allocation.m_size = Size;

Modified: lldb/branches/windows/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Host/common/Host.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Host/common/Host.cpp (original)
+++ lldb/branches/windows/source/Host/common/Host.cpp Thu Nov 22 06:24:07 2012
@@ -374,7 +374,6 @@
 
         case llvm::Triple::sparcv9:
         case llvm::Triple::ppc64:
-        case llvm::Triple::cellspu:
             g_host_arch_64.SetTriple(triple);
             g_supports_64 = true;
             break;

Modified: lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Thu Nov 22 06:24:07 2012
@@ -1048,8 +1048,9 @@
     
     virtual bool
     Describe (std::function <void (ObjCLanguageRuntime::ObjCISA)> const &superclass_func,
-              std::function <void (const char *, const char *)> const &instance_method_func,
-              std::function <void (const char *, const char *)> const &class_method_func)
+              std::function <bool (const char *, const char *)> const &instance_method_func,
+              std::function <bool (const char *, const char *)> const &class_method_func,
+              std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> const &ivar_func)
     {
         lldb_private::Process *process = m_runtime.GetProcess();
 
@@ -1085,7 +1086,8 @@
             {
                 method->Read(process, base_method_list->m_first_ptr + (i * base_method_list->m_entsize));
                 
-                instance_method_func(method->m_name.c_str(), method->m_types.c_str());
+                if (instance_method_func(method->m_name.c_str(), method->m_types.c_str()))
+                    break;
             }
         }
         
@@ -1098,9 +1100,32 @@
             
             metaclass.Describe(std::function <void (ObjCLanguageRuntime::ObjCISA)> (nullptr),
                                class_method_func,
-                               std::function <void (const char *, const char *)> (nullptr));
+                               std::function <bool (const char *, const char *)> (nullptr),
+                               std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> (nullptr));
+        }
+        
+        if (ivar_func)
+        {
+            std::auto_ptr <ivar_list_t> ivar_list;
+            
+            ivar_list.reset(new ivar_list_t);
+            if (!ivar_list->Read(process, class_ro->m_ivars_ptr))
+                return false;
+            
+            if (ivar_list->m_entsize != ivar_t::GetSize(process))
+                return false;
+            
+            std::auto_ptr <ivar_t> ivar;
+            ivar.reset(new ivar_t);
+            
+            for (uint32_t i = 0, e = ivar_list->m_count; i < e; ++i)
+            {
+                ivar->Read(process, ivar_list->m_first_ptr + (i * ivar_list->m_entsize));
+                
+                if (ivar_func(ivar->m_name.c_str(), ivar->m_type.c_str(), ivar->m_offset_ptr, ivar->m_size))
+                    break;
+            }
         }
-        while (0);
             
         return true;
     }
@@ -1393,6 +1418,98 @@
         }
     };
     
+    struct ivar_list_t
+    {
+        uint32_t        m_entsize;
+        uint32_t        m_count;
+        lldb::addr_t    m_first_ptr;
+        
+        bool Read(Process *process, lldb::addr_t addr)
+        {
+            size_t size = sizeof(uint32_t)  // uint32_t entsize;
+                        + sizeof(uint32_t); // uint32_t count;
+            
+            DataBufferHeap buffer (size, '\0');
+            Error error;
+            
+            process->ReadMemory(addr, buffer.GetBytes(), size, error);
+            if (error.Fail())
+            {
+                return false;
+            }
+            
+            DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());
+            
+            uint32_t cursor = 0;
+            
+            m_entsize   = extractor.GetU32_unchecked(&cursor);
+            m_count     = extractor.GetU32_unchecked(&cursor);
+            m_first_ptr = addr + cursor;
+            
+            return true;
+        }
+    };
+    
+    struct ivar_t
+    {
+        lldb::addr_t    m_offset_ptr;
+        lldb::addr_t    m_name_ptr;
+        lldb::addr_t    m_type_ptr;
+        uint32_t        m_alignment;
+        uint32_t        m_size;
+        
+        std::string     m_name;
+        std::string     m_type;
+        
+        static size_t GetSize(Process *process)
+        {
+            size_t ptr_size = process->GetAddressByteSize();
+            
+            return ptr_size             // uintptr_t *offset;
+                 + ptr_size             // const char *name;
+                 + ptr_size             // const char *type;
+                 + sizeof(uint32_t)     // uint32_t alignment;
+                 + sizeof(uint32_t);    // uint32_t size;
+        }
+        
+        bool Read(Process *process, lldb::addr_t addr)
+        {
+            size_t size = GetSize(process);
+            
+            DataBufferHeap buffer (size, '\0');
+            Error error;
+            
+            process->ReadMemory(addr, buffer.GetBytes(), size, error);
+            if (error.Fail())
+            {
+                return false;
+            }
+            
+            DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(), process->GetAddressByteSize());
+            
+            uint32_t cursor = 0;
+            
+            m_offset_ptr = extractor.GetAddress_unchecked(&cursor);
+            m_name_ptr   = extractor.GetAddress_unchecked(&cursor);
+            m_type_ptr   = extractor.GetAddress_unchecked(&cursor);
+            m_alignment  = extractor.GetU32_unchecked(&cursor);
+            m_size       = extractor.GetU32_unchecked(&cursor);
+            
+            const size_t buffer_size = 1024;
+            size_t count;
+            
+            DataBufferHeap string_buf(buffer_size, 0);
+            
+            count = process->ReadCStringFromMemory(m_name_ptr, (char*)string_buf.GetBytes(), buffer_size, error);
+            m_name.assign((char*)string_buf.GetBytes(), count);
+            
+            count = process->ReadCStringFromMemory(m_type_ptr, (char*)string_buf.GetBytes(), buffer_size, error);
+            m_type.assign((char*)string_buf.GetBytes(), count);
+            
+            return true;
+        }
+    };
+    
     bool Read_objc_class (Process* process, std::auto_ptr<objc_class_t> &objc_class)
     {
         objc_class.reset(new objc_class_t);
@@ -1867,3 +1984,53 @@
     
     return m_type_vendor_ap.get();
 }
+
+lldb::addr_t
+AppleObjCRuntimeV2::LookupRuntimeSymbol (const ConstString &name)
+{
+    lldb::addr_t ret = LLDB_INVALID_ADDRESS;
+
+    const char *name_cstr = name.AsCString();    
+    
+    if (name_cstr)
+    {
+        llvm::StringRef name_strref(name_cstr);
+        
+        static const llvm::StringRef ivar_prefix("OBJC_IVAR_$_");
+        
+        if (name_strref.startswith(ivar_prefix))
+        {
+            llvm::StringRef ivar_skipped_prefix = name_strref.substr(ivar_prefix.size());
+            std::pair<llvm::StringRef, llvm::StringRef> class_and_ivar = ivar_skipped_prefix.split('.');
+            
+            if (class_and_ivar.first.size() && class_and_ivar.second.size())
+            {
+                const ConstString class_name_cs(class_and_ivar.first);
+                ClassDescriptorSP descriptor = ObjCLanguageRuntime::GetClassDescriptor(class_name_cs);
+                                
+                if (descriptor)
+                {
+                    const ConstString ivar_name_cs(class_and_ivar.second);
+                    const char *ivar_name_cstr = ivar_name_cs.AsCString();
+                    
+                    auto ivar_func = [&ret, ivar_name_cstr](const char *name, const char *type, lldb::addr_t offset_addr, uint64_t size) -> bool 
+                    {
+                        if (!strcmp(name, ivar_name_cstr))
+                        {
+                            ret = offset_addr;
+                            return true;
+                        }
+                        return false;
+                    };
+
+                    descriptor->Describe(std::function<void (ObjCISA)>(nullptr),
+                                         std::function<bool (const char *, const char *)>(nullptr),
+                                         std::function<bool (const char *, const char *)>(nullptr),
+                                         ivar_func);
+                }
+            }
+        }
+    } 
+    
+    return ret;
+}

Modified: lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original)
+++ lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Thu Nov 22 06:24:07 2012
@@ -99,6 +99,9 @@
     virtual TypeVendor *
     GetTypeVendor();
     
+    virtual lldb::addr_t
+    LookupRuntimeSymbol (const ConstString &name);
+    
 protected:
     virtual lldb::BreakpointResolverSP
     CreateExceptionResolver (Breakpoint *bkpt, bool catch_bp, bool throw_bp);

Modified: lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp (original)
+++ lldb/branches/windows/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeVendor.cpp Thu Nov 22 06:24:07 2012
@@ -518,7 +518,7 @@
         interface_decl->setSuperClass(superclass_decl);
     };
     
-    auto instance_method_func = [log, interface_decl, this](const char *name, const char *types)
+    auto instance_method_func = [log, interface_decl, this](const char *name, const char *types) -> bool
     {        
         ObjCRuntimeMethodType method_type(types);
         
@@ -529,9 +529,11 @@
         
         if (method_decl)
             interface_decl->addDecl(method_decl);
+        
+        return false;
     };
     
-    auto class_method_func = [log, interface_decl, this](const char *name, const char *types)
+    auto class_method_func = [log, interface_decl, this](const char *name, const char *types) -> bool
     {
         ObjCRuntimeMethodType method_type(types);
         
@@ -542,6 +544,8 @@
         
         if (method_decl)
             interface_decl->addDecl(method_decl);
+        
+        return false;
     };
     
     if (log)
@@ -552,7 +556,10 @@
     }
     
     
-    if (!descriptor->Describe(superclass_func, instance_method_func, class_method_func))
+    if (!descriptor->Describe(superclass_func,
+                              instance_method_func,
+                              class_method_func,
+                              std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> (nullptr)))
         return false;
     
     if (log)

Modified: lldb/branches/windows/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (original)
+++ lldb/branches/windows/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Thu Nov 22 06:24:07 2012
@@ -411,7 +411,7 @@
             if (object)
                 return ObjectFile::FindPlugin (module_sp, 
                                                file, 
-                                               object->ar_file_offset, 
+                                               m_offset + object->ar_file_offset,
                                                object->ar_file_size, 
                                                m_data.GetSharedDataBuffer());
         }

Modified: lldb/branches/windows/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/branches/windows/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu Nov 22 06:24:07 2012
@@ -563,6 +563,11 @@
 
             ArchSpec mach_arch(eArchTypeMachO, m_header.cputype, m_header.cpusubtype);
             
+            // Check if the module has a required architecture
+            const ArchSpec &module_arch = module_sp->GetArchitecture();
+            if (module_arch.IsValid() && !module_arch.IsExactMatch(mach_arch))
+                return false;
+
             if (SetModulesArchitecture (mach_arch))
             {
                 const size_t header_and_lc_size = m_header.sizeofcmds + MachHeaderSizeFromMagic(m_header.magic);

Modified: lldb/branches/windows/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/branches/windows/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Thu Nov 22 06:24:07 2012
@@ -904,7 +904,7 @@
 
 // Answer the question: Where did THIS frame save the CALLER frame ("previous" frame)'s register value?
 
-bool
+enum UnwindLLDB::RegisterSearchResult
 RegisterContextLLDB::SavedLocationForRegister (uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation &regloc)
 {
     // Have we already found this register location?
@@ -915,7 +915,8 @@
         if (iterator != m_registers.end())
         {
             regloc = iterator->second;
-            return true;
+            UnwindLogMsg ("supplying caller's saved reg %d's location, cached", lldb_regnum);
+            return UnwindLLDB::RegisterSearchResult::eRegisterFound;
         }
     }
 
@@ -938,7 +939,8 @@
         regloc.type = UnwindLLDB::RegisterLocation::eRegisterValueInferred;
         regloc.location.inferred_value = m_cfa;
         m_registers[lldb_regnum] = regloc;
-        return true;
+        UnwindLogMsg ("supplying caller's stack pointer (%d) value, computed from CFA", lldb_regnum);
+        return UnwindLLDB::RegisterSearchResult::eRegisterFound;
     }
 
     // Look through the available UnwindPlans for the register location.
@@ -956,7 +958,7 @@
         {
             UnwindLogMsg ("could not convert lldb regnum %d into %d RegisterKind reg numbering scheme",
                     lldb_regnum, (int) unwindplan_registerkind);
-            return false;
+            return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
         }
         if (active_row->GetRegisterInfo (row_regnum, unwindplan_regloc))
         {
@@ -994,7 +996,7 @@
                     else
                         UnwindLogMsg ("could not convert lldb regnum %d into %d RegisterKind reg numbering scheme",
                                 lldb_regnum, (int) unwindplan_registerkind);
-                    return false;
+                    return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
                 }
             }
 
@@ -1065,7 +1067,7 @@
             if (reg_info && abi->RegisterIsVolatile (reg_info))
             {
                 UnwindLogMsg ("did not supply reg location for %d because it is volatile", lldb_regnum);
-                return false;
+                return UnwindLLDB::RegisterSearchResult::eRegisterIsVolatile;
             }
         }
 
@@ -1077,11 +1079,12 @@
             new_regloc.location.register_number = lldb_regnum;
             m_registers[lldb_regnum] = new_regloc;
             regloc = new_regloc;
-            return true;
+            UnwindLogMsg ("supplying caller's register %d from the live RegisterContext at frame 0", lldb_regnum);
+            return UnwindLLDB::RegisterSearchResult::eRegisterFound;
         }
         else
         UnwindLogMsg ("could not supply caller's reg %d location", lldb_regnum);
-        return false;
+        return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
     }
 
     // unwindplan_regloc has valid contents about where to retrieve the register
@@ -1091,7 +1094,7 @@
         new_regloc.type = UnwindLLDB::RegisterLocation::eRegisterNotSaved;
         m_registers[lldb_regnum] = new_regloc;
         UnwindLogMsg ("could not supply caller's reg %d location", lldb_regnum);
-        return false;
+        return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
     }
 
     if (unwindplan_regloc.IsSame())
@@ -1099,11 +1102,11 @@
         if (IsFrameZero ())
         {
             UnwindLogMsg ("could not supply caller's reg %d location", lldb_regnum);
-            return false;
+            return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
         }
         else
         {
-            return false;
+            return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
         }
     }
 
@@ -1113,7 +1116,8 @@
         regloc.type = UnwindLLDB::RegisterLocation::eRegisterValueInferred;
         regloc.location.inferred_value = m_cfa + offset;
         m_registers[lldb_regnum] = regloc;
-        return true;
+        UnwindLogMsg ("supplying caller's register %d, value is CFA plus offset", lldb_regnum);
+        return UnwindLLDB::RegisterSearchResult::eRegisterFound;
     }
 
     if (unwindplan_regloc.IsAtCFAPlusOffset())
@@ -1122,7 +1126,8 @@
         regloc.type = UnwindLLDB::RegisterLocation::eRegisterSavedAtMemoryLocation;
         regloc.location.target_memory_location = m_cfa + offset;
         m_registers[lldb_regnum] = regloc;
-        return true;
+        UnwindLogMsg ("supplying caller's register %d from the stack, saved at CFA plus offset", lldb_regnum);
+        return UnwindLLDB::RegisterSearchResult::eRegisterFound;
     }
 
     if (unwindplan_regloc.IsInOtherRegister())
@@ -1132,12 +1137,13 @@
         if (!m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (unwindplan_registerkind, unwindplan_regnum, eRegisterKindLLDB, row_regnum_in_lldb))
         {
             UnwindLogMsg ("could not supply caller's reg %d location", lldb_regnum);
-            return false;
+            return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
         }
         regloc.type = UnwindLLDB::RegisterLocation::eRegisterInRegister;
         regloc.location.register_number = row_regnum_in_lldb;
         m_registers[lldb_regnum] = regloc;
-        return true;
+        UnwindLogMsg ("supplying caller's register %d, saved in register %d", lldb_regnum, row_regnum_in_lldb);
+        return UnwindLLDB::RegisterSearchResult::eRegisterFound;
     }
 
     if (unwindplan_regloc.IsDWARFExpression() || unwindplan_regloc.IsAtDWARFExpression())
@@ -1158,25 +1164,27 @@
                 regloc.type = UnwindLLDB::RegisterLocation::eRegisterValueInferred;
                 regloc.location.inferred_value = val;
                 m_registers[lldb_regnum] = regloc;
-                return true;
+                UnwindLogMsg ("supplying caller's register %d via DWARF expression (IsDWARFExpression)", lldb_regnum);
+                return UnwindLLDB::RegisterSearchResult::eRegisterFound;
             }
             else
             {
-               regloc.type = UnwindLLDB::RegisterLocation::eRegisterSavedAtMemoryLocation;
-               regloc.location.target_memory_location = val;
-               m_registers[lldb_regnum] = regloc;
-               return true;
+                regloc.type = UnwindLLDB::RegisterLocation::eRegisterSavedAtMemoryLocation;
+                regloc.location.target_memory_location = val;
+                m_registers[lldb_regnum] = regloc;
+                UnwindLogMsg ("supplying caller's register %d via DWARF expression (IsAtDWARFExpression)", lldb_regnum);
+                return UnwindLLDB::RegisterSearchResult::eRegisterFound;
             }
         }
         UnwindLogMsg ("tried to use IsDWARFExpression or IsAtDWARFExpression for reg %d but failed", lldb_regnum);
-        return false;
+        return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
     }
 
     UnwindLogMsg ("could not supply caller's reg %d location", lldb_regnum);
 
     // FIXME UnwindPlan::Row types atDWARFExpression and isDWARFExpression are unsupported.
 
-    return false;
+    return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
 }
 
 // If the Full unwindplan has been determined to be incorrect, this method will

Modified: lldb/branches/windows/source/Plugins/Process/Utility/RegisterContextLLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/Process/Utility/RegisterContextLLDB.h (original)
+++ lldb/branches/windows/source/Plugins/Process/Utility/RegisterContextLLDB.h Thu Nov 22 06:24:07 2012
@@ -131,7 +131,7 @@
     // If a non-volatile register (a "preserved" register) is requested mid-stack and no frames "below" the requested
     // stack have saved the register anywhere, it is safe to assume that frame 0's register values are still the same
     // as the requesting frame's.
-    bool
+    lldb_private::UnwindLLDB::RegisterSearchResult
     SavedLocationForRegister (uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation &regloc);
 
     bool

Modified: lldb/branches/windows/source/Plugins/Process/Utility/UnwindLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/Process/Utility/UnwindLLDB.cpp (original)
+++ lldb/branches/windows/source/Plugins/Process/Utility/UnwindLLDB.cpp Thu Nov 22 06:24:07 2012
@@ -272,15 +272,21 @@
     // isn't saved by frame_num, none of the frames lower on the stack will have a useful value.
     if (pc_or_return_address_reg)
     {
-        if (m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister (lldb_regnum, regloc))
+        UnwindLLDB::RegisterSearchResult result;
+        result = m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister (lldb_regnum, regloc);
+        if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound)
           return true;
         else
           return false;
     }
     while (frame_num >= 0)
     {
-        if (m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister (lldb_regnum, regloc))
+        UnwindLLDB::RegisterSearchResult result;
+        result = m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister (lldb_regnum, regloc);
+        if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound)
             return true;
+        if (result == UnwindLLDB::RegisterSearchResult::eRegisterIsVolatile)
+            return false;
         frame_num--;
     }
     return false;

Modified: lldb/branches/windows/source/Plugins/Process/Utility/UnwindLLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Process/Utility/UnwindLLDB.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/Process/Utility/UnwindLLDB.h (original)
+++ lldb/branches/windows/source/Plugins/Process/Utility/UnwindLLDB.h Thu Nov 22 06:24:07 2012
@@ -30,6 +30,13 @@
     virtual
     ~UnwindLLDB() { }
 
+    enum RegisterSearchResult
+    {
+        eRegisterFound = 0,
+        eRegisterNotFound,
+        eRegisterIsVolatile
+    };
+
 protected:
     friend class lldb_private::RegisterContextLLDB;
 

Modified: lldb/branches/windows/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/branches/windows/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Thu Nov 22 06:24:07 2012
@@ -651,6 +651,16 @@
                     }
                     break;
 
+                case 'A':
+                    // Async miscellaneous reply. Right now, only profile data is coming through this channel.
+                    {
+                        const std::string& profile_data = response.GetStringRef();
+                        const char *data_cstr = profile_data.c_str();
+                        data_cstr++; // Move beyond 'A'
+                        process->BroadcastAsyncProfileData (data_cstr, profile_data.size()-1);
+                    }
+                    break;
+
                 case 'E':
                     // ERROR
                     state = eStateInvalid;

Modified: lldb/branches/windows/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/branches/windows/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Nov 22 06:24:07 2012
@@ -3222,9 +3222,8 @@
                                                 const char *base_name_start,
                                                 const char *base_name_end)
 {
-    // If we are looking only for methods, throw away all the ones that aren't in C++ classes:
-    if (name_type_mask == eFunctionNameTypeMethod
-        || name_type_mask == eFunctionNameTypeBase)
+    // If we are looking only for methods, throw away all the ones that are or aren't in C++ classes:
+    if (name_type_mask == eFunctionNameTypeMethod || name_type_mask == eFunctionNameTypeBase)
     {
         clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIEOffset(die->GetOffset());
         if (!containing_decl_ctx)
@@ -3232,10 +3231,17 @@
         
         bool is_cxx_method = DeclKindIsCXXClass(containing_decl_ctx->getDeclKind());
         
-        if (!is_cxx_method && name_type_mask == eFunctionNameTypeMethod)
-            return false;
-        if (is_cxx_method && name_type_mask == eFunctionNameTypeBase)
-            return false;
+        if (name_type_mask == eFunctionNameTypeMethod)
+        {
+            if (is_cxx_method == false)
+                return false;
+        }
+        
+        if (name_type_mask == eFunctionNameTypeBase)
+        {
+            if (is_cxx_method == true)
+                return false;
+        }
     }
 
     // Now we need to check whether the name we got back for this type matches the extra specifications
@@ -3246,20 +3252,31 @@
         // we can pull out the mips linkage name attribute:
         
         Mangled best_name;
-
         DWARFDebugInfoEntry::Attributes attributes;
+        DWARFFormValue form_value;
         die->GetAttributes(this, dwarf_cu, NULL, attributes);
         uint32_t idx = attributes.FindAttributeIndex(DW_AT_MIPS_linkage_name);
         if (idx != UINT32_MAX)
         {
-            DWARFFormValue form_value;
             if (attributes.ExtractFormValueAtIndex(this, idx, form_value))
             {
+                const char *mangled_name = form_value.AsCString(&get_debug_str_data());
+                if (mangled_name)
+                    best_name.SetValue (ConstString(mangled_name), true);
+            }
+        }
+
+        if (!best_name)
+        {
+            idx = attributes.FindAttributeIndex(DW_AT_name);
+            if (idx != UINT32_MAX && attributes.ExtractFormValueAtIndex(this, idx, form_value))
+            {
                 const char *name = form_value.AsCString(&get_debug_str_data());
-                best_name.SetValue (ConstString(name), true);
-            } 
+                best_name.SetValue (ConstString(name), false);
+            }
         }
-        if (best_name)
+
+        if (best_name.GetDemangledName())
         {
             const char *demangled = best_name.GetDemangledName().GetCString();
             if (demangled)
@@ -3489,20 +3506,20 @@
                         const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
                         if (die)
                         {
+                            if (!include_inlines && die->Tag() == DW_TAG_inlined_subroutine)
+                                continue;
+                            
                             if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die))
                                 continue;
                             
-                            if (!FunctionDieMatchesPartialName(die, 
+                            if (!FunctionDieMatchesPartialName(die,
                                                                dwarf_cu, 
-                                                               effective_name_type_mask, 
+                                                               effective_name_type_mask,
                                                                name_cstr, 
                                                                base_name_start, 
                                                                base_name_end))
                                 continue;
                             
-                            if (!include_inlines && die->Tag() == DW_TAG_inlined_subroutine)
-                                continue;
-                                
                             // If we get to here, the die is good, and we should add it:
                             ResolveFunction (dwarf_cu, die, sc_list);
                         }
@@ -3540,20 +3557,20 @@
                 const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu);
                 if (die)
                 {
+                    if (!include_inlines && die->Tag() == DW_TAG_inlined_subroutine)
+                        continue;
+                    
                     if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die))
                         continue;
                     
                     if (!FunctionDieMatchesPartialName(die, 
                                                        dwarf_cu, 
-                                                       effective_name_type_mask, 
+                                                       eFunctionNameTypeBase, 
                                                        name_cstr, 
                                                        base_name_start, 
                                                        base_name_end))
                         continue;
                     
-                    if (!include_inlines && die->Tag() == DW_TAG_inlined_subroutine)
-                        continue;
-                    
                     // If we get to here, the die is good, and we should add it:
                     ResolveFunction (dwarf_cu, die, sc_list);
                 }
@@ -3573,17 +3590,17 @@
                     const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu);
                     if (die)
                     {
-                        if (!FunctionDieMatchesPartialName(die, 
+                        if (!include_inlines && die->Tag() == DW_TAG_inlined_subroutine)
+                            continue;
+                        
+                        if (!FunctionDieMatchesPartialName(die,
                                                            dwarf_cu, 
-                                                           effective_name_type_mask, 
+                                                           eFunctionNameTypeMethod, 
                                                            name_cstr, 
                                                            base_name_start, 
                                                            base_name_end))
                             continue;
                         
-                        if (!include_inlines && die->Tag() == DW_TAG_inlined_subroutine)
-                            continue;
-                        
                         // If we get to here, the die is good, and we should add it:
                         ResolveFunction (dwarf_cu, die, sc_list);
                     }

Modified: lldb/branches/windows/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Symbol/ClangASTContext.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/branches/windows/source/Symbol/ClangASTContext.cpp Thu Nov 22 06:24:07 2012
@@ -626,7 +626,7 @@
 {
     // target_triple should be something like "x86_64-apple-macosx"
     if (m_target_info_ap.get() == NULL && !m_target_triple.empty())
-        m_target_info_ap.reset (TargetInfo::CreateTargetInfo(*getDiagnosticsEngine(), *getTargetOptions()));
+        m_target_info_ap.reset (TargetInfo::CreateTargetInfo(*getDiagnosticsEngine(), getTargetOptions()));
     return m_target_info_ap.get();
 }
 
@@ -715,12 +715,12 @@
     return NULL;
 }
 
-clang_type_t
-ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name, uint32_t dw_ate, uint32_t bit_size)
-{
-    ASTContext *ast = getASTContext();
-    
-#define streq(a,b) strcmp(a,b) == 0
+clang_type_t
+ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize (const char *type_name, uint32_t dw_ate, uint32_t bit_size)
+{
+    ASTContext *ast = getASTContext();
+    
+#define streq(a,b) strcmp(a,b) == 0
     assert (ast != NULL);
     if (ast)
     {

Modified: lldb/branches/windows/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Target/Process.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Target/Process.cpp (original)
+++ lldb/branches/windows/source/Target/Process.cpp Thu Nov 22 06:24:07 2012
@@ -957,6 +957,8 @@
     m_stdio_communication_mutex (Mutex::eMutexTypeRecursive),
     m_stdout_data (),
     m_stderr_data (),
+    m_profile_data_comm_mutex (Mutex::eMutexTypeRecursive),
+    m_profile_data (),
     m_memory_cache (*this),
     m_allocated_memory_cache (*this),
     m_should_detach (false),
@@ -976,6 +978,7 @@
     SetEventName (eBroadcastBitInterrupt, "interrupt");
     SetEventName (eBroadcastBitSTDOUT, "stdout-available");
     SetEventName (eBroadcastBitSTDERR, "stderr-available");
+    SetEventName (eBroadcastBitProfileData, "profile-data-available");
     
     m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlStop  , "control-stop"  );
     m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlPause , "control-pause" );
@@ -985,7 +988,8 @@
                                       eBroadcastBitStateChanged |
                                       eBroadcastBitInterrupt |
                                       eBroadcastBitSTDOUT |
-                                      eBroadcastBitSTDERR);
+                                      eBroadcastBitSTDERR |
+                                      eBroadcastBitProfileData);
 
     m_private_state_listener.StartListeningForEvents(&m_private_state_broadcaster,
                                                      eBroadcastBitStateChanged |
@@ -2550,6 +2554,7 @@
     return error;
 }
 
+
 ModuleSP
 Process::ReadModuleFromMemory (const FileSpec& file_spec, 
                                lldb::addr_t header_addr, 
@@ -3285,7 +3290,8 @@
         // If we have been interrupted (to kill us) in the middle of running, we may not end up propagating
         // the last events through the event system, in which case we might strand the write lock.  Unlock
         // it here so when we do to tear down the process we don't get an error destroying the lock.
-        m_run_lock.WriteUnlock();
+        if (!StateIsStoppedState(m_public_state.GetValue(), false))
+            m_run_lock.WriteUnlock();
     }
     return error;
 }
@@ -4011,6 +4017,40 @@
     BroadcastEventIfUnique (eBroadcastBitSTDERR, new ProcessEventData (shared_from_this(), GetState()));
 }
 
+void
+Process::BroadcastAsyncProfileData(const char *s, size_t len)
+{
+    Mutex::Locker locker (m_profile_data_comm_mutex);
+    m_profile_data.append (s, len);
+    BroadcastEventIfUnique (eBroadcastBitProfileData, new ProcessEventData (shared_from_this(), GetState()));
+}
+
+size_t
+Process::GetAsyncProfileData (char *buf, size_t buf_size, Error &error)
+{
+    Mutex::Locker locker(m_profile_data_comm_mutex);
+    size_t bytes_available = m_profile_data.size();
+    if (bytes_available > 0)
+    {
+        LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+        if (log)
+            log->Printf ("Process::GetProfileData (buf = %p, size = %llu)", buf, (uint64_t)buf_size);
+        if (bytes_available > buf_size)
+        {
+            memcpy(buf, m_profile_data.c_str(), buf_size);
+            m_profile_data.erase(0, buf_size);
+            bytes_available = buf_size;
+        }
+        else
+        {
+            memcpy(buf, m_profile_data.c_str(), bytes_available);
+            m_profile_data.clear();
+        }
+    }
+    return bytes_available;
+}
+
+
 //------------------------------------------------------------------
 // Process STDIO
 //------------------------------------------------------------------
@@ -4292,7 +4332,7 @@
         // The simplest thing to do is to spin up a temporary thread to handle private state thread events while
         // we are fielding public events here.
         if (log)
-			log->Printf ("Running thread plan on private state thread, spinning up another state thread to handle the events.");
+            log->Printf ("Running thread plan on private state thread, spinning up another state thread to handle the events.");
             
 
         backup_private_state_thread = m_private_state_thread;

Modified: lldb/branches/windows/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Target/Thread.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Target/Thread.cpp (original)
+++ lldb/branches/windows/source/Target/Thread.cpp Thu Nov 22 06:24:07 2012
@@ -1682,6 +1682,8 @@
         // Clear out all stack frames as our world just changed.
         ClearStackFrames();
         frame_sp->GetRegisterContext()->InvalidateIfNeeded(true);
+        if (m_unwinder_ap.get())
+            m_unwinder_ap->Clear();
 
         return ret;
     }
@@ -1723,7 +1725,7 @@
     m_reg_context_sp.reset();
 }
 
-const bool
+bool
 Thread::IsStillAtLastBreakpointHit ()
 {
     // If we are currently stopped at a breakpoint, always return that stopinfo and don't reset it.

Modified: lldb/branches/windows/source/Target/ThreadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/source/Target/ThreadList.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/source/Target/ThreadList.cpp (original)
+++ lldb/branches/windows/source/Target/ThreadList.cpp Thu Nov 22 06:24:07 2012
@@ -175,16 +175,29 @@
 bool
 ThreadList::ShouldStop (Event *event_ptr)
 {
-    Mutex::Locker locker(m_threads_mutex);
-
+    bool should_stop = false;    
     // Running events should never stop, obviously...
 
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
 
-    bool should_stop = false;    
-    m_process->UpdateThreadListIfNeeded();
+    // The ShouldStop method of the threads can do a whole lot of work,
+    // running breakpoint commands & conditions, etc.  So we don't want
+    // to keep the ThreadList locked the whole time we are doing this.
+    // FIXME: It is possible that running code could cause new threads
+    // to be created.  If that happens we will miss asking them whether
+    // then should stop.  This is not a big deal, since we haven't had
+    // a chance to hang any interesting operations on those threads yet.
+    
+    collection threads_copy;
+    {
+        // Scope for locker
+        Mutex::Locker locker(m_threads_mutex);
 
-    collection::iterator pos, end = m_threads.end();
+        m_process->UpdateThreadListIfNeeded();
+        threads_copy = m_threads;
+    }
+
+    collection::iterator pos, end = threads_copy.end();
 
     if (log)
     {
@@ -192,7 +205,7 @@
         log->Printf ("ThreadList::%s: %llu threads", __FUNCTION__, (uint64_t)m_threads.size());
     }
 
-    for (pos = m_threads.begin(); pos != end; ++pos)
+    for (pos = threads_copy.begin(); pos != end; ++pos)
     {
         ThreadSP thread_sp(*pos);
         
@@ -206,7 +219,7 @@
 
     if (should_stop)
     {
-        for (pos = m_threads.begin(); pos != end; ++pos)
+        for (pos = threads_copy.begin(); pos != end; ++pos)
         {
             ThreadSP thread_sp(*pos);
             thread_sp->WillStop ();

Modified: lldb/branches/windows/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/dotest.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/dotest.py (original)
+++ lldb/branches/windows/test/dotest.py Thu Nov 22 06:24:07 2012
@@ -95,7 +95,7 @@
 # Use @dsym_test or @dwarf_test decorators, defined in lldbtest.py, to mark a test
 # as a dsym or dwarf test.  Use '-N dsym' or '-N dwarf' to exclude dsym or dwarf
 # tests from running.
-dont_do_dsym_test = False
+dont_do_dsym_test = "linux" in sys.platform
 dont_do_dwarf_test = False
 
 # The blacklist is optional (-b blacklistFile) and allows a central place to skip

Modified: lldb/branches/windows/test/expression_command/call-function/TestCallStdStringFunction.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/expression_command/call-function/TestCallStdStringFunction.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/expression_command/call-function/TestCallStdStringFunction.py (original)
+++ lldb/branches/windows/test/expression_command/call-function/TestCallStdStringFunction.py Thu Nov 22 06:24:07 2012
@@ -28,7 +28,7 @@
     @dwarf_test
     def test_with_dwarf(self):
         """Test calling std::String member function."""
-        self.buildDsym()
+        self.buildDwarf()
         self.call_function()
 
     def call_function(self):

Modified: lldb/branches/windows/test/expression_command/formatters/TestFormatters.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/expression_command/formatters/TestFormatters.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/expression_command/formatters/TestFormatters.py (original)
+++ lldb/branches/windows/test/expression_command/formatters/TestFormatters.py Thu Nov 22 06:24:07 2012
@@ -28,7 +28,7 @@
     @dwarf_test
     def test_with_dwarf(self):
         """Test expr + formatters for good interoperability."""
-        self.buildDsym()
+        self.buildDwarf()
         self.do_my_test()
 
     def do_my_test(self):

Modified: lldb/branches/windows/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py (original)
+++ lldb/branches/windows/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py Thu Nov 22 06:24:07 2012
@@ -38,6 +38,9 @@
         TestBase.setUp(self)
         # Find the line number to break inside main().
         self.line = line_number('main.c', '// Set break point at this line.')
+        # disable "There is a running process, kill it and restart?" prompt
+        self.runCmd("settings set auto-confirm true")
+        self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
 
     def breakpoint_command_sequence(self):
         """Test a sequence of breakpoint command add, list, and delete."""

Modified: lldb/branches/windows/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py (original)
+++ lldb/branches/windows/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py Thu Nov 22 06:24:07 2012
@@ -24,7 +24,7 @@
         self.expect("command script import ./fail12586188.py --allow-reload",
                 error=True, substrs = ['error: module importing failed: I do not want to be imported'])
         self.expect("command script import ./fail212586188.py --allow-reload",
-                error=True, substrs = ['error: module importing failed: Python raised an error while importing module'])
+                error=True, substrs = ['error: module importing failed: Python error raised while importing module: I do not want to be imported'])
 
 if __name__ == '__main__':
     import atexit

Modified: lldb/branches/windows/test/functionalities/command_script/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/functionalities/command_script/main.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/functionalities/command_script/main.cpp (original)
+++ lldb/branches/windows/test/functionalities/command_script/main.cpp Thu Nov 22 06:24:07 2012
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <cstdlib>
+#include <cstring>
 #include <string>
 #include <fstream>
 #include <iostream>

Modified: lldb/branches/windows/test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py (original)
+++ lldb/branches/windows/test/functionalities/data-formatter/rdar-10642615/Test-rdar-10642615.py Thu Nov 22 06:24:07 2012
@@ -20,6 +20,7 @@
         self.buildDsym()
         self.data_formatter_commands()
 
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     @dwarf_test
     def test_with_dwarf_and_run_command(self):
         """Test data formatter commands."""

Modified: lldb/branches/windows/test/lang/cpp/stl/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/lang/cpp/stl/main.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/lang/cpp/stl/main.cpp (original)
+++ lldb/branches/windows/test/lang/cpp/stl/main.cpp Thu Nov 22 06:24:07 2012
@@ -6,6 +6,7 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
+#include <cstdio>
 #include <iostream>
 #include <string>
 #include <map>

Modified: lldb/branches/windows/test/logging/TestLogging.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/logging/TestLogging.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/logging/TestLogging.py (original)
+++ lldb/branches/windows/test/logging/TestLogging.py Thu Nov 22 06:24:07 2012
@@ -43,26 +43,30 @@
         self.runCmd ("bp l")
 
         expected_log_lines = [
-            "com.apple.main-thread Processing command: command alias bp breakpoint\n",
-            "com.apple.main-thread HandleCommand, cmd_obj : 'command alias'\n",
-            "com.apple.main-thread HandleCommand, revised_command_line: 'command alias bp breakpoint'\n",
-            "com.apple.main-thread HandleCommand, wants_raw_input:'True'\n",
-            "com.apple.main-thread HandleCommand, command line after removing command name(s): 'bp breakpoint'\n",
-            "com.apple.main-thread HandleCommand, command succeeded\n",
-            "com.apple.main-thread Processing command: bp set -n main\n",
-            "com.apple.main-thread HandleCommand, cmd_obj : 'breakpoint set'\n",
-            "com.apple.main-thread HandleCommand, revised_command_line: 'breakpoint set -n main'\n",
-            "com.apple.main-thread HandleCommand, wants_raw_input:'False'\n",
-            "com.apple.main-thread HandleCommand, command line after removing command name(s): '-n main'\n",
-            "com.apple.main-thread HandleCommand, command succeeded\n",
-            "com.apple.main-thread Processing command: bp l\n",
-            "com.apple.main-thread HandleCommand, cmd_obj : 'breakpoint list'\n",
-            "com.apple.main-thread HandleCommand, revised_command_line: 'breakpoint l'\n",
-            "com.apple.main-thread HandleCommand, wants_raw_input:'False'\n",
-            "com.apple.main-thread HandleCommand, command line after removing command name(s): ''\n",
-            "com.apple.main-thread HandleCommand, command succeeded\n",
+            "Processing command: command alias bp breakpoint\n",
+            "HandleCommand, cmd_obj : 'command alias'\n",
+            "HandleCommand, revised_command_line: 'command alias bp breakpoint'\n",
+            "HandleCommand, wants_raw_input:'True'\n",
+            "HandleCommand, command line after removing command name(s): 'bp breakpoint'\n",
+            "HandleCommand, command succeeded\n",
+            "Processing command: bp set -n main\n",
+            "HandleCommand, cmd_obj : 'breakpoint set'\n",
+            "HandleCommand, revised_command_line: 'breakpoint set -n main'\n",
+            "HandleCommand, wants_raw_input:'False'\n",
+            "HandleCommand, command line after removing command name(s): '-n main'\n",
+            "HandleCommand, command succeeded\n",
+            "Processing command: bp l\n",
+            "HandleCommand, cmd_obj : 'breakpoint list'\n",
+            "HandleCommand, revised_command_line: 'breakpoint l'\n",
+            "HandleCommand, wants_raw_input:'False'\n",
+            "HandleCommand, command line after removing command name(s): ''\n",
+            "HandleCommand, command succeeded\n",
             ]
 
+        # com.apple.main-thread identifier appears on darwin only
+        if sys.platform.startswith("darwin"):
+            expected_log_lines = ['com.apple.main-thread ' + x for x in expected_log_lines]
+
         self.assertTrue (os.path.isfile (log_file))
 
         idx = 0

Modified: lldb/branches/windows/test/python_api/event/TestEvents.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/python_api/event/TestEvents.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/python_api/event/TestEvents.py (original)
+++ lldb/branches/windows/test/python_api/event/TestEvents.py Thu Nov 22 06:24:07 2012
@@ -20,6 +20,7 @@
         self.buildDsym()
         self.do_listen_for_and_print_event()
 
+    @unittest2.skipIf(sys.platform.startswith("linux"), "Hanging on Linux: bugzilla #14384")
     @python_api_test
     @dwarf_test
     def test_listen_for_and_print_event_with_dwarf(self):
@@ -35,6 +36,7 @@
         self.buildDsym()
         self.do_wait_for_event()
 
+    @unittest2.skipIf(sys.platform.startswith("linux"), "Hanging on Linux: bugzilla #14384")
     @python_api_test
     @dwarf_test
     def test_wait_for_event_with_dwarf(self):

Modified: lldb/branches/windows/test/types/TestFloatTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/types/TestFloatTypes.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/types/TestFloatTypes.py (original)
+++ lldb/branches/windows/test/types/TestFloatTypes.py Thu Nov 22 06:24:07 2012
@@ -12,6 +12,13 @@
 
     mydir = "types"
 
+    def setUp(self):
+        # Call super's setUp().
+        AbstractBase.GenericTester.setUp(self)
+        # disable "There is a running process, kill it and restart?" prompt
+        self.runCmd("settings set auto-confirm true")
+        self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
+
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     @dsym_test
     def test_float_type_with_dsym(self):

Modified: lldb/branches/windows/test/types/TestFloatTypesExpr.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/types/TestFloatTypesExpr.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/types/TestFloatTypesExpr.py (original)
+++ lldb/branches/windows/test/types/TestFloatTypesExpr.py Thu Nov 22 06:24:07 2012
@@ -15,6 +15,13 @@
     # rdar://problem/8493023
     # test/types failures for Test*TypesExpr.py: element offset computed wrong and sign error?
 
+    def setUp(self):
+        # Call super's setUp().
+        AbstractBase.GenericTester.setUp(self)
+        # disable "There is a running process, kill it and restart?" prompt
+        self.runCmd("settings set auto-confirm true")
+        self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
+
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     @dsym_test
     def test_float_type_with_dsym(self):

Modified: lldb/branches/windows/test/types/TestIntegerTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/types/TestIntegerTypes.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/types/TestIntegerTypes.py (original)
+++ lldb/branches/windows/test/types/TestIntegerTypes.py Thu Nov 22 06:24:07 2012
@@ -12,6 +12,13 @@
 
     mydir = "types"
 
+    def setUp(self):
+        # Call super's setUp().
+        AbstractBase.GenericTester.setUp(self)
+        # disable "There is a running process, kill it and restart?" prompt
+        self.runCmd("settings set auto-confirm true")
+        self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
+
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     @dsym_test
     def test_char_type_with_dsym(self):

Modified: lldb/branches/windows/test/types/TestIntegerTypesExpr.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/test/types/TestIntegerTypesExpr.py?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/test/types/TestIntegerTypesExpr.py (original)
+++ lldb/branches/windows/test/types/TestIntegerTypesExpr.py Thu Nov 22 06:24:07 2012
@@ -12,6 +12,13 @@
 
     mydir = "types"
 
+    def setUp(self):
+        # Call super's setUp().
+        AbstractBase.GenericTester.setUp(self)
+        # disable "There is a running process, kill it and restart?" prompt
+        self.runCmd("settings set auto-confirm true")
+        self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
+
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     @dsym_test
     def test_char_type_with_dsym(self):

Modified: lldb/branches/windows/tools/debugserver/source/DNB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/DNB.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/DNB.cpp (original)
+++ lldb/branches/windows/tools/debugserver/source/DNB.cpp Thu Nov 22 06:24:07 2012
@@ -1217,6 +1217,28 @@
     return -1;
 }
 
+const char *
+DNBProcessGetProfileDataAsCString (nub_process_t pid)
+{
+    MachProcessSP procSP;
+    if (GetProcessSP (pid, procSP))
+        return procSP->Task().GetProfileDataAsCString();
+    
+    return NULL;
+}
+
+nub_bool_t
+DNBProcessSetAsyncEnableProfiling (nub_process_t pid, nub_bool_t enable, uint64_t interval_usec)
+{
+    MachProcessSP procSP;
+    if (GetProcessSP (pid, procSP))
+    {
+        procSP->SetAsyncEnableProfiling(enable, interval_usec);
+        return true;
+    }
+    
+    return false;    
+}
 
 //----------------------------------------------------------------------
 // Formatted output that uses memory and registers from process and
@@ -2072,6 +2094,15 @@
 }
 
 nub_size_t
+DNBProcessGetAvailableProfileData (nub_process_t pid, char *buf, nub_size_t buf_size)
+{
+    MachProcessSP procSP;
+    if (GetProcessSP (pid, procSP))
+        return procSP->GetAsyncProfileData (buf, buf_size);
+    return 0;
+}
+
+nub_size_t
 DNBProcessGetStopCount (nub_process_t pid)
 {
     MachProcessSP procSP;

Modified: lldb/branches/windows/tools/debugserver/source/DNB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/DNB.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/DNB.h (original)
+++ lldb/branches/windows/tools/debugserver/source/DNB.h Thu Nov 22 06:24:07 2012
@@ -67,6 +67,8 @@
 nub_addr_t      DNBProcessMemoryAllocate    (nub_process_t pid, nub_size_t size, uint32_t permissions) DNB_EXPORT;
 nub_bool_t      DNBProcessMemoryDeallocate  (nub_process_t pid, nub_addr_t addr) DNB_EXPORT;
 int             DNBProcessMemoryRegionInfo  (nub_process_t pid, nub_addr_t addr, DNBRegionInfo *region_info) DNB_EXPORT;
+const char *    DNBProcessGetProfileDataAsCString (nub_process_t pid) DNB_EXPORT; // Process owns the returned string. Do not free.
+nub_bool_t      DNBProcessSetAsyncEnableProfiling   (nub_process_t pid, nub_bool_t enable, uint64_t interval_usec) DNB_EXPORT;
 
 //----------------------------------------------------------------------
 // Process status
@@ -88,6 +90,7 @@
 nub_addr_t      DNBProcessLookupAddress                 (nub_process_t pid, const char *name, const char *shlib) DNB_EXPORT;
 nub_size_t      DNBProcessGetAvailableSTDOUT            (nub_process_t pid, char *buf, nub_size_t buf_size) DNB_EXPORT;
 nub_size_t      DNBProcessGetAvailableSTDERR            (nub_process_t pid, char *buf, nub_size_t buf_size) DNB_EXPORT;
+nub_size_t      DNBProcessGetAvailableProfileData       (nub_process_t pid, char *buf, nub_size_t buf_size) DNB_EXPORT;
 nub_size_t      DNBProcessGetStopCount                  (nub_process_t pid) DNB_EXPORT;
 uint32_t        DNBProcessGetCPUType                    (nub_process_t pid) DNB_EXPORT; 
 

Modified: lldb/branches/windows/tools/debugserver/source/DNBDefs.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/DNBDefs.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/DNBDefs.h (original)
+++ lldb/branches/windows/tools/debugserver/source/DNBDefs.h Thu Nov 22 06:24:07 2012
@@ -134,11 +134,13 @@
     eEventProcessStoppedStateChanged = 1 << 1,  // The process has changed state to stopped
     eEventSharedLibsStateChange = 1 << 2,       // Shared libraries loaded/unloaded state has changed
     eEventStdioAvailable = 1 << 3,              // Something is available on stdout/stderr
-    eEventProcessAsyncInterrupt = 1 << 4,               // Gives the ability for any infinite wait calls to be interrupted
+    eEventProfileDataAvailable = 1 << 4,        // Profile data ready for retrieval
+    eEventProcessAsyncInterrupt = 1 << 5,       // Gives the ability for any infinite wait calls to be interrupted
     kAllEventsMask = eEventProcessRunningStateChanged |
                      eEventProcessStoppedStateChanged |
                      eEventSharedLibsStateChange |
                      eEventStdioAvailable |
+                     eEventProfileDataAvailable |
                      eEventProcessAsyncInterrupt
 };
 

Modified: lldb/branches/windows/tools/debugserver/source/MacOSX/MachProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/MacOSX/MachProcess.cpp (original)
+++ lldb/branches/windows/tools/debugserver/source/MacOSX/MachProcess.cpp Thu Nov 22 06:24:07 2012
@@ -83,6 +83,11 @@
     m_stdio_mutex       (PTHREAD_MUTEX_RECURSIVE),
     m_stdout_data       (),
     m_thread_actions    (),
+    m_profile_enabled   (false),
+    m_profile_interval_usec (0),
+    m_profile_thread    (0),
+    m_profile_data_mutex(PTHREAD_MUTEX_RECURSIVE),
+    m_profile_data      (),
     m_thread_list        (),
     m_exception_messages (),
     m_exception_messages_mutex (PTHREAD_MUTEX_RECURSIVE),
@@ -286,6 +291,11 @@
         PTHREAD_MUTEX_LOCKER(locker, m_exception_messages_mutex);
         m_exception_messages.clear();
     }
+    if (m_profile_thread)
+    {
+        pthread_join(m_profile_thread, NULL);
+        m_profile_thread = NULL;
+    }
 }
 
 
@@ -297,6 +307,26 @@
     return ::pthread_create (&m_stdio_thread, NULL, MachProcess::STDIOThread, this) == 0;
 }
 
+void
+MachProcess::SetAsyncEnableProfiling(bool enable, uint64_t interval_usec)
+{
+    m_profile_enabled = enable;
+    m_profile_interval_usec = interval_usec;
+    
+    if (m_profile_enabled && (m_profile_thread == 0))
+    {
+        StartProfileThread();
+    }
+}
+
+bool
+MachProcess::StartProfileThread()
+{
+    DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s ( )", __FUNCTION__);
+    // Create the thread that profiles the inferior and reports back if enabled
+    return ::pthread_create (&m_profile_thread, NULL, MachProcess::ProfileThread, this) == 0;
+}
+
 
 nub_addr_t
 MachProcess::LookupSymbol(const char *name, const char *shlib)
@@ -1311,6 +1341,74 @@
     return NULL;
 }
 
+
+void
+MachProcess::SignalAsyncProfileData (const char *info)
+{
+    DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (%s) ...", __FUNCTION__, info);
+    PTHREAD_MUTEX_LOCKER (locker, m_profile_data_mutex);
+    m_profile_data.append(info);
+    m_events.SetEvents(eEventProfileDataAvailable);
+    
+    // Wait for the event bit to reset if a reset ACK is requested
+    m_events.WaitForResetAck(eEventProfileDataAvailable);
+}
+
+
+size_t
+MachProcess::GetAsyncProfileData (char *buf, size_t buf_size)
+{
+    DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (&%p[%llu]) ...", __FUNCTION__, buf, (uint64_t)buf_size);
+    PTHREAD_MUTEX_LOCKER (locker, m_profile_data_mutex);
+    size_t bytes_available = m_profile_data.size();
+    if (bytes_available > 0)
+    {
+        if (bytes_available > buf_size)
+        {
+            memcpy(buf, m_profile_data.data(), buf_size);
+            m_profile_data.erase(0, buf_size);
+            bytes_available = buf_size;
+        }
+        else
+        {
+            memcpy(buf, m_profile_data.data(), bytes_available);
+            m_profile_data.clear();
+        }
+    }
+    return bytes_available;
+}
+
+
+void *
+MachProcess::ProfileThread(void *arg)
+{
+    MachProcess *proc = (MachProcess*) arg;
+    DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s ( arg = %p ) thread starting...", __FUNCTION__, arg);
+
+    while (proc->IsProfilingEnabled())
+    {
+        nub_state_t state = proc->GetState();
+        if (state == eStateRunning)
+        {
+            const char *data = proc->Task().GetProfileDataAsCString();
+            if (data)
+            {
+                proc->SignalAsyncProfileData(data);
+            }
+        }
+        else if ((state == eStateUnloaded) || (state == eStateDetached) || (state == eStateUnloaded))
+        {
+            // Done. Get out of this thread.
+            break;
+        }
+        
+        // A simple way to set up the profile interval. We can also use select() or dispatch timer source if necessary.
+        usleep(proc->ProfileInterval());
+    }
+    return NULL;
+}
+
+
 pid_t
 MachProcess::AttachForDebug (pid_t pid, char *err_str, size_t err_len)
 {
@@ -1719,7 +1817,7 @@
             }
         }
 
-		// if no_stdio or std paths not supplied, then route to "/dev/null".
+        // if no_stdio or std paths not supplied, then route to "/dev/null".
         if (no_stdio || stdin_path == NULL || stdin_path[0] == '\0')
             stdin_path = "/dev/null";
         if (no_stdio || stdout_path == NULL || stdout_path[0] == '\0')

Modified: lldb/branches/windows/tools/debugserver/source/MacOSX/MachProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/MacOSX/MachProcess.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/MacOSX/MachProcess.h (original)
+++ lldb/branches/windows/tools/debugserver/source/MacOSX/MachProcess.h Thu Nov 22 06:24:07 2012
@@ -144,6 +144,17 @@
     void                    ExceptionMessageBundleComplete ();
     void                    SharedLibrariesUpdated ();
     nub_size_t              CopyImageInfos (struct DNBExecutableImageInfo **image_infos, bool only_changed);
+    
+    //----------------------------------------------------------------------
+    // Profile functions
+    //----------------------------------------------------------------------
+    void                    SetAsyncEnableProfiling (bool enable, uint64_t internal_usec);
+    bool                    IsProfilingEnabled () { return m_profile_enabled; }
+    uint64_t                ProfileInterval () { return m_profile_interval_usec; }
+    bool                    StartProfileThread ();
+    static void *           ProfileThread (void *arg);
+    void                    SignalAsyncProfileData (const char *info);
+    size_t                  GetAsyncProfileData (char *buf, size_t buf_size);
 
     //----------------------------------------------------------------------
     // Accessors
@@ -266,6 +277,13 @@
     pthread_t                   m_stdio_thread;             // Thread ID for the thread that watches for child process stdio
     PThreadMutex                m_stdio_mutex;              // Multithreaded protection for stdio
     std::string                 m_stdout_data;
+    
+    bool                        m_profile_enabled;          // A flag to indicate if profiling is enabled
+    uint64_t                    m_profile_interval_usec;    // If enable, the profiling interval in microseconds
+    pthread_t                   m_profile_thread;           // Thread ID for the thread that profiles the inferior
+    PThreadMutex                m_profile_data_mutex;       // Multithreaded protection for profile info data
+    std::string                 m_profile_data;             // Profile data, must be protected by m_profile_data_mutex
+    
     DNBThreadResumeActions      m_thread_actions;           // The thread actions for the current MachProcess::Resume() call
     MachException::Message::collection
                                 m_exception_messages;       // A collection of exception messages caught when listening to the exception port

Modified: lldb/branches/windows/tools/debugserver/source/MacOSX/MachTask.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/MacOSX/MachTask.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/MacOSX/MachTask.cpp (original)
+++ lldb/branches/windows/tools/debugserver/source/MacOSX/MachTask.cpp Thu Nov 22 06:24:07 2012
@@ -23,6 +23,8 @@
 #include <mach/mach_vm.h>
 
 // C++ Includes
+#include <sstream>
+
 // Other libraries and framework includes
 // Project includes
 #include "CFUtils.h"
@@ -87,18 +89,18 @@
 {
     struct task_basic_info task_info;
     task_t task = TaskPort();
-	if (task == TASK_NULL)
-		return KERN_INVALID_ARGUMENT;
+    if (task == TASK_NULL)
+        return KERN_INVALID_ARGUMENT;
 
     DNBError err;
     err = BasicInfo(task, &task_info);
 
     if (err.Success())
     {
-		// task_resume isn't counted like task_suspend calls are, are, so if the 
-		// task is not suspended, don't try and resume it since it is already 
-		// running
-		if (task_info.suspend_count > 0)
+        // task_resume isn't counted like task_suspend calls are, are, so if the 
+        // task is not suspended, don't try and resume it since it is already 
+        // running
+        if (task_info.suspend_count > 0)
         {
             err = ::task_resume (task);
             if (DNBLogCheckLogBit(LOG_TASK) || err.Fail())
@@ -224,6 +226,132 @@
     return ret;
 }
 
+#define TIME_VALUE_TO_TIMEVAL(a, r) do {        \
+(r)->tv_sec = (a)->seconds;                     \
+(r)->tv_usec = (a)->microseconds;               \
+} while (0)
+
+// todo: make use of existing MachThread, if there is already one?
+static void update_used_time(task_t task, int &num_threads, uint64_t **threads_id, uint64_t **threads_used_usec, struct timeval &current_used_time)
+{
+    kern_return_t kr;
+    thread_act_array_t threads;
+    mach_msg_type_number_t tcnt;
+    
+    kr = task_threads(task, &threads, &tcnt);
+    if (kr != KERN_SUCCESS)
+        return;
+    
+    num_threads = tcnt;
+    *threads_id = (uint64_t *)malloc(num_threads * sizeof(uint64_t));
+    *threads_used_usec = (uint64_t *)malloc(num_threads * sizeof(uint64_t));
+
+    for (int i = 0; i < tcnt; i++) {
+        thread_identifier_info_data_t identifier_info;
+        mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
+        kr = thread_info(threads[i], THREAD_IDENTIFIER_INFO, (thread_info_t)&identifier_info, &count);
+        if (kr != KERN_SUCCESS) continue;
+
+        thread_basic_info_data_t basic_info;
+        count = THREAD_BASIC_INFO_COUNT;
+        kr = thread_info(threads[i], THREAD_BASIC_INFO, (thread_info_t)&basic_info, &count);
+        if (kr != KERN_SUCCESS) continue;
+        
+        if ((basic_info.flags & TH_FLAGS_IDLE) == 0) {
+            (*threads_id)[i] = identifier_info.thread_id;
+
+            struct timeval tv;
+            struct timeval thread_tv;
+            TIME_VALUE_TO_TIMEVAL(&basic_info.user_time, &tv);
+            TIME_VALUE_TO_TIMEVAL(&basic_info.user_time, &thread_tv);
+            timeradd(&current_used_time, &tv, &current_used_time);
+            TIME_VALUE_TO_TIMEVAL(&basic_info.system_time, &tv);
+            timeradd(&thread_tv, &tv, &thread_tv);
+            timeradd(&current_used_time, &tv, &current_used_time);
+            uint64_t used_usec = thread_tv.tv_sec * 1000000ULL + thread_tv.tv_usec;
+            (*threads_used_usec)[i] = used_usec;
+        }
+        
+        kr = mach_port_deallocate(mach_task_self(), threads[i]);
+    }
+    kr = mach_vm_deallocate(mach_task_self(), (mach_vm_address_t)(uintptr_t)threads, tcnt * sizeof(*threads));
+}
+
+const char *
+MachTask::GetProfileDataAsCString ()
+{
+    task_t task = TaskPort();
+    if (task == TASK_NULL)
+        return NULL;
+    
+    struct task_basic_info task_info;
+    DNBError err;
+    err = BasicInfo(task, &task_info);
+    
+    if (!err.Success())
+        return NULL;
+    
+    uint64_t elapsed_usec = 0;
+    uint64_t task_used_usec = 0;
+    int num_threads = 0;
+    uint64_t *threads_used_usec = NULL;
+    uint64_t *threads_id = NULL;
+    mach_vm_size_t rprvt = 0;
+    mach_vm_size_t rsize = 0;
+    mach_vm_size_t vprvt = 0;
+    mach_vm_size_t vsize = 0;
+    mach_vm_size_t dirty_size = 0;
+
+    // Get current used time.
+    struct timeval current_used_time;
+    struct timeval tv;
+    TIME_VALUE_TO_TIMEVAL(&task_info.user_time, &current_used_time);
+    TIME_VALUE_TO_TIMEVAL(&task_info.system_time, &tv);
+    timeradd(&current_used_time, &tv, &current_used_time);
+    task_used_usec = current_used_time.tv_sec * 1000000ULL + current_used_time.tv_usec;
+    update_used_time(task, num_threads, &threads_id, &threads_used_usec, current_used_time);
+    
+    struct timeval current_elapsed_time;
+    int res = gettimeofday(&current_elapsed_time, NULL);
+    if (res == 0)
+    {
+        elapsed_usec = current_elapsed_time.tv_sec * 1000000ULL + current_elapsed_time.tv_usec;
+    }
+    
+    if (m_vm_memory.GetMemoryProfile(task, task_info, m_process->GetCPUType(), m_process->ProcessID(), rprvt, rsize, vprvt, vsize, dirty_size))
+    {
+        std::ostringstream profile_data_stream;
+        
+        profile_data_stream << "elapsed_usec:" << elapsed_usec << ';';
+        profile_data_stream << "task_used_usec:" << task_used_usec << ';';
+        
+        profile_data_stream << "threads_info:" << num_threads;
+        for (int i=0; i<num_threads; i++) {
+            profile_data_stream << ',' << threads_id[i];
+            profile_data_stream << ',' << threads_used_usec[i];
+        }
+        profile_data_stream << ';';
+        
+        profile_data_stream << "rprvt:" << rprvt << ';';
+        profile_data_stream << "rsize:" << rsize << ';';
+        profile_data_stream << "vprvt:" << vprvt << ';';
+        profile_data_stream << "vsize:" << vsize << ';';
+        profile_data_stream << "dirty:" << dirty_size << ';';
+        profile_data_stream << "$";
+        
+        m_profile_data = profile_data_stream.str();
+    }
+    else
+    {
+        m_profile_data.clear();
+    }
+    
+    free(threads_id);
+    free(threads_used_usec);
+    
+    return m_profile_data.c_str();
+}
+
 
 //----------------------------------------------------------------------
 // MachTask::TaskPortForProcessID
@@ -242,14 +370,14 @@
 task_t
 MachTask::TaskPortForProcessID (pid_t pid, DNBError &err, uint32_t num_retries, uint32_t usec_interval)
 {
-	if (pid != INVALID_NUB_PROCESS)
-	{
-		DNBError err;
-		mach_port_t task_self = mach_task_self ();	
-		task_t task = TASK_NULL;
-		for (uint32_t i=0; i<num_retries; i++)
-		{	
-			err = ::task_for_pid ( task_self, pid, &task);
+    if (pid != INVALID_NUB_PROCESS)
+    {
+        DNBError err;
+        mach_port_t task_self = mach_task_self ();  
+        task_t task = TASK_NULL;
+        for (uint32_t i=0; i<num_retries; i++)
+        {   
+            err = ::task_for_pid ( task_self, pid, &task);
 
             if (DNBLogCheckLogBit(LOG_TASK) || err.Fail())
             {
@@ -266,14 +394,14 @@
                 err.LogThreaded(str);
             }
 
-			if (err.Success())
-				return task;
+            if (err.Success())
+                return task;
 
-			// Sleep a bit and try again
-			::usleep (usec_interval);
-		}
-	}
-	return TASK_NULL;
+            // Sleep a bit and try again
+            ::usleep (usec_interval);
+        }
+    }
+    return TASK_NULL;
 }
 
 

Modified: lldb/branches/windows/tools/debugserver/source/MacOSX/MachTask.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/MacOSX/MachTask.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/MacOSX/MachTask.h (original)
+++ lldb/branches/windows/tools/debugserver/source/MacOSX/MachTask.h Thu Nov 22 06:24:07 2012
@@ -23,6 +23,7 @@
 #include <sys/socket.h>
 // C++ Includes
 #include <map>
+#include <string>
 // Other libraries and framework includes
 // Project includes
 #include "MachException.h"
@@ -65,6 +66,7 @@
             nub_size_t      ReadMemory (nub_addr_t addr, nub_size_t size, void *buf);
             nub_size_t      WriteMemory (nub_addr_t addr, nub_size_t size, const void *buf);
             int             GetMemoryRegionInfo (nub_addr_t addr, DNBRegionInfo *region_info);
+            const char *    GetProfileDataAsCString ();
 
             nub_addr_t      AllocateMemory (nub_size_t size, uint32_t permissions);
             nub_bool_t      DeallocateMemory (nub_addr_t addr);
@@ -121,6 +123,7 @@
 
             typedef std::map <mach_vm_address_t, size_t> allocation_collection;
             allocation_collection m_allocations;
+            std::string m_profile_data;
 
 private:
     MachTask(const MachTask&); // Outlaw

Modified: lldb/branches/windows/tools/debugserver/source/MacOSX/MachVMMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/MacOSX/MachVMMemory.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/MacOSX/MachVMMemory.cpp (original)
+++ lldb/branches/windows/tools/debugserver/source/MacOSX/MachVMMemory.cpp Thu Nov 22 06:24:07 2012
@@ -15,6 +15,7 @@
 #include "MachVMRegion.h"
 #include "DNBLog.h"
 #include <mach/mach_vm.h>
+#include <mach/shared_region.h>
 
 MachVMMemory::MachVMMemory() :
     m_page_size    (kInvalidPageSize),
@@ -88,6 +89,206 @@
     return true;
 }
 
+// rsize and dirty_size is not adjusted for dyld shared cache and multiple __LINKEDIT segment, as in vmmap. In practice, dirty_size doesn't differ much but rsize may. There is performance penalty for the adjustment. Right now, only use the dirty_size.
+static void GetRegionSizes(task_t task, mach_vm_size_t &rsize, mach_vm_size_t &dirty_size)
+{
+    mach_vm_address_t address = 0;
+    mach_vm_size_t size;
+    kern_return_t err = 0;
+    unsigned nestingDepth = 0;
+    mach_vm_size_t pages_resident = 0;
+    mach_vm_size_t pages_dirtied = 0;
+    
+    while (1)
+    {
+        mach_msg_type_number_t  count;
+        struct vm_region_submap_info_64 info;
+        
+        count = VM_REGION_SUBMAP_INFO_COUNT_64;
+        err = mach_vm_region_recurse(task, &address, &size, &nestingDepth, (vm_region_info_t)&info, &count);
+        if (err == KERN_INVALID_ADDRESS)
+        {
+            // It seems like this is a good break too.
+            break;
+        }
+        else if (err)
+        {
+            mach_error("vm_region",err);
+            break; // reached last region
+        }
+        
+        bool should_count = true;
+        if (info.is_submap)
+        { // is it a submap?
+            nestingDepth++;
+            should_count = false;
+        }
+        else
+        {
+            // Don't count malloc stack logging data in the TOTAL VM usage lines.
+            if (info.user_tag == VM_MEMORY_ANALYSIS_TOOL)
+                should_count = false;
+            // Don't count system shared library region not used by this process.
+            if (address >= SHARED_REGION_BASE && address < (SHARED_REGION_BASE + SHARED_REGION_SIZE))
+                should_count = false;
+
+            address = address+size;
+        }
+        
+        if (should_count)
+        {
+            pages_resident += info.pages_resident;
+            pages_dirtied += info.pages_dirtied;
+        }
+    }
+    
+    rsize = pages_resident * vm_page_size;
+    dirty_size = pages_dirtied * vm_page_size;
+}
+
+// Test whether the virtual address is within the architecture's shared region.
+static bool InSharedRegion(mach_vm_address_t addr, cpu_type_t type)
+{
+    mach_vm_address_t base = 0, size = 0;
+    
+    switch(type) {
+        case CPU_TYPE_ARM:
+            base = SHARED_REGION_BASE_ARM;
+            size = SHARED_REGION_SIZE_ARM;
+            break;
+            
+        case CPU_TYPE_X86_64:
+            base = SHARED_REGION_BASE_X86_64;
+            size = SHARED_REGION_SIZE_X86_64;
+            break;
+            
+        case CPU_TYPE_I386:
+            base = SHARED_REGION_BASE_I386;
+            size = SHARED_REGION_SIZE_I386;
+            break;
+            
+        default: {
+            // Log error abut unknown CPU type
+            break;
+        }
+    }
+    
+    
+    return(addr >= base && addr < (base + size));
+}
+
+static void GetMemorySizes(task_t task, cpu_type_t cputype, nub_process_t pid, mach_vm_size_t &rprvt, mach_vm_size_t &vprvt)
+{
+    // Collecting some other info cheaply but not reporting for now.
+    mach_vm_size_t empty = 0;
+    mach_vm_size_t fw_private = 0;
+    
+    mach_vm_size_t aliased = 0;
+    mach_vm_size_t pagesize = vm_page_size;
+    bool global_shared_text_data_mapped = false;
+    
+    for (mach_vm_address_t addr=0, size=0; ; addr += size)
+    {
+        vm_region_top_info_data_t info;
+        mach_msg_type_number_t count = VM_REGION_TOP_INFO_COUNT;
+        mach_port_t object_name;
+        
+        kern_return_t kr = mach_vm_region(task, &addr, &size, VM_REGION_TOP_INFO, (vm_region_info_t)&info, &count, &object_name);
+        if (kr != KERN_SUCCESS) break;
+        
+        if (InSharedRegion(addr, cputype))
+        {
+            // Private Shared
+            fw_private += info.private_pages_resident * pagesize;
+            
+            // Check if this process has the globally shared text and data regions mapped in.  If so, set global_shared_text_data_mapped to TRUE and avoid checking again.
+            if (global_shared_text_data_mapped == FALSE && info.share_mode == SM_EMPTY) {
+                vm_region_basic_info_data_64_t  b_info;
+                mach_vm_address_t b_addr = addr;
+                mach_vm_size_t b_size = size;
+                count = VM_REGION_BASIC_INFO_COUNT_64;
+                
+                kr = mach_vm_region(task, &b_addr, &b_size, VM_REGION_BASIC_INFO, (vm_region_info_t)&b_info, &count, &object_name);
+                if (kr != KERN_SUCCESS) break;
+                
+                if (b_info.reserved) {
+                    global_shared_text_data_mapped = TRUE;
+                }
+            }
+            
+            // Short circuit the loop if this isn't a shared private region, since that's the only region type we care about within the current address range.
+            if (info.share_mode != SM_PRIVATE)
+            {
+                continue;
+            }
+        }
+        
+        // Update counters according to the region type.
+        if (info.share_mode == SM_COW && info.ref_count == 1)
+        {
+            // Treat single reference SM_COW as SM_PRIVATE
+            info.share_mode = SM_PRIVATE;
+        }
+        
+        switch (info.share_mode)
+        {
+            case SM_LARGE_PAGE:
+                // Treat SM_LARGE_PAGE the same as SM_PRIVATE
+                // since they are not shareable and are wired.
+            case SM_PRIVATE:
+                rprvt += info.private_pages_resident * pagesize;
+                rprvt += info.shared_pages_resident * pagesize;
+                vprvt += size;
+                break;
+                
+            case SM_EMPTY:
+                empty += size;
+                break;
+                
+            case SM_COW:
+            case SM_SHARED:
+            {
+                if (pid == 0)
+                {
+                    // Treat kernel_task specially
+                    if (info.share_mode == SM_COW)
+                    {
+                        rprvt += info.private_pages_resident * pagesize;
+                        vprvt += size;
+                    }
+                    break;
+                }
+                
+                if (info.share_mode == SM_COW)
+                {
+                    rprvt += info.private_pages_resident * pagesize;
+                    vprvt += info.private_pages_resident * pagesize;
+                }
+                break;
+            }
+            default:
+                // log that something is really bad.
+                break;
+        }
+    }
+    
+    rprvt += aliased;
+}
+
+nub_bool_t
+MachVMMemory::GetMemoryProfile(task_t task, struct task_basic_info ti, cpu_type_t cputype, nub_process_t pid, mach_vm_size_t &rprvt, mach_vm_size_t &rsize, mach_vm_size_t &vprvt, mach_vm_size_t &vsize, mach_vm_size_t &dirty_size)
+{
+    // This uses vmmap strategy. We don't use the returned rsize for now. We prefer to match top's version since that's what we do for the rest of the metrics.
+    GetRegionSizes(task, rsize, dirty_size);
+    
+    GetMemorySizes(task, cputype, pid, rprvt, vprvt);
+    
+    rsize = ti.resident_size;
+    vsize = ti.virtual_size;
+    
+    return true;
+}
+
 nub_size_t
 MachVMMemory::Read(task_t task, nub_addr_t address, void *data, nub_size_t data_count)
 {

Modified: lldb/branches/windows/tools/debugserver/source/MacOSX/MachVMMemory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/MacOSX/MachVMMemory.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/MacOSX/MachVMMemory.h (original)
+++ lldb/branches/windows/tools/debugserver/source/MacOSX/MachVMMemory.h Thu Nov 22 06:24:07 2012
@@ -28,12 +28,13 @@
     nub_size_t Write(task_t task, nub_addr_t address, const void *data, nub_size_t data_count);
     nub_size_t PageSize();
     nub_bool_t GetMemoryRegionInfo(task_t task, nub_addr_t address, DNBRegionInfo *region_info);
+    nub_bool_t GetMemoryProfile(task_t task, struct task_basic_info ti, cpu_type_t cputype, nub_process_t pid, mach_vm_size_t &rprvt, mach_vm_size_t &rsize, mach_vm_size_t &vprvt, mach_vm_size_t &vsize, mach_vm_size_t &dirty_size);
 
 protected:
     nub_size_t MaxBytesLeftInPage(nub_addr_t addr, nub_size_t count);
 
     nub_size_t WriteRegion(task_t task, const nub_addr_t address, const void *data, const nub_size_t data_count);
-    vm_size_t        m_page_size;
+    vm_size_t   m_page_size;
     DNBError    m_err;
 };
 

Modified: lldb/branches/windows/tools/debugserver/source/RNBContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/RNBContext.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/RNBContext.cpp (original)
+++ lldb/branches/windows/tools/debugserver/source/RNBContext.cpp Thu Nov 22 06:24:07 2012
@@ -148,9 +148,9 @@
     bool done = false;
     while (!done)
     {
-        DNBLogThreadedIf(LOG_RNB_PROC, "RNBContext::%s calling DNBProcessWaitForEvent(pid, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged | eEventStdioAvailable, true)...", __FUNCTION__);
-        nub_event_t pid_status_event = DNBProcessWaitForEvents (pid, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged | eEventStdioAvailable, true, NULL);
-        DNBLogThreadedIf(LOG_RNB_PROC, "RNBContext::%s calling DNBProcessWaitForEvent(pid, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged | eEventStdioAvailable, true) => 0x%8.8x", __FUNCTION__, pid_status_event);
+        DNBLogThreadedIf(LOG_RNB_PROC, "RNBContext::%s calling DNBProcessWaitForEvent(pid, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged | eEventStdioAvailable | eEventProfileDataAvailable, true)...", __FUNCTION__);
+        nub_event_t pid_status_event = DNBProcessWaitForEvents (pid, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged | eEventStdioAvailable | eEventProfileDataAvailable, true, NULL);
+        DNBLogThreadedIf(LOG_RNB_PROC, "RNBContext::%s calling DNBProcessWaitForEvent(pid, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged | eEventStdioAvailable | eEventProfileDataAvailable, true) => 0x%8.8x", __FUNCTION__, pid_status_event);
 
         if (pid_status_event == 0)
         {
@@ -167,6 +167,13 @@
                 ctx.Events().WaitForResetAck(RNBContext::event_proc_stdio_available);
             }
 
+            if (pid_status_event & eEventProfileDataAvailable)
+            {
+                DNBLogThreadedIf(LOG_RNB_PROC, "RNBContext::%s (pid=%4.4x) got profile data event....", __FUNCTION__, pid);
+                ctx.Events().SetEvents (RNBContext::event_proc_profile_data);
+                // Wait for the main thread to consume this notification if it requested we wait for it
+                ctx.Events().WaitForResetAck(RNBContext::event_proc_profile_data);
+            }
 
             if (pid_status_event & (eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged))
             {
@@ -217,6 +224,8 @@
         s += "proc_thread_exiting ";
     if (events & event_proc_stdio_available)
         s += "proc_stdio_available ";
+    if (events & event_proc_profile_data)
+        s += "proc_profile_data ";
     if (events & event_read_packet_available)
         s += "read_packet_available ";
     if (events & event_read_thread_running)

Modified: lldb/branches/windows/tools/debugserver/source/RNBContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/RNBContext.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/RNBContext.h (original)
+++ lldb/branches/windows/tools/debugserver/source/RNBContext.h Thu Nov 22 06:24:07 2012
@@ -29,13 +29,15 @@
         event_proc_thread_running       = 0x02, // Sticky
         event_proc_thread_exiting       = 0x04,
         event_proc_stdio_available      = 0x08,
-        event_read_packet_available     = 0x10,
-        event_read_thread_running       = 0x20, // Sticky
-        event_read_thread_exiting       = 0x40,
+        event_proc_profile_data         = 0x10,
+        event_read_packet_available     = 0x20,
+        event_read_thread_running       = 0x40, // Sticky
+        event_read_thread_exiting       = 0x80,
 
         normal_event_bits   = event_proc_state_changed |
                               event_proc_thread_exiting |
                               event_proc_stdio_available |
+                              event_proc_profile_data | 
                               event_read_packet_available |
                               event_read_thread_exiting,
 

Modified: lldb/branches/windows/tools/debugserver/source/RNBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/RNBRemote.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/branches/windows/tools/debugserver/source/RNBRemote.cpp Thu Nov 22 06:24:07 2012
@@ -193,6 +193,8 @@
     t.push_back (Packet (allocate_memory,               &RNBRemote::HandlePacket_AllocateMemory, NULL, "_M", "Allocate memory in the inferior process."));
     t.push_back (Packet (deallocate_memory,             &RNBRemote::HandlePacket_DeallocateMemory, NULL, "_m", "Deallocate memory in the inferior process."));
     t.push_back (Packet (memory_region_info,            &RNBRemote::HandlePacket_MemoryRegionInfo, NULL, "qMemoryRegionInfo", "Return size and attributes of a memory region that contains the given address"));
+    t.push_back (Packet (get_profile_data,              &RNBRemote::HandlePacket_GetProfileData, NULL, "qGetProfileData", "Return profiling data of the current target."));
+    t.push_back (Packet (set_enable_profiling,          &RNBRemote::HandlePacket_SetAsyncEnableProfiling, NULL, "QSetAsyncEnableProfiling", "Enable or disable the profiling of current target."));
     t.push_back (Packet (watchpoint_support_info,       &RNBRemote::HandlePacket_WatchpointSupportInfo, NULL, "qWatchpointSupportInfo", "Return the number of supported hardware watchpoints"));
 
 }
@@ -226,6 +228,25 @@
     }
 }
 
+void
+RNBRemote::SendAsyncProfileData ()
+{
+    if (m_ctx.HasValidProcessID())
+    {
+        nub_process_t pid = m_ctx.ProcessID();
+        char buf[256];
+        nub_size_t count;
+        do
+        {
+            count = DNBProcessGetAvailableProfileData(pid, buf, sizeof(buf));
+            if (count > 0)
+            {
+                SendAsyncProfileDataPacket (buf, count);
+            }
+        } while (count > 0);
+    }
+}
+
 rnb_err_t
 RNBRemote::SendHexEncodedBytePacket (const char *header, const void *buf, size_t buf_len, const char *footer)
 {
@@ -262,6 +283,18 @@
     return SendHexEncodedBytePacket("O", buf, buf_size, NULL);
 }
 
+// This makes use of asynchronous bit 'A' in the gdb remote protocol.
+rnb_err_t
+RNBRemote::SendAsyncProfileDataPacket (char *buf, nub_size_t buf_size)
+{
+    if (buf_size == 0)
+        return rnb_success;
+    
+    std::string packet("A");
+    packet.append(buf, buf_size);
+    return SendPacket(packet);
+}
+
 rnb_err_t
 RNBRemote::SendPacket (const std::string &s)
 {
@@ -3428,6 +3461,58 @@
 }
 
 rnb_err_t
+RNBRemote::HandlePacket_GetProfileData (const char *p)
+{
+    nub_process_t pid = m_ctx.ProcessID();
+    if (pid == INVALID_NUB_PROCESS)
+        return SendPacket ("OK");
+
+    const char *data = DNBProcessGetProfileDataAsCString(pid);
+    if (data)
+    {
+        return SendPacket (data);
+    }
+    else
+    {
+        return SendPacket ("OK");
+    }
+}
+
+
+// QSetAsyncEnableProfiling;enable:[0|1]:interval_usec:XXXXXX;
+rnb_err_t
+RNBRemote::HandlePacket_SetAsyncEnableProfiling (const char *p)
+{
+    nub_process_t pid = m_ctx.ProcessID();
+    if (pid == INVALID_NUB_PROCESS)
+        return SendPacket ("");
+
+    StringExtractor packet(p += sizeof ("QSetAsyncEnableProfiling:") - 1);
+    bool enable = false;
+    uint64_t interval_usec = 0;
+    std::string name;
+    std::string value;
+    while (packet.GetNameColonValue(name, value))
+    {
+        if (name.compare ("enable") == 0)
+        {
+            enable  = strtoul(value.c_str(), NULL, 10) > 0;
+        }
+        else if (name.compare ("interval_usec") == 0)
+        {
+            interval_usec  = strtoul(value.c_str(), NULL, 10);
+        }
+    }
+    
+    if (interval_usec == 0)
+    {
+        enable = 0;
+    }
+    DNBProcessSetAsyncEnableProfiling(pid, enable, interval_usec);
+    return SendPacket ("OK");
+}
+
+rnb_err_t
 RNBRemote::HandlePacket_WatchpointSupportInfo (const char *p)
 {
     /* This packet simply returns the number of supported hardware watchpoints.

Modified: lldb/branches/windows/tools/debugserver/source/RNBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/RNBRemote.h?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/RNBRemote.h (original)
+++ lldb/branches/windows/tools/debugserver/source/RNBRemote.h Thu Nov 22 06:24:07 2012
@@ -112,6 +112,8 @@
         set_list_threads_in_stop_reply, // 'QListThreadsInStopReply:'
         sync_thread_state,              // 'QSyncThreadState:'
         memory_region_info,             // 'qMemoryRegionInfo:'
+        get_profile_data,               // 'qGetProfileData'
+        set_enable_profiling,           // 'QSetAsyncEnableProfiling'
         watchpoint_support_info,        // 'qWatchpointSupportInfo:'
         allocate_memory,                // '_M'
         deallocate_memory,              // '_m'
@@ -210,6 +212,8 @@
     rnb_err_t HandlePacket_AllocateMemory (const char *p);
     rnb_err_t HandlePacket_DeallocateMemory (const char *p);
     rnb_err_t HandlePacket_MemoryRegionInfo (const char *p);
+    rnb_err_t HandlePacket_GetProfileData(const char *p);
+    rnb_err_t HandlePacket_SetAsyncEnableProfiling(const char *p);
     rnb_err_t HandlePacket_WatchpointSupportInfo (const char *p);
 
     rnb_err_t HandlePacket_stop_process (const char *p);
@@ -219,6 +223,8 @@
     rnb_err_t SendSTDOUTPacket (char *buf, nub_size_t buf_size);
     rnb_err_t SendSTDERRPacket (char *buf, nub_size_t buf_size);
     void      FlushSTDIO ();
+    void      SendAsyncProfileData ();
+    rnb_err_t SendAsyncProfileDataPacket (char *buf, nub_size_t buf_size);
 
     RNBContext&     Context() { return m_ctx; }
     RNBSocket&      Comm() { return m_comm; }

Modified: lldb/branches/windows/tools/debugserver/source/debugserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/tools/debugserver/source/debugserver.cpp?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/tools/debugserver/source/debugserver.cpp (original)
+++ lldb/branches/windows/tools/debugserver/source/debugserver.cpp Thu Nov 22 06:24:07 2012
@@ -498,8 +498,9 @@
 
         if (!ctx.ProcessStateRunning())
         {
-            // Clear the stdio bits if we are not running so we don't send any async packets
+            // Clear some bits if we are not running so we don't send any async packets
             event_mask &= ~RNBContext::event_proc_stdio_available;
+            event_mask &= ~RNBContext::event_proc_profile_data;
         }
 
         // We want to make sure we consume all process state changes and have
@@ -519,6 +520,11 @@
                 remote->FlushSTDIO();
             }
 
+            if (set_events & RNBContext::event_proc_profile_data)
+            {
+                remote->SendAsyncProfileData();
+            }
+
             if (set_events & RNBContext::event_read_packet_available)
             {
                 // handleReceivedPacket will take care of resetting the

Modified: lldb/branches/windows/www/lldb-gdb.html
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/www/lldb-gdb.html?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/www/lldb-gdb.html (original)
+++ lldb/branches/windows/www/lldb-gdb.html Thu Nov 22 06:24:07 2012
@@ -631,6 +631,17 @@
                         </td>
                     </tr>
 
+                    <tr><td class="header" colspan="2">Calling a function so you can stop at a breakpoint in the function.</td></tr>
+                    <tr>
+                        <td class="content">
+                            <b>(gdb)</b> set unwindonsignal 0<br>
+                            <b>(gdb)</b> p function_with_a_breakpoint()<br>
+                        </td>
+                        <td class="content">
+                            <b>(lldb)</b> expr -u 0 -- function_with_a_breakpoint()<br>
+                        </td>
+                    </tr>
+
 
                     </table>
                     <p>
@@ -873,6 +884,44 @@
                             <b>(lldb)</b> me r -o /tmp/mem.bin -b 0x1000 0x1200<br>
                         </td>
                     </tr>
+                    <tr><td class="header" colspan="2">Get information about a specific heap allocation (available on Mac OS X only).</td></tr>
+                    <tr>
+                        <td class="content">
+                            <b>(gdb)</b> info malloc 0x10010d680
+                        </td>
+                        <td class="content">
+                            <b>(lldb)</b> script import lldb.macosx.heap<br>
+                            <b>(lldb)</b> process launch --environment MallocStackLogging=1 -- [ARGS]<br>	
+                            <b>(lldb)</b> malloc_info --stack-history 0x10010d680<br>
+                        </td>
+                    </tr>
+                    <tr><td class="header" colspan="2">Get information about a specific heap allocation and cast the result to any dynamic type that can be deduced (available on Mac OS X only)</td></tr>
+                    <tr>
+                        <td class="content">
+                        </td>
+                        <td class="content">
+                            <b>(lldb)</b> script import lldb.macosx.heap<br>
+                            <b>(lldb)</b> malloc_info --type 0x10010d680<br>
+                        </td>
+                    </tr>
+                    <tr><td class="header" colspan="2">Find all heap blocks that contain a pointer specified by an expression EXPR (available on Mac OS X only).</td></tr>
+                    <tr>
+                        <td class="content">
+                        </td>
+                        <td class="content">
+                            <b>(lldb)</b> script import lldb.macosx.heap<br>
+                            <b>(lldb)</b> ptr_refs EXPR <br>
+                        </td>
+                    </tr>
+                    <tr><td class="header" colspan="2">Find all heap blocks that contain a C string anywhere in the block (available on Mac OS X only).</td></tr>
+                    <tr>
+                        <td class="content">
+                        </td>
+                        <td class="content">
+                            <b>(lldb)</b> script import lldb.macosx.heap<br>
+                            <b>(lldb)</b> cstr_refs CSTRING<br>
+                        </td>
+                    </tr>
                     <tr><td class="header" colspan="2">Disassemble the current function for the current frame.</td></tr>
                     <tr>
                         <td class="content">

Modified: lldb/branches/windows/www/sidebar.incl
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/windows/www/sidebar.incl?rev=168494&r1=168493&r2=168494&view=diff
==============================================================================
--- lldb/branches/windows/www/sidebar.incl (original)
+++ lldb/branches/windows/www/sidebar.incl Thu Nov 22 06:24:07 2012
@@ -20,6 +20,7 @@
         <li><a href="varformats.html">Variable Formatting</a></li>
         <li><a href="python-reference.html">Python Reference</a></li>
         <li><a href="scripting.html">Python Example</a></li>
+        <li><a href="symbols.html">Symbols on Mac OS X</a></li>
         <li><a href="architecture.html">Architecture</a></li>
       </ul>
     </div>





More information about the lldb-commits mailing list