[Lldb-commits] [lldb] r124171 - in /lldb/trunk: include/lldb/Core/Broadcaster.h include/lldb/Core/Section.h source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.h source/Target/Process.cpp

Greg Clayton gclayton at apple.com
Mon Jan 24 18:58:48 PST 2011


Author: gclayton
Date: Mon Jan 24 20:58:48 2011
New Revision: 124171

URL: http://llvm.org/viewvc/llvm-project?rev=124171&view=rev
Log:
Fixed ProcessGDBRemote to kill the process correctly when it is either running
or stopped. 

Added support for sections to be able to state if they are encrypted or not.


Modified:
    lldb/trunk/include/lldb/Core/Broadcaster.h
    lldb/trunk/include/lldb/Core/Section.h
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Core/Broadcaster.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Broadcaster.h?rev=124171&r1=124170&r2=124171&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Broadcaster.h (original)
+++ lldb/trunk/include/lldb/Core/Broadcaster.h Mon Jan 24 20:58:48 2011
@@ -222,6 +222,14 @@
     bool
     HijackBroadcaster (Listener *listener, uint32_t event_mask = UINT32_MAX);
     
+    bool
+    IsHijackedForEvent (uint32_t event_mask)
+    {
+        if (m_hijacking_listener)
+            return (event_mask & m_hijacking_mask) != 0;
+        return false;
+    }
+
     //------------------------------------------------------------------
     /// Restore the state of the Broadcaster from a previous hijack attempt.
     ///

Modified: lldb/trunk/include/lldb/Core/Section.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=124171&r1=124170&r2=124171&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Section.h (original)
+++ lldb/trunk/include/lldb/Core/Section.h Mon Jan 24 20:58:48 2011
@@ -213,6 +213,18 @@
     {
         m_fake = fake;
     }
+    
+    bool
+    IsEncrypted () const
+    {
+        return m_encrypted;
+    }
+    
+    void
+    SetIsEncrypted (bool b)
+    {
+        m_encrypted = b;
+    }
 
     bool
     IsDescendant (const Section *section);
@@ -273,10 +285,11 @@
     uint64_t        m_file_offset;      // Object file offset (if any)
     uint64_t        m_file_size;        // Object file size (can be smaller than m_byte_size for zero filled sections...)
     SectionList     m_children;         // Child sections
-    bool            m_fake;             // If true, then this section only can contain the address if one of its
+    bool            m_fake:1,           // If true, then this section only can contain the address if one of its
                                         // children contains an address. This allows for gaps between the children
                                         // that are contained in the address range for this section, but do not produce
                                         // hits unless the children contain the address.
+                    m_encrypted:1;      // Set to true if the contents are encrypted
     const Section * m_linked_section;
     uint64_t        m_linked_offset;
 private:

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=124171&r1=124170&r2=124171&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Mon Jan 24 20:58:48 2011
@@ -251,6 +251,9 @@
                 load_cmd.filesize = m_data.GetAddress(&offset);
                 if (m_data.GetU32(&offset, &load_cmd.maxprot, 4))
                 {
+                    
+                    const bool segment_is_encrypted = (load_cmd.flags & SegmentCommandFlagBitProtectedVersion1) != 0;
+
                     // Keep a list of mach segments around in case we need to
                     // get at data that isn't stored in the abstracted Sections.
                     m_mach_segments.push_back (load_cmd);
@@ -272,6 +275,7 @@
                                                       load_cmd.filesize,      // Size in bytes of this section as found in the the file
                                                       load_cmd.flags));       // Flags for this section
 
+                        segment_sp->SetIsEncrypted (segment_is_encrypted);
                         m_sections_ap->AddSection(segment_sp);
                     }
 
@@ -369,6 +373,7 @@
                                                              load_cmd.flags));       // Flags for this section
                                 segment_sp->SetIsFake(true);
                                 m_sections_ap->AddSection(segment_sp);
+                                segment_sp->SetIsEncrypted (segment_is_encrypted);
                             }
                         }
                         assert (segment_sp.get());
@@ -482,6 +487,9 @@
                                                          sect64.offset,
                                                          sect64.offset == 0 ? 0 : sect64.size,
                                                          sect64.flags));
