Add a "thread specification" class that specifies thread specific breakpoints by name, index, queue or TID.  
Push this through all the breakpoint management code.  Allow this to be set when the breakpoint is created.
Fix the Process classes so that a breakpoint hit that is not for a particular thread is not reported as a 
breakpoint hit event for that thread.
Added a "breakpoint configure" command to allow you to reset any of the thread 
specific options (or the ignore count.)


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@106078 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
index d887b09..2dfbaa1 100644
--- a/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
@@ -1000,16 +1000,20 @@
 
     if (bp_site->HardwarePreferred())
     {
-        ThreadMacOSX *thread = (ThreadMacOSX *)m_thread_list.FindThreadByID(bp_site->GetThreadID()).get();
-        if (thread)
-        {
-            bp_site->SetHardwareIndex (thread->SetHardwareBreakpoint(bp_site));
-            if (bp_site->IsHardware())
-            {
-                bp_site->SetEnabled(true);
-                return error;
-            }
-        }
+        // FIXME: This code doesn't make sense.  Breakpoint sites don't really have single ThreadID's, since one site could be
+        // owned by a number of Locations, each with a different Thread ID.  So either this should run over all the Locations and
+        // set it for all threads owned by those locations, or set it for all threads, and let the thread specific code sort it out.
+        
+//        ThreadMacOSX *thread = (ThreadMacOSX *)m_thread_list.FindThreadByID(bp_site->GetThreadID()).get();
+//        if (thread)
+//        {
+//            bp_site->SetHardwareIndex (thread->SetHardwareBreakpoint(bp_site));
+//            if (bp_site->IsHardware())
+//            {
+//                bp_site->SetEnabled(true);
+//                return error;
+//            }
+//        }
     }
 
     // Just let lldb::Process::EnableSoftwareBreakpoint() handle everything...
@@ -1030,17 +1034,6 @@
 
     if (bp_site->IsHardware())
     {
-        ThreadMacOSX *thread = (ThreadMacOSX *)m_thread_list.FindThreadByID(bp_site->GetThreadID()).get();
-        if (thread)
-        {
-            if (thread->ClearHardwareBreakpoint(bp_site))
-            {
-                bp_site->SetEnabled(false);
-                if (log)
-                    log->Printf ("ProcessMacOSX::DisableBreakpoint (site_id = %d) addr = 0x%8.8llx -- SUCCESS (hardware)", site_id, (uint64_t)addr);
-                return error;
-            }
-        }
         error.SetErrorString("hardware breakpoints are no supported");
         return error;
     }
@@ -1068,20 +1061,8 @@
         }
         else
         {
-            ThreadMacOSX *thread = (ThreadMacOSX *)m_thread_list.FindThreadByID(wp->GetThreadID()).get();
-            if (thread)
-            {
-                wp->SetHardwareIndex (thread->SetHardwareWatchpoint (wp));
-                if (wp->IsHardware ())
-                {
-                    wp->SetEnabled(true);
-                    return error;
-                }
-            }
-            else
-            {
-                error.SetErrorString("Watchpoints currently only support thread specific watchpoints.");
-            }
+            // Watchpoints aren't supported at present.
+            error.SetErrorString("Watchpoints aren't currently supported.");
         }
     }
     return error;
@@ -1103,17 +1084,7 @@
 
         if (wp->IsHardware())
         {
-            ThreadMacOSX *thread = (ThreadMacOSX *)m_thread_list.FindThreadByID(wp->GetThreadID()).get();
-            if (thread)
-            {
-                if (thread->ClearHardwareWatchpoint (wp))
-                {
-                    wp->SetEnabled(false);
-                    if (log)
-                        log->Printf ("ProcessMacOSX::Disablewatchpoint (watchID = %d) addr = 0x%8.8llx (hardware) => success", watchID, (uint64_t)addr);
-                    return error;
-                }
-            }
+            error.SetErrorString("Watchpoints aren't currently supported.");
         }
         // TODO: clear software watchpoints if we implement them
         error.SetErrorToGenericError();
diff --git a/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp b/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
index 46d84a8..8264076 100644
--- a/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp
@@ -81,11 +81,19 @@
             if (data_0 == MACH_SOFTWARE_BREAKPOINT_DATA_0)
             {
                 lldb::addr_t pc = GetRegisterContext()->GetPC();
-                lldb::user_id_t break_id = m_process.GetBreakpointSiteList().FindIDByAddress(pc);
-                if (break_id != LLDB_INVALID_BREAK_ID)
+                lldb::BreakpointSiteSP bp_site_sp = m_process.GetBreakpointSiteList().FindByAddress(pc);
+                if (bp_site_sp)
                 {
-                    stop_info->Clear ();
-                    stop_info->SetStopReasonWithBreakpointSiteID (break_id);
+                    if (bp_site_sp->ValidForThisThread (this))
+                    {
+                        stop_info->Clear ();
+                        stop_info->SetStopReasonWithBreakpointSiteID (GetID());
+                    }
+                    else
+                    {
+                        stop_info->Clear ();
+                        stop_info->SetStopReasonToNone();
+                    }
                     return success;
                 }
             }
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 81369c2..a528120 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1034,8 +1034,8 @@
                     else if (exc_type == EXC_BREAKPOINT && exc_data[0] == MACH_EXC_DATA0_SOFTWARE_BREAKPOINT)
                     {
                         addr_t pc = gdb_thread->GetRegisterContext()->GetPC();
-                        user_id_t break_id = GetBreakpointSiteList().FindIDByAddress(pc);
-                        if (break_id == LLDB_INVALID_BREAK_ID)
+                        lldb::BreakpointSiteSP bp_site_sp = GetBreakpointSiteList().FindByAddress(pc);
+                        if (!bp_site_sp)
                         {
                             //log->Printf("got EXC_BREAKPOINT at 0x%llx but didn't find a breakpoint site.\n", pc);
                             stop_info.SetStopReasonWithException(exc_type, exc_data.size());
@@ -1044,8 +1044,17 @@
                         }
                         else
                         {
-                            stop_info.Clear ();
-                            stop_info.SetStopReasonWithBreakpointSiteID (break_id);
+                            if (bp_site_sp->ValidForThisThread (thread_sp.get()))
+                            {
+                                stop_info.Clear ();
+                                stop_info.SetStopReasonWithBreakpointSiteID (bp_site_sp->GetID());
+                            }
+                            else
+                            {
+                                stop_info.Clear ();
+                                stop_info.SetStopReasonToNone();
+                            }
+
                         }
                     }
 #endif