David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** Copyright 2011, The Android Open Source Project |
| 3 | ** |
| 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | ** you may not use this file except in compliance with the License. |
| 6 | ** You may obtain a copy of the License at |
| 7 | ** |
| 8 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | ** |
| 10 | ** Unless required by applicable law or agreed to in writing, software |
| 11 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | ** See the License for the specific language governing permissions and |
| 14 | ** limitations under the License. |
| 15 | */ |
| 16 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 17 | #include <sys/ioctl.h> |
| 18 | #include <unistd.h> |
| 19 | #include <sys/socket.h> |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 20 | #include <fcntl.h> |
| 21 | #include <netinet/in.h> |
| 22 | #include <arpa/inet.h> |
| 23 | #include <pthread.h> |
| 24 | |
| 25 | #include "header.h" |
| 26 | |
| 27 | namespace android |
| 28 | { |
| 29 | |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 30 | int serverSock = -1, clientSock = -1; |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 31 | FILE * file = NULL; |
| 32 | unsigned int MAX_FILE_SIZE = 0; |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 33 | int timeMode = SYSTEM_TIME_THREAD; |
| 34 | |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 35 | static void Die(const char * msg) |
| 36 | { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 37 | ALOGD("\n*\n*\n* GLESv2_dbg: Die: %s \n*\n*", msg); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 38 | StopDebugServer(); |
| 39 | exit(1); |
| 40 | } |
| 41 | |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 42 | void StartDebugServer(const unsigned short port, const bool forceUseFile, |
| 43 | const unsigned int maxFileSize, const char * const filePath) |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 44 | { |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 45 | MAX_FILE_SIZE = maxFileSize; |
| 46 | |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 47 | ALOGD("GLESv2_dbg: StartDebugServer"); |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 48 | if (serverSock >= 0 || file) |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 49 | return; |
| 50 | |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 51 | ALOGD("GLESv2_dbg: StartDebugServer create socket"); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 52 | struct sockaddr_in server = {}, client = {}; |
| 53 | |
| 54 | /* Create the TCP socket */ |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 55 | if (forceUseFile || (serverSock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { |
| 56 | file = fopen(filePath, "wb"); |
| 57 | if (!file) |
| 58 | Die("Failed to create socket and file"); |
| 59 | else |
| 60 | return; |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 61 | } |
| 62 | /* Construct the server sockaddr_in structure */ |
| 63 | server.sin_family = AF_INET; /* Internet/IP */ |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 64 | server.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* Incoming addr */ |
| 65 | server.sin_port = htons(port); /* server port */ |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 66 | |
| 67 | /* Bind the server socket */ |
| 68 | socklen_t sizeofSockaddr_in = sizeof(sockaddr_in); |
| 69 | if (bind(serverSock, (struct sockaddr *) &server, |
| 70 | sizeof(server)) < 0) { |
| 71 | Die("Failed to bind the server socket"); |
| 72 | } |
| 73 | /* Listen on the server socket */ |
| 74 | if (listen(serverSock, 1) < 0) { |
| 75 | Die("Failed to listen on server socket"); |
| 76 | } |
| 77 | |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 78 | ALOGD("server started on %d \n", server.sin_port); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 79 | |
| 80 | |
| 81 | /* Wait for client connection */ |
| 82 | if ((clientSock = |
| 83 | accept(serverSock, (struct sockaddr *) &client, |
| 84 | &sizeofSockaddr_in)) < 0) { |
| 85 | Die("Failed to accept client connection"); |
| 86 | } |
| 87 | |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 88 | ALOGD("Client connected: %s\n", inet_ntoa(client.sin_addr)); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 89 | // fcntl(clientSock, F_SETFL, O_NONBLOCK); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | void StopDebugServer() |
| 93 | { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 94 | ALOGD("GLESv2_dbg: StopDebugServer"); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 95 | if (clientSock > 0) { |
| 96 | close(clientSock); |
| 97 | clientSock = -1; |
| 98 | } |
| 99 | if (serverSock > 0) { |
| 100 | close(serverSock); |
| 101 | serverSock = -1; |
| 102 | } |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 103 | if (file) { |
| 104 | fclose(file); |
| 105 | file = NULL; |
| 106 | } |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 107 | } |
| 108 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 109 | void Receive(glesv2debugger::Message & cmd) |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 110 | { |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 111 | if (clientSock < 0) |
| 112 | return; |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 113 | unsigned len = 0; |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 114 | int received = recv(clientSock, &len, 4, MSG_WAITALL); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 115 | if (received < 0) |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 116 | Die("Failed to receive response length"); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 117 | else if (4 != received) { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 118 | ALOGD("received %dB: %.8X", received, len); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 119 | Die("Received length mismatch, expected 4"); |
| 120 | } |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 121 | static void * buffer = NULL; |
| 122 | static unsigned bufferSize = 0; |
| 123 | if (bufferSize < len) { |
| 124 | buffer = realloc(buffer, len); |
David Li | 5c425f2 | 2011-03-10 16:40:37 -0800 | [diff] [blame] | 125 | assert(buffer); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 126 | bufferSize = len; |
| 127 | } |
| 128 | received = recv(clientSock, buffer, len, MSG_WAITALL); |
| 129 | if (received < 0) |
| 130 | Die("Failed to receive response"); |
| 131 | else if (len != received) |
| 132 | Die("Received length mismatch"); |
| 133 | cmd.Clear(); |
| 134 | cmd.ParseFromArray(buffer, len); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 135 | } |
| 136 | |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 137 | bool TryReceive(glesv2debugger::Message & cmd) |
| 138 | { |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 139 | if (clientSock < 0) |
| 140 | return false; |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 141 | fd_set readSet; |
| 142 | FD_ZERO(&readSet); |
| 143 | FD_SET(clientSock, &readSet); |
| 144 | timeval timeout; |
| 145 | timeout.tv_sec = timeout.tv_usec = 0; |
| 146 | |
| 147 | int rc = select(clientSock + 1, &readSet, NULL, NULL, &timeout); |
| 148 | if (rc < 0) |
| 149 | Die("failed to select clientSock"); |
| 150 | |
| 151 | bool received = false; |
| 152 | if (FD_ISSET(clientSock, &readSet)) { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 153 | ALOGD("TryReceive: avaiable for read"); |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 154 | Receive(cmd); |
| 155 | return true; |
| 156 | } |
| 157 | return false; |
| 158 | } |
| 159 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 160 | float Send(const glesv2debugger::Message & msg, glesv2debugger::Message & cmd) |
| 161 | { |
David Li | 31918cc | 2011-04-15 15:35:10 -0700 | [diff] [blame] | 162 | // TODO: use per DbgContext send/receive buffer and async socket |
| 163 | // instead of mutex and blocking io; watch out for large messages |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 164 | static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; |
David Li | 31918cc | 2011-04-15 15:35:10 -0700 | [diff] [blame] | 165 | struct Autolock { |
| 166 | Autolock() { |
| 167 | pthread_mutex_lock(&mutex); |
| 168 | } |
| 169 | ~Autolock() { |
| 170 | pthread_mutex_unlock(&mutex); |
| 171 | } |
| 172 | } autolock; |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 173 | |
David Li | 5c425f2 | 2011-03-10 16:40:37 -0800 | [diff] [blame] | 174 | if (msg.function() != glesv2debugger::Message_Function_ACK) |
| 175 | assert(msg.has_context_id() && msg.context_id() != 0); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 176 | static std::string str; |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 177 | msg.SerializeToString(&str); |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 178 | const uint32_t len = str.length(); |
| 179 | if (clientSock < 0) { |
| 180 | if (file) { |
| 181 | fwrite(&len, sizeof(len), 1, file); |
| 182 | fwrite(str.data(), len, 1, file); |
| 183 | if (ftell(file) >= MAX_FILE_SIZE) { |
| 184 | fclose(file); |
| 185 | Die("MAX_FILE_SIZE reached"); |
| 186 | } |
| 187 | } |
David Li | 27f130a | 2011-04-08 18:43:16 -0700 | [diff] [blame] | 188 | return 0; |
| 189 | } |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 190 | int sent = -1; |
David Li | f9bc124 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 191 | sent = send(clientSock, &len, sizeof(len), 0); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 192 | if (sent != sizeof(len)) { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 193 | ALOGD("actual sent=%d expected=%d clientSock=%d", sent, sizeof(len), clientSock); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 194 | Die("Failed to send message length"); |
| 195 | } |
| 196 | nsecs_t c0 = systemTime(timeMode); |
David Li | e9f619f | 2011-04-14 11:20:22 -0700 | [diff] [blame] | 197 | sent = send(clientSock, str.data(), str.length(), 0); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 198 | float t = (float)ns2ms(systemTime(timeMode) - c0); |
| 199 | if (sent != str.length()) { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 200 | ALOGD("actual sent=%d expected=%d clientSock=%d", sent, str.length(), clientSock); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 201 | Die("Failed to send message"); |
| 202 | } |
David Li | 31918cc | 2011-04-15 15:35:10 -0700 | [diff] [blame] | 203 | // TODO: factor Receive & TryReceive out and into MessageLoop, or add control argument. |
| 204 | // mean while, if server is sending a SETPROP then don't try to receive, |
| 205 | // because server will not be processing received command |
| 206 | if (msg.function() == msg.SETPROP) |
| 207 | return t; |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 208 | // try to receive commands even though not expecting response, |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 209 | // since client can send SETPROP and other commands anytime |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 210 | if (!msg.expect_response()) { |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 211 | if (TryReceive(cmd)) { |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 212 | if (glesv2debugger::Message_Function_SETPROP == cmd.function()) |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 213 | ALOGD("Send: TryReceived SETPROP"); |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 214 | else |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 215 | ALOGD("Send: TryReceived %u", cmd.function()); |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 216 | } |
| 217 | } else |
| 218 | Receive(cmd); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 219 | return t; |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 220 | } |
| 221 | |
David Li | fbfc703 | 2011-03-21 16:25:58 -0700 | [diff] [blame] | 222 | void SetProp(DbgContext * const dbg, const glesv2debugger::Message & cmd) |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 223 | { |
| 224 | switch (cmd.prop()) { |
David Li | e7180e8 | 2011-04-08 18:45:45 -0700 | [diff] [blame] | 225 | case glesv2debugger::Message_Prop_CaptureDraw: |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 226 | ALOGD("SetProp Message_Prop_CaptureDraw %d", cmd.arg0()); |
David Li | e7180e8 | 2011-04-08 18:45:45 -0700 | [diff] [blame] | 227 | dbg->captureDraw = cmd.arg0(); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 228 | break; |
| 229 | case glesv2debugger::Message_Prop_TimeMode: |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 230 | ALOGD("SetProp Message_Prop_TimeMode %d", cmd.arg0()); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 231 | timeMode = cmd.arg0(); |
| 232 | break; |
David Li | fbfc703 | 2011-03-21 16:25:58 -0700 | [diff] [blame] | 233 | case glesv2debugger::Message_Prop_ExpectResponse: |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 234 | ALOGD("SetProp Message_Prop_ExpectResponse %d=%d", cmd.arg0(), cmd.arg1()); |
David Li | fbfc703 | 2011-03-21 16:25:58 -0700 | [diff] [blame] | 235 | dbg->expectResponse.Bit((glesv2debugger::Message_Function)cmd.arg0(), cmd.arg1()); |
| 236 | break; |
David Li | e7180e8 | 2011-04-08 18:45:45 -0700 | [diff] [blame] | 237 | case glesv2debugger::Message_Prop_CaptureSwap: |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 238 | ALOGD("SetProp CaptureSwap %d", cmd.arg0()); |
David Li | e7180e8 | 2011-04-08 18:45:45 -0700 | [diff] [blame] | 239 | dbg->captureSwap = cmd.arg0(); |
| 240 | break; |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 241 | default: |
| 242 | assert(0); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | int * MessageLoop(FunctionCall & functionCall, glesv2debugger::Message & msg, |
David Li | fbfc703 | 2011-03-21 16:25:58 -0700 | [diff] [blame] | 247 | const glesv2debugger::Message_Function function) |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 248 | { |
David Li | 5c425f2 | 2011-03-10 16:40:37 -0800 | [diff] [blame] | 249 | DbgContext * const dbg = getDbgContextThreadSpecific(); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 250 | const int * ret = 0; |
| 251 | glesv2debugger::Message cmd; |
David Li | 5c425f2 | 2011-03-10 16:40:37 -0800 | [diff] [blame] | 252 | msg.set_context_id(reinterpret_cast<int>(dbg)); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 253 | msg.set_type(glesv2debugger::Message_Type_BeforeCall); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 254 | bool expectResponse = dbg->expectResponse.Bit(function); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 255 | msg.set_expect_response(expectResponse); |
| 256 | msg.set_function(function); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 257 | |
| 258 | // when not exectResponse, set cmd to CONTINUE then SKIP |
David Li | e9f619f | 2011-04-14 11:20:22 -0700 | [diff] [blame] | 259 | // cmd will be overwritten by received command |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 260 | cmd.set_function(glesv2debugger::Message_Function_CONTINUE); |
David Li | e9f619f | 2011-04-14 11:20:22 -0700 | [diff] [blame] | 261 | cmd.set_expect_response(expectResponse); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 262 | glesv2debugger::Message_Function oldCmd = cmd.function(); |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 263 | Send(msg, cmd); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 264 | expectResponse = cmd.expect_response(); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 265 | while (true) { |
| 266 | msg.Clear(); |
| 267 | nsecs_t c0 = systemTime(timeMode); |
| 268 | switch (cmd.function()) { |
| 269 | case glesv2debugger::Message_Function_CONTINUE: |
David Li | 5c425f2 | 2011-03-10 16:40:37 -0800 | [diff] [blame] | 270 | ret = functionCall(&dbg->hooks->gl, msg); |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 271 | while (GLenum error = dbg->hooks->gl.glGetError()) |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 272 | ALOGD("Function=%u glGetError() = 0x%.4X", function, error); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 273 | if (!msg.has_time()) // some has output data copy, so time inside call |
| 274 | msg.set_time((systemTime(timeMode) - c0) * 1e-6f); |
David Li | 5c425f2 | 2011-03-10 16:40:37 -0800 | [diff] [blame] | 275 | msg.set_context_id(reinterpret_cast<int>(dbg)); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 276 | msg.set_function(function); |
| 277 | msg.set_type(glesv2debugger::Message_Type_AfterCall); |
| 278 | msg.set_expect_response(expectResponse); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 279 | if (!expectResponse) { |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 280 | cmd.set_function(glesv2debugger::Message_Function_SKIP); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 281 | cmd.set_expect_response(false); |
| 282 | } |
| 283 | oldCmd = cmd.function(); |
David Li | 940c3f8 | 2011-03-10 19:07:42 -0800 | [diff] [blame] | 284 | Send(msg, cmd); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 285 | expectResponse = cmd.expect_response(); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 286 | break; |
| 287 | case glesv2debugger::Message_Function_SKIP: |
| 288 | return const_cast<int *>(ret); |
| 289 | case glesv2debugger::Message_Function_SETPROP: |
David Li | fbfc703 | 2011-03-21 16:25:58 -0700 | [diff] [blame] | 290 | SetProp(dbg, cmd); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 291 | expectResponse = cmd.expect_response(); |
| 292 | if (!expectResponse) // SETPROP is "out of band" |
| 293 | cmd.set_function(oldCmd); |
| 294 | else |
| 295 | Receive(cmd); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 296 | break; |
| 297 | default: |
David Li | 291f5fe | 2011-03-21 17:42:50 -0700 | [diff] [blame] | 298 | ret = GenerateCall(dbg, cmd, msg, ret); |
| 299 | msg.set_expect_response(expectResponse); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 300 | if (!expectResponse) { |
David Li | 291f5fe | 2011-03-21 17:42:50 -0700 | [diff] [blame] | 301 | cmd.set_function(cmd.SKIP); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 302 | cmd.set_expect_response(expectResponse); |
| 303 | } |
| 304 | oldCmd = cmd.function(); |
David Li | 291f5fe | 2011-03-21 17:42:50 -0700 | [diff] [blame] | 305 | Send(msg, cmd); |
David Li | e2ad4d0 | 2011-04-08 18:41:00 -0700 | [diff] [blame] | 306 | expectResponse = cmd.expect_response(); |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 307 | break; |
| 308 | } |
| 309 | } |
| 310 | return 0; |
| 311 | } |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 312 | }; // namespace android { |