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

Commit 5be46f64 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9794275 from 2c7e9b78 to udc-release

Change-Id: I629006570d91e51832e346e5ef80d1bdccaa2e0b
parents 7b2d80aa 2c7e9b78
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1254,7 +1254,8 @@ static Dumpstate::RunStatus RunDumpsysTextByPriority(const std::string& title, i
             dumpsys.writeDumpHeader(STDOUT_FILENO, service, priority);
             dumpsys.writeDumpFooter(STDOUT_FILENO, service, std::chrono::milliseconds(1));
        } else {
             status_t status = dumpsys.startDumpThread(Dumpsys::TYPE_DUMP | Dumpsys::TYPE_PID,
             status_t status = dumpsys.startDumpThread(Dumpsys::TYPE_DUMP | Dumpsys::TYPE_PID |
                                                       Dumpsys::TYPE_CLIENTS | Dumpsys::TYPE_THREAD,
                                                       service, args);
             if (status == OK) {
                dumpsys.writeDumpHeader(STDOUT_FILENO, service, priority);
+4 −0
Original line number Diff line number Diff line
@@ -360,6 +360,10 @@ Status ServiceManager::addService(const std::string& name, const sp<IBinder>& bi
    }
#endif  // !VENDORSERVICEMANAGER

    if ((dumpPriority & DUMP_FLAG_PRIORITY_ALL) == 0) {
        ALOGW("Dump flag priority is not set when adding %s", name.c_str());
    }

    // implicitly unlinked when the binder is removed
    if (binder->remoteBinder() != nullptr &&
        binder->linkToDeath(sp<ServiceManager>::fromExisting(this)) != OK) {
+21 −6
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public:
            }

            LOG_RPC_DETAIL("RpcTransport poll(): %s", strerror(savedErrno));
            return -savedErrno;
            return adjustStatus(-savedErrno);
        }

        if (pfd.revents & POLLNVAL) {
@@ -87,8 +87,10 @@ public:
                                "File descriptors are not supported on Trusty yet");
            return TEMP_FAILURE_RETRY(tipc_send(mSocket.fd.get(), iovs, niovs, nullptr, 0));
        };
        return interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, writeFn, "tipc_send",
                                        POLLOUT, altPoll);

        status_t status = interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, writeFn,
                                                   "tipc_send", POLLOUT, altPoll);
        return adjustStatus(status);
    }

    status_t interruptableReadFully(
@@ -121,13 +123,26 @@ public:

            return processSize;
        };
        return interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, readFn, "read", POLLIN,
                                        altPoll);

        status_t status = interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, readFn, "read",
                                                   POLLIN, altPoll);
        return adjustStatus(status);
    }

    bool isWaiting() override { return mSocket.isInPollingState(); }