+                        // Set the section to be encrypted to match the segment
+                        section_sp->SetIsEncrypted (segment_is_encrypted);
+
                         segment_sp->GetChildren().AddSection(section_sp);
 
                         if (segment_sp->IsFake())

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=124171&r1=124170&r2=124171&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Mon Jan 24 20:58:48 2011
@@ -151,7 +151,7 @@
             
             bool timed_out = false;
             bool sent_interrupt = false;
-            if (SendInterrupt(locker, 1, sent_interrupt, timed_out))
+            if (SendInterrupt(locker, 2, sent_interrupt, timed_out))
             {
                 if (m_async_packet_predicate.WaitForValueEqualTo (false, &timeout_time, &timed_out))
                 {
@@ -206,7 +206,6 @@
 )
 {
     LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
-    LogSP async_log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_ASYNC));
     if (log)
         log->Printf ("GDBRemoteCommunication::%s ()", __FUNCTION__);
 
@@ -222,21 +221,18 @@
 
     while (state == eStateRunning)
     {
-        log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS);
         if (log)
             log->Printf ("GDBRemoteCommunication::%s () WaitForPacket(...)", __FUNCTION__);
 
         if (WaitForPacket (response, (TimeValue*)NULL))
         {
-            log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS);
-            async_log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_ASYNC);
             if (response.Empty())
                 state = eStateInvalid;
             else
             {
                 const char stop_type = response.GetChar();
                 if (log)
-                    log->Printf ("GDBRemoteCommunication::%s () got '%c' packet", __FUNCTION__, stop_type);
+                    log->Printf ("GDBRemoteCommunication::%s () got packet: %s", __FUNCTION__, response.GetStringRef().c_str());
                 switch (stop_type)
                 {
                 case 'T':
@@ -248,8 +244,8 @@
                     m_private_is_running.SetValue (false, eBroadcastAlways);
                     if (m_async_signal != -1)
                     {
-                        if (async_log) 
-                            async_log->Printf ("async: send signo = %s", Host::GetSignalAsCString (m_async_signal));
+                        if (log) 
+                            log->Printf ("async: send signo = %s", Host::GetSignalAsCString (m_async_signal));
 
                         // Save off the async signal we are supposed to send
                         const int async_signal = m_async_signal;
@@ -260,8 +256,8 @@
                         uint8_t signo = response.GetHexU8(255);
                         if (signo == async_signal)
                         {
-                            if (async_log) 
-                                async_log->Printf ("async: stopped with signal %s, we are done running", Host::GetSignalAsCString (signo));
+                            if (log) 
+                                log->Printf ("async: stopped with signal %s, we are done running", Host::GetSignalAsCString (signo));
 
                             // We already stopped with a signal that we wanted
                             // to stop with, so we are done
@@ -279,15 +275,15 @@
                                                             "C%2.2x",
                                                             async_signal);
 
-                            if (async_log) 
-                                async_log->Printf ("async: stopped with signal %s, resume with %s", 
+                            if (log) 
+                                log->Printf ("async: stopped with signal %s, resume with %s", 
                                                    Host::GetSignalAsCString (signo),
                                                    Host::GetSignalAsCString (async_signal));
 
                             if (SendPacket(signal_packet, signal_packet_len) == 0)
                             {
-                                if (async_log) 
-                                    async_log->Printf ("async: error: failed to resume with %s", 
+                                if (log) 
+                                    log->Printf ("async: error: failed to resume with %s", 
                                                        Host::GetSignalAsCString (async_signal));
                                 state = eStateExited;
                                 break;
@@ -301,9 +297,9 @@
                     }
                     else if (m_async_packet_predicate.GetValue())
                     {
-                        if (async_log) 
-                            async_log->Printf ("async: send async packet: %s", 
-                                               m_async_packet.c_str());
+                        if (log) 
+                            log->Printf ("async: send async packet: %s", 
+                                         m_async_packet.c_str());
 
                         // We are supposed to send an asynchronous packet while
                         // we are running. 
@@ -320,9 +316,9 @@
                         // packet know that the packet has been sent.
                         m_async_packet_predicate.SetValue(false, eBroadcastAlways);
 
-                        if (async_log) 
-                            async_log->Printf ("async: resume after async response received: %s", 
-                                               m_async_response.GetStringRef().c_str());
+                        if (log) 
+                            log->Printf ("async: resume after async response received: %s", 
+                                         m_async_response.GetStringRef().c_str());
 
                         // Continue again
                         if (SendPacket("c", 1) == 0)
@@ -342,6 +338,7 @@
                     break;
 
                 case 'W':
+                case 'X':
                     // process exited
                     state = eStateExited;
                     break;
@@ -365,20 +362,18 @@
 
                 default:
                     if (log)
-                        log->Printf ("GDBRemoteCommunication::%s () got unrecognized async packet: '%s'", __FUNCTION__, stop_type);
+                        log->Printf ("GDBRemoteCommunication::%s () unrecognized async packet", __FUNCTION__);
                     break;
                 }
             }
         }
         else
         {
-            log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS);
             if (log)
                 log->Printf ("GDBRemoteCommunication::%s () WaitForPacket(...) => false", __FUNCTION__);
             state = eStateInvalid;
         }
     }
-    log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS);
     if (log)
         log->Printf ("GDBRemoteCommunication::%s () => %s", __FUNCTION__, StateAsCString(state));
     response.SetFilePos(0);
