OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2010 The Native Client Authors. All rights reserved. | 2 * Copyright 2010 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 // This module provides an object for handling RSP responsibilities of | 7 // This module provides an object for handling RSP responsibilities of |
8 // the host side of the connection. The host behaves like a cache, and | 8 // the host side of the connection. The host behaves like a cache, and |
9 // is responsible for syncronization of state between the Target and Host. | 9 // is responsible for syncronization of state between the Target and Host. |
10 // For example, the Host is responsible for updating the thread context | 10 // For example, the Host is responsible for updating the thread context |
11 // before restarting the Target, and for updating it's internal array of | 11 // before restarting the Target, and for updating it's internal array of |
12 // threads whenever the Target stops. | 12 // threads whenever the Target stops. |
13 | 13 |
14 #ifndef NATIVE_CLIENT_GDB_RSP_HOST_H_ | 14 #ifndef SRC_TRUSTED_GDB_RSP_HOST_H_ |
noelallen_use_chromium
2010/12/07 23:04:44
NATIVE_CLIENT_xxxx
| |
15 #define NATIVE_CLIENT_GDB_RSP_HOST_H_ 1 | 15 #define SRC_TRUSTED_GDB_RSP_HOST_H_ 1 |
16 | 16 |
17 #include <map> | 17 #include <map> |
18 #include <string> | 18 #include <string> |
19 #include <vector> | 19 #include <vector> |
20 | 20 |
21 #include "native_client/src/trusted/port/std_types.h" | 21 #include "native_client/src/trusted/port/std_types.h" |
22 | 22 |
23 namespace gdb_rsp { | 23 namespace gdb_rsp { |
24 | 24 |
25 class Abi; | 25 class Abi; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 const Abi *abi_; | 57 const Abi *abi_; |
58 | 58 |
59 friend class Host; | 59 friend class Host; |
60 }; | 60 }; |
61 | 61 |
62 typedef std::map<uint32_t, Host::Thread*> ThreadMap_t; | 62 typedef std::map<uint32_t, Host::Thread*> ThreadMap_t; |
63 typedef std::map<std::string, std::string> PropertyMap_t; | 63 typedef std::map<std::string, std::string> PropertyMap_t; |
64 typedef std::vector<uint32_t> ThreadVector_t; | 64 typedef std::vector<uint32_t> ThreadVector_t; |
65 | 65 |
66 explicit Host(Session *session); | 66 explicit Host(Session *session); |
67 ~Host(); | 67 virtual ~Host(); |
68 bool Init(); | 68 virtual bool Init(); |
69 | 69 |
70 // The following functions are provided cached values when possible. | 70 // The following functions are provided cached values when possible. |
71 // For instance, GetSignal, GetThreads, and GetThread, will return | 71 // For instance, GetSignal, GetThreads, and GetThread, will return |
72 // values that were computed during Update. | 72 // values that were computed during Update. |
73 // cause a communication between the host and target, so the public | 73 // cause a communication between the host and target, so the public |
74 // functions above should be used when possible. | 74 // functions above should be used when possible. |
75 | 75 |
76 // Issue a break request if the target is still running. This is | 76 // Issue a break request if the target is still running. This is |
77 // asynchronous, we won't actually be "broken" until we get the signal | 77 // asynchronous, we won't actually be "broken" until we get the signal |
78 bool Break(); | 78 virtual bool Break(); |
79 | 79 |
80 // Requests that we cleanly detach from the target. | 80 // Requests that we cleanly detach from the target. |
81 bool Detach(); | 81 virtual bool Detach(); |
82 | 82 |
83 // Get the current status of the Target. | 83 // Get the current status of the Target. |
84 Status GetStatus(); | 84 virtual Status GetStatus(); |
85 | 85 |
86 // Get the last signal (which put us into the broken state) | 86 // Get the last signal (which put us into the broken state) |
87 int32_t GetSignal(); | 87 virtual int32_t GetSignal(); |
88 | 88 |
89 // Get a list of currently active threads | 89 // Get a list of currently active threads |
90 bool GetThreads(ThreadVector_t *threads) const; | 90 virtual bool GetThreads(ThreadVector_t *threads) const; |
91 | 91 |
92 // Get a thread object by ID. | 92 // Get a thread object by ID. |
93 Thread *GetThread(uint32_t id); | 93 virtual Thread *GetThread(uint32_t id); |
94 | 94 |
95 // Get and set a block of target memory. | 95 // Get and set a block of target memory. |
96 bool GetMemory(void *dst, uint64_t addr, uint32_t size); | 96 virtual bool GetMemory(void *dst, uint64_t addr, uint32_t size); |
97 bool SetMemory(const void *src, uint64_t addr, uint32_t size); | 97 virtual bool SetMemory(const void *src, uint64_t addr, uint32_t size); |
98 | 98 |
99 // Read locally cached properties | 99 // Read locally cached properties |
100 bool HasProperty(const char *name) const; | 100 virtual bool HasProperty(const char *name) const; |
101 bool ReadProperty(const char *name, std::string *val) const; | 101 virtual bool ReadProperty(const char *name, std::string *val) const; |
102 | 102 |
103 // Read remote object | 103 // Read remote object |
104 bool ReadObject(const char *type, const char *name, std::string *val); | 104 virtual bool ReadObject(const char *type, const char *name, std::string *val); |
105 | |
106 // Generic Request | |
noelallen_use_chromium
2010/12/07 23:04:44
nit: The other comments are sentence, this is a n
mlinck
2010/12/10 21:10:27
Done.
| |
107 virtual bool Request(const std::string &req, std::string *resp); | |
105 | 108 |
106 // Set the SINGLE STEP flag on the current thread context, and | 109 // Set the SINGLE STEP flag on the current thread context, and |
107 // putting the target back into the RUN state. | 110 // putting the target back into the RUN state. |
108 bool Step(); | 111 virtual bool Step(); |
109 | 112 |
110 // Issue a step request, putting us back into the RUN state. | 113 // Issue a step request, putting us back into the RUN state. |
111 bool Continue(); | 114 virtual bool Continue(); |
112 | 115 |
113 // Wait upto the session's packet timeout to see if we receive a break | 116 // Wait upto the session's packet timeout to see if we receive a break |
114 bool WaitForBreak(); | 117 virtual bool WaitForBreak(); |
115 | 118 |
116 // The following functions are internal only and cause communication to | 119 // The following functions are internal only and cause communication to |
117 // happen between the target and host. These functions will always | 120 // happen between the target and host. These functions will always |
118 // cause a communication between the host and target, so the public | 121 // cause a communication between the host and target, so the public |
119 // functions above should be used when possible. | 122 // functions above should be used when possible. |
120 protected: | 123 protected: |
121 // Called whenever the target transitions from running to stopped to | 124 // Called whenever the target transitions from running to stopped to |
122 // fetch information about the current state. | 125 // fetch information about the current state. |
123 bool Update(); | 126 virtual bool Update(); |
124 | 127 |
125 bool Send(Packet *req, Packet *resp); | 128 virtual bool Send(Packet *req, Packet *resp); |
126 bool SendOnly(Packet *req); | 129 virtual bool SendOnly(Packet *req); |
127 | 130 |
128 bool Request(const std::string &req, std::string *resp); | 131 virtual bool RequestOnly(const std::string &req); |
129 bool RequestOnly(const std::string &req); | 132 virtual bool RequestThreadList(ThreadVector_t *ids); |
130 bool RequestThreadList(ThreadVector_t *ids); | |
131 | 133 |
132 // Parse a string, returning true and update if a valid stop packet | 134 // Parse a string, returning true and update if a valid stop packet |
133 bool ParseStopPacket(const char *data); | 135 virtual bool ParseStopPacket(const char *data); |
134 | 136 |
135 private: | 137 protected: |
noelallen_use_chromium
2010/12/07 23:04:44
Add a comment that this was switched from private
mlinck
2010/12/10 21:10:27
Done.
| |
136 Session *session_; | 138 Session *session_; |
137 const Abi *abi_; | 139 const Abi *abi_; |
138 | 140 |
139 PropertyMap_t properties_; | 141 PropertyMap_t properties_; |
140 ThreadMap_t threads_; | 142 ThreadMap_t threads_; |
141 int32_t lastSignal_; | 143 int32_t lastSignal_; |
142 Status status_; | 144 Status status_; |
143 }; | 145 }; |
144 | 146 |
145 | 147 |
146 } // namespace gdb_rsp | 148 } // namespace gdb_rsp |
147 | 149 |
148 #endif // NATIVE_CLIENT_GDB_RSP_HOST_H_ | 150 #endif // SRC_TRUSTED_GDB_RSP_HOST_H_ |
149 | 151 |
OLD | NEW |