diff options
author | Zhengyin Qian <qianzy@google.com> | 2016-06-21 14:05:44 -0700 |
---|---|---|
committer | Zhengyin Qian <qianzy@google.com> | 2016-06-22 16:12:35 -0700 |
commit | d93aa418071ba2bbf72de4003719d68650426c58 (patch) | |
tree | 44a55908685e07abe1cb8d605dbebdf12c870f31 | |
parent | 9e90477a678b5b5fa6ac6dd7e78770746d6c50bf (diff) | |
download | extras-d93aa418071ba2bbf72de4003719d68650426c58.tar.gz |
ANRdaemon: move trace result from /sdcard to /data
Bug: 28765756
Change-Id: Ic9461bc66c8ba4df1455d8b75c4fb6b544d0cf27
-rw-r--r-- | ANRdaemon/ANRdaemon.cpp | 23 | ||||
-rwxr-xr-x | ANRdaemon/ANRdaemon_get_trace.sh | 6 |
2 files changed, 11 insertions, 18 deletions
diff --git a/ANRdaemon/ANRdaemon.cpp b/ANRdaemon/ANRdaemon.cpp index 7b77a86c..d611bf62 100644 --- a/ANRdaemon/ANRdaemon.cpp +++ b/ANRdaemon/ANRdaemon.cpp @@ -67,6 +67,8 @@ static const int min_buffer_size = 16; static const int max_buffer_size = 2048; static const char *min_buffer_size_str = "16"; static const char *max_buffer_size_str = "2048"; +static const int time_buf_size = 20; +static const int path_buf_size = 60; typedef struct cpu_stat { unsigned long utime, ntime, stime, itime; @@ -337,28 +339,17 @@ static void dump_trace() } /* - * Create /sdcard/ANRdaemon/ if it doesn't exist - */ - struct stat st; - if (stat("/sdcard/ANRdaemon", &st) == -1) { - ALOGI("Creating /sdcard/ANRdaemon/"); - int err = mkdir("/sdcard/ANRdaemon", 0700); - if (err != 0) - ALOGI("Creating /sdcard/ANRdaemon/ failed with %s", strerror(err)); - } - - /* - * Create a dump file "dump_of_anrdaemon.<current_time>" under /sdcard/ANRdaemon/ + * Create a dump file "dump_of_anrdaemon.<current_time>" under /data/misc/anrd */ time_t now = time(0); struct tm tstruct; - char time_buf[80]; - char path_buf[200]; + char time_buf[time_buf_size]; + char path_buf[path_buf_size]; const char* header = " done\nTRACE:\n"; ssize_t header_len = strlen(header); tstruct = *localtime(&now); - strftime(time_buf, sizeof(time_buf), "%Y-%m-%d.%X", &tstruct); - sprintf(path_buf, "/sdcard/ANRdaemon/dump_of_anrdaemon.%s", time_buf); + strftime(time_buf, time_buf_size, "%Y-%m-%d.%X", &tstruct); + snprintf(path_buf, path_buf_size, "/data/misc/anrd/dump_of_anrdaemon.%s", time_buf); int output_fd = creat(path_buf, S_IRWXU); if (output_fd == -1) { ALOGE("Failed to create %s. Dump aborted.", path_buf); diff --git a/ANRdaemon/ANRdaemon_get_trace.sh b/ANRdaemon/ANRdaemon_get_trace.sh index be4062c7..afe3120b 100755 --- a/ANRdaemon/ANRdaemon_get_trace.sh +++ b/ANRdaemon/ANRdaemon_get_trace.sh @@ -1,6 +1,7 @@ #!/bin/bash -TRACE_DIR=/sdcard/ANRdaemon +TRACE_DIR=/data/misc/anrd +TRACE_FILE_PATTEN=dump_of_anrdaemon if [ $# -eq 1 ]; then DEVICE=$(echo "-s $1") @@ -18,7 +19,8 @@ fi PID=$(echo "$PID" | awk '{ print $2 }') adb $DEVICE shell "kill -s SIGUSR1 $PID" -TRACE_FILE=$(adb $DEVICE shell "ls $TRACE_DIR | tail -n1" | tr -d '\r') +TRACE_FILE=$(adb $DEVICE shell "ls $TRACE_DIR \ + grep $TRACE_FILE_PATTEN | tail -n1" | tr -d '\r') # Wiat the trace file generation to complete adb $DEVICE shell "lsof $PID" | grep $TRACE_FILE > /dev/null |