Index: src/trusted/gdb_rsp/target.h |
=================================================================== |
--- src/trusted/gdb_rsp/target.h (revision 3879) |
+++ src/trusted/gdb_rsp/target.h (working copy) |
@@ -48,12 +48,6 @@ |
FAILED = 3 |
}; |
- enum State { |
- UNINIT = 0, |
- RUNNING = 1, |
- STOPPED = 2 |
- }; |
- |
typedef ErrDef (*QFunc_t)(Target *, stringvec&, std::string); |
typedef std::map<uint32_t, port::IThread*> ThreadMap_t; |
typedef std::map<std::string, std::string> PropertyMap_t; |
@@ -68,6 +62,15 @@ |
// build the Target internal structures. |
bool Init(); |
+ // Set/Get locally cached properties |
+ bool SetProperty(const std::string &name, const std::string& val); |
+ bool GetProperty(const std::string &name, std::string* val) const; |
+ |
+ // MatchQuery does a longest prefix match against the locally cased |
+ // properties, and returns the length of the match, as well as the |
+ // requested value. |
+ size_t MatchQuery(const std::string& match, std::string* val) const; |
+ |
// Add and remove temporary breakpoints. These breakpoints |
// must be added just before we start running, and removed |
// just before we stop running to prevent the debugger from |
@@ -97,6 +100,19 @@ |
void IgnoreThread(port::IThread *thread); |
protected: |
+ // Protected member functions, should only be called by the stub thread |
+ // from within "Run", at which point stateMutex_ is already held, so |
+ // it is always safe for a protected function to access the signal |
+ // state or thread map. |
+ |
+ // Called whenever the target transitions from running to stopped to |
+ // update information about the current state. |
+ void Update(); |
+ |
+ // Called to stop and start all debug threads |
+ void Pause(); |
+ void Resume(); |
+ |
// This function always succeedes, since all errors |
// are reported as an error string of "E<##>" where |
// the two digit number. The error codes are not |
@@ -113,14 +129,19 @@ |
uint32_t GetRegThreadId() const; |
uint32_t GetRunThreadId() const; |
- port::IThread *GetThread(uint32_t id); |
+ port::IThread *GetThread(uint32_t id) const; |
- public: |
+ private: |
const Abi *abi_; |
- // This mutex protects debugging state (threads_, cur_signal, sig_thread_) |
- port::IMutex *mutex_; |
+ // This mutex protects debugging state (threads_, cur_signal, sig_thread_). |
+ // This mutex is held by the stub thread, while in a broken state. |
+ port::IMutex *stateMutex_; |
+ // This mutex protects the public data (breakpoint, property), and is only |
+ // held temporarily as needed. |
+ port::IMutex *publicMutex_; |
+ |
// This event is signalled when the target is really to process an |
// exception. It ensures only one exception is processed at a time. |
port::IEvent *sig_start_; |
@@ -135,10 +156,11 @@ |
ThreadMap_t::const_iterator threadItr_; |
BreakMap_t breakMap_; |
- |
+ // A map of generic properties for the target. |
PropertyMap_t properties_; |
- uint8_t *ctx_; // Context Scratchpad |
+ // Context Scratchpad |
+ uint8_t *ctx_; |
// The current signal and signaling thread data is protected by |
// the mutex, and can only be owned by one thread at a time. |
@@ -148,8 +170,15 @@ |
volatile int8_t cur_signal_; |
volatile uint32_t sig_thread_; |
- uint32_t run_thread_; // Which thread to issue step commands on |
- uint32_t reg_thread_; // Which thread to issue context (reg) commands on |
+ // The debugger tracks two thread ids for its operations, one for |
+ // getting and setting registers, the other for step and continue. |
+ // The value can be 0 for any, -1 for all, or a specific ID for |
+ // a specific thread. The "_req_" variable stores the requested |
+ // id, while the "_last_" value stores the last value returned. |
+ uint32_t run_req_; // Requested thread for run operations. |
+ uint32_t reg_req_; // Requested thread for reg operations. |
+ mutable uint32_t run_last_; // Last result from a run thread query. |
+ mutable uint32_t reg_last_; // Last result from a reg thread query. |
}; |