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

Commit 655da335 authored by Yifan Hong's avatar Yifan Hong Committed by android-build-merger
Browse files

Merge changes from topic "lshal_pretty" am: 303322f0

am: e1111eb1

Change-Id: I8a053e2ad9c41fa5583cfcfcf4a2c6f8a686eb0d
parents 68fff238 e1111eb1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ cc_library_shared {
        "Lshal.cpp",
        "ListCommand.cpp",
        "PipeRelay.cpp",
        "TableEntry.cpp",
        "TextTable.cpp",
        "utils.cpp",
    ],
@@ -60,6 +61,7 @@ cc_test {
        "libgmock"
    ],
    shared_libs: [
        "libvintf",
        "android.hardware.tests.baz@1.0"
    ],
    srcs: [
+117 −178

File changed.

Preview size limit exceeded, changes collapsed.

+18 −17
Original line number Diff line number Diff line
@@ -36,34 +36,38 @@ namespace lshal {

class Lshal;

struct PidInfo {
    std::map<uint64_t, Pids> refPids; // pids that are referenced
    uint32_t threadUsage; // number of threads in use
    uint32_t threadCount; // number of threads total
};

class ListCommand {
public:
    ListCommand(Lshal &lshal);
    virtual ~ListCommand() = default;
    Status main(const std::string &command, const Arg &arg);
private:
protected:
    Status parseArgs(const std::string &command, const Arg &arg);
    Status fetch();
    void postprocess();
    void dump();
    Status dump();
    void putEntry(TableEntrySource source, TableEntry &&entry);
    Status fetchPassthrough(const sp<::android::hidl::manager::V1_0::IServiceManager> &manager);
    Status fetchBinderized(const sp<::android::hidl::manager::V1_0::IServiceManager> &manager);
    Status fetchAllLibraries(const sp<::android::hidl::manager::V1_0::IServiceManager> &manager);

    struct PidInfo {
        std::map<uint64_t, Pids> refPids; // pids that are referenced
        uint32_t threadUsage; // number of threads in use
        uint32_t threadCount; // number of threads total
    };
    bool getPidInfo(pid_t serverPid, PidInfo *info) const;
    virtual bool getPidInfo(pid_t serverPid, PidInfo *info) const;

    void dumpTable();
    void dumpVintf() const;
    void dumpTable(const NullableOStream<std::ostream>& out) const;
    void dumpVintf(const NullableOStream<std::ostream>& out) const;
    void addLine(TextTable *table, const std::string &interfaceName, const std::string &transport,
                 const std::string &arch, const std::string &threadUsage, const std::string &server,
                 const std::string &serverCmdline, const std::string &address,
                 const std::string &clients, const std::string &clientCmdlines) const;
    void addLine(TextTable *table, const TableEntry &entry);
    // Read and return /proc/{pid}/cmdline.
    virtual std::string parseCmdline(pid_t pid) const;
    // Return /proc/{pid}/cmdline if it exists, else empty string.
    const std::string &getCmdline(pid_t pid);
    // Call getCmdline on all pid in pids. If it returns empty string, the process might
@@ -72,21 +76,18 @@ private:
    void forEachTable(const std::function<void(Table &)> &f);
    void forEachTable(const std::function<void(const Table &)> &f) const;

    NullableOStream<std::ostream> err() const;
    NullableOStream<std::ostream> out() const;

    Lshal &mLshal;

    Table mServicesTable{};
    Table mPassthroughRefTable{};
    Table mImplementationsTable{};

    NullableOStream<std::ostream> mErr;
    NullableOStream<std::ostream> mOut;
    NullableOStream<std::ofstream> mFileOutput = nullptr;
    std::string mFileOutputPath;
    TableEntryCompare mSortColumn = nullptr;
    std::vector<TableColumnType> mSelectedColumns;
    // If true, cmdlines will be printed instead of pid.
    bool mEnableCmdlines = false;

    // If true, calls IBase::debug(...) on each service.
    bool mEmitDebugInfo = false;

    // If true, output in VINTF format.
+4 −4
Original line number Diff line number Diff line
@@ -109,15 +109,15 @@ void Lshal::usage(const std::string &command) const {
            "        Print help message for debug\n";

    if (command == "list") {
        mErr << list;
        err() << list;
        return;
    }
    if (command == "debug") {
        mErr << debug;
        err() << debug;
        return;
    }

    mErr << helpSummary << "\n" << list << "\n" << debug << "\n" << help;
    err() << helpSummary << "\n" << list << "\n" << debug << "\n" << help;
}

// A unique_ptr type using a custom deleter function.
@@ -206,7 +206,7 @@ Status Lshal::parseArgs(const Arg &arg) {
        return OK;
    }

    mErr << arg.argv[0] << ": unrecognized option `" << arg.argv[optind] << "`" << std::endl;
    err() << arg.argv[0] << ": unrecognized option `" << arg.argv[optind] << "`" << std::endl;
    usage();
    return USAGE;
}
+3 −2
Original line number Diff line number Diff line
@@ -33,13 +33,14 @@ namespace lshal {
class Lshal {
public:
    Lshal();
    virtual ~Lshal() {}
    Lshal(std::ostream &out, std::ostream &err,
            sp<hidl::manager::V1_0::IServiceManager> serviceManager,
            sp<hidl::manager::V1_0::IServiceManager> passthroughManager);
    Status main(const Arg &arg);
    void usage(const std::string &command = "") const;
    NullableOStream<std::ostream> err() const;
    NullableOStream<std::ostream> out() const;
    virtual NullableOStream<std::ostream> err() const;
    virtual NullableOStream<std::ostream> out() const;
    const sp<hidl::manager::V1_0::IServiceManager> &serviceManager() const;
    const sp<hidl::manager::V1_0::IServiceManager> &passthroughManager() const;

Loading