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

Commit ea7f05ab authored by Jason Iman's avatar Jason Iman
Browse files

dumpstate: Handle prev_boot_dump.trace specially

prev_boot_dump.trace is a special trace stored by the kernel of its last
boot events. This is specially useful when crashes are happening.

DD: go/persistent-tracing

Bug: 412895485
Test: See the the file is reported and not removed
Flag: NONE do nothing if the file does not exist
Change-Id: Ie5c8eb6f6584c1c71616db7ed2a3180d9b788ffd
parent f423c74b
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -212,6 +212,11 @@ static const std::string SHUTDOWN_CHECKPOINTS_FILE_PREFIX = "checkpoints-";
// File path to default screenshot image, that used when failed to capture the real screenshot.
static const std::string DEFAULT_SCREENSHOT_PATH = "/system/etc/default_screenshot.png";

// File path of the persistent ring buffer perfetto trace. This always exists when persistent ring
// buffer trace feature is enabled.
static const std::string PREV_BOOT_TRACE_PATH =
    std::string(SYSTEM_TRACE_DIR) + "/prev_boot_dump.trace";

// TODO: temporary variables and functions used during C++ refactoring

#define RETURN_IF_USER_DENIED_CONSENT()                                                        \
@@ -1129,6 +1134,9 @@ static void MaybeAddSystemTraceToZip() {
    // tracing was happening.
    size_t traces_found = android::os::ForEachTrace([&](const std::string& trace_path) {
        ds.AddZipEntry(ZIP_ROOT_DIR + trace_path, trace_path);
        if (trace_path == PREV_BOOT_TRACE_PATH) {
            return;
        }
        android::os::UnlinkAndLogOnError(trace_path);
    });

@@ -3604,7 +3612,12 @@ std::future<std::string> Dumpstate::MaybeSnapshotSystemTraceAsync() {
    }

    // If a stale file exists already, remove it.
    android::os::ForEachTrace([&](const std::string& trace_path) { unlink(trace_path.c_str()); });
    android::os::ForEachTrace([&](const std::string& trace_path) {
        if (trace_path == PREV_BOOT_TRACE_PATH) {
            return;
        }
        unlink(trace_path.c_str());
    });

    MYLOGI("Launching async '%s'", SERIALIZE_PERFETTO_TRACE_TASK.c_str())