[lldb][nfc] Deindent ProcessGDBRemote::SetThreadStopInfo by two levels
This commit is contained in:
parent
8d692b4b8d
commit
b32931c5b3
|
@ -1607,15 +1607,17 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
// queue_serial are valid
|
||||
LazyBool associated_with_dispatch_queue, addr_t dispatch_queue_t,
|
||||
std::string &queue_name, QueueKind queue_kind, uint64_t queue_serial) {
|
||||
|
||||
if (tid == LLDB_INVALID_THREAD_ID)
|
||||
return nullptr;
|
||||
|
||||
ThreadSP thread_sp;
|
||||
if (tid != LLDB_INVALID_THREAD_ID) {
|
||||
// Scope for "locker" below
|
||||
{
|
||||
// m_thread_list_real does have its own mutex, but we need to hold onto
|
||||
// the mutex between the call to m_thread_list_real.FindThreadByID(...)
|
||||
// and the m_thread_list_real.AddThread(...) so it doesn't change on us
|
||||
std::lock_guard<std::recursive_mutex> guard(
|
||||
m_thread_list_real.GetMutex());
|
||||
// m_thread_list_real does have its own mutex, but we need to hold onto the
|
||||
// mutex between the call to m_thread_list_real.FindThreadByID(...) and the
|
||||
// m_thread_list_real.AddThread(...) so it doesn't change on us
|
||||
std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex());
|
||||
thread_sp = m_thread_list_real.FindThreadByProtocolID(tid, false);
|
||||
|
||||
if (!thread_sp) {
|
||||
|
@ -1625,25 +1627,21 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
}
|
||||
}
|
||||
|
||||
if (thread_sp) {
|
||||
ThreadGDBRemote *gdb_thread =
|
||||
static_cast<ThreadGDBRemote *>(thread_sp.get());
|
||||
ThreadGDBRemote *gdb_thread = static_cast<ThreadGDBRemote *>(thread_sp.get());
|
||||
RegisterContextSP gdb_reg_ctx_sp(gdb_thread->GetRegisterContext());
|
||||
|
||||
gdb_reg_ctx_sp->InvalidateIfNeeded(true);
|
||||
|
||||
auto iter = std::find(m_thread_ids.begin(), m_thread_ids.end(), tid);
|
||||
if (iter != m_thread_ids.end()) {
|
||||
if (iter != m_thread_ids.end())
|
||||
SetThreadPc(thread_sp, iter - m_thread_ids.begin());
|
||||
}
|
||||
|
||||
for (const auto &pair : expedited_register_map) {
|
||||
StringExtractor reg_value_extractor(pair.second);
|
||||
WritableDataBufferSP buffer_sp(new DataBufferHeap(
|
||||
reg_value_extractor.GetStringRef().size() / 2, 0));
|
||||
WritableDataBufferSP buffer_sp(
|
||||
new DataBufferHeap(reg_value_extractor.GetStringRef().size() / 2, 0));
|
||||
reg_value_extractor.GetHexBytes(buffer_sp->GetData(), '\xcc');
|
||||
uint32_t lldb_regnum =
|
||||
gdb_reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
|
||||
uint32_t lldb_regnum = gdb_reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
|
||||
eRegisterKindProcessPlugin, pair.first);
|
||||
gdb_thread->PrivateSetRegisterValue(lldb_regnum, buffer_sp->GetData());
|
||||
}
|
||||
|
@ -1664,23 +1662,21 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
thread_sp->SetName(thread_name.empty() ? nullptr : thread_name.c_str());
|
||||
|
||||
gdb_thread->SetThreadDispatchQAddr(thread_dispatch_qaddr);
|
||||
// Check if the GDB server was able to provide the queue name, kind and
|
||||
// serial number
|
||||
// Check if the GDB server was able to provide the queue name, kind and serial
|
||||
// number
|
||||
if (queue_vars_valid)
|
||||
gdb_thread->SetQueueInfo(std::move(queue_name), queue_kind,
|
||||
queue_serial, dispatch_queue_t,
|
||||
associated_with_dispatch_queue);
|
||||
gdb_thread->SetQueueInfo(std::move(queue_name), queue_kind, queue_serial,
|
||||
dispatch_queue_t, associated_with_dispatch_queue);
|
||||
else
|
||||
gdb_thread->ClearQueueInfo();
|
||||
|
||||
gdb_thread->SetAssociatedWithLibdispatchQueue(
|
||||
associated_with_dispatch_queue);
|
||||
gdb_thread->SetAssociatedWithLibdispatchQueue(associated_with_dispatch_queue);
|
||||
|
||||
if (dispatch_queue_t != LLDB_INVALID_ADDRESS)
|
||||
gdb_thread->SetQueueLibdispatchQueueAddress(dispatch_queue_t);
|
||||
|
||||
// Make sure we update our thread stop reason just once, but don't
|
||||
// overwrite the stop info for threads that haven't moved:
|
||||
// Make sure we update our thread stop reason just once, but don't overwrite
|
||||
// the stop info for threads that haven't moved:
|
||||
StopInfoSP current_stop_info_sp = thread_sp->GetPrivateStopInfo(false);
|
||||
if (thread_sp->GetTemporaryResumeState() == eStateSuspended &&
|
||||
current_stop_info_sp) {
|
||||
|
@ -1690,10 +1686,9 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
|
||||
if (!thread_sp->StopInfoIsUpToDate()) {
|
||||
thread_sp->SetStopInfo(StopInfoSP());
|
||||
// If there's a memory thread backed by this thread, we need to use it
|
||||
// to calculate StopInfo.
|
||||
if (ThreadSP memory_thread_sp =
|
||||
m_thread_list.GetBackingThread(thread_sp))
|
||||
// If there's a memory thread backed by this thread, we need to use it to
|
||||
// calculate StopInfo.
|
||||
if (ThreadSP memory_thread_sp = m_thread_list.GetBackingThread(thread_sp))
|
||||
thread_sp = memory_thread_sp;
|
||||
|
||||
if (exc_type != 0) {
|
||||
|
@ -1711,13 +1706,12 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
if (!reason.empty()) {
|
||||
if (reason == "trace") {
|
||||
addr_t pc = thread_sp->GetRegisterContext()->GetPC();
|
||||
lldb::BreakpointSiteSP bp_site_sp = thread_sp->GetProcess()
|
||||
->GetBreakpointSiteList()
|
||||
.FindByAddress(pc);
|
||||
lldb::BreakpointSiteSP bp_site_sp =
|
||||
thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
|
||||
pc);
|
||||
|
||||
// If the current pc is a breakpoint site then the StopInfo
|
||||
// should be set to Breakpoint Otherwise, it will be set to
|
||||
// Trace.
|
||||
// If the current pc is a breakpoint site then the StopInfo should be
|
||||
// set to Breakpoint Otherwise, it will be set to Trace.
|
||||
if (bp_site_sp && bp_site_sp->ValidForThisThread(*thread_sp)) {
|
||||
thread_sp->SetStopInfo(
|
||||
StopInfo::CreateStopReasonWithBreakpointSiteID(
|
||||
|
@ -1728,15 +1722,15 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
handled = true;
|
||||
} else if (reason == "breakpoint") {
|
||||
addr_t pc = thread_sp->GetRegisterContext()->GetPC();
|
||||
lldb::BreakpointSiteSP bp_site_sp = thread_sp->GetProcess()
|
||||
->GetBreakpointSiteList()
|
||||
.FindByAddress(pc);
|
||||
lldb::BreakpointSiteSP bp_site_sp =
|
||||
thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
|
||||
pc);
|
||||
if (bp_site_sp) {
|
||||
// If the breakpoint is for this thread, then we'll report the
|
||||
// hit, but if it is for another thread, we can just report no
|
||||
// reason. We don't need to worry about stepping over the
|
||||
// breakpoint here, that will be taken care of when the thread
|
||||
// resumes and notices that there's a breakpoint under the pc.
|
||||
// If the breakpoint is for this thread, then we'll report the hit,
|
||||
// but if it is for another thread, we can just report no reason.
|
||||
// We don't need to worry about stepping over the breakpoint here,
|
||||
// that will be taken care of when the thread resumes and notices
|
||||
// that there's a breakpoint under the pc.
|
||||
handled = true;
|
||||
if (bp_site_sp->ValidForThisThread(*thread_sp)) {
|
||||
thread_sp->SetStopInfo(
|
||||
|
@ -1762,11 +1756,10 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
core <= ArchSpec::kCore_mips_last) ||
|
||||
(core >= ArchSpec::eCore_arm_generic &&
|
||||
core <= ArchSpec::eCore_arm_aarch64))
|
||||
wp_sp = GetTarget().GetWatchpointList().FindByAddress(
|
||||
wp_hit_addr);
|
||||
if (!wp_sp)
|
||||
wp_sp =
|
||||
GetTarget().GetWatchpointList().FindByAddress(wp_addr);
|
||||
GetTarget().GetWatchpointList().FindByAddress(wp_hit_addr);
|
||||
if (!wp_sp)
|
||||
wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_addr);
|
||||
if (wp_sp) {
|
||||
wp_sp->SetHardwareIndex(wp_index);
|
||||
watch_id = wp_sp->GetID();
|
||||
|
@ -1793,19 +1786,17 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
*thread_sp, description.c_str()));
|
||||
} else if (reason == "fork") {
|
||||
StringExtractor desc_extractor(description.c_str());
|
||||
lldb::pid_t child_pid = desc_extractor.GetU64(
|
||||
LLDB_INVALID_PROCESS_ID);
|
||||
lldb::tid_t child_tid = desc_extractor.GetU64(
|
||||
LLDB_INVALID_THREAD_ID);
|
||||
thread_sp->SetStopInfo(StopInfo::CreateStopReasonFork(
|
||||
*thread_sp, child_pid, child_tid));
|
||||
lldb::pid_t child_pid =
|
||||
desc_extractor.GetU64(LLDB_INVALID_PROCESS_ID);
|
||||
lldb::tid_t child_tid = desc_extractor.GetU64(LLDB_INVALID_THREAD_ID);
|
||||
thread_sp->SetStopInfo(
|
||||
StopInfo::CreateStopReasonFork(*thread_sp, child_pid, child_tid));
|
||||
handled = true;
|
||||
} else if (reason == "vfork") {
|
||||
StringExtractor desc_extractor(description.c_str());
|
||||
lldb::pid_t child_pid = desc_extractor.GetU64(
|
||||
LLDB_INVALID_PROCESS_ID);
|
||||
lldb::tid_t child_tid = desc_extractor.GetU64(
|
||||
LLDB_INVALID_THREAD_ID);
|
||||
lldb::pid_t child_pid =
|
||||
desc_extractor.GetU64(LLDB_INVALID_PROCESS_ID);
|
||||
lldb::tid_t child_tid = desc_extractor.GetU64(LLDB_INVALID_THREAD_ID);
|
||||
thread_sp->SetStopInfo(StopInfo::CreateStopReasonVFork(
|
||||
*thread_sp, child_pid, child_tid));
|
||||
handled = true;
|
||||
|
@ -1817,17 +1808,15 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
} else if (!signo) {
|
||||
addr_t pc = thread_sp->GetRegisterContext()->GetPC();
|
||||
lldb::BreakpointSiteSP bp_site_sp =
|
||||
thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
|
||||
pc);
|
||||
thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
|
||||
|
||||
// If the current pc is a breakpoint site then the StopInfo should
|
||||
// be set to Breakpoint even though the remote stub did not set it
|
||||
// as such. This can happen when the thread is involuntarily
|
||||
// interrupted (e.g. due to stops on other threads) just as it is
|
||||
// about to execute the breakpoint instruction.
|
||||
// If the current pc is a breakpoint site then the StopInfo should be
|
||||
// set to Breakpoint even though the remote stub did not set it as such.
|
||||
// This can happen when the thread is involuntarily interrupted (e.g.
|
||||
// due to stops on other threads) just as it is about to execute the
|
||||
// breakpoint instruction.
|
||||
if (bp_site_sp && bp_site_sp->ValidForThisThread(*thread_sp)) {
|
||||
thread_sp->SetStopInfo(
|
||||
StopInfo::CreateStopReasonWithBreakpointSiteID(
|
||||
thread_sp->SetStopInfo(StopInfo::CreateStopReasonWithBreakpointSiteID(
|
||||
*thread_sp, bp_site_sp->GetID()));
|
||||
handled = true;
|
||||
}
|
||||
|
@ -1838,18 +1827,18 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
// Currently we are going to assume SIGTRAP means we are either
|
||||
// hitting a breakpoint or hardware single stepping.
|
||||
handled = true;
|
||||
addr_t pc = thread_sp->GetRegisterContext()->GetPC() +
|
||||
m_breakpoint_pc_offset;
|
||||
lldb::BreakpointSiteSP bp_site_sp = thread_sp->GetProcess()
|
||||
->GetBreakpointSiteList()
|
||||
.FindByAddress(pc);
|
||||
addr_t pc =
|
||||
thread_sp->GetRegisterContext()->GetPC() + m_breakpoint_pc_offset;
|
||||
lldb::BreakpointSiteSP bp_site_sp =
|
||||
thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(
|
||||
pc);
|
||||
|
||||
if (bp_site_sp) {
|
||||
// If the breakpoint is for this thread, then we'll report the
|
||||
// hit, but if it is for another thread, we can just report no
|
||||
// reason. We don't need to worry about stepping over the
|
||||
// breakpoint here, that will be taken care of when the thread
|
||||
// resumes and notices that there's a breakpoint under the pc.
|
||||
// If the breakpoint is for this thread, then we'll report the hit,
|
||||
// but if it is for another thread, we can just report no reason.
|
||||
// We don't need to worry about stepping over the breakpoint here,
|
||||
// that will be taken care of when the thread resumes and notices
|
||||
// that there's a breakpoint under the pc.
|
||||
if (bp_site_sp->ValidForThisThread(*thread_sp)) {
|
||||
if (m_breakpoint_pc_offset != 0)
|
||||
thread_sp->GetRegisterContext()->SetPC(pc);
|
||||
|
@ -1861,10 +1850,10 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
thread_sp->SetStopInfo(invalid_stop_info_sp);
|
||||
}
|
||||
} else {
|
||||
// If we were stepping then assume the stop was the result of
|
||||
// the trace. If we were not stepping then report the SIGTRAP.
|
||||
// FIXME: We are still missing the case where we single step
|
||||
// over a trap instruction.
|
||||
// If we were stepping then assume the stop was the result of the
|
||||
// trace. If we were not stepping then report the SIGTRAP.
|
||||
// FIXME: We are still missing the case where we single step over a
|
||||
// trap instruction.
|
||||
if (thread_sp->GetTemporaryResumeState() == eStateStepping)
|
||||
thread_sp->SetStopInfo(
|
||||
StopInfo::CreateStopReasonToTrace(*thread_sp));
|
||||
|
@ -1891,8 +1880,6 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return thread_sp;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue