StopInfo.h revision b344843f75ef893762c93fd0a22d2d45712ce74d
1//===-- StopInfo.h ----------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef liblldb_StopInfo_h_ 11#define liblldb_StopInfo_h_ 12 13// C Includes 14// C++ Includes 15// Other libraries and framework includes 16// Project includes 17#include "lldb/lldb-public.h" 18 19namespace lldb_private { 20 21class StopInfo 22{ 23public: 24 //------------------------------------------------------------------ 25 // Constructors and Destructors 26 //------------------------------------------------------------------ 27 StopInfo (Thread &thread, uint64_t value); 28 29 virtual ~StopInfo() 30 { 31 } 32 33 34 bool 35 IsValid () const; 36 37 Thread & 38 GetThread() 39 { 40 return m_thread; 41 } 42 43 const Thread & 44 GetThread() const 45 { 46 return m_thread; 47 } 48 49 // The value of the StopInfo depends on the StopReason. 50 // StopReason Meaning 51 // ---------------------------------------------- 52 // eStopReasonBreakpoint BreakpointSiteID 53 // eStopReasonSignal Signal number 54 // eStopReasonWatchpoint WatchpointSiteID 55 // eStopReasonPlanComplete No significance 56 57 uint64_t 58 GetValue() const 59 { 60 return m_value; 61 } 62 63 virtual lldb::StopReason 64 GetStopReason () const = 0; 65 66 // Perform any action that is associated with this stop. This is done as the 67 // Event is removed from the event queue. 68 virtual void 69 PerformAction (Event *event_ptr) 70 { 71 } 72 73 // Stop the thread by default. Subclasses can override this to allow 74 // the thread to continue if desired. 75 virtual bool 76 ShouldStop (Event *event_ptr) 77 { 78 return true; 79 } 80 81 // If should stop returns false, check if we should notify of this event 82 virtual bool 83 ShouldNotify (Event *event_ptr) 84 { 85 return false; 86 } 87 88 virtual void 89 WillResume (lldb::StateType resume_state) 90 { 91 // By default, don't do anything 92 } 93 94 virtual const char * 95 GetDescription () = 0; 96 97 98 static lldb::StopInfoSP 99 CreateStopReasonWithBreakpointSiteID (Thread &thread, lldb::break_id_t break_id); 100 101 // This creates a StopInfo for the thread where the should_stop is already set, and won't be recalculated. 102 static lldb::StopInfoSP 103 CreateStopReasonWithBreakpointSiteID (Thread &thread, lldb::break_id_t break_id, bool should_stop); 104 105 static lldb::StopInfoSP 106 CreateStopReasonWithWatchpointID (Thread &thread, lldb::break_id_t watch_id); 107 108 static lldb::StopInfoSP 109 CreateStopReasonWithSignal (Thread &thread, int signo); 110 111 static lldb::StopInfoSP 112 CreateStopReasonToTrace (Thread &thread); 113 114 static lldb::StopInfoSP 115 CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan); 116 117protected: 118 //------------------------------------------------------------------ 119 // Classes that inherit from StackID can see and modify these 120 //------------------------------------------------------------------ 121 Thread & m_thread; // The thread corresponding to the stop reason. 122 uint32_t m_stop_id; // The process stop ID for which this stop info is valid 123 uint64_t m_value; // A generic value that can be used for things pertaining to this stop info 124private: 125 friend class Thread; 126 127 // MakeStopInfoValid is necessary to allow saved stop infos to resurrect themselves as valid. It should 128 // only need to be called by Thread::RestoreThreadStateFromCheckpoint. 129 void 130 MakeStopInfoValid (); 131 132 DISALLOW_COPY_AND_ASSIGN (StopInfo); 133}; 134 135 136} // namespace lldb_private 137 138#endif // liblldb_StopInfo_h_ 139