From b9d8674bb9a795a3cf0452873f7defc7b1460306 Mon Sep 17 00:00:00 2001 From: shripad621git Date: Tue, 3 Oct 2023 16:51:45 +0530 Subject: [PATCH] Approach 2 --- src/lib/support/CHIPCounter.h | 5 +++++ src/protocols/secure_channel/CASESession.cpp | 10 ++++++++++ src/tracing/esp32_trace/BUILD.gn | 11 +++++++++-- .../include/matter/tracing/macros_impl.cpp | 6 ++++-- .../esp32_trace/include/matter/tracing/macros_impl.h | 8 ++++++++ 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/lib/support/CHIPCounter.h b/src/lib/support/CHIPCounter.h index 89a7bb751ad645..894ada9265d228 100644 --- a/src/lib/support/CHIPCounter.h +++ b/src/lib/support/CHIPCounter.h @@ -119,4 +119,9 @@ class MonotonicallyIncreasingCounter : public Counter T mCounterValue; }; +#define CHIP_GENERIC_COUNTER(label, group) \ + do \ + { \ + } while (false) + } // namespace chip diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp index 2afc40feacaf02..2b7b8f51b190f5 100644 --- a/src/protocols/secure_channel/CASESession.cpp +++ b/src/protocols/secure_channel/CASESession.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include #include @@ -50,6 +52,9 @@ namespace { +chip::AdvanceCounter sigma1cnt("sigma1cnt","CASE"); +chip::AdvanceCounter sigma2cnt("sigma2cnt","CASE"); + enum { kTag_TBEData_SenderNOC = 1, @@ -747,6 +752,9 @@ CHIP_ERROR CASESession::SendSigma1() CHIP_ERROR CASESession::HandleSigma1_and_SendSigma2(System::PacketBufferHandle && msg) { MATTER_TRACE_SCOPE("HandleSigma1_and_SendSigma2", "CASESession"); + sigma1cnt.Advance(); + printf("Sigma1 cnt %d",sigma1cnt.GetValue()); + CHIP_GENERIC_COUNTER("sigma1cnt","CASE"); ReturnErrorOnFailure(HandleSigma1(std::move(msg))); return CHIP_NO_ERROR; @@ -971,6 +979,8 @@ CHIP_ERROR CASESession::SendSigma2Resume() CHIP_ERROR CASESession::SendSigma2() { MATTER_TRACE_SCOPE("SendSigma2", "CASESession"); + sigma2cnt.Advance(); + printf("Sigma2 cnt %d",sigma2cnt.GetValue()); VerifyOrReturnError(GetLocalSessionId().HasValue(), CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(mFabricsTable != nullptr, CHIP_ERROR_INCORRECT_STATE); diff --git a/src/tracing/esp32_trace/BUILD.gn b/src/tracing/esp32_trace/BUILD.gn index d7580a3e68ac2a..d674e82aecdb59 100644 --- a/src/tracing/esp32_trace/BUILD.gn +++ b/src/tracing/esp32_trace/BUILD.gn @@ -21,7 +21,14 @@ config("tracing") { } source_set("esp32_trace") { - public = [ "include/matter/tracing/macros_impl.h" ] - sources = [ "include/matter/tracing/macros_impl.cpp" ] + public = [ "include/matter/tracing/macros_impl.h", + "include/matter/tracing/helper.h", + "include/matter/tracing/ESP32Counter.h", + "include/matter/tracing/counter.h", ] + sources = [ "include/matter/tracing/macros_impl.cpp", + "include/matter/tracing/counter.cpp",] + public_deps = ["${chip_root}/src/lib/support", + "${chip_root}/src/lib/core", + ] public_configs = [ ":tracing" ] } diff --git a/src/tracing/esp32_trace/include/matter/tracing/macros_impl.cpp b/src/tracing/esp32_trace/include/matter/tracing/macros_impl.cpp index 7046dd9cc8d7d9..4305b0ac721e45 100644 --- a/src/tracing/esp32_trace/include/matter/tracing/macros_impl.cpp +++ b/src/tracing/esp32_trace/include/matter/tracing/macros_impl.cpp @@ -17,6 +17,8 @@ #include "macros_impl.h" #include #include + + namespace Insights { #define LOG_HEAP_INFO(label, group, entry_exit) \ @@ -38,7 +40,7 @@ ESP32Backend::ESP32Backend(const char * str, ...) } ESP32Backend::~ESP32Backend() -{ - LOG_HEAP_INFO(mlabel, mgroup, "Exit"); +{ + LOG_HEAP_INFO(mlabel, mgroup, "Exit"); } } // namespace Insights diff --git a/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h b/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h index 1ab529313c3192..b88cafac519664 100644 --- a/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h +++ b/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h @@ -21,6 +21,9 @@ #error "Tracing macros seem to be double defined" #endif +#include "counter.h" + + namespace Insights { class ESP32Backend { @@ -48,3 +51,8 @@ class ESP32Backend #define MATTER_TRACE_BEGIN(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_END(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_INSTANT(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) + +#ifdef CONFIG_ENABLE_ESP_INSIGHTS_COUNTERS +#undef CHIP_GENERIC_COUNTER +#define CHIP_GENERIC_COUNTER(label, group) Insights::InstantObject::getInstance(label, group)->traceInstant() +#endif