diff options
author | zhouwenjie <zhouwenjie@google.com> | 2019-10-30 14:31:54 -0700 |
---|---|---|
committer | zhouwenjie <zhouwenjie@google.com> | 2019-11-01 11:24:44 -0700 |
commit | c3bf8040a30b2e53bf212c57a665830a3acc78f0 (patch) | |
tree | b55cbe1687d741f960a66d401a746df46d69e62e /cmds/incidentd/src | |
parent | 68be4332ae3d3cfa97981295ab38e54a816f24c0 (diff) |
Add last logcat data to incident report
Bug: 142721354
Test: adb sehll incident -p EXPLICIT 1109
Change-Id: Iaee370310e36998e161955e0f12d98ac8cd8eb90
Diffstat (limited to 'cmds/incidentd/src')
-rw-r--r-- | cmds/incidentd/src/Section.cpp | 30 | ||||
-rw-r--r-- | cmds/incidentd/src/Section.h | 6 |
2 files changed, 28 insertions, 8 deletions
diff --git a/cmds/incidentd/src/Section.cpp b/cmds/incidentd/src/Section.cpp index f476fcf91bd5..0176f8047974 100644 --- a/cmds/incidentd/src/Section.cpp +++ b/cmds/incidentd/src/Section.cpp @@ -476,10 +476,27 @@ status_t DumpsysSection::BlockingCall(int pipeWriteFd) const { // initialization only once in Section.cpp. map<log_id_t, log_time> LogSection::gLastLogsRetrieved; -LogSection::LogSection(int id, log_id_t logID) : WorkerThreadSection(id), mLogID(logID) { - name = "logcat "; - name += android_log_id_to_name(logID); - switch (logID) { +LogSection::LogSection(int id, const char* logID, ...) : WorkerThreadSection(id), mLogMode(logModeBase) { + name = "logcat -b "; + name += logID; + + va_list args; + va_start(args, logID); + mLogID = android_name_to_log_id(logID); + while(true) { + const char* arg = va_arg(args, const char*); + if (arg == NULL) { + break; + } + if (!strcmp(arg, "-L")) { + // Read from last logcat buffer + mLogMode = mLogMode | ANDROID_LOG_PSTORE; + } + name += " "; + name += arg; + } + + switch (mLogID) { case LOG_ID_EVENTS: case LOG_ID_STATS: case LOG_ID_SECURITY: @@ -512,9 +529,8 @@ status_t LogSection::BlockingCall(int pipeWriteFd) const { // Open log buffer and getting logs since last retrieved time if any. unique_ptr<logger_list, void (*)(logger_list*)> loggers( gLastLogsRetrieved.find(mLogID) == gLastLogsRetrieved.end() - ? android_logger_list_alloc(ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 0, 0) - : android_logger_list_alloc_time(ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, - gLastLogsRetrieved[mLogID], 0), + ? android_logger_list_alloc(mLogMode, 0, 0) + : android_logger_list_alloc_time(mLogMode, gLastLogsRetrieved[mLogID], 0), android_logger_list_free); if (android_logger_open(loggers.get(), mLogID) == NULL) { diff --git a/cmds/incidentd/src/Section.h b/cmds/incidentd/src/Section.h index c9b80563a609..fcf12f7336fd 100644 --- a/cmds/incidentd/src/Section.h +++ b/cmds/incidentd/src/Section.h @@ -146,8 +146,11 @@ class LogSection : public WorkerThreadSection { // global last log retrieved timestamp for each log_id_t. static map<log_id_t, log_time> gLastLogsRetrieved; + // log mode: read only & non blocking. + const static int logModeBase = ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK; + public: - LogSection(int id, log_id_t logID); + LogSection(int id, const char* logID, ...); virtual ~LogSection(); virtual status_t BlockingCall(int pipeWriteFd) const; @@ -155,6 +158,7 @@ public: private: log_id_t mLogID; bool mBinary; + int mLogMode; }; /** |