private:
    status_t adjustStatus(status_t status) {
        if (status == -ENOTCONN) {
            // TIPC returns ENOTCONN on disconnect, but that's basically
            // the same as DEAD_OBJECT and the latter is the common libbinder
            // error code for dead connections
            return DEAD_OBJECT;
        }

        return status;
    }

    status_t fillReadBuffer() {
        if (mReadBufferPos < mReadBufferSize) {
            return OK;
@@ -167,7 +182,7 @@ private:
                    continue;
                } else {
                    LOG_RPC_DETAIL("RpcTransport fillBuffer(): %s", strerror(savedErrno));
                    return -savedErrno;
                    return adjustStatus(-savedErrno);
                }
            } else {
                mReadBufferSize = static_cast<size_t>(processSize);
+96 −70
Original line number Diff line number Diff line
@@ -48,14 +48,12 @@ static status_t scanBinderContext(pid_t pid, const std::string& contextName,
            return -errno;
        }
    }
    static const std::regex kContextLine("^context (\\w+)$");

    bool isDesiredContext = false;
    std::string line;
    std::smatch match;
    while (getline(ifs, line)) {
        if (std::regex_search(line, match, kContextLine)) {
            isDesiredContext = match.str(1) == contextName;
        if (base::StartsWith(line, "context")) {
            isDesiredContext = base::Split(line, " ").back() == contextName;
            continue;
        }
        if (!isDesiredContext) {
@@ -66,42 +64,55 @@ static status_t scanBinderContext(pid_t pid, const std::string& contextName,
    return OK;
}

// Examples of what we are looking at:
// node 66730: u00007590061890e0 c0000759036130950 pri 0:120 hs 1 hw 1 ls 0 lw 0 is 2 iw 2 tr 1 proc 2300 1790
// thread 2999: l 00 need_return 1 tr 0
status_t getBinderPidInfo(BinderDebugContext context, pid_t pid, BinderPidInfo* pidInfo) {
    std::smatch match;
    static const std::regex kReferencePrefix("^\\s*node \\d+:\\s+u([0-9a-f]+)\\s+c([0-9a-f]+)\\s+");
    static const std::regex kThreadPrefix("^\\s*thread \\d+:\\s+l\\s+(\\d)(\\d)");
    std::string contextStr = contextToString(context);
    status_t ret = scanBinderContext(pid, contextStr, [&](const std::string& line) {
        if (std::regex_search(line, match, kReferencePrefix)) {
            const std::string& ptrString = "0x" + match.str(2); // use number after c
            uint64_t ptr;
        if (base::StartsWith(line, "  node")) {
            std::vector<std::string> splitString = base::Tokenize(line, " ");
            bool pids = false;
            uint64_t ptr = 0;
            for (const auto& token : splitString) {
                if (base::StartsWith(token, "u")) {
                    const std::string ptrString = "0x" + token.substr(1);
                    if (!::android::base::ParseUint(ptrString.c_str(), &ptr)) {
                // Should not reach here, but just be tolerant.
                        LOG(ERROR) << "Failed to parse pointer: " << ptrString;
                        return;
                    }
            const std::string proc = " proc ";
            auto pos = line.rfind(proc);
            if (pos != std::string::npos) {
                for (const std::string& pidStr : base::Split(line.substr(pos + proc.size()), " ")) {
                } else {
                    // The last numbers in the line after "proc" are all client PIDs
                    if (token == "proc") {
                        pids = true;
                    } else if (pids) {
                        int32_t pid;
                    if (!::android::base::ParseInt(pidStr, &pid)) {
                        if (!::android::base::ParseInt(token, &pid)) {
                            LOG(ERROR) << "Failed to parse pid int: " << token;
                            return;
                        }
                        if (ptr == 0) {
                            LOG(ERROR) << "We failed to parse the pointer, so we can't add the refPids";
                            return;
                        }
                        pidInfo->refPids[ptr].push_back(pid);
                    }
                }

            return;
            }
        if (std::regex_search(line, match, kThreadPrefix)) {
        } else if (base::StartsWith(line, "  thread")) {
            auto pos = line.find("l ");
            if (pos != std::string::npos) {
                // "1" is waiting in binder driver
                // "2" is poll. It's impossible to tell if these are in use.
                //     and HIDL default code doesn't use it.
            bool isInUse = match.str(1) != "1";
                bool isInUse = line.at(pos + 2) != '1';
                // "0" is a thread that has called into binder
                // "1" is looper thread
                // "2" is main looper thread
            bool isBinderThread = match.str(2) != "0";
                bool isBinderThread = line.at(pos + 3) != '0';
                if (!isBinderThread) {
                    return;
                }
@@ -110,13 +121,15 @@ status_t getBinderPidInfo(BinderDebugContext context, pid_t pid, BinderPidInfo*
                }

                pidInfo->threadCount++;
            return;
            }
        return;
        }
    });
    return ret;
}

// Examples of what we are looking at:
// ref 52493: desc 910 node 52492 s 1 w 1 d 0000000000000000
// node 29413: u00007803fc982e80 c000078042c982210 pri 0:139 hs 1 hw 1 ls 0 lw 0 is 2 iw 2 tr 1 proc 488 683
status_t getBinderClientPids(BinderDebugContext context, pid_t pid, pid_t servicePid,
                             int32_t handle, std::vector<pid_t>* pids) {
    std::smatch match;
@@ -124,51 +137,64 @@ status_t getBinderClientPids(BinderDebugContext context, pid_t pid, pid_t servic
    std::string contextStr = contextToString(context);
    int32_t node;
    status_t ret = scanBinderContext(pid, contextStr, [&](const std::string& line) {
        if (std::regex_search(line, match, kNodeNumber)) {
            const std::string& descString = match.str(1);
            int32_t desc;
            if (!::android::base::ParseInt(descString.c_str(), &desc)) {
                LOG(ERROR) << "Failed to parse desc int: " << descString;
        if (!base::StartsWith(line, "  ref")) return;

        std::vector<std::string> splitString = base::Tokenize(line, " ");
        if (splitString.size() < 12) {
            LOG(ERROR) << "Failed to parse binder_logs ref entry. Expecting size greater than 11, but got: " << splitString.size();
            return;
        }
            if (handle != desc) {
        int32_t desc;
        if (!::android::base::ParseInt(splitString[3].c_str(), &desc)) {
            LOG(ERROR) << "Failed to parse desc int: " << splitString[3];
            return;
        }
            const std::string& nodeString = match.str(2);
            if (!::android::base::ParseInt(nodeString.c_str(), &node)) {
                LOG(ERROR) << "Failed to parse node int: " << nodeString;
        if (handle != desc) {
            return;
        }
        if (!::android::base::ParseInt(splitString[5].c_str(), &node)) {
            LOG(ERROR) << "Failed to parse node int: " << splitString[5];
            return;
        }
        return;
        LOG(INFO) << "Parsed the node: " << node;
    });
    if (ret != OK) {
        return ret;
    }
    static const std::regex kClients("^\\s+node\\s+(\\d+).*proc\\s+([\\d+\\s*]*)");

    ret = scanBinderContext(servicePid, contextStr, [&](const std::string& line) {
        if (std::regex_search(line, match, kClients)) {
            const std::string nodeString = match.str(1);
        if (!base::StartsWith(line, "  node")) return;

        std::vector<std::string> splitString = base::Tokenize(line, " ");
        if (splitString.size() < 21) {
            LOG(ERROR) << "Failed to parse binder_logs node entry. Expecting size greater than 20, but got: " << splitString.size();
            return;
        }

        // remove the colon
        const std::string nodeString = splitString[1].substr(0, splitString[1].size() - 1);
        int32_t matchedNode;
        if (!::android::base::ParseInt(nodeString.c_str(), &matchedNode)) {
            LOG(ERROR) << "Failed to parse node int: " << nodeString;
            return;
        }

        if (node != matchedNode) {
            return;
        }
            const std::string clients = match.str(2);
            for (const std::string& pidStr : base::Split(clients, " ")) {
        bool pidsSection = false;
        for (const auto& token : splitString) {
            if (token == "proc") {
                pidsSection = true;
            } else if (pidsSection == true) {
                int32_t pid;
                if (!::android::base::ParseInt(pidStr, &pid)) {
                if (!::android::base::ParseInt(token.c_str(), &pid)) {
                    LOG(ERROR) << "Failed to parse PID int: " << token;
                    return;
                }
                pids->push_back(pid);
            }
            return;
        }
        return;
    });
    return ret;
}
+2 −2
Original line number Diff line number Diff line
@@ -177,14 +177,14 @@ enum AHardwareBuffer_Format {
    /**
     * Corresponding formats:
     *   Vulkan: VK_FORMAT_R16_UINT
     *   OpenGL ES: GR_GL_R16UI
     *   OpenGL ES: GL_R16UI
     */
    AHARDWAREBUFFER_FORMAT_R16_UINT                 = 0x39,

    /**
     * Corresponding formats:
     *   Vulkan: VK_FORMAT_R16G16_UINT
     *   OpenGL ES: GR_GL_RG16UI
     *   OpenGL ES: GL_RG16UI
     */
    AHARDWAREBUFFER_FORMAT_R16G16_UINT              = 0x3a,

Loading