diff options
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 53 | ||||
-rw-r--r-- | lldb/source/Target/Process.cpp | 22 |
2 files changed, 63 insertions, 12 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index ffec00e6d6f..6139031cefb 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1181,18 +1181,35 @@ ProcessGDBRemote::InterruptIfRunning { Error error; - if (m_gdb_comm.IsRunning()) + LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + + 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", + discard_thread_plans, + catch_stop_event, + resume_private_state_thread, + is_running); + + if (catch_stop_event) + { + if (log) + log->Printf ("ProcessGDBRemote::InterruptIfRunning() pausing private state thread"); + PausePrivateStateThread(); + } + + if (discard_thread_plans) + { + if (log) + log->Printf ("ProcessGDBRemote::InterruptIfRunning() discarding all thread plans"); + m_thread_list.DiscardThreadPlans(); + } + if (is_running) { bool timed_out = false; bool sent_interrupt = false; Mutex::Locker locker; - if (catch_stop_event) - PausePrivateStateThread(); - - if (discard_thread_plans) - m_thread_list.DiscardThreadPlans(); - //m_debugserver_pid = LLDB_INVALID_PROCESS_ID; if (!m_gdb_comm.SendInterrupt (locker, 1, sent_interrupt, timed_out)) { @@ -1205,20 +1222,27 @@ ProcessGDBRemote::InterruptIfRunning return error; } - if (catch_stop_event) { TimeValue timeout_time; timeout_time = TimeValue::Now(); timeout_time.OffsetWithSeconds(1); StateType state = WaitForProcessStopPrivate (&timeout_time, stop_event_sp); + + const bool timed_out = state == eStateInvalid; + if (log) + log->Printf ("ProcessGDBRemote::InterruptIfRunning() catch stop event: state = %s, timed-out=%i", StateAsCString(state), timed_out); - if (state == eStateInvalid) + if (timed_out) error.SetErrorString("unable to verify target stopped"); } if (catch_stop_event && resume_private_state_thread) + { + if (log) + log->Printf ("ProcessGDBRemote::InterruptIfRunning() resuming private state thread"); ResumePrivateStateThread(); + } } return error; } @@ -1226,6 +1250,10 @@ ProcessGDBRemote::InterruptIfRunning Error ProcessGDBRemote::WillDetach () { + LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + if (log) + log->Printf ("ProcessGDBRemote::WillDetach()"); + bool discard_thread_plans = true; bool catch_stop_event = true; bool resume_private_state_thread = false; // DoDetach will resume the thread @@ -1269,11 +1297,16 @@ ProcessGDBRemote::DoDetach() 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); + return InterruptIfRunning (discard_thread_plans, catch_stop_event, resume_private_state_thread, event_sp); + + } Error diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index f0b79b99ff0..c7d511e4887 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1398,13 +1398,31 @@ Process::AllocateMemory(size_t size, uint32_t permissions, Error &error) { // Fixme: we should track the blocks we've allocated, and clean them up... // We could even do our own allocator here if that ends up being more efficient. - return DoAllocateMemory (size, permissions, error); + addr_t allocated_addr = DoAllocateMemory (size, permissions, error); + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); + if (log) + log->Printf("Process::AllocateMemory(size = %zu, permissions=%c%c%c) => 0x%16.16llx (m_stop_id = %u)", + size, + permissions & ePermissionsReadable ? 'r' : '-', + permissions & ePermissionsWritable ? 'w' : '-', + permissions & ePermissionsExecutable ? 'x' : '-', + (uint64_t)allocated_addr, + m_stop_id); + return allocated_addr; } Error Process::DeallocateMemory (addr_t ptr) { - return DoDeallocateMemory (ptr); + Error error(DoDeallocateMemory (ptr)); + + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); + if (log) + log->Printf("Process::DeallocateMemory(addr=0x%16.16llx) => err = %s (m_stop_id = %u)", + ptr, + error.AsCString("SUCCESS"), + m_stop_id); + return error; } |