summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2016-04-07 08:16:10 +0000
committerPavel Labath <labath@google.com>2016-04-07 08:16:10 +0000
commitef40912a2ffd0abd6ed40ccb138a3a7ff04ac8ee (patch)
treeded88766a9f01234d0a94e01a20f84986ddee884 /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
parentd54bae65258a3c7fdd1e9b680a5dc91dba3d9453 (diff)
downloadbcm5719-llvm-ef40912a2ffd0abd6ed40ccb138a3a7ff04ac8ee.tar.gz
bcm5719-llvm-ef40912a2ffd0abd6ed40ccb138a3a7ff04ac8ee.zip
Revert "Reduce code duplication in ProcessGDBRemote"
In turns out this does make a functional change, in case when the inferior hits an int3 that was not placed by the debugger. Backing out for now. llvm-svn: 265647
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp56
1 files changed, 39 insertions, 17 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 0f5b022b631..0e95574cbbe 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2009,15 +2009,40 @@ ProcessGDBRemote::SetThreadStopInfo (lldb::tid_t tid,
{
if (reason.compare("trace") == 0)
{
- if (!SetThreadStopReasonIfAtBreakpoint(*thread_sp))
- thread_sp->SetStopInfo(StopInfo::CreateStopReasonToTrace(*thread_sp));
+ addr_t pc = thread_sp->GetRegisterContext()->GetPC();
+ 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 (bp_site_sp && bp_site_sp->ValidForThisThread(thread_sp.get()))
+ {
+ thread_sp->SetStopInfo(
+ StopInfo::CreateStopReasonWithBreakpointSiteID(*thread_sp, bp_site_sp->GetID()));
+ }
+ else
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
handled = true;
}
else if (reason.compare("breakpoint") == 0)
{
- if (!SetThreadStopReasonIfAtBreakpoint(*thread_sp))
- thread_sp->SetStopInfo(StopInfoSP());
- handled = true;
+ addr_t pc = thread_sp->GetRegisterContext()->GetPC();
+ 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.
+ handled = true;
+ if (bp_site_sp->ValidForThisThread (thread_sp.get()))
+ {
+ thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID()));
+ }
+ else
+ {
+ StopInfoSP invalid_stop_info_sp;
+ thread_sp->SetStopInfo (invalid_stop_info_sp);
+ }
+ }
}
else if (reason.compare("trap") == 0)
{
@@ -2066,12 +2091,20 @@ ProcessGDBRemote::SetThreadStopInfo (lldb::tid_t tid,
}
else if (!signo)
{
+ addr_t pc = thread_sp->GetRegisterContext()->GetPC();
+ 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
// 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 (SetThreadStopReasonIfAtBreakpoint(*thread_sp))
+ if (bp_site_sp && bp_site_sp->ValidForThisThread(thread_sp.get()))
+ {
+ thread_sp->SetStopInfo(
+ StopInfo::CreateStopReasonWithBreakpointSiteID(*thread_sp, bp_site_sp->GetID()));
handled = true;
+ }
}
if (!handled && signo && did_exec == false)
@@ -4931,17 +4964,6 @@ ProcessGDBRemote::ModulesDidLoad (ModuleList &module_list)
m_gdb_comm.ServeSymbolLookups(this);
}
-bool
-ProcessGDBRemote::SetThreadStopReasonIfAtBreakpoint(Thread &thread)
-{
- const addr_t pc = thread.GetRegisterContext()->GetPC();
- lldb::BreakpointSiteSP bp_site_sp = thread.GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
- if (!bp_site_sp || !bp_site_sp->ValidForThisThread(&thread))
- return false;
-
- thread.SetStopInfo(StopInfo::CreateStopReasonWithBreakpointSiteID(thread, bp_site_sp->GetID()));
- return true;
-}
class CommandObjectProcessGDBRemoteSpeedTest: public CommandObjectParsed
{
OpenPOWER on IntegriCloud