Enable profiling in passthrough mode.
Bug: 32141398
Test: hidl_test
Change-Id: I9c9d3855b28f555a8edf283289e426c0bb8ce3d7
diff --git a/generateCpp.cpp b/generateCpp.cpp
index 7356acb..2e381ec 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -466,14 +466,21 @@
generateCheckNonNull(out, "_hidl_cb");
}
- out << "return ";
+ generateCppInstrumentationCall(
+ out,
+ InstrumentationEvent::PASSTHROUGH_ENTRY,
+ method);
+
+ out << "auto _hidl_return = ";
if (method->isOneway()) {
out << "addOnewayTask([this";
for (const auto &arg : method->args()) {
out << ", " << arg->name();
}
- out << "] {this->";
+ out << "] {\n";
+ out.indent();
+ out << "this->";
}
out << "mImpl->"
@@ -495,12 +502,19 @@
out << "_hidl_cb";
}
- out << ")";
+ out << ");\n\n";
+
+ generateCppInstrumentationCall(
+ out,
+ InstrumentationEvent::PASSTHROUGH_EXIT,
+ method);
if (method->isOneway()) {
- out << ";})";
+ out.unindent();
+ out << "});\n";
}
- out << ";\n";
+
+ out << "return _hidl_return;\n";
out.unindent();
out << "}\n";
@@ -1506,7 +1520,7 @@
out << "struct "
<< klassName
<< " : " << ifaceName
- << " {\n";
+ << ", HidlInstrumentor {\n";
out.indent();
out << "explicit "
@@ -1622,7 +1636,9 @@
<< klassName
<< "(const sp<"
<< iface->fullName()
- << "> impl) : mImpl(impl) {";
+ << "> impl) : HidlInstrumentor(\""
+ << iface->fqName().string()
+ << "\"), mImpl(impl) {";
if (iface->hasOnewayMethods()) {
out << "\n";
out.indentBlock([&] {
@@ -1710,6 +1726,22 @@
}
break;
}
+ case PASSTHROUGH_ENTRY:
+ {
+ event_str = "InstrumentationEvent::PASSTHROUGH_ENTRY";
+ for (const auto &arg : method->args()) {
+ out << "_hidl_args.push_back((void *)&"
+ << arg->name()
+ << ");\n";
+ }
+ break;
+ }
+ case PASSTHROUGH_EXIT:
+ {
+ event_str = "InstrumentationEvent::PASSTHROUGH_EXIT";
+ // TODO(b/32576620): passthrough return values
+ break;
+ }
default:
{
LOG(ERROR) << "Unsupported instrumentation event: " << event;