Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 430e0797 authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Add dumpsys finish timestamp



Dumpsys are very helpful to debug issues.
Nevertheless a recurrent problem is that the dumpsys take time especially
if multiple are taken like during a bug report generation.
Due to this delay, it can be hard to understand during
which logs a dumpsys was taken.

This commit changes the last line of a dumpsys to contain the time it
was generated.
Here is an example:

[... normal dumpsys...]
    - Mix ID 8 I/O handle 37
  - 1 sinks:
    - Device ID 7 AUDIO_DEVICE_OUT_TELEPHONY_TX
Audio Policy Mix:
--------- 0.036s was the duration of dumpsys media.audio_policy, ending at: 2017-08-14 20:35:43

This patch adds the last part:
*, ending at: 2017-08-14 20:35:43*

Bug: 64699427
Test: adb bugreport
Test:  mmm -j32 frameworks/native/cmds/dumpsys && adb sync data && adb shell /data/nativetest/dumpsys_test/dumpsys_test --gtest_filter=-DumpsysTest.DumpRunningServiceTimeout
       # DumpRunningServiceTimeout is broken independently of this patch
Change-Id: I9873e7dd915b4f7cdd6eac5c44487ae5740fa805
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent d2bc3ac8
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


#include <algorithm>
#include <algorithm>
#include <chrono>
#include <chrono>
#include <iomanip>
#include <thread>
#include <thread>


#include <android-base/file.h>
#include <android-base/file.h>
@@ -282,7 +283,14 @@ int Dumpsys::main(int argc, char* const argv[]) {
              std::chrono::duration<double> elapsed_seconds =
              std::chrono::duration<double> elapsed_seconds =
                  std::chrono::steady_clock::now() - start;
                  std::chrono::steady_clock::now() - start;
              aout << StringPrintf("--------- %.3fs ", elapsed_seconds.count()).c_str()
              aout << StringPrintf("--------- %.3fs ", elapsed_seconds.count()).c_str()
                   << "was the duration of dumpsys " << service_name << endl;
                   << "was the duration of dumpsys " << service_name;

              using std::chrono::system_clock;
              const auto finish = system_clock::to_time_t(system_clock::now());
              std::tm finish_tm;
              localtime_r(&finish, &finish_tm);
              aout << ", ending at: " << std::put_time(&finish_tm, "%Y-%m-%d %H:%M:%S")
                   << endl;
            }
            }
        } else {
        } else {
            aerr << "Can't find service: " << service_name << endl;
            aerr << "Can't find service: " << service_name << endl;