Index: src/trusted/gdb_rsp/target.h |
=================================================================== |
--- src/trusted/gdb_rsp/target.h (revision 3879) |
+++ src/trusted/gdb_rsp/target.h (working copy) |
@@ -20,8 +20,8 @@ |
// and that all threads are updated with thier modified contexts and |
// restarted when the target returns from Run. |
-#ifndef NATIVE_CLIENT_GDB_RSP_TARGET_H_ |
-#define NATIVE_CLIENT_GDB_RSP_TARGET_H_ 1 |
+#ifndef SRC_TRUSTED_GDB_RSP_TARGET_H_ |
+#define SRC_TRUSTED_GDB_RSP_TARGET_H_ 1 |
#include <map> |
#include <string> |
@@ -48,10 +48,10 @@ |
FAILED = 3 |
}; |
- enum State { |
- UNINIT = 0, |
- RUNNING = 1, |
- STOPPED = 2 |
+ enum ConState { |
+ DETACHED = 0, |
+ ATTACHED = 1, |
+ DETACHING= 2 |
}; |
typedef ErrDef (*QFunc_t)(Target *, stringvec&, std::string); |
@@ -68,6 +68,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 +106,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 +135,22 @@ |
uint32_t GetRegThreadId() const; |
uint32_t GetRunThreadId() const; |
- port::IThread *GetThread(uint32_t id); |
+ port::IThread *GetThread(uint32_t id) const; |
noelallen_use_chromium
2010/12/07 23:04:44
Good catch.
|
- public: |
+ private: |
+ // Current Target state |
+ ConState conState_; |
+ |
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 +165,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,12 +179,19 @@ |
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. |
mmortensen
2010/12/07 22:53:58
If run_req and run_reg can bo -1, why are the decl
mlinck
2010/12/10 21:10:27
Excellent question. I'm not sure what the best ap
noelallen_use_chromium
2010/12/13 19:28:10
I set this to 32b so you would get that behavior.
mlinck
2010/12/14 17:23:24
Changed to int32_t
|
+ 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. |
}; |
} // namespace gdb_rsp |
-#endif // NATIVE_CLIENT_GDB_RSP_TARGET_H_ |
+#endif // SRC_TRUSTED_GDB_RSP_TARGET_H_ |