Add 'exclude parent' option to debug.
We could add this to list in the future if it seems useful.
This allows someone to call debug on all registered hal instances
without dumping subclasses multiple times.
Bug: 72123369
Test: w/ bugreport using this and manual
Change-Id: Ib201194a9f81ae1aded7105d123ac6399c847494
diff --git a/cmds/lshal/Lshal.cpp b/cmds/lshal/Lshal.cpp
index c6f28ac..8c83457 100644
--- a/cmds/lshal/Lshal.cpp
+++ b/cmds/lshal/Lshal.cpp
@@ -23,6 +23,7 @@
#include <string>
#include <hidl/ServiceManagement.h>
+#include <hidl/HidlTransportUtils.h>
#include "DebugCommand.h"
#include "ListCommand.h"
@@ -97,9 +98,11 @@
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);
@@ -120,6 +123,18 @@
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) {