forked from OSchip/llvm-project
Improved process logging for both lldb_private::Process and ProcessGDBRemote.
llvm-svn: 124080
This commit is contained in:
parent
c5efca47fc
commit
b2daec9b04
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue