1 /* 2 * Copyright 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "HalHidlProfilerCodeGen.h" 18 #include "VtsCompilerUtils.h" 19 #include "utils/InterfaceSpecUtil.h" 20 #include "utils/StringUtil.h" 21 22 namespace android { 23 namespace vts { 24 25 void HalHidlProfilerCodeGen::GenerateProfilerForScalarVariable( 26 Formatter& out, const VariableSpecificationMessage& val, 27 const std::string& arg_name, const std::string& arg_value) { 28 out << arg_name << "->set_type(TYPE_SCALAR);\n"; 29 out << arg_name << "->mutable_scalar_value()->set_" << val.scalar_type() 30 << "(" << arg_value << ");\n"; 31 } 32 33 void HalHidlProfilerCodeGen::GenerateProfilerForStringVariable( 34 Formatter& out, const VariableSpecificationMessage&, 35 const std::string& arg_name, const std::string& arg_value) { 36 out << arg_name << "->set_type(TYPE_STRING);\n"; 37 out << arg_name << "->mutable_string_value()->set_message" 38 << "(" << arg_value << ".c_str());\n"; 39 out << arg_name << "->mutable_string_value()->set_length" 40 << "(" << arg_value << ".size());\n"; 41 } 42 43 void HalHidlProfilerCodeGen::GenerateProfilerForEnumVariable( 44 Formatter& out, const VariableSpecificationMessage& val, 45 const std::string& arg_name, const std::string& arg_value) { 46 out << arg_name << "->set_type(TYPE_ENUM);\n"; 47 48 // For predefined type, call the corresponding profile method. 49 if (val.has_predefined_type()) { 50 std::string predefined_type = val.predefined_type(); 51 ReplaceSubString(predefined_type, "::", "__"); 52 out << "profile__" << predefined_type << "(" << arg_name << ", " 53 << arg_value << ");\n"; 54 } else { 55 const std::string scalar_type = val.enum_value().scalar_type(); 56 out << arg_name << "->mutable_scalar_value()->set_" << scalar_type 57 << "(static_cast<" << scalar_type << ">(" << arg_value << "));\n"; 58 out << arg_name << "->set_scalar_type(\"" << scalar_type << "\");\n"; 59 } 60 } 61 62 void HalHidlProfilerCodeGen::GenerateProfilerForVectorVariable( 63 Formatter& out, const VariableSpecificationMessage& val, 64 const std::string& arg_name, const std::string& arg_value) { 65 out << arg_name << "->set_type(TYPE_VECTOR);\n"; 66 out << arg_name << "->set_vector_size(" << arg_value << ".size());\n"; 67 std::string index_name = GetVarString(arg_name) + "_index"; 68 out << "for (int " << index_name << " = 0; " << index_name << " < (int)" 69 << arg_value << ".size(); " << index_name << "++) {\n"; 70 out.indent(); 71 std::string vector_element_name = 72 GetVarString(arg_name) + "_vector_" + index_name; 73 out << "auto *" << vector_element_name 74 << " __attribute__((__unused__)) = " << arg_name 75 << "->add_vector_value();\n"; 76 GenerateProfilerForTypedVariable(out, val.vector_value(0), 77 vector_element_name, 78 arg_value + "[" + index_name + "]"); 79 out.unindent(); 80 out << "}\n"; 81 } 82 83 void HalHidlProfilerCodeGen::GenerateProfilerForArrayVariable( 84 Formatter& out, const VariableSpecificationMessage& val, 85 const std::string& arg_name, const std::string& arg_value) { 86 out << arg_name << "->set_type(TYPE_ARRAY);\n"; 87 out << arg_name << "->set_vector_size(" << val.vector_size() << ");\n"; 88 std::string index_name = GetVarString(arg_name) + "_index"; 89 out << "for (int " << index_name << " = 0; " << index_name << " < " 90 << val.vector_size() << "; " << index_name << "++) {\n"; 91 out.indent(); 92 std::string array_element_name = 93 GetVarString(arg_name) + "_array_" + index_name; 94 out << "auto *" << array_element_name 95 << " __attribute__((__unused__)) = " << arg_name 96 << "->add_vector_value();\n"; 97 GenerateProfilerForTypedVariable(out, val.vector_value(0), array_element_name, 98 arg_value + "[" + index_name + "]"); 99 out.unindent(); 100 out << "}\n"; 101 } 102 103 void HalHidlProfilerCodeGen::GenerateProfilerForStructVariable( 104 Formatter& out, const VariableSpecificationMessage& val, 105 const std::string& arg_name, const std::string& arg_value) { 106 out << arg_name << "->set_type(TYPE_STRUCT);\n"; 107 // For predefined type, call the corresponding profile method. 108 if (val.struct_value().size() == 0 && val.has_predefined_type()) { 109 std::string predefined_type = val.predefined_type(); 110 ReplaceSubString(predefined_type, "::", "__"); 111 out << "profile__" << predefined_type << "(" << arg_name << ", " 112 << arg_value << ");\n"; 113 } else { 114 for (const auto struct_field : val.struct_value()) { 115 std::string struct_field_name = arg_name + "_" + struct_field.name(); 116 out << "auto *" << struct_field_name 117 << " __attribute__((__unused__)) = " << arg_name 118 << "->add_struct_value();\n"; 119 GenerateProfilerForTypedVariable(out, struct_field, struct_field_name, 120 arg_value + "." + struct_field.name()); 121 } 122 } 123 } 124 125 void HalHidlProfilerCodeGen::GenerateProfilerForUnionVariable( 126 Formatter& out, const VariableSpecificationMessage& val, 127 const std::string& arg_name, const std::string& arg_value) { 128 out << arg_name << "->set_type(TYPE_UNION);\n"; 129 // For predefined type, call the corresponding profile method. 130 if (val.union_value().size() == 0 && val.has_predefined_type()) { 131 std::string predefined_type = val.predefined_type(); 132 ReplaceSubString(predefined_type, "::", "__"); 133 out << "profile__" << predefined_type << "(" << arg_name << ", " 134 << arg_value << ");\n"; 135 } else { 136 for (const auto union_field : val.union_value()) { 137 std::string union_field_name = arg_name + "_" + union_field.name(); 138 out << "auto *" << union_field_name << " = " << arg_name 139 << "->add_union_value();\n"; 140 GenerateProfilerForTypedVariable(out, union_field, union_field_name, 141 arg_value + "." + union_field.name()); 142 } 143 } 144 } 145 146 void HalHidlProfilerCodeGen::GenerateProfilerForHidlCallbackVariable( 147 Formatter& out, const VariableSpecificationMessage& val, 148 const std::string& arg_name, const std::string&) { 149 out << arg_name << "->set_type(TYPE_HIDL_CALLBACK);\n"; 150 out << arg_name << "->set_predefined_type(\"" << val.predefined_type() 151 << "\");\n"; 152 } 153 154 void HalHidlProfilerCodeGen::GenerateProfilerForHidlInterfaceVariable( 155 Formatter& out, const VariableSpecificationMessage& val, 156 const std::string& arg_name, const std::string&) { 157 out << arg_name << "->set_type(TYPE_HIDL_INTERFACE);\n"; 158 out << arg_name << "->set_predefined_type(\"" << val.predefined_type() 159 << "\");\n"; 160 } 161 162 void HalHidlProfilerCodeGen::GenerateProfilerForMaskVariable( 163 Formatter& out, const VariableSpecificationMessage& val, 164 const std::string& arg_name, const std::string& arg_value) { 165 out << arg_name << "->set_type(TYPE_MASK);\n"; 166 out << arg_name << "->set_scalar_type(\"" << val.scalar_type() << "\");\n"; 167 out << arg_name << "->mutable_scalar_value()->set_" << val.scalar_type() 168 << "(" << arg_value << ");\n"; 169 } 170 171 void HalHidlProfilerCodeGen::GenerateProfilerForHandleVariable( 172 Formatter& out, const VariableSpecificationMessage&, 173 const std::string& arg_name, const std::string& arg_value) { 174 out << arg_name << "->set_type(TYPE_HANDLE);\n"; 175 std::string handle_name = arg_name + "_h"; 176 out << "auto " << handle_name << " = " << arg_value 177 << ".getNativeHandle();\n"; 178 out << "if (!" << handle_name << ") {\n"; 179 out.indent(); 180 out << "LOG(WARNING) << \"null handle\";\n"; 181 out << "return;\n"; 182 out.unindent(); 183 out << "}\n"; 184 out << arg_name << "->mutable_handle_value()->set_version(" << handle_name 185 << "->version);\n"; 186 out << arg_name << "->mutable_handle_value()->set_num_ints(" << handle_name 187 << "->numInts);\n"; 188 out << arg_name << "->mutable_handle_value()->set_num_fds(" << handle_name 189 << "->numFds);\n"; 190 out << "for (int i = 0; i < " << handle_name << "->numInts + " << handle_name 191 << "->numFds; i++) {\n"; 192 out.indent(); 193 out << "if(i < " << handle_name << "->numFds) {\n"; 194 out.indent(); 195 out << "auto* fd_val_i = " << arg_name 196 << "->mutable_handle_value()->add_fd_val();\n"; 197 out << "char filePath[PATH_MAX];\n"; 198 out << "string procPath = \"/proc/self/fd/\" + to_string(" << handle_name 199 << "->data[i]);\n"; 200 out << "ssize_t r = readlink(procPath.c_str(), filePath, " 201 "sizeof(filePath));\n"; 202 out << "if (r == -1) {\n"; 203 out.indent(); 204 out << "LOG(ERROR) << \"Unable to get file path\";\n"; 205 out << "continue;\n"; 206 out.unindent(); 207 out << "}\n"; 208 out << "filePath[r] = '\\0';\n"; 209 out << "fd_val_i->set_file_name(filePath);\n"; 210 out << "struct stat statbuf;\n"; 211 out << "fstat(" << handle_name << "->data[i], &statbuf);\n"; 212 out << "fd_val_i->set_mode(statbuf.st_mode);\n"; 213 out << "if (S_ISREG(statbuf.st_mode) || S_ISDIR(statbuf.st_mode)) {\n"; 214 out.indent(); 215 out << "fd_val_i->set_type(S_ISREG(statbuf.st_mode)? FILE_TYPE: DIR_TYPE);\n"; 216 out << "int flags = fcntl(" << handle_name << "->data[i], F_GETFL);\n"; 217 out << "fd_val_i->set_flags(flags);\n"; 218 out.unindent(); 219 out << "}\n"; 220 out << "else if (S_ISCHR(statbuf.st_mode) || S_ISBLK(statbuf.st_mode)) {\n"; 221 out.indent(); 222 out << "fd_val_i->set_type(DEV_TYPE);\n"; 223 out << "if (strcmp(filePath, \"/dev/ashmem\") == 0) {\n"; 224 out.indent(); 225 out << "int size = ashmem_get_size_region(" << handle_name << "->data[i]);\n"; 226 out << "fd_val_i->mutable_memory()->set_size(size);\n"; 227 out.unindent(); 228 out << "}\n"; 229 out.unindent(); 230 out << "}\n"; 231 out << "else if (S_ISFIFO(statbuf.st_mode)){\n"; 232 out.indent(); 233 out << "fd_val_i->set_type(PIPE_TYPE);\n"; 234 out.unindent(); 235 out << "}\n"; 236 out << "else if (S_ISSOCK(statbuf.st_mode)) {\n"; 237 out.indent(); 238 out << "fd_val_i->set_type(SOCKET_TYPE);\n"; 239 out.unindent(); 240 out << "}\n"; 241 out << "else {\n"; 242 out.indent(); 243 out << "fd_val_i->set_type(LINK_TYPE);\n"; 244 out.unindent(); 245 out << "}\n"; 246 out.unindent(); 247 out << "} else {\n"; 248 out.indent(); 249 out << arg_name << "->mutable_handle_value()->add_int_val(" << handle_name 250 << "->data[i]);\n"; 251 out.unindent(); 252 out << "}\n"; 253 out.unindent(); 254 out << "}\n"; 255 } 256 257 void HalHidlProfilerCodeGen::GenerateProfilerForHidlMemoryVariable( 258 Formatter& out, const VariableSpecificationMessage&, 259 const std::string& arg_name, const std::string& arg_value) { 260 out << arg_name << "->set_type(TYPE_HIDL_MEMORY);\n"; 261 out << arg_name << "->mutable_hidl_memory_value()->set_size" 262 << "(" << arg_value << ".size());\n"; 263 // TODO(zhuoyao): dump the memory contents as well. 264 } 265 266 void HalHidlProfilerCodeGen::GenerateProfilerForPointerVariable( 267 Formatter& out, const VariableSpecificationMessage&, 268 const std::string& arg_name, const std::string&) { 269 out << arg_name << "->set_type(TYPE_POINTER);\n"; 270 // TODO(zhuoyao): figure the right way to profile pointer type. 271 } 272 273 void HalHidlProfilerCodeGen::GenerateProfilerForFMQSyncVariable( 274 Formatter& out, const VariableSpecificationMessage& val, 275 const std::string& arg_name, const std::string& arg_value) { 276 out << arg_name << "->set_type(TYPE_FMQ_SYNC);\n"; 277 string element_type = GetCppVariableType(val.fmq_value(0)); 278 std::string queue_name = arg_name + "_q"; 279 std::string temp_result_name = arg_name + "_result"; 280 out << "MessageQueue<" << element_type << ", kSynchronizedReadWrite> " 281 << queue_name << "(" << arg_value << ", false);\n"; 282 out << "if (" << queue_name << ".isValid()) {\n"; 283 out.indent(); 284 out << "for (int i = 0; i < (int)" << queue_name 285 << ".availableToRead(); i++) {\n"; 286 out.indent(); 287 std::string fmq_item_name = arg_name + "_item_i"; 288 out << "auto *" << fmq_item_name << " = " << arg_name 289 << "->add_fmq_value();\n"; 290 out << element_type << " " << temp_result_name << ";\n"; 291 out << queue_name << ".read(&" << temp_result_name << ");\n"; 292 out << queue_name << ".write(&" << temp_result_name << ");\n"; 293 GenerateProfilerForTypedVariable(out, val.fmq_value(0), fmq_item_name, 294 temp_result_name); 295 out.unindent(); 296 out << "}\n"; 297 out.unindent(); 298 out << "}\n"; 299 } 300 301 void HalHidlProfilerCodeGen::GenerateProfilerForFMQUnsyncVariable( 302 Formatter& out, const VariableSpecificationMessage& val, 303 const std::string& arg_name, const std::string& arg_value) { 304 out << arg_name << "->set_type(TYPE_FMQ_UNSYNC);\n"; 305 string element_type = GetCppVariableType(val.fmq_value(0)); 306 std::string queue_name = arg_name + "_q"; 307 std::string temp_result_name = arg_name + "_result"; 308 out << "MessageQueue<" << element_type << ", kUnsynchronizedWrite> " 309 << queue_name << "(" << arg_value << ");\n"; 310 out << "if (" << queue_name << ".isValid()) {\n"; 311 out.indent(); 312 out << "for (int i = 0; i < (int)" << queue_name 313 << ".availableToRead(); i++) {\n"; 314 out.indent(); 315 std::string fmq_item_name = arg_name + "_item_i"; 316 out << "auto *" << fmq_item_name << " = " << arg_name 317 << "->add_fmq_value();\n"; 318 out << element_type << " " << temp_result_name << ";\n"; 319 out << queue_name << ".read(&" << temp_result_name << ");\n"; 320 GenerateProfilerForTypedVariable(out, val.fmq_value(0), fmq_item_name, 321 temp_result_name); 322 out.unindent(); 323 out << "}\n"; 324 out.unindent(); 325 out << "}\n"; 326 } 327 328 void HalHidlProfilerCodeGen::GenerateProfilerForMethod( 329 Formatter& out, const FunctionSpecificationMessage& method) { 330 out << "FunctionSpecificationMessage msg;\n"; 331 out << "msg.set_name(\"" << method.name() << "\");\n"; 332 out << "if (!args) {\n"; 333 out.indent(); 334 out << "LOG(WARNING) << \"no argument passed\";\n"; 335 out.unindent(); 336 out << "} else {\n"; 337 out.indent(); 338 out << "switch (event) {\n"; 339 out.indent(); 340 // TODO(b/32141398): Support profiling in passthrough mode. 341 out << "case details::HidlInstrumentor::CLIENT_API_ENTRY:\n"; 342 out << "case details::HidlInstrumentor::SERVER_API_ENTRY:\n"; 343 out << "case details::HidlInstrumentor::PASSTHROUGH_ENTRY:\n"; 344 out << "{\n"; 345 out.indent(); 346 ComponentSpecificationMessage message; 347 out << "if ((*args).size() != " << method.arg().size() << ") {\n"; 348 out.indent(); 349 out << "LOG(ERROR) << \"Number of arguments does not match. expect: " 350 << method.arg().size() 351 << ", actual: \" << (*args).size() << \", method name: " << method.name() 352 << ", event type: \" << event;\n"; 353 out << "break;\n"; 354 out.unindent(); 355 out << "}\n"; 356 for (int i = 0; i < method.arg().size(); i++) { 357 const VariableSpecificationMessage arg = method.arg(i); 358 std::string arg_name = "arg_" + std::to_string(i); 359 std::string arg_value = "arg_val_" + std::to_string(i); 360 out << "auto *" << arg_name 361 << " __attribute__((__unused__)) = msg.add_arg();\n"; 362 out << GetCppVariableType(arg) << " *" << arg_value 363 << " __attribute__((__unused__)) = reinterpret_cast<" 364 << GetCppVariableType(arg) << "*> ((*args)[" << i << "]);\n"; 365 out << "if (" << arg_value << " != nullptr) {\n"; 366 out.indent(); 367 GenerateProfilerForTypedVariable(out, arg, arg_name, 368 "(*" + arg_value + ")"); 369 out.unindent(); 370 out << "} else {\n"; 371 out.indent(); 372 out << "LOG(WARNING) << \"argument " << i << " is null.\";\n"; 373 out.unindent(); 374 out << "}\n"; 375 } 376 out << "break;\n"; 377 out.unindent(); 378 out << "}\n"; 379 380 out << "case details::HidlInstrumentor::CLIENT_API_EXIT:\n"; 381 out << "case details::HidlInstrumentor::SERVER_API_EXIT:\n"; 382 out << "case details::HidlInstrumentor::PASSTHROUGH_EXIT:\n"; 383 out << "{\n"; 384 out.indent(); 385 out << "if ((*args).size() != " << method.return_type_hidl().size() 386 << ") {\n"; 387 out.indent(); 388 out << "LOG(ERROR) << \"Number of return values does not match. expect: " 389 << method.return_type_hidl().size() 390 << ", actual: \" << (*args).size() << \", method name: " << method.name() 391 << ", event type: \" << event;\n"; 392 out << "break;\n"; 393 out.unindent(); 394 out << "}\n"; 395 for (int i = 0; i < method.return_type_hidl().size(); i++) { 396 const VariableSpecificationMessage arg = method.return_type_hidl(i); 397 std::string result_name = "result_" + std::to_string(i); 398 std::string result_value = "result_val_" + std::to_string(i); 399 out << "auto *" << result_name 400 << " __attribute__((__unused__)) = msg.add_return_type_hidl();\n"; 401 out << GetCppVariableType(arg) << " *" << result_value 402 << " __attribute__((__unused__)) = reinterpret_cast<" 403 << GetCppVariableType(arg) << "*> ((*args)[" << i << "]);\n"; 404 out << "if (" << result_value << " != nullptr) {\n"; 405 out.indent(); 406 GenerateProfilerForTypedVariable(out, arg, result_name, 407 "(*" + result_value + ")"); 408 out.unindent(); 409 out << "} else {\n"; 410 out.indent(); 411 out << "LOG(WARNING) << \"return value " << i << " is null.\";\n"; 412 out.unindent(); 413 out << "}\n"; 414 } 415 out << "break;\n"; 416 out.unindent(); 417 out << "}\n"; 418 out << "default:\n"; 419 out << "{\n"; 420 out.indent(); 421 out << "LOG(WARNING) << \"not supported. \";\n"; 422 out << "break;\n"; 423 out.unindent(); 424 out << "}\n"; 425 out.unindent(); 426 out << "}\n"; 427 out.unindent(); 428 out << "}\n"; 429 out << "profiler.AddTraceEvent(event, package, version, interface, msg);\n"; 430 } 431 432 void HalHidlProfilerCodeGen::GenerateHeaderIncludeFiles( 433 Formatter& out, const ComponentSpecificationMessage& message) { 434 // Basic includes. 435 out << "#include <android-base/logging.h>\n"; 436 out << "#include <hidl/HidlSupport.h>\n"; 437 out << "#include <linux/limits.h>\n"; 438 out << "#include <test/vts/proto/ComponentSpecificationMessage.pb.h>\n"; 439 out << "#include \"VtsProfilingInterface.h\"\n"; 440 out << "\n"; 441 442 // Include generated hal classes. 443 out << "#include <" << GetPackagePath(message) << "/" << GetVersion(message) 444 << "/" << GetComponentName(message) << ".h>\n"; 445 446 // Include imported classes. 447 for (const auto& import : message.import()) { 448 FQName import_name = FQName(import); 449 string imported_package_name = import_name.package(); 450 string imported_package_version = import_name.version(); 451 string imported_component_name = import_name.name(); 452 string imported_package_path = imported_package_name; 453 ReplaceSubString(imported_package_path, ".", "/"); 454 out << "#include <" << imported_package_path << "/" 455 << imported_package_version << "/" << imported_component_name 456 << ".h>\n"; 457 // Exclude the base hal in include list. 458 if (imported_package_name.find("android.hidl.base") == std::string::npos) { 459 if (imported_component_name[0] == 'I') { 460 imported_component_name = imported_component_name.substr(1); 461 } 462 out << "#include <" << imported_package_path << "/" 463 << imported_package_version << "/" << imported_component_name 464 << ".vts.h>\n"; 465 } 466 } 467 out << "\n\n"; 468 } 469 470 void HalHidlProfilerCodeGen::GenerateSourceIncludeFiles( 471 Formatter& out, const ComponentSpecificationMessage& message) { 472 // Include the corresponding profiler header file. 473 out << "#include \"" << GetPackagePath(message) << "/" << GetVersion(message) 474 << "/" << GetComponentBaseName(message) << ".vts.h\"\n"; 475 out << "#include <cutils/ashmem.h>\n"; 476 out << "#include <fcntl.h>\n"; 477 out << "#include <fmq/MessageQueue.h>\n"; 478 out << "#include <sys/stat.h>\n"; 479 out << "\n"; 480 } 481 482 void HalHidlProfilerCodeGen::GenerateUsingDeclaration( 483 Formatter& out, const ComponentSpecificationMessage& message) { 484 out << "using namespace "; 485 out << GetPackageNamespaceToken(message) << "::" << GetVersion(message, true) 486 << ";\n"; 487 out << "using namespace android::hardware;\n"; 488 out << "\n"; 489 } 490 491 void HalHidlProfilerCodeGen::GenerateMacros( 492 Formatter& out, const ComponentSpecificationMessage&) { 493 out << "#define TRACEFILEPREFIX \"/data/local/tmp/\"\n"; 494 out << "\n"; 495 } 496 497 void HalHidlProfilerCodeGen::GenerateProfilerSanityCheck( 498 Formatter& out, const ComponentSpecificationMessage& message) { 499 out << "if (strcmp(package, \"" << GetPackageName(message) << "\") != 0) {\n"; 500 out.indent(); 501 out << "LOG(WARNING) << \"incorrect package. Expect: " 502 << GetPackageName(message) << " actual: \" << package;\n"; 503 out << "return;\n"; 504 out.unindent(); 505 out << "}\n"; 506 out << "std::string version_str = std::string(version);\n"; 507 out << "int major_version = stoi(version_str.substr(0, " 508 "version_str.find('.')));\n"; 509 out << "int minor_version = stoi(version_str.substr(version_str.find('.') + " 510 "1));\n"; 511 out << "if (major_version != " << GetMajorVersion(message) 512 << " || minor_version > " << GetMinorVersion(message) << ") {\n"; 513 out.indent(); 514 out << "LOG(WARNING) << \"incorrect version. Expect: " << GetVersion(message) 515 << " or lower (if version != x.0), actual: \" << version;\n"; 516 out << "return;\n"; 517 out.unindent(); 518 out << "}\n"; 519 520 out << "if (strcmp(interface, \"" << GetComponentName(message) 521 << "\") != 0) {\n"; 522 out.indent(); 523 out << "LOG(WARNING) << \"incorrect interface. Expect: " 524 << GetComponentName(message) << " actual: \" << interface;\n"; 525 out << "return;\n"; 526 out.unindent(); 527 out << "}\n"; 528 out << "\n"; 529 } 530 531 void HalHidlProfilerCodeGen::GenerateLocalVariableDefinition( 532 Formatter& out, const ComponentSpecificationMessage&) { 533 // create and initialize the VTS profiler interface. 534 out << "VtsProfilingInterface& profiler = " 535 << "VtsProfilingInterface::getInstance(TRACEFILEPREFIX);\n\n"; 536 } 537 538 } // namespace vts 539 } // namespace android 540