[Lldb-commits] [lldb] r132615 - in /lldb/trunk: include/lldb/Target/StopInfo.h source/Core/EmulateInstruction.cpp source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/StopInfo.cpp

Greg Clayton gclayton at apple.com
Fri Jun 3 18:26:30 PDT 2011


Author: gclayton
Date: Fri Jun  3 20:26:29 2011
New Revision: 132615

URL: http://llvm.org/viewvc/llvm-project?rev=132615&view=rev
Log:
Created a std::string in the base StopInfo class for the description and
cleaned up all base classes that had their own copy. Added a SetDescription
accessor to the StopInfo class.


Modified:
    lldb/trunk/include/lldb/Target/StopInfo.h
    lldb/trunk/source/Core/EmulateInstruction.cpp
    lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Target/StopInfo.cpp

Modified: lldb/trunk/include/lldb/Target/StopInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StopInfo.h?rev=132615&r1=132614&r2=132615&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StopInfo.h (original)
+++ lldb/trunk/include/lldb/Target/StopInfo.h Fri Jun  3 20:26:29 2011
@@ -12,6 +12,8 @@
 
 // C Includes
 // C++ Includes
+#include <string>
+
 // Other libraries and framework includes
 // Project includes
 #include "lldb/lldb-public.h"
@@ -92,8 +94,19 @@
     }
     
     virtual const char *
-    GetDescription () = 0;
+    GetDescription ()
+    {
+        return m_description.c_str();
+    }
 
+    virtual void
+    SetDescription (const char *desc_cstr)
+    {
+        if (desc_cstr && desc_cstr[0])
+            m_description.assign (desc_cstr);
+        else
+            m_description.clear();
+    }
 
     static lldb::StopInfoSP
     CreateStopReasonWithBreakpointSiteID (Thread &thread, lldb::break_id_t break_id);
@@ -114,6 +127,9 @@
     static lldb::StopInfoSP
     CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan);
 
+    static lldb::StopInfoSP
+    CreateStopReasonWithException (Thread &thread, const char *description);
+
 protected:
     //------------------------------------------------------------------
     // Classes that inherit from StackID can see and modify these
@@ -121,6 +137,7 @@
     Thread &        m_thread;   // The thread corresponding to the stop reason.
     uint32_t        m_stop_id;  // The process stop ID for which this stop info is valid
     uint64_t        m_value;    // A generic value that can be used for things pertaining to this stop info
+    std::string     m_description; // A textual description describing this stop.
 private:
     friend class Thread;
     

Modified: lldb/trunk/source/Core/EmulateInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=132615&r1=132614&r2=132615&view=diff
==============================================================================
--- lldb/trunk/source/Core/EmulateInstruction.cpp (original)
+++ lldb/trunk/source/Core/EmulateInstruction.cpp Fri Jun  3 20:26:29 2011
@@ -454,6 +454,10 @@
             strm.PutCString ("adjust sp");
             break;
             
+        case eContextSetFramePointer:
+            strm.PutCString ("set frame pointer");
+            break;
+            
         case eContextAdjustBaseRegister:
             strm.PutCString ("adjusting (writing value back to) a base register");
             break;

Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=132615&r1=132614&r2=132615&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Fri Jun  3 20:26:29 2011
@@ -391,9 +391,6 @@
         pc_reg_num == LLDB_INVALID_REGNUM)
         return false;
 
-    unwind_plan.Clear();
-    unwind_plan.SetRegisterKind (eRegisterKindDWARF);
-    
     UnwindPlan::Row row;
     
     // Our previous Call Frame Address is the stack pointer
@@ -439,7 +436,7 @@
         return false;
     
     UnwindPlan::Row row;    
-    const int32_t ptr_size = 8;
+    const int32_t ptr_size = 4;
     
     unwind_plan.SetRegisterKind (eRegisterKindGeneric);
     row.SetCFARegister (fp_reg_num);

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=132615&r1=132614&r2=132615&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Jun  3 20:26:29 2011
@@ -1120,6 +1120,8 @@
             std::string name;
             std::string value;
             std::string thread_name;
+            std::string reason;
+            std::string description;
             uint32_t exc_type = 0;
             std::vector<addr_t> exc_data;
             uint32_t tid = LLDB_INVALID_THREAD_ID;
@@ -1174,6 +1176,18 @@
                 {
                     thread_dispatch_qaddr = Args::StringToUInt64 (value.c_str(), 0, 16);
                 }
+                else if (name.compare("reason") == 0)
+                {
+                    reason.swap(value);
+                }
+                else if (name.compare("description") == 0)
+                {
+                    StringExtractor desc_extractor;
+                    // Swap "value" over into "name_extractor"
+                    desc_extractor.GetStringRef().swap(value);
+                    // Now convert the HEX bytes into a string value
+                    desc_extractor.GetHexByteString (thread_name);
+                }
                 else if (name.size() == 2 && ::isxdigit(name[0]) && ::isxdigit(name[1]))
                 {
                     // We have a register number that contains an expedited
@@ -1218,8 +1232,83 @@
                                                                                                        exc_data_size >= 1 ? exc_data[0] : 0,
                                                                                                        exc_data_size >= 2 ? exc_data[1] : 0));
                 }
