Loading cmds/lshal/DebugCommand.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,14 @@ Status DebugCommand::parseArgs(const Arg &arg) { if (optind >= arg.argc) { return USAGE; } // Optargs cannnot be used because the flag should not be considered set // if it should really be contained in mOptions. if (std::string(arg.argv[optind]) == "-E") { mExcludesParentInstances = true; optind++; } mInterfaceName = arg.argv[optind]; ++optind; for (; optind < arg.argc; ++optind) { Loading @@ -59,6 +67,7 @@ Status DebugCommand::main(const Arg &arg) { return mLshal.emitDebugInfo( pair.first, pair.second.empty() ? "default" : pair.second, mOptions, mExcludesParentInstances, mLshal.out().buf(), mLshal.err()); } Loading @@ -67,8 +76,9 @@ void DebugCommand::usage() const { static const std::string debug = "debug:\n" " lshal debug <interface> [options [options [...]]] \n" " lshal debug [-E] <interface> [options [options [...]]] \n" " Print debug information of a specified interface.\n" " -E: excludes debug output if HAL is actually a subclass.\n" " <inteface>: Format is `android.hardware.foo@1.0::IFoo/default`.\n" " If instance name is missing `default` is used.\n" " options: space separated options to IBase::debug.\n"; Loading cmds/lshal/DebugCommand.h +4 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,10 @@ private: std::string mInterfaceName; std::vector<std::string> mOptions; // Outputs the actual descriptor of a hal instead of the debug output // if the arguments provided are a superclass of the actual hal impl. bool mExcludesParentInstances; DISALLOW_COPY_AND_ASSIGN(DebugCommand); }; Loading cmds/lshal/ListCommand.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -397,7 +397,8 @@ void ListCommand::dumpTable(const NullableOStream<std::ostream>& out) const { emitDebugInfo = [this](const auto& iName) { std::stringstream ss; auto pair = splitFirst(iName, '/'); mLshal.emitDebugInfo(pair.first, pair.second, {}, ss, mLshal.emitDebugInfo(pair.first, pair.second, {}, false /* excludesParentInstances */, ss, NullableOStream<std::ostream>(nullptr)); return ss.str(); }; Loading cmds/lshal/Lshal.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <string> #include <hidl/ServiceManagement.h> #include <hidl/HidlTransportUtils.h> #include "DebugCommand.h" #include "ListCommand.h" Loading Loading @@ -97,9 +98,11 @@ Status Lshal::emitDebugInfo( const std::string &interfaceName, const std::string &instanceName, const std::vector<std::string> &options, bool excludesParentInstances, std::ostream &out, NullableOStream<std::ostream> err) const { using android::hidl::base::V1_0::IBase; using android::hardware::details::getDescriptor; hardware::Return<sp<IBase>> retBase = serviceManager()->get(interfaceName, instanceName); Loading @@ -120,6 +123,18 @@ Status Lshal::emitDebugInfo( return NO_INTERFACE; } if (excludesParentInstances) { const std::string descriptor = getDescriptor(base.get()); if (descriptor.empty()) { std::string msg = interfaceName + "/" + instanceName + " getDescriptor failed"; err << msg << std::endl; LOG(ERROR) << msg; } if (descriptor != interfaceName) { return OK; } } PipeRelay relay(out); if (relay.initCheck() != OK) { Loading cmds/lshal/Lshal.h +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ public: const std::string &interfaceName, const std::string &instanceName, const std::vector<std::string> &options, bool excludesParentInstances, std::ostream &out, NullableOStream<std::ostream> err) const; Loading Loading
cmds/lshal/DebugCommand.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,14 @@ Status DebugCommand::parseArgs(const Arg &arg) { if (optind >= arg.argc) { return USAGE; } // Optargs cannnot be used because the flag should not be considered set // if it should really be contained in mOptions. if (std::string(arg.argv[optind]) == "-E") { mExcludesParentInstances = true; optind++; } mInterfaceName = arg.argv[optind]; ++optind; for (; optind < arg.argc; ++optind) { Loading @@ -59,6 +67,7 @@ Status DebugCommand::main(const Arg &arg) { return mLshal.emitDebugInfo( pair.first, pair.second.empty() ? "default" : pair.second, mOptions, mExcludesParentInstances, mLshal.out().buf(), mLshal.err()); } Loading @@ -67,8 +76,9 @@ void DebugCommand::usage() const { static const std::string debug = "debug:\n" " lshal debug <interface> [options [options [...]]] \n" " lshal debug [-E] <interface> [options [options [...]]] \n" " Print debug information of a specified interface.\n" " -E: excludes debug output if HAL is actually a subclass.\n" " <inteface>: Format is `android.hardware.foo@1.0::IFoo/default`.\n" " If instance name is missing `default` is used.\n" " options: space separated options to IBase::debug.\n"; Loading
cmds/lshal/DebugCommand.h +4 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,10 @@ private: std::string mInterfaceName; std::vector<std::string> mOptions; // Outputs the actual descriptor of a hal instead of the debug output // if the arguments provided are a superclass of the actual hal impl. bool mExcludesParentInstances; DISALLOW_COPY_AND_ASSIGN(DebugCommand); }; Loading
cmds/lshal/ListCommand.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -397,7 +397,8 @@ void ListCommand::dumpTable(const NullableOStream<std::ostream>& out) const { emitDebugInfo = [this](const auto& iName) { std::stringstream ss; auto pair = splitFirst(iName, '/'); mLshal.emitDebugInfo(pair.first, pair.second, {}, ss, mLshal.emitDebugInfo(pair.first, pair.second, {}, false /* excludesParentInstances */, ss, NullableOStream<std::ostream>(nullptr)); return ss.str(); }; Loading
cmds/lshal/Lshal.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <string> #include <hidl/ServiceManagement.h> #include <hidl/HidlTransportUtils.h> #include "DebugCommand.h" #include "ListCommand.h" Loading Loading @@ -97,9 +98,11 @@ Status Lshal::emitDebugInfo( const std::string &interfaceName, const std::string &instanceName, const std::vector<std::string> &options, bool excludesParentInstances, std::ostream &out, NullableOStream<std::ostream> err) const { using android::hidl::base::V1_0::IBase; using android::hardware::details::getDescriptor; hardware::Return<sp<IBase>> retBase = serviceManager()->get(interfaceName, instanceName); Loading @@ -120,6 +123,18 @@ Status Lshal::emitDebugInfo( return NO_INTERFACE; } if (excludesParentInstances) { const std::string descriptor = getDescriptor(base.get()); if (descriptor.empty()) { std::string msg = interfaceName + "/" + instanceName + " getDescriptor failed"; err << msg << std::endl; LOG(ERROR) << msg; } if (descriptor != interfaceName) { return OK; } } PipeRelay relay(out); if (relay.initCheck() != OK) { Loading
cmds/lshal/Lshal.h +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ public: const std::string &interfaceName, const std::string &instanceName, const std::vector<std::string> &options, bool excludesParentInstances, std::ostream &out, NullableOStream<std::ostream> err) const; Loading