Loading cmds/dumpstate/dumpstate.cpp +19 −1 Original line number Diff line number Diff line Loading @@ -219,7 +219,8 @@ static bool dump_anrd_trace() { struct dirent *trace; struct stat st; DIR *trace_dir; long max_ctime = 0; int retry = 5; long max_ctime = 0, old_mtime; long long cur_size = 0; const char *trace_path = "/data/misc/anrd/"; Loading @@ -232,6 +233,13 @@ static bool dump_anrd_trace() { pid = pid_of_process("/system/xbin/anrd"); if (pid > 0) { if (stat(trace_path, &st) == 0) { old_mtime = st.st_mtime; } else { MYLOGE("Failed to find: %s\n", trace_path); return false; } // send SIGUSR1 to the anrd to generate a trace. sprintf(buf, "%u", pid); if (run_command("ANRD_DUMP", 1, "kill", "-SIGUSR1", buf, NULL)) { Loading @@ -239,6 +247,16 @@ static bool dump_anrd_trace() { return false; } while (retry-- > 0 && old_mtime == st.st_mtime) { sleep(1); stat(trace_path, &st); } if (retry < 0 && old_mtime == st.st_mtime) { MYLOGE("Failed to stat %s or trace creation timeout\n", trace_path); return false; } // identify the trace file by its creation time. if (!(trace_dir = opendir(trace_path))) { MYLOGE("Can't open trace file under %s\n", trace_path); Loading Loading
cmds/dumpstate/dumpstate.cpp +19 −1 Original line number Diff line number Diff line Loading @@ -219,7 +219,8 @@ static bool dump_anrd_trace() { struct dirent *trace; struct stat st; DIR *trace_dir; long max_ctime = 0; int retry = 5; long max_ctime = 0, old_mtime; long long cur_size = 0; const char *trace_path = "/data/misc/anrd/"; Loading @@ -232,6 +233,13 @@ static bool dump_anrd_trace() { pid = pid_of_process("/system/xbin/anrd"); if (pid > 0) { if (stat(trace_path, &st) == 0) { old_mtime = st.st_mtime; } else { MYLOGE("Failed to find: %s\n", trace_path); return false; } // send SIGUSR1 to the anrd to generate a trace. sprintf(buf, "%u", pid); if (run_command("ANRD_DUMP", 1, "kill", "-SIGUSR1", buf, NULL)) { Loading @@ -239,6 +247,16 @@ static bool dump_anrd_trace() { return false; } while (retry-- > 0 && old_mtime == st.st_mtime) { sleep(1); stat(trace_path, &st); } if (retry < 0 && old_mtime == st.st_mtime) { MYLOGE("Failed to stat %s or trace creation timeout\n", trace_path); return false; } // identify the trace file by its creation time. if (!(trace_dir = opendir(trace_path))) { MYLOGE("Can't open trace file under %s\n", trace_path); Loading