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

Commit 73855b5e authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "binderRpcTest: backtrace on leaked session" am: 44568205 am:...

Merge "binderRpcTest: backtrace on leaked session" am: 44568205 am: 341a05cc am: 992e9ef4 am: 7c4521cc

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



Change-Id: I3c861393de2c7188dd37986c290de1297d620792
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 5cff7f4c 7c4521cc
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -85,6 +85,11 @@ static std::string WaitStatusToString(int wstatus) {
    return base::StringPrintf("unexpected state %d", wstatus);
}

static void debugBacktrace(pid_t pid) {
    std::cerr << "TAKING BACKTRACE FOR PID " << pid << std::endl;
    system((std::string("debuggerd -b ") + std::to_string(pid)).c_str());
}

class Process {
public:
    Process(Process&&) = default;
@@ -125,6 +130,8 @@ public:
    // Kill the process. Avoid if possible. Shutdown gracefully via an RPC instead.
    void terminate() { kill(mPid, SIGTERM); }

    pid_t getPid() { return mPid; }

private:
    std::function<void(int wstatus)> mCustomExitStatusCheck;
    pid_t mPid = 0;
@@ -173,7 +180,9 @@ struct ProcessSession {

            wp<RpcSession> weakSession = session;
            session = nullptr;
            EXPECT_EQ(nullptr, weakSession.promote()) << "Leaked session";

            EXPECT_EQ(nullptr, weakSession.promote())
                    << (debugBacktrace(host.getPid()), debugBacktrace(getpid()), "Leaked session");
        }
    }
};