@@ -498,7 +493,7 @@
                 timeout = TimeValue::Now();
                 timeout.OffsetWithSeconds (seconds_to_wait_for_stop);
             }
-            ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "send packet: \\x03");
+            ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS | GDBR_LOG_PROCESS, "send packet: \\x03");
             if (Write (&ctrl_c, 1, status, NULL) > 0)
             {
                 sent_interrupt = true;

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=124171&r1=124170&r2=124171&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Jan 24 20:58:48 2011
@@ -1175,7 +1175,6 @@
 (
     bool discard_thread_plans, 
     bool catch_stop_event, 
-    bool resume_private_state_thread,
     EventSP &stop_event_sp
 )
 {
@@ -1183,21 +1182,14 @@
 
     LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
     
+    bool paused_private_state_thread = false;
     const bool is_running = m_gdb_comm.IsRunning();
     if (log)
-        log->Printf ("ProcessGDBRemote::InterruptIfRunning(discard_thread_plans=%i, catch_stop_event=%i, resume_private_state_thread=%i) is_running=%i", 
+        log->Printf ("ProcessGDBRemote::InterruptIfRunning(discard_thread_plans=%i, catch_stop_event=%i) is_running=%i", 
                      discard_thread_plans, 
-                     catch_stop_event, 
-                     resume_private_state_thread,
+                     catch_stop_event,
                      is_running);
 
-    if (catch_stop_event)
-    {
-        if (log)
-            log->Printf ("ProcessGDBRemote::InterruptIfRunning() pausing private state thread");
-        PausePrivateStateThread();
-    }
-    
     if (discard_thread_plans)
     {
         if (log)
@@ -1206,6 +1198,14 @@
     }
     if (is_running)
     {
+        if (catch_stop_event)
+        {
+            if (log)
+                log->Printf ("ProcessGDBRemote::InterruptIfRunning() pausing private state thread");
+            PausePrivateStateThread();
+            paused_private_state_thread = true;
+        }
+
         bool timed_out = false;
         bool sent_interrupt = false;
         Mutex::Locker locker;
@@ -1217,17 +1217,18 @@
                 error.SetErrorString("timed out sending interrupt packet");
             else
                 error.SetErrorString("unknown error sending interrupt packet");
-            if (catch_stop_event)
+            if (paused_private_state_thread)
                 ResumePrivateStateThread();
             return error;
         }
         
         if (catch_stop_event)
         {
+            // LISTEN HERE
             TimeValue timeout_time;
             timeout_time = TimeValue::Now();
-            timeout_time.OffsetWithSeconds(1);
-            StateType state = WaitForProcessStopPrivate (&timeout_time, stop_event_sp);
+            timeout_time.OffsetWithSeconds(5);
+            StateType state = WaitForStateChangedEventsPrivate (&timeout_time, stop_event_sp);
     
             const bool timed_out = state == eStateInvalid;
             if (log)
@@ -1237,7 +1238,7 @@
                 error.SetErrorString("unable to verify target stopped");
         }
         
-        if (catch_stop_event && resume_private_state_thread)
+        if (paused_private_state_thread)
         {
             if (log)
                 log->Printf ("ProcessGDBRemote::InterruptIfRunning() resuming private state thread");
@@ -1256,9 +1257,8 @@
 
     bool discard_thread_plans = true; 
     bool catch_stop_event = true;
-    bool resume_private_state_thread = false; // DoDetach will resume the thread
     EventSP event_sp;
-    return InterruptIfRunning (discard_thread_plans, catch_stop_event, resume_private_state_thread, event_sp);
+    return InterruptIfRunning (discard_thread_plans, catch_stop_event, event_sp);
 }
 
 Error
@@ -1295,21 +1295,6 @@
 }
 
 Error
-ProcessGDBRemote::WillDestroy ()
-{
-    LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-    if (log)
-        log->Printf ("ProcessGDBRemote::WillDestroy()");
-    bool discard_thread_plans = true; 
-    bool catch_stop_event = true;
-    bool resume_private_state_thread = true;
-    EventSP event_sp;
-    return InterruptIfRunning (discard_thread_plans, catch_stop_event, resume_private_state_thread, event_sp);
-    
-
-}
-
-Error
 ProcessGDBRemote::DoDestroy ()
 {
     Error error;
@@ -1320,38 +1305,11 @@
     // Interrupt if our inferior is running...
     if (m_gdb_comm.IsConnected())
     {
-        m_continue_packet.Clear();
-        m_continue_packet.Printf("k");
-        Listener listener ("gdb-remote.kill-packet-sent");
-        if (listener.StartListeningForEvents (&m_gdb_comm, GDBRemoteCommunication::eBroadcastBitRunPacketSent))
-        {
-            EventSP event_sp;
-            TimeValue timeout;
-            timeout = TimeValue::Now();
-            timeout.OffsetWithSeconds (1);
-            m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncContinue, new EventDataBytes (m_continue_packet.GetData(), m_continue_packet.GetSize()));
-
-            // Wait for the async thread to send the "k" packet
-            if (listener.WaitForEvent (&timeout, event_sp))
-            {
-                if (log)
-                    log->Printf ("ProcessGDBRemote::DoDestroy() got confirmation the \"k\" packet was sent");
-            }
-            else
-            {
-                if (log)
-                    log->Printf ("ProcessGDBRemote::DoDestroy() timed out waiting for \"k\" packet to be sent");
-                error.SetErrorString("Resume timed out.");
-            }
-            
-            // Wait for the async thread to exit which will indicate we stopped.
-            // Hopefully the stop will be a process exited state since we are
-            // asking the process to go away.
-            if (!m_gdb_comm.WaitForNotRunning (&timeout))
-            {
-                if (log)
-                    log->Printf ("ProcessGDBRemote::DoDestroy() timed out waiting for \"k\" stop reply packet");
-            }
+        StringExtractorGDBRemote response;
+        bool send_async = true;
+        if (m_gdb_comm.SendPacketAndWaitForResponse("k", 1, response, 3, send_async) == 0)
+        {
+            error.SetErrorString("kill packet failed");
         }
     }
     StopAsyncThread ();

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=124171&r1=124170&r2=124171&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Mon Jan 24 20:58:48 2011
@@ -150,9 +150,6 @@
     DoSignal (int signal);
 
     virtual lldb_private::Error
-    WillDestroy ();
-
-    virtual lldb_private::Error
     DoDestroy ();
 
     virtual void
@@ -392,7 +389,6 @@
     lldb_private::Error
     InterruptIfRunning (bool discard_thread_plans, 
                         bool catch_stop_event, 
-                        bool resume_private_state_thread,
                         lldb::EventSP &stop_event_sp);
 
 private:

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=124171&r1=124170&r2=124171&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Mon Jan 24 20:58:48 2011
@@ -555,9 +555,20 @@
 bool
 Process::SetExitStatus (int status, const char *cstr)
 {
+    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE | LIBLLDB_LOG_PROCESS));
+    if (log)
+        log->Printf("Process::SetExitStatus (status=%i (0x%8.8x), description=%s%s%s)", 
+                    status, status,
+                    cstr ? "\"" : "",
+                    cstr ? cstr : "NULL",
+                    cstr ? "\"" : "");
+
     // We were already in the exited state
     if (m_private_state.GetValue() == eStateExited)
+    {
+        log->Printf("Process::SetExitStatus () ignoring exit status because state was already set to eStateExited");
         return false;
+    }
     
     m_exit_status = status;
     if (cstr)
@@ -621,7 +632,7 @@
 void
 Process::SetPublicState (StateType new_state)
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE));
+    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE | LIBLLDB_LOG_PROCESS));
     if (log)
         log->Printf("Process::SetPublicState (%s)", StateAsCString(new_state));
     m_public_state.SetValue (new_state);
