• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

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

system/corennnnn


コミットメタ情報

リビジョン1f546e6d1f6ccd1964336ddf0d8e8b3b11b1e945 (tree)
日時2009-05-26 07:17:55
作者Mike Lockwood <lockwood@andr...>
コミッターMike Lockwood

ログメッセージ

adb: Allow enabling of device side adbd logging with a persistent system property.

To enable logging, set the property persist.adb.trace_mask to a hex value
containing the bitmask for adb_trace_mask (see the TRACE_* enum values in adb.h).
This will result in adb writing log output to a file in /data/adb/
No logging will occur if persist.adb.trace_mask is not set or has a value
that cannot be parsed as a hex integer.
The property is read once only at startup, so you must reboot or restart adbd
for changes in the property to take effect.

Signed-off-by: Mike Lockwood <lockwood@android.com>

変更サマリ

差分

--- a/adb/adb.c
+++ b/adb/adb.c
@@ -23,6 +23,7 @@
2323 #include <errno.h>
2424 #include <string.h>
2525 #include <time.h>
26+#include <sys/time.h>
2627
2728 #include "sysdeps.h"
2829 #include "adb.h"
@@ -657,10 +658,25 @@ void start_logging(void)
657658 void start_device_log(void)
658659 {
659660 int fd;
660- char path[100];
661+ char path[PATH_MAX];
662+ struct tm now;
663+ time_t t;
664+ char value[PROPERTY_VALUE_MAX];
665+
666+ // read the trace mask from persistent property persist.adb.trace_mask
667+ // give up if the property is not set or cannot be parsed
668+ property_get("persist.adb.trace_mask", value, "");
669+ if (sscanf(value, "%x", &adb_trace_mask) != 1)
670+ return;
661671
662- snprintf(path, sizeof path, "/data/adb_%ld.txt", (long)time(NULL));
663- fd = unix_open(path, O_WRONLY | O_CREAT | O_APPEND, 0640);
672+ adb_mkdir("/data/adb", 0775);
673+ tzset();
674+ time(&t);
675+ localtime_r(&t, &now);
676+ strftime(path, sizeof(path),
677+ "/data/adb/adb-%Y-%m-%d-%H-%M-%S.txt",
678+ &now);
679+ fd = unix_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640);
664680 if (fd < 0)
665681 return;
666682
@@ -671,11 +687,6 @@ void start_device_log(void)
671687
672688 fd = unix_open("/dev/null", O_RDONLY);
673689 dup2(fd, 0);
674-
675- // log everything
676- adb_trace_mask = ~0;
677- // except TRACE_RWX is a bit too verbose
678- adb_trace_mask &= ~TRACE_RWX;
679690 }
680691 #endif
681692
@@ -1079,9 +1090,8 @@ int main(int argc, char **argv)
10791090 adb_device_banner = "recovery";
10801091 recovery_mode = 1;
10811092 }
1082-#if ADB_DEVICE_LOG
1093+
10831094 start_device_log();
1084-#endif
10851095 return adb_main(0);
10861096 #endif
10871097 }
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -345,11 +345,6 @@ typedef enum {
345345 #endif
346346
347347
348-/* set this to log to /data/adb/adb_<time>.txt on the device.
349- * has no effect if the /data/adb/ directory does not exist.
350- */
351-#define ADB_DEVICE_LOG 0
352-
353348 #if !TRACE_PACKETS
354349 #define print_packet(tag,p) do {} while (0)
355350 #endif