summaryrefslogtreecommitdiffstats
path: root/debuggerd
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2018-12-14 13:05:12 -0800
committerJosh Gao <jmgao@google.com>2018-12-14 13:29:52 -0800
commit6f4644d15b3df1a9be92348f23a62282a8b332f6 (patch)
treed96da52cef9a7b0d4e55cf8053139aff8b777e06 /debuggerd
parent8f1fcd5b943121e7b021c50468e01e71adb9d514 (diff)
downloadsystem_core-6f4644d15b3df1a9be92348f23a62282a8b332f6.tar.gz
system_core-6f4644d15b3df1a9be92348f23a62282a8b332f6.tar.bz2
system_core-6f4644d15b3df1a9be92348f23a62282a8b332f6.zip
libdebuggerd: add timestamp to tombstones.
Bug: http://b/120099273 Test: debuggerd_test Change-Id: I457506f8d9920d969e1eba0265f85693b484f1a9
Diffstat (limited to 'debuggerd')
-rw-r--r--debuggerd/libdebuggerd/test/tombstone_test.cpp8
-rw-r--r--debuggerd/libdebuggerd/tombstone.cpp10
2 files changed, 18 insertions, 0 deletions
diff --git a/debuggerd/libdebuggerd/test/tombstone_test.cpp b/debuggerd/libdebuggerd/test/tombstone_test.cpp
index 421ce43c0..d24c88731 100644
--- a/debuggerd/libdebuggerd/test/tombstone_test.cpp
+++ b/debuggerd/libdebuggerd/test/tombstone_test.cpp
@@ -15,6 +15,7 @@
*/
#include <stdlib.h>
+#include <time.h>
#include <memory>
#include <string>
@@ -494,3 +495,10 @@ TEST_F(TombstoneTest, dump_header_info) {
expected += android::base::StringPrintf("ABI: '%s'\n", ABI_STRING);
ASSERT_STREQ(expected.c_str(), amfd_data_.c_str());
}
+
+TEST_F(TombstoneTest, dump_timestamp) {
+ setenv("TZ", "UTC", 1);
+ tzset();
+ dump_timestamp(&log_, 0);
+ ASSERT_STREQ("Timestamp: 1970-01-01 00:00:00+0000\n", amfd_data_.c_str());
+}
diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp
index 11792635d..b20014f59 100644
--- a/debuggerd/libdebuggerd/tombstone.cpp
+++ b/debuggerd/libdebuggerd/tombstone.cpp
@@ -78,6 +78,15 @@ static void dump_header_info(log_t* log) {
_LOG(log, logtype::HEADER, "ABI: '%s'\n", ABI_STRING);
}
+static void dump_timestamp(log_t* log, time_t time) {
+ struct tm tm;
+ localtime_r(&time, &tm);
+
+ char buf[strlen("1970-01-01 00:00:00+0830") + 1];
+ strftime(buf, sizeof(buf), "%F %T%z", &tm);
+ _LOG(log, logtype::HEADER, "Timestamp: %s\n", buf);
+}
+
static void dump_probable_cause(log_t* log, const siginfo_t* si, BacktraceMap* map) {
std::string cause;
if (si->si_signo == SIGSEGV && si->si_code == SEGV_MAPERR) {
@@ -654,6 +663,7 @@ void engrave_tombstone(unique_fd output_fd, BacktraceMap* map, Memory* process_m
_LOG(&log, logtype::HEADER, "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n");
dump_header_info(&log);
+ dump_timestamp(&log, time(nullptr));
auto it = threads.find(target_thread);
if (it == threads.end()) {