-                else if (signo)
+                else
                 {
+                    bool handled = false;
+                    if (!reason.empty())
+                    {
+                        if (reason.compare("trace") == 0)
+                        {
+                            gdb_thread->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
+                            handled = true;
+                        }
+                        else if (reason.compare("breakpoint") == 0)
+                        {
+                            addr_t pc = gdb_thread->GetRegisterContext()->GetPC();
+                            lldb::BreakpointSiteSP bp_site_sp = gdb_thread->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 (bp_site_sp->ValidForThisThread (gdb_thread))
+                                {
+                                    gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID()));
+                                    handled = true;
+                                }
+                            }
+                            
+                            if (!handled)
+                            {
+                                gdb_thread->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
+                            }
+                        }
+                        else if (reason.compare("trap") == 0)
+                        {
+                            // Let the trap just use the standard signal stop reason below...
+                        }
+                        else if (reason.compare("watchpoint") == 0)
+                        {
+                            break_id_t watch_id = LLDB_INVALID_WATCH_ID;
+                            // TODO: locate the watchpoint somehow...
+                            gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithWatchpointID (*thread_sp, watch_id));
+                            handled = true;
+                        }
+                        else if (reason.compare("exception") == 0)
+                        {
+                            gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithException(*thread_sp, description.c_str()));
+                            handled = true;
+                        }
+                    }
+                    
+                    if (signo)
+                    {
+                        if (signo == SIGTRAP)
+                        {
+                            // Currently we are going to assume SIGTRAP means we are either
+                            // hitting a breakpoint or hardware single stepping. 
+                            addr_t pc = gdb_thread->GetRegisterContext()->GetPC();
+                            lldb::BreakpointSiteSP bp_site_sp = gdb_thread->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 (bp_site_sp->ValidForThisThread (gdb_thread))
+                                {
+                                    gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID()));
+                                    handled = true;
+                                }
+                            }
+                            if (!handled)
+                            {
+                                // TODO: check for breakpoint or trap opcode in case there is a hard 
+                                // coded software trap
+                                gdb_thread->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp));
+                                handled = true;
+                            }
+                        }
+                        if (!handled)
                     gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo));
                 }
                 else
@@ -1227,6 +1316,20 @@
                     StopInfoSP invalid_stop_info_sp;
                     gdb_thread->SetStopInfo (invalid_stop_info_sp);
                 }
+                    
+                    if (!description.empty())
+                    {
+                        lldb::StopInfoSP stop_info_sp (gdb_thread->GetStopInfo ());
+                        if (stop_info_sp)
+                        {
+                            stop_info_sp->SetDescription (description.c_str());
+            }
+                        else
+                        {
+                            gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithException (*thread_sp, description.c_str()));
+                        }
+                    }
+                }
             }
             return eStateStopped;
         }

Modified: lldb/trunk/source/Target/StopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=132615&r1=132614&r2=132615&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Fri Jun  3 20:26:29 2011
@@ -253,8 +253,7 @@
 public:
 
     StopInfoUnixSignal (Thread &thread, int signo) :
-        StopInfo (thread, signo),
-        m_description()
+        StopInfo (thread, signo)
     {
     }
     
@@ -306,9 +305,6 @@
         }
         return m_description.c_str();
     }
-
-private:
-    std::string m_description;
 };
 
 //----------------------------------------------------------------------
@@ -337,7 +333,47 @@
     virtual const char *
     GetDescription ()
     {
+        if (m_description.empty())
         return "trace";
+        else
+            return m_description.c_str();
+    }
+};
+
+
+//----------------------------------------------------------------------
+// StopInfoException
+//----------------------------------------------------------------------
+
+class StopInfoException : public StopInfo
+{
+public:
+    
+    StopInfoException (Thread &thread, const char *description) :
+        StopInfo (thread, LLDB_INVALID_UID)
+    {
+        if (description)
+            SetDescription (description);
+    }
+    
+    virtual 
+    ~StopInfoException ()
+    {
+    }
+    
+    virtual StopReason
+    GetStopReason () const
+    {
+        return eStopReasonException;
+    }
+    
+    virtual const char *
+    GetDescription ()
+    {
+        if (m_description.empty())
+            return "exception";
+        else
+            return m_description.c_str();
     }
 };
 
@@ -380,7 +416,6 @@
 
 private:
     ThreadPlanSP m_plan_sp;
-    std::string m_description;
 };
 
 StopInfoSP
@@ -418,3 +453,9 @@
 {
     return StopInfoSP (new StopInfoThreadPlan (plan_sp));
 }
+
+StopInfoSP
+StopInfo::CreateStopReasonWithException (Thread &thread, const char *description)
+{
+    return StopInfoSP (new StopInfoException (thread, description));
+}





More information about the lldb-commits mailing list