From a05f09616779d2283e56016a4d659c01407ceaab Mon Sep 17 00:00:00 2001 From: deanlee Date: Wed, 15 Dec 2021 01:41:15 +0800 Subject: [PATCH 1/4] put logcat in boot log --- selfdrive/logcatd/logcatd_android.cc | 6 ++++-- selfdrive/loggerd/bootlog.cc | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/selfdrive/logcatd/logcatd_android.cc b/selfdrive/logcatd/logcatd_android.cc index 1a982a0feb48d7..4452e2f093ee28 100644 --- a/selfdrive/logcatd/logcatd_android.cc +++ b/selfdrive/logcatd/logcatd_android.cc @@ -14,8 +14,10 @@ int main() { ExitHandler do_exit; PubMaster pm({"androidLog"}); - log_time last_log_time = {}; - logger_list *logger_list = android_logger_list_alloc(ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 0, 0); + struct timespec cur_time; + clock_gettime(CLOCK_REALTIME, &cur_time); + log_time last_log_time(cur_time); + logger_list *logger_list = nullptr; while (!do_exit) { // setup android logging diff --git a/selfdrive/loggerd/bootlog.cc b/selfdrive/loggerd/bootlog.cc index 52099583775c12..0931694054e799 100644 --- a/selfdrive/loggerd/bootlog.cc +++ b/selfdrive/loggerd/bootlog.cc @@ -11,6 +11,8 @@ static kj::Array build_boot_log() { if (Hardware::TICI()) { bootlog_commands.push_back("journalctl"); bootlog_commands.push_back("sudo nvme smart-log --output-format=json /dev/nvme0"); + } else if(Hardware::EON()) { + bootlog_commands.push_back("logcat"); } MessageBuilder msg; From a0a5f35072e72f2a865a7108029b8239810f0834 Mon Sep 17 00:00:00 2001 From: deanlee Date: Wed, 15 Dec 2021 03:29:54 +0800 Subject: [PATCH 2/4] continue --- selfdrive/loggerd/bootlog.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/loggerd/bootlog.cc b/selfdrive/loggerd/bootlog.cc index 0931694054e799..478eb16852c4ef 100644 --- a/selfdrive/loggerd/bootlog.cc +++ b/selfdrive/loggerd/bootlog.cc @@ -11,8 +11,8 @@ static kj::Array build_boot_log() { if (Hardware::TICI()) { bootlog_commands.push_back("journalctl"); bootlog_commands.push_back("sudo nvme smart-log --output-format=json /dev/nvme0"); - } else if(Hardware::EON()) { - bootlog_commands.push_back("logcat"); + } else if (Hardware::EON()) { + bootlog_commands.push_back("logcat -d"); } MessageBuilder msg; From c671f8ca7160691791bade508c4a8eb5cdb73fb8 Mon Sep 17 00:00:00 2001 From: deanlee Date: Wed, 15 Dec 2021 03:38:27 +0800 Subject: [PATCH 3/4] use std::unique_ptr --- selfdrive/logcatd/logcatd_android.cc | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/selfdrive/logcatd/logcatd_android.cc b/selfdrive/logcatd/logcatd_android.cc index 4452e2f093ee28..af25d45bf5eec2 100644 --- a/selfdrive/logcatd/logcatd_android.cc +++ b/selfdrive/logcatd/logcatd_android.cc @@ -1,6 +1,8 @@ #include #include +#include + #include #include #include @@ -17,29 +19,28 @@ int main() { struct timespec cur_time; clock_gettime(CLOCK_REALTIME, &cur_time); log_time last_log_time(cur_time); - logger_list *logger_list = nullptr; while (!do_exit) { // setup android logging - if (!logger_list) { - logger_list = android_logger_list_alloc_time(ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, last_log_time, 0); - } + std::unique_ptr logger_list( + android_logger_list_alloc_time(ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, last_log_time, 0), + &android_logger_list_free); assert(logger_list); - struct logger *main_logger = android_logger_open(logger_list, LOG_ID_MAIN); + struct logger *main_logger = android_logger_open(logger_list.get(), LOG_ID_MAIN); assert(main_logger); - struct logger *radio_logger = android_logger_open(logger_list, LOG_ID_RADIO); + struct logger *radio_logger = android_logger_open(logger_list.get(), LOG_ID_RADIO); assert(radio_logger); - struct logger *system_logger = android_logger_open(logger_list, LOG_ID_SYSTEM); + struct logger *system_logger = android_logger_open(logger_list.get(), LOG_ID_SYSTEM); assert(system_logger); - struct logger *crash_logger = android_logger_open(logger_list, LOG_ID_CRASH); + struct logger *crash_logger = android_logger_open(logger_list.get(), LOG_ID_CRASH); assert(crash_logger); - struct logger *kernel_logger = android_logger_open(logger_list, (log_id_t)5); // LOG_ID_KERNEL + struct logger *kernel_logger = android_logger_open(logger_list.get(), (log_id_t)5); // LOG_ID_KERNEL assert(kernel_logger); while (!do_exit) { log_msg log_msg; - int err = android_logger_list_read(logger_list, &log_msg); + int err = android_logger_list_read(logger_list.get(), &log_msg); if (err <= 0) break; AndroidLogEntry entry; @@ -61,14 +62,8 @@ int main() { pm.send("androidLog", msg); } - android_logger_list_free(logger_list); - logger_list = NULL; util::sleep_for(500); } - if (logger_list) { - android_logger_list_free(logger_list); - } - return 0; } From 78043afeed0909d1dc914f7ea69d496e8c3515ee Mon Sep 17 00:00:00 2001 From: deanlee Date: Wed, 15 Dec 2021 03:43:29 +0800 Subject: [PATCH 4/4] Revert "use std::unique_ptr" This reverts commit c671f8ca7160691791bade508c4a8eb5cdb73fb8. --- selfdrive/logcatd/logcatd_android.cc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/selfdrive/logcatd/logcatd_android.cc b/selfdrive/logcatd/logcatd_android.cc index af25d45bf5eec2..4452e2f093ee28 100644 --- a/selfdrive/logcatd/logcatd_android.cc +++ b/selfdrive/logcatd/logcatd_android.cc @@ -1,8 +1,6 @@ #include #include -#include - #include #include #include @@ -19,28 +17,29 @@ int main() { struct timespec cur_time; clock_gettime(CLOCK_REALTIME, &cur_time); log_time last_log_time(cur_time); + logger_list *logger_list = nullptr; while (!do_exit) { // setup android logging - std::unique_ptr logger_list( - android_logger_list_alloc_time(ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, last_log_time, 0), - &android_logger_list_free); + if (!logger_list) { + logger_list = android_logger_list_alloc_time(ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, last_log_time, 0); + } assert(logger_list); - struct logger *main_logger = android_logger_open(logger_list.get(), LOG_ID_MAIN); + struct logger *main_logger = android_logger_open(logger_list, LOG_ID_MAIN); assert(main_logger); - struct logger *radio_logger = android_logger_open(logger_list.get(), LOG_ID_RADIO); + struct logger *radio_logger = android_logger_open(logger_list, LOG_ID_RADIO); assert(radio_logger); - struct logger *system_logger = android_logger_open(logger_list.get(), LOG_ID_SYSTEM); + struct logger *system_logger = android_logger_open(logger_list, LOG_ID_SYSTEM); assert(system_logger); - struct logger *crash_logger = android_logger_open(logger_list.get(), LOG_ID_CRASH); + struct logger *crash_logger = android_logger_open(logger_list, LOG_ID_CRASH); assert(crash_logger); - struct logger *kernel_logger = android_logger_open(logger_list.get(), (log_id_t)5); // LOG_ID_KERNEL + struct logger *kernel_logger = android_logger_open(logger_list, (log_id_t)5); // LOG_ID_KERNEL assert(kernel_logger); while (!do_exit) { log_msg log_msg; - int err = android_logger_list_read(logger_list.get(), &log_msg); + int err = android_logger_list_read(logger_list, &log_msg); if (err <= 0) break; AndroidLogEntry entry; @@ -62,8 +61,14 @@ int main() { pm.send("androidLog", msg); } + android_logger_list_free(logger_list); + logger_list = NULL; util::sleep_for(500); } + if (logger_list) { + android_logger_list_free(logger_list); + } + return 0; }