diff options
Diffstat (limited to 'logcat')
-rw-r--r-- | logcat/Android.mk | 8 | ||||
-rw-r--r-- | logcat/logcat.cpp | 89 | ||||
-rw-r--r-- | logcat/tests/Android.mk | 4 | ||||
-rw-r--r-- | logcat/tests/logcat_test.cpp | 8 |
4 files changed, 36 insertions, 73 deletions
diff --git a/logcat/Android.mk b/logcat/Android.mk index dd15cb3..f46a4de 100644 --- a/logcat/Android.mk +++ b/logcat/Android.mk @@ -3,15 +3,13 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -ifneq ($(filter userdebug eng,$(TARGET_BUILD_VARIANT)),) -LOCAL_CFLAGS += -DUSERDEBUG_BUILD=1 -endif - LOCAL_SRC_FILES:= logcat.cpp event.logtags LOCAL_SHARED_LIBRARIES := liblog -LOCAL_MODULE:= logcat +LOCAL_MODULE := logcat + +LOCAL_CFLAGS := -Werror include $(BUILD_EXECUTABLE) diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index 5a80efe..ea46345 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -227,22 +227,20 @@ static void show_help(const char *cmd) " -T <count> print only the most recent <count> lines (does not imply -d)\n" " -g get the size of the log's ring buffer and exit\n" " -b <buffer> Request alternate ring buffer, 'main', 'system', 'radio',\n" - " 'events' or 'all'. Multiple -b parameters are allowed and\n" - " results are interleaved. The default is -b main -b system.\n" + " 'events', 'crash' or 'all'. Multiple -b parameters are\n" + " allowed and results are interleaved. The default is\n" + " -b main -b system -b crash.\n" " -B output the log in binary.\n" - " -S output statistics.\n"); - -#ifdef USERDEBUG_BUILD - - fprintf(stderr, "--------------------- eng & userdebug builds only ---------------------------\n" - " -G <count> set size of log's ring buffer and exit\n" - " -p output prune white and ~black list\n" - " -P '<list> ...' set prune white and ~black list; UID, /PID or !(worst UID)\n" - " default is ~!, prune worst UID.\n" - "-----------------------------------------------------------------------------\n" - ); - -#endif + " -S output statistics.\n" + " -G <size> set size of log ring buffer, may suffix with K or M.\n" + " -p print prune white and ~black list. Service is specified as\n" + " UID, UID/PID or /PID. Weighed for quicker pruning if prefix\n" + " with ~, otherwise weighed for longevity if unadorned. All\n" + " other pruning activity is oldest first. Special case ~!\n" + " represents an automatic quicker pruning for the noisiest\n" + " UID as determined by the current statistics.\n" + " -P '<list> ...' set prune white and ~black list, using same format as\n" + " printed above. Must be quoted.\n"); fprintf(stderr,"\nfilterspecs are a series of \n" " <tag>[:priority]\n\n" @@ -283,19 +281,15 @@ static int setLogFormat(const char * formatString) return 0; } -extern "C" void logprint_run_tests(void); - int main(int argc, char **argv) { int err; int hasSetLogFormat = 0; int clearLog = 0; int getLogSize = 0; -#ifdef USERDEBUG_BUILD unsigned long setLogSize = 0; int getPruneList = 0; char *setPruneList = NULL; -#endif int printStatistics = 0; int mode = O_RDONLY; const char *forceFilters = NULL; @@ -310,11 +304,6 @@ int main(int argc, char **argv) g_logformat = android_log_format_new(); - if (argc == 2 && 0 == strcmp(argv[1], "--test")) { - logprint_run_tests(); - exit(0); - } - if (argc == 2 && 0 == strcmp(argv[1], "--help")) { android::show_help(argv[0]); exit(0); @@ -323,13 +312,7 @@ int main(int argc, char **argv) for (;;) { int ret; - ret = getopt(argc, argv, -#ifdef USERDEBUG_BUILD - "cdt:T:gG:sQf:r::n:v:b:BSpP:" -#else - "cdt:T:gsQf:r::n:v:b:BS" -#endif - ); + ret = getopt(argc, argv, "cdt:T:gG:sQf:r::n:v:b:BSpP:"); if (ret < 0) { break; @@ -386,8 +369,6 @@ int main(int argc, char **argv) getLogSize = 1; break; -#ifdef USERDEBUG_BUILD - case 'G': { // would use atol if not for the multiplier char *cp = optarg; @@ -433,8 +414,6 @@ int main(int argc, char **argv) setPruneList = optarg; break; -#endif - case 'b': { if (strcmp(optarg, "all") == 0) { while (devices) { @@ -462,10 +441,17 @@ int main(int argc, char **argv) if (android_name_to_log_id("events") == LOG_ID_EVENTS) { dev->next = new log_device_t("events", true, 'e'); if (dev->next) { + dev = dev->next; android::g_devCount++; needBinary = true; } } + if (android_name_to_log_id("crash") == LOG_ID_CRASH) { + dev->next = new log_device_t("crash", false, 'c'); + if (dev->next) { + android::g_devCount++; + } + } break; } @@ -503,9 +489,6 @@ int main(int argc, char **argv) android::g_logRotateSizeKBytes = DEFAULT_LOG_ROTATE_SIZE_KBYTES; } else { - long logRotateSize; - char *lastDigit; - if (!isdigit(optarg[0])) { fprintf(stderr,"Invalid parameter to -r\n"); android::show_help(argv[0]); @@ -622,6 +605,14 @@ int main(int argc, char **argv) devices->next = new log_device_t("system", false, 's'); android::g_devCount++; } + if (android_name_to_log_id("crash") == LOG_ID_CRASH) { + if (devices->next) { + devices->next->next = new log_device_t("crash", false, 'c'); + } else { + devices->next = new log_device_t("crash", false, 'c'); + } + android::g_devCount++; + } } if (android::g_logRotateSizeKBytes != 0 @@ -704,15 +695,11 @@ int main(int argc, char **argv) } } -#ifdef USERDEBUG_BUILD - if (setLogSize && android_logger_set_log_size(dev->logger, setLogSize)) { perror("failed to set the log size"); exit(EXIT_FAILURE); } -#endif - if (getLogSize) { long size, readable; @@ -737,8 +724,6 @@ int main(int argc, char **argv) dev = dev->next; } -#ifdef USERDEBUG_BUILD - if (setPruneList) { size_t len = strlen(setPruneList) + 32; // margin to allow rc char *buf = (char *) malloc(len); @@ -753,30 +738,18 @@ int main(int argc, char **argv) } } -#endif - - if ( -#ifdef USERDEBUG_BUILD - printStatistics || getPruneList -#else - printStatistics -#endif - ) { + if (printStatistics || getPruneList) { size_t len = 8192; char *buf; for(int retry = 32; (retry >= 0) && ((buf = new char [len])); delete [] buf, --retry) { -#ifdef USERDEBUG_BUILD if (getPruneList) { android_logger_get_prune_list(logger_list, buf, len); } else { android_logger_get_statistics(logger_list, buf, len); } -#else - android_logger_get_statistics(logger_list, buf, len); -#endif buf[len-1] = '\0'; size_t ret = atol(buf) + 1; if (ret < 4) { @@ -824,11 +797,9 @@ int main(int argc, char **argv) if (getLogSize) { exit(0); } -#ifdef USERDEBUG_BUILD if (setLogSize || setPruneList) { exit(0); } -#endif if (clearLog) { exit(0); } diff --git a/logcat/tests/Android.mk b/logcat/tests/Android.mk index 733af31..d42b3d0 100644 --- a/logcat/tests/Android.mk +++ b/logcat/tests/Android.mk @@ -30,10 +30,6 @@ test_c_flags := \ -Werror \ -fno-builtin -ifneq ($(filter userdebug eng,$(TARGET_BUILD_VARIANT)),) -test_c_flags += -DUSERDEBUG_BUILD=1 -endif - test_src_files := \ logcat_test.cpp \ diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp index 0165073..2e8ae8b 100644 --- a/logcat/tests/logcat_test.cpp +++ b/logcat/tests/logcat_test.cpp @@ -392,7 +392,7 @@ TEST(logcat, get_) { ASSERT_EQ(4, count); } -static void caught_blocking(int signum) +static void caught_blocking(int /*signum*/) { unsigned long long v = 0xDEADBEEFA55A0000ULL; @@ -461,7 +461,7 @@ TEST(logcat, blocking) { EXPECT_EQ(1, signals); } -static void caught_blocking_tail(int signum) +static void caught_blocking_tail(int /*signum*/) { unsigned long long v = 0xA55ADEADBEEF0000ULL; @@ -532,7 +532,7 @@ TEST(logcat, blocking_tail) { EXPECT_EQ(1, signals); } -static void caught_blocking_clear(int signum) +static void caught_blocking_clear(int /*signum*/) { unsigned long long v = 0xDEADBEEFA55C0000ULL; @@ -609,7 +609,6 @@ TEST(logcat, blocking_clear) { EXPECT_EQ(1, signals); } -#ifdef USERDEBUG_BUILD static bool get_white_black(char **list) { FILE *fp; @@ -705,4 +704,3 @@ TEST(logcat, white_black_adjust) { free(list); list = NULL; } -#endif // USERDEBUG_BUILD |