• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

修訂43dd52ffef9283cf7386fd0b77ad98964af958bb (tree)
時間2013-06-16 17:06:07
作者Ken Lierman <ken.lierman@wind...>
CommiterChih-Wei Huang

Log Message

cleanup ADB's debug output

The server was using stderr to talk back to the client to ACK it
starting correctly, which made the debug output from the server get
lost (before it later gets redirected to a file). Change it to stdout
and add a fflush() to force the output.

Add the pid to the output so you can tell which process the output is
coming from.

Add basename to the FILE part of the output to remove the unnecessary
and redundant system/core/adb path info from every output line.

Remove the duplicated fdevents debug output macro so it gets redirected
into the server log file like it should.

Change-Id: I8eaf3c8ccbca62f907b0ee7b52a0e179db5ff82d

Change Summary

差異

--- a/adb/adb.c
+++ b/adb/adb.c
@@ -105,6 +105,7 @@ void adb_trace_init(void)
105105 { "jdwp", TRACE_JDWP },
106106 { "services", TRACE_SERVICES },
107107 { "auth", TRACE_AUTH },
108+ { "fdevents", TRACE_FDEVENT },
108109 { NULL, 0 }
109110 };
110111
@@ -1009,10 +1010,9 @@ int launch_server(int server_port)
10091010 if (pid == 0) {
10101011 // child side of the fork
10111012
1012- // redirect stderr to the pipe
1013- // we use stderr instead of stdout due to stdout's buffering behavior.
1013+ // redirect stdout to the pipe
10141014 adb_close(fd[0]);
1015- dup2(fd[1], STDERR_FILENO);
1015+ dup2(fd[1], STDOUT_FILENO);
10161016 adb_close(fd[1]);
10171017
10181018 char str_port[30];
@@ -1229,7 +1229,8 @@ int adb_main(int is_daemon, int server_port)
12291229 DWORD count;
12301230 WriteFile( GetStdHandle( STD_OUTPUT_HANDLE ), "OK\n", 3, &count, NULL );
12311231 #elif defined(HAVE_FORKEXEC)
1232- fprintf(stderr, "OK\n");
1232+ fprintf(stdout, "OK\n");
1233+ fflush(stdout);
12331234 #endif
12341235 start_logging();
12351236 }
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -18,6 +18,7 @@
1818 #define __ADB_H
1919
2020 #include <limits.h>
21+#include <libgen.h>
2122
2223 #include "transport.h" /* readx(), writex() */
2324
@@ -359,6 +360,7 @@ typedef enum {
359360 TRACE_JDWP, /* 0x100 */
360361 TRACE_SERVICES,
361362 TRACE_AUTH,
363+ TRACE_FDEVENT,
362364 } AdbTrace;
363365
364366 #if ADB_TRACE
@@ -390,8 +392,10 @@ void adb_qemu_trace(const char* fmt, ...);
390392 if (ADB_TRACING) { \
391393 int save_errno = errno; \
392394 adb_mutex_lock(&D_lock); \
393- fprintf(stderr, "%s::%s():", \
394- __FILE__, __FUNCTION__); \
395+ fprintf(stderr, "%d::%s::%s():", \
396+ getpid(), \
397+ basename(__FILE__), \
398+ __FUNCTION__); \
395399 errno = save_errno; \
396400 fprintf(stderr, __VA_ARGS__ ); \
397401 fflush(stderr); \
--- a/adb/fdevent.c
+++ b/adb/fdevent.c
@@ -28,23 +28,22 @@
2828 #include <stdarg.h>
2929 #include <stddef.h>
3030
31+#define TRACE_TAG TRACE_FDEVENT
32+
3133 #include "fdevent.h"
3234 #include "transport.h"
3335 #include "sysdeps.h"
36+#include "adb.h"
3437
3538
36-/* !!! Do not enable DEBUG for the adb that will run as the server:
37-** both stdout and stderr are used to communicate between the client
38-** and server. Any extra output will cause failures.
39-*/
40-#define DEBUG 0 /* non-0 will break adb server */
39+#define DEBUG 0
4140
4241 // This socket is used when a subproc shell service exists.
4342 // It wakes up the fdevent_loop() and cause the correct handling
4443 // of the shell's pseudo-tty master. I.e. force close it.
4544 int SHELL_EXIT_NOTIFY_FD = -1;
4645
47-static void fatal(const char *fn, const char *fmt, ...)
46+static void ffatal(const char *fn, const char *fmt, ...)
4847 {
4948 va_list ap;
5049 va_start(ap, fmt);
@@ -54,19 +53,10 @@ static void fatal(const char *fn, const char *fmt, ...)
5453 abort();
5554 }
5655
57-#define FATAL(x...) fatal(__FUNCTION__, x)
56+
57+#define FATAL(x...) ffatal(__FUNCTION__, x)
5858
5959 #if DEBUG
60-#define D(...) \
61- do { \
62- adb_mutex_lock(&D_lock); \
63- int save_errno = errno; \
64- fprintf(stderr, "%s::%s():", __FILE__, __FUNCTION__); \
65- errno = save_errno; \
66- fprintf(stderr, __VA_ARGS__); \
67- adb_mutex_unlock(&D_lock); \
68- errno = save_errno; \
69- } while(0)
7060 static void dump_fde(fdevent *fde, const char *info)
7161 {
7262 adb_mutex_lock(&D_lock);
@@ -78,7 +68,6 @@ static void dump_fde(fdevent *fde, const char *info)
7868 adb_mutex_unlock(&D_lock);
7969 }
8070 #else
81-#define D(...) ((void)0)
8271 #define dump_fde(fde, info) do { } while(0)
8372 #endif
8473