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

Commit 561ca13c authored by Kevin Jeon's avatar Kevin Jeon Committed by Automerger Merge Worker
Browse files

Merge "Skip dumping backtraces for cached processes" am: 8731e5ab am:...

Merge "Skip dumping backtraces for cached processes" am: 8731e5ab am: 1ec4ca1f am: c881f772 am: eb11699a

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2528109



Change-Id: I0da96927fd3005f2bbed4ae0c9eab1623aea13e9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 47f31f5a eb11699a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2206,6 +2206,16 @@ Dumpstate::RunStatus Dumpstate::DumpTraces(const char** path) {
            continue;
        }

        // Skip cached processes.
        if (IsCached(pid)) {
            // For consistency, the header and footer to this message match those
            // dumped by debuggerd in the success case.
            dprintf(fd, "\n---- pid %d at [unknown] ----\n", pid);
            dprintf(fd, "Dump skipped for cached process.\n");
            dprintf(fd, "---- end %d ----", pid);
            continue;
        }

        const std::string link_name = android::base::StringPrintf("/proc/%d/exe", pid);
        std::string exe;
        if (!android::base::Readlink(link_name, &exe)) {
+16 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include <set>

#include <android-base/file.h>
#include <android-base/parseint.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
@@ -210,3 +211,18 @@ bool IsZygote(int pid) {
    return cmdline == "zygote" || cmdline == "zygote64" || cmdline == "usap32" ||
            cmdline == "usap64" || cmdline == "webview_zygote";
}

bool IsCached(int pid) {
    std::string oom_score_adj;
    if (!android::base::ReadFileToString(android::base::StringPrintf("/proc/%d/oom_score_adj",
                                                                     pid),
                                         &oom_score_adj)) {
        return false;
    }
    int32_t oom_score_adj_value;
    if (!android::base::ParseInt(android::base::Trim(oom_score_adj), &oom_score_adj_value)) {
        return false;
    }
    // An OOM score greater than 900 indicates a cached process.
    return oom_score_adj_value >= 900;
}
+2 −0
Original line number Diff line number Diff line
@@ -25,4 +25,6 @@ std::set<int> get_interesting_pids();

bool IsZygote(int pid);

bool IsCached(int pid);

#endif  // DUMPUTILS_H_