labath created this revision.
labath added a reviewer: clayborg.
labath added a subscriber: lldb-commits.

This resolves a similar problem as D16720 (which handled the case when we 
single-step onto a
breakpoint), but this one deals with involutary stops: when we stop a thread 
(e.g. because
another thread has hit a breakpont and we are doing a full stop), we can end up 
stopping it right
before it executes a breakpoint instruction. In this case, the stop reason will 
be empty, but we
will still step over the breakpoint when do the next resume, thereby missing a 
breakpoint hit.

I have observed this happening in TestConcurrentEvents, but I have no idea how 
to reproduce this
behavior more reliably.

http://reviews.llvm.org/D18692

Files:
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2089,6 +2089,23 @@
                             handled = true;
                         }
                     }
+                    else
+                    {
+                        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 (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)
                     {


Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2089,6 +2089,23 @@
                             handled = true;
                         }
                     }
+                    else
+                    {
+                        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 (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)
                     {
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to