@@ -636,7 +647,7 @@
 void
 Process::SetPrivateState (StateType new_state)
 {
-    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE));
+    LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE | LIBLLDB_LOG_PROCESS));
     bool state_changed = false;
 
     if (log)
@@ -2111,19 +2122,22 @@
 Process::HandlePrivateEvent (EventSP &event_sp)
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-    const StateType internal_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
+    const StateType new_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
     // See if we should broadcast this state to external clients?
     const bool should_broadcast = ShouldBroadcastEvent (event_sp.get());
-    if (log)
-        log->Printf ("Process::%s (arg = %p, pid = %i) got event '%s' broadcast = %s", __FUNCTION__, this, GetID(), StateAsCString(internal_state), should_broadcast ? "yes" : "no");
 
     if (should_broadcast)
     {
         if (log)
         {
-            log->Printf ("\tChanging public state from: %s to %s", StateAsCString(GetState ()), StateAsCString (internal_state));
+            log->Printf ("Process::%s (pid = %i) broadcasting new state %s (old state %s) to %s", 
+                         __FUNCTION__, 
+                         GetID(), 
+                         StateAsCString(new_state), 
+                         StateAsCString (GetState ()),
+                         IsHijackedForEvent(eBroadcastBitStateChanged) ? "hijacked" : "public");
         }
-        if (StateIsRunningState (internal_state))
+        if (StateIsRunningState (new_state))
             PushProcessInputReader ();
         else 
             PopProcessInputReader ();
@@ -2134,7 +2148,12 @@
     {
         if (log)
         {
-            log->Printf ("\tNot changing public state with event: %s", StateAsCString (internal_state));
+            log->Printf ("Process::%s (pid = %i) suppressing state %s (old state %s): should_broadcast == false", 
+                         __FUNCTION__, 
+                         GetID(), 
+                         StateAsCString(new_state), 
+                         StateAsCString (GetState ()),
+                         IsHijackedForEvent(eBroadcastBitStateChanged) ? "hijacked" : "public");
         }
     }
 }
