diff options
author | Zhengyin Qian <qianzy@google.com> | 2016-06-29 17:55:47 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-06-29 17:55:47 +0000 |
commit | bcbe37b0ee88331659dff7dfbb77386aa6222f63 (patch) | |
tree | 3ce24dd697425d622854c3af5a3d6fcd21b135e7 | |
parent | 9458a99b0c69dd65facc6ef975218848e8b1f0b6 (diff) | |
parent | 20e3c1bc9429230b7379db3747fd0c918f76af27 (diff) | |
download | extras-bcbe37b0ee88331659dff7dfbb77386aa6222f63.tar.gz |
ANRdaemon: move trace result from /sdcard to /data am: d93aa41807 am: adfc967454
am: 20e3c1bc94
Change-Id: Ib688c2e38c181d6fdc2ca901782934dc4726eb52
-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 |