adb: clean up debug tracing a little.
Always use LOG() for debug tracing.
Remove useless D_lock. I believe it is useless to lock just before and after fprintf.
I verified the log output both on host and on device. The output looks fine to me.
Change-Id: I96ccfe408ff56864361551afe9ad464d197ae104
diff --git a/transport_local.cpp b/transport_local.cpp
index 6821cfc..0c4315a 100644
--- a/transport_local.cpp
+++ b/transport_local.cpp
@@ -51,22 +51,22 @@
static int remote_read(apacket *p, atransport *t)
{
if(!ReadFdExactly(t->sfd, &p->msg, sizeof(amessage))){
- D("remote local: read terminated (message)\n");
+ D("remote local: read terminated (message)");
return -1;
}
if(check_header(p, t)) {
- D("bad header: terminated (data)\n");
+ D("bad header: terminated (data)");
return -1;
}
if(!ReadFdExactly(t->sfd, p->data, p->msg.data_length)){
- D("remote local: terminated (data)\n");
+ D("remote local: terminated (data)");
return -1;
}
if(check_data(p)) {
- D("bad data: terminated (data)\n");
+ D("bad data: terminated (data)");
return -1;
}
@@ -78,7 +78,7 @@
int length = p->msg.data_length;
if(!WriteFdExactly(t->sfd, &p->msg, sizeof(amessage) + length)) {
- D("remote local: write terminated\n");
+ D("remote local: write terminated");
return -1;
}
@@ -108,7 +108,7 @@
}
if (fd >= 0) {
- D("client: connected on remote on fd %d\n", fd);
+ D("client: connected on remote on fd %d", fd);
close_on_exec(fd);
disable_tcp_nagle(fd);
std::string serial = android::base::StringPrintf("emulator-%d", console_port);
@@ -124,7 +124,7 @@
static void *client_socket_thread(void *x)
{
adb_thread_setname("client_socket_thread");
- D("transport: client_socket_thread() starting\n");
+ D("transport: client_socket_thread() starting");
while (true) {
int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT;
int count = ADB_LOCAL_TRANSPORT_MAX;
@@ -148,14 +148,14 @@
int port = (int) (uintptr_t) arg;
adb_thread_setname("server socket");
- D("transport: server_socket_thread() starting\n");
+ D("transport: server_socket_thread() starting");
serverfd = -1;
for(;;) {
if(serverfd == -1) {
std::string error;
serverfd = network_inaddr_any_server(port, SOCK_STREAM, &error);
if(serverfd < 0) {
- D("server: cannot bind socket yet: %s\n", error.c_str());
+ D("server: cannot bind socket yet: %s", error.c_str());
adb_sleep_ms(1000);
continue;
}
@@ -163,16 +163,16 @@
}
alen = sizeof(addr);
- D("server: trying to get new connection from %d\n", port);
+ D("server: trying to get new connection from %d", port);
fd = adb_socket_accept(serverfd, &addr, &alen);
if(fd >= 0) {
- D("server: new connection on fd %d\n", fd);
+ D("server: new connection on fd %d", fd);
close_on_exec(fd);
disable_tcp_nagle(fd);
register_socket_transport(fd, "host", port, 1);
}
}
- D("transport: server_socket_thread() exiting\n");
+ D("transport: server_socket_thread() exiting");
return 0;
}
@@ -234,7 +234,7 @@
char con_name[32];
adb_thread_setname("qemu socket");
- D("transport: qemu_socket_thread() starting\n");
+ D("transport: qemu_socket_thread() starting");
/* adb QEMUD service connection request. */
snprintf(con_name, sizeof(con_name), "qemud:adb:%d", port);
@@ -244,7 +244,7 @@
if (fd < 0) {
/* This could be an older version of the emulator, that doesn't
* implement adb QEMUD service. Fall back to the old TCP way. */
- D("adb service is not available. Falling back to TCP socket.\n");
+ D("adb service is not available. Falling back to TCP socket.");
adb_thread_create(server_socket_thread, arg);
return 0;
}
@@ -261,7 +261,7 @@
* or 'ko' on failure. */
res = adb_read(fd, tmp, sizeof(tmp));
if (res != 2 || memcmp(tmp, _ok_resp, 2)) {
- D("Accepting ADB host connection has failed.\n");
+ D("Accepting ADB host connection has failed.");
adb_close(fd);
} else {
/* Host is connected. Register the transport, and start the
@@ -273,15 +273,15 @@
/* Prepare for accepting of the next ADB host connection. */
fd = qemu_pipe_open(con_name);
if (fd < 0) {
- D("adb service become unavailable.\n");
+ D("adb service become unavailable.");
return 0;
}
} else {
- D("Unable to send the '%s' request to ADB service.\n", _accept_req);
+ D("Unable to send the '%s' request to ADB service.", _accept_req);
return 0;
}
}
- D("transport: qemu_socket_thread() exiting\n");
+ D("transport: qemu_socket_thread() exiting");
return 0;
}
#endif // !ADB_HOST
@@ -309,7 +309,7 @@
debug_name = "server";
#endif // !ADB_HOST
- D("transport: local %s init\n", debug_name);
+ D("transport: local %s init", debug_name);
if (!adb_thread_create(func, (void *) (uintptr_t) port)) {
fatal_errno("cannot create local socket %s thread", debug_name);
}
@@ -410,12 +410,12 @@
find_emulator_transport_by_adb_port_locked(adb_port);
int index = get_available_local_transport_index_locked();
if (existing_transport != NULL) {
- D("local transport for port %d already registered (%p)?\n",
+ D("local transport for port %d already registered (%p)?",
adb_port, existing_transport);
fail = -1;
} else if (index < 0) {
// Too many emulators.
- D("cannot register more emulators. Maximum is %d\n",
+ D("cannot register more emulators. Maximum is %d",
ADB_LOCAL_TRANSPORT_MAX);
fail = -1;
} else {