@@ -2649,7 +2668,7 @@
     {
         StreamString s;
         thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
-        log->Printf ("Resuming thread %u - 0x%4.4x to run thread plan \"%s\".",  exe_ctx.thread->GetIndexID(), exe_ctx.thread->GetID(), s.GetData());
+        log->Printf ("Process::RunThreadPlan(): Resuming thread %u - 0x%4.4x to run thread plan \"%s\".",  exe_ctx.thread->GetIndexID(), exe_ctx.thread->GetID(), s.GetData());
     }
     
     Error resume_error = exe_ctx.process->Resume ();
@@ -2690,10 +2709,10 @@
             // Not really sure what to do if Halt fails here...
             if (log) {
                 if (try_all_threads)
-                    log->Printf ("Running function with timeout: %d timed out, trying with all threads enabled.",
+                    log->Printf ("Process::RunThreadPlan(): Running function with timeout: %d timed out, trying with all threads enabled.",
                                  single_thread_timeout_usec);
                 else
-                    log->Printf ("Running function with timeout: %d timed out, abandoning execution.", 
+                    log->Printf ("Process::RunThreadPlan(): Running function with timeout: %d timed out, abandoning execution.", 
                                  single_thread_timeout_usec);
             }
             
@@ -2703,7 +2722,7 @@
             {
                 timeout_ptr = NULL;
                 if (log)
-                    log->Printf ("Halt succeeded.");
+                    log->Printf ("Process::RunThreadPlan(): Halt succeeded.");
                     
                 // Between the time that we got the timeout and the time we halted, but target
                 // might have actually completed the plan.  If so, we're done.  Note, I call WFE here with a short 
@@ -2715,7 +2734,7 @@
                     stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
                     if (log)
                     {
-                        log->Printf ("Stopped with event: %s", StateAsCString(stop_state));
+                        log->Printf ("Process::RunThreadPlan(): Stopped with event: %s", StateAsCString(stop_state));
                         if (stop_state == lldb::eStateStopped && Process::ProcessEventData::GetInterruptedFromEvent(event_sp.get()))
                             log->Printf ("    Event was the Halt interruption event.");
                     }
@@ -2723,7 +2742,7 @@
                     if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get()))
                     {
                         if (log)
-                            log->Printf ("Even though we timed out, the call plan was done.  Exiting wait loop.");
+                            log->Printf ("Process::RunThreadPlan(): Even though we timed out, the call plan was done.  Exiting wait loop.");
                         return_value = lldb::eExecutionCompleted;
                         break;
                     }
@@ -2734,7 +2753,7 @@
                         
                         thread_plan_sp->SetStopOthers (false);
                         if (log)
-                            log->Printf ("About to resume.");
+                            log->Printf ("Process::RunThreadPlan(): About to resume.");
 
                         exe_ctx.process->Resume();
                         continue;
@@ -2750,7 +2769,7 @@
             {
                 
                 if (log)
-                    log->Printf ("Halt failed: \"%s\", I'm just going to wait a little longer and see if the world gets nicer to me.", 
+                    log->Printf ("Process::RunThreadPlan(): halt failed: error = \"%s\", I'm just going to wait a little longer and see if the world gets nicer to me.", 
                                  halt_error.AsCString());
 //                abort();
                 
@@ -2767,18 +2786,22 @@
         
         stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get());
         if (log)
-            log->Printf("Got event: %s.", StateAsCString(stop_state));
+            log->Printf("Process::RunThreadPlan(): got event: %s.", StateAsCString(stop_state));
         
         if (stop_state == lldb::eStateRunning || stop_state == lldb::eStateStepping)
             continue;
         
         if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get()))
         {
+            if (log)
+                log->Printf("Process::RunThreadPlan(): thread plan is done");
             return_value = lldb::eExecutionCompleted;
             break;
         }
         else if (exe_ctx.thread->WasThreadPlanDiscarded (thread_plan_sp.get()))
         {
+            if (log)
+                log->Printf("Process::RunThreadPlan(): thread plan was discarded");
             return_value = lldb::eExecutionDiscarded;
             break;
         }
@@ -2791,7 +2814,7 @@
                     event_sp->Dump (&s);
                 else
                 {
-                    log->Printf ("Stop event that interrupted us is NULL.");
+                    log->Printf ("Process::RunThreadPlan(): Stop event that interrupted us is NULL.");
                 }
 
                 StreamString ts;
@@ -2860,7 +2883,7 @@
                 if (!GetThreadList().ShouldStop(event_sp.get()))
                 {
                     if (log)
-                        log->Printf("Execution interrupted, but nobody wanted to stop, so we continued: %s %s", 
+                        log->Printf("Process::RunThreadPlan(): execution interrupted, but nobody wanted to stop, so we continued: %s %s", 
                                     s.GetData(), event_explanation);
                     if (single_thread_timeout_usec != 0)
                     {
@@ -2874,7 +2897,7 @@
                 else
                 {
                     if (log)
-                        log->Printf("Execution interrupted: %s %s", s.GetData(), event_explanation);
+                        log->Printf("Process::RunThreadPlan(): execution interrupted: %s %s", s.GetData(), event_explanation);
                 }
             }
             





More information about the lldb-commits mailing list