From 87194968b9658d02de56e67a58eeead667d246b5 Mon Sep 17 00:00:00 2001 From: Ken Rowland Date: Tue, 17 Jan 2023 14:07:40 -0500 Subject: [PATCH] HPCC-28789 Keep ESP service execution profile enable per defined service Added profile execution enabled flag to service info structure Removed profile execution enabled flag from HIDL compiler class Signed-Off-By: Kenneth Rowland kenneth.rowland@lexisnexisrisk.com --- tools/hidl/hidlcomp.cpp | 36 +++++++++++++++++++++--------------- tools/hidl/hidlcomp.h | 4 +++- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/tools/hidl/hidlcomp.cpp b/tools/hidl/hidlcomp.cpp index 03cbaff7537..a8e38112115 100644 --- a/tools/hidl/hidlcomp.cpp +++ b/tools/hidl/hidlcomp.cpp @@ -7143,11 +7143,7 @@ void HIDLcompiler::processExecutionProfiling() for (si=servs; si; si=si->next) { StrBuffer serviceProfilingOptions; - bool serviceProfileExecutionEnabled = si->getMetaStringValue(serviceProfilingOptions,"profile_execution"); - - // - // At the HIDL top level, execution profiling is enabled if any service is enabled - executionProfilingEnabled |= serviceProfileExecutionEnabled; + si->executionProfilingEnabled = si->getMetaStringValue(serviceProfilingOptions,"profile_execution"); // // Go through each method and save any profile information to make if faster later when @@ -7160,8 +7156,8 @@ void HIDLcompiler::processExecutionProfiling() // Collect method profile execution values StrBuffer methodProfilingOptions; bool methodProfileExecutionEnabled = mthi->getMetaStringValue(methodProfilingOptions, "profile_execution"); - executionProfilingEnabled |= methodProfileExecutionEnabled; // again, if a method is enabled, set top flag - if (serviceProfileExecutionEnabled || methodProfileExecutionEnabled) + si->executionProfilingEnabled |= methodProfileExecutionEnabled; // again, if a method is enabled, set top flag + if (si->executionProfilingEnabled || methodProfileExecutionEnabled) { if (!mthi->getMetaInt("no_profile_execution")) { @@ -7185,11 +7181,18 @@ void HIDLcompiler::write_esp() outf("#define %s_ESPGEN_INCLUDED\n\n", packagename); outf("#include \"%s_esp.ipp\"\n", packagename); - if (executionProfilingEnabled) + // If any defined service has execution profiling enabled, add the required includes + EspServInfo *si; + for (si=servs;si;si=si->next) { - outs("#include \"espcommon.hpp\"\n"); - outs("#include \"jmetrics.hpp\"\n"); + if (si->executionProfilingEnabled) + { + outs("#include \"espcommon.hpp\"\n"); + outs("#include \"jmetrics.hpp\"\n"); + break; + } } + outs("\n"); outs("#ifdef _WIN32\n"); outs("#include \"edwin.h\"\n"); @@ -7204,7 +7207,6 @@ void HIDLcompiler::write_esp() mi->write_esp(); } - EspServInfo *si; for (si=servs;si;si=si->next) { si->write_esp_binding(); @@ -7252,10 +7254,15 @@ void HIDLcompiler::write_esp_ex_ipp() outs("\n\n"); // metrics execution profiling requires the memory header - if (executionProfilingEnabled) + EspServInfo *si; + for (si=servs;si;si=si->next) { - outs("#include \n"); - outs("\n\n"); + if (si->executionProfilingEnabled) + { + outs("#include \n"); + outs("\n\n"); + break; + } } outf("namespace %s\n{\n\n", packagename); @@ -7266,7 +7273,6 @@ void HIDLcompiler::write_esp_ex_ipp() mi->write_esp_ipp(); } - EspServInfo *si; for (si=servs;si;si=si->next) { si->write_esp_service_ipp(); diff --git a/tools/hidl/hidlcomp.h b/tools/hidl/hidlcomp.h index e382d0c979d..2bb4405f6fa 100644 --- a/tools/hidl/hidlcomp.h +++ b/tools/hidl/hidlcomp.h @@ -1185,6 +1185,9 @@ class EspServInfo char *base_; bool needsXslt; +public: + bool executionProfilingEnabled = false; + public: EspServInfo(const char *name) @@ -1335,7 +1338,6 @@ class HIDLcompiler EspMessageInfo *msgs; EspServInfo *servs; IncludeInfo *includes; - bool executionProfilingEnabled = false; };