Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: src/trusted/gdb_rsp/target.h

Issue 5633007: This change contains changes that were made on a separate copy of this code,... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
Cliff L. Biffle 2010/12/14 21:46:08 cased? cached?
mlinck 2010/12/16 20:03:01 Done.
+ // 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_;
@@ -128,17 +149,15 @@
// This event is signalled when the target done processing an exception.
port::IEvent *sig_done_;
- // This value is set if the exception cather is requesting a continue signal
- bool send_done_;
-
ThreadMap_t threads_;
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 +167,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.
+ int32_t run_req_; // Requested thread for run operations.
Cliff L. Biffle 2010/12/14 21:46:08 These names are not great. They should probably c
mlinck 2010/12/16 20:03:01 Done.
+ int32_t reg_req_; // Requested thread for reg operations.
+ mutable int32_t run_last_; // Last result from a run thread query.
+ mutable int32_t reg_last_; // Last result from a reg thread query.
};

Powered by Google App Engine
This is Rietveld 408576698