{
JdwpNetState* netState;
- LOGV("ADB transport startup");
+ ALOGV("ADB transport startup");
state->netState = netState = new JdwpNetState;
if (netState == NULL)
if (ret <= 0) {
if (ret < 0) {
- LOGW("receiving file descriptor from ADB failed (socket %d): %s",
+ ALOGW("receiving file descriptor from ADB failed (socket %d): %s",
netState->controlSock, strerror(errno));
- } else {
- LOGD("adbd disconnected");
}
close(netState->controlSock);
netState->controlSock = -1;
netState->controlSock = socket(PF_UNIX, SOCK_STREAM, 0);
if (netState->controlSock < 0) {
- LOGE("Could not create ADB control socket:%s",
+ ALOGE("Could not create ADB control socket:%s",
strerror(errno));
return false;
}
if (pipe(netState->wakeFds) < 0) {
- LOGE("pipe failed");
+ ALOGE("pipe failed");
return false;
}
if (!ret) {
if (!socket_peer_is_trusted(netState->controlSock)) {
if (shutdown(netState->controlSock, SHUT_RDWR)) {
- LOGE("trouble shutting down socket: %s", strerror(errno));
+ ALOGE("trouble shutting down socket: %s", strerror(errno));
}
return false;
}
} while (ret < 0 && errno == EINTR);
if (ret >= 0) {
- LOGV("PID sent as '%.*s' to ADB", 4, buff);
+ ALOGV("PID sent as '%.*s' to ADB", 4, buff);
break;
}
- LOGE("Weird, can't send JDWP process pid to ADB: %s",
+ ALOGE("Weird, can't send JDWP process pid to ADB: %s",
strerror(errno));
return false;
}
- LOGV("Can't connect to ADB control socket:%s",
+ ALOGV("Can't connect to ADB control socket:%s",
strerror(errno));
usleep( sleep_ms*1000 );
}
}
- LOGV("trying to receive file descriptor from ADB");
+ ALOGV("trying to receive file descriptor from ADB");
/* now we can receive a client file descriptor */
netState->clientSock = receiveClientFd(netState);
if (netState->shuttingDown)
if (netState->clientSock < 0) {
if (++retryCount > 5) {
- LOGE("adb connection max retries exceeded");
+ ALOGE("adb connection max retries exceeded");
return false;
}
goto retry;
} else {
- LOGV("received file descriptor %d from ADB", netState->clientSock);
+ ALOGV("received file descriptor %d from ADB", netState->clientSock);
netState->awaitingHandshake = 1;
netState->inputCount = 0;
return true;
if (netState->clientSock < 0)
return;
- LOGV("+++ closed JDWP <-> ADB connection");
+ ALOGV("+++ closed JDWP <-> ADB connection");
close(netState->clientSock);
netState->clientSock = -1;
}
if (netState->wakeFds[1] >= 0) {
- LOGV("+++ writing to wakePipe");
- write(netState->wakeFds[1], "", 1);
+ ALOGV("+++ writing to wakePipe");
+ TEMP_FAILURE_RETRY(write(netState->wakeFds[1], "", 1));
}
}
ssize_t cc = netState->writePacket(pReply);
if (cc != (ssize_t) expandBufGetLength(pReply)) {
- LOGE("Failed sending reply to debugger: %s", strerror(errno));
+ ALOGE("Failed sending reply to debugger: %s", strerror(errno));
expandBufFree(pReply);
return false;
}
} else {
- LOGW("No reply created for set=%d cmd=%d", cmdSet, cmd);
+ ALOGW("No reply created for set=%d cmd=%d", cmdSet, cmd);
}
expandBufFree(pReply);
} else {
- LOGV("reply?!");
+ ALOGV("reply?!");
assert(false);
}
- LOGV("----------");
+ ALOGV("----------");
consumeBytes(netState, length);
return true;
if (maxfd < fd)
maxfd = fd;
} else {
- LOGI("NOTE: entering select w/o wakepipe");
+ ALOGI("NOTE: entering select w/o wakepipe");
}
if (maxfd < 0) {
- LOGV("+++ all fds are closed");
+ ALOGV("+++ all fds are closed");
return false;
}
if (selCount < 0) {
if (errno == EINTR)
continue;
- LOGE("select failed: %s", strerror(errno));
+ ALOGE("select failed: %s", strerror(errno));
goto fail;
}
if (netState->wakeFds[0] >= 0 &&
FD_ISSET(netState->wakeFds[0], &readfds))
{
- LOGD("Got wake-up signal, bailing out of select");
+ ALOGD("Got wake-up signal, bailing out of select");
goto fail;
}
if (netState->controlSock >= 0 &&
{
int sock = receiveClientFd(netState);
if (sock >= 0) {
- LOGI("Ignoring second debugger -- accepting and dropping");
+ ALOGI("Ignoring second debugger -- accepting and dropping");
close(sock);
} else {
assert(netState->controlSock < 0);
/* read failed */
if (errno != EINTR)
goto fail;
- LOGD("+++ EINTR hit");
+ ALOGD("+++ EINTR hit");
return true;
} else if (readCount == 0) {
/* EOF hit -- far end went away */
- LOGV("+++ peer disconnected");
+ ALOGV("+++ peer disconnected");
goto fail;
} else
break;
if (memcmp(netState->inputBuffer,
kMagicHandshake, kMagicHandshakeLen) != 0)
{
- LOGE("ERROR: bad handshake '%.14s'", netState->inputBuffer);
+ ALOGE("ERROR: bad handshake '%.14s'", netState->inputBuffer);
goto fail;
}
errno = 0;
- cc = write(netState->clientSock, netState->inputBuffer,
- kMagicHandshakeLen);
+ cc = TEMP_FAILURE_RETRY(write(netState->clientSock, netState->inputBuffer,
+ kMagicHandshakeLen));
if (cc != kMagicHandshakeLen) {
- LOGE("Failed writing handshake bytes: %s (%d of %d)",
+ ALOGE("Failed writing handshake bytes: %s (%d of %d)",
strerror(errno), cc, (int) kMagicHandshakeLen);
goto fail;
}
consumeBytes(netState, kMagicHandshakeLen);
netState->awaitingHandshake = false;
- LOGV("+++ handshake complete");
+ ALOGV("+++ handshake complete");
return true;
}
if (netState->clientSock < 0) {
/* can happen with some DDMS events */
- LOGV("NOT sending request -- no debugger is attached");
+ ALOGV("NOT sending request -- no debugger is attached");
return false;
}
ssize_t cc = netState->writePacket(pReq);
if (cc != (ssize_t) expandBufGetLength(pReq)) {
- LOGE("Failed sending req to debugger: %s (%d of %d)",
+ ALOGE("Failed sending req to debugger: %s (%d of %d)",
strerror(errno), (int) cc, (int) expandBufGetLength(pReq));
return false;
}
if (netState->clientSock < 0) {
/* can happen with some DDMS events */
- LOGV("NOT sending request -- no debugger is attached");
+ ALOGV("NOT sending request -- no debugger is attached");
return false;
}
ssize_t actual = netState->writeBufferedPacket(iov, iovcnt);
if ((size_t)actual != expected) {
- LOGE("Failed sending b-req to debugger: %s (%d of %zu)",
+ ALOGE("Failed sending b-req to debugger: %s (%d of %zu)",
strerror(errno), (int) actual, expected);
return false;
}