From 7522efef5d78a47776f49be46284bc6e4da455ca Mon Sep 17 00:00:00 2001 From: shripad621git Date: Tue, 19 Dec 2023 18:23:58 +0530 Subject: [PATCH] Made the perfetto backend implementation more inline: --- src/protocols/secure_channel/CASESession.cpp | 8 ++++---- .../include/matter/tracing/macros_impl.h | 1 - src/tracing/macros.h | 7 ++++++- .../include/matter/tracing/macros_impl.h | 1 - .../none/include/matter/tracing/macros_impl.h | 4 ---- src/tracing/perfetto/BUILD.gn | 1 - .../perfetto/include/matter/tracing/macros_impl.h | 2 -- src/tracing/perfetto/perfetto_tracing.cpp | 13 +++++++------ src/tracing/perfetto/perfetto_tracing.h | 2 +- 9 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp index 2295ec12daff82..aedaf8a543e4d5 100644 --- a/src/protocols/secure_channel/CASESession.cpp +++ b/src/protocols/secure_channel/CASESession.cpp @@ -546,7 +546,7 @@ void CASESession::OnResponseTimeout(ExchangeContext * ec) { VerifyOrReturn(ec != nullptr, ChipLogError(SecureChannel, "CASESession::OnResponseTimeout was called by null exchange")); VerifyOrReturn(mExchangeCtxt == ec, ChipLogError(SecureChannel, "CASESession::OnResponseTimeout exchange doesn't match")); - MATTER_TRACE_COUNTER("casetimeout","CASE"); + MATTER_TRACE_COUNTER("casetimeout", "CASESession"); ChipLogError(SecureChannel, "CASESession timed out while waiting for a response from the peer. Current state was %u", to_underlying(mState)); // Discard the exchange so that Clear() doesn't try aborting it. The @@ -743,7 +743,7 @@ CHIP_ERROR CASESession::SendSigma1() CHIP_ERROR CASESession::HandleSigma1_and_SendSigma2(System::PacketBufferHandle && msg) { MATTER_TRACE_SCOPE("HandleSigma1_and_SendSigma2", "CASESession"); - MATTER_TRACE_COUNTER("sigma1cnt", "CASE"); + MATTER_TRACE_COUNTER("sigma1cnt", "CASESession"); ReturnErrorOnFailure(HandleSigma1(std::move(msg))); @@ -964,7 +964,7 @@ CHIP_ERROR CASESession::SendSigma2Resume() CHIP_ERROR CASESession::SendSigma2() { MATTER_TRACE_SCOPE("SendSigma2", "CASESession"); - MATTER_TRACE_COUNTER("sigma2cnt","CASE"); + MATTER_TRACE_COUNTER("sigma2cnt", "CASESession"); VerifyOrReturnError(GetLocalSessionId().HasValue(), CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(mFabricsTable != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -1560,7 +1560,7 @@ CHIP_ERROR CASESession::SendSigma3c(SendSigma3Data & data, CHIP_ERROR status) CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg) { MATTER_TRACE_SCOPE("HandleSigma3", "CASESession"); - MATTER_TRACE_COUNTER("sigma3cnt","CASE"); + MATTER_TRACE_COUNTER("sigma3cnt", "CASESession"); CHIP_ERROR err = CHIP_NO_ERROR; System::PacketBufferTLVReader tlvReader; TLV::TLVReader decryptedDataTlvReader; 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 c439922f2cd5ff..4d8a8a2a214525 100644 --- a/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h +++ b/src/tracing/esp32_trace/include/matter/tracing/macros_impl.h @@ -28,7 +28,6 @@ #define MATTER_TRACE_BEGIN(label, group) ::chip::Tracing::Internal::Begin(label, group) #define MATTER_TRACE_END(label, group) ::chip::Tracing::Internal::End(label, group) #define MATTER_TRACE_INSTANT(label, group) ::chip::Tracing::Internal::Instant(label, group) -#define MATTER_TRACE_COUNTER(label, group) ::chip::Tracing::Internal::Counter(label, group) namespace chip { namespace Tracing { diff --git a/src/tracing/macros.h b/src/tracing/macros.h index 2d5188f89eec44..a320040422c6f2 100644 --- a/src/tracing/macros.h +++ b/src/tracing/macros.h @@ -26,7 +26,6 @@ // MATTER_TRACE_END(label, group) // MATTER_TRACE_INSTANT(label, group) // MATTER_TRACE_SCOPE(label, group) -// MATTER_TRACE_COUNTER(label, group) #include #include #include @@ -68,6 +67,12 @@ ::chip::Tracing::Internal::LogNodeDiscoveryFailed(_trace_data); \ } while (false) +#define MATTER_TRACE_COUNTER(label, group) \ + do \ + { \ + ::chip::Tracing::Internal::Counter(label, group); \ + } while (false) + #else // MATTER_TRACING_ENABLED #define _MATTER_TRACE_DISABLE(...) \ diff --git a/src/tracing/multiplexed/include/matter/tracing/macros_impl.h b/src/tracing/multiplexed/include/matter/tracing/macros_impl.h index 4fe42e930da1fd..e1f2adc56d989e 100644 --- a/src/tracing/multiplexed/include/matter/tracing/macros_impl.h +++ b/src/tracing/multiplexed/include/matter/tracing/macros_impl.h @@ -29,7 +29,6 @@ #define MATTER_TRACE_END(label, group) ::chip::Tracing::Internal::End(label, group) #define MATTER_TRACE_INSTANT(label, group) ::chip::Tracing::Internal::Instant(label, group) -#define MATTER_TRACE_COUNTER(label, group) ::chip::Tracing::Internal::Counter(label, group) namespace chip { namespace Tracing { diff --git a/src/tracing/none/include/matter/tracing/macros_impl.h b/src/tracing/none/include/matter/tracing/macros_impl.h index 456264765d16c4..3f7f052b5cac0d 100644 --- a/src/tracing/none/include/matter/tracing/macros_impl.h +++ b/src/tracing/none/include/matter/tracing/macros_impl.h @@ -31,7 +31,3 @@ #define MATTER_TRACE_END(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_INSTANT(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) #define MATTER_TRACE_SCOPE(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) -#define MATTER_TRACE_COUNTER(label, group) \ - do \ - { \ - } while (false) diff --git a/src/tracing/perfetto/BUILD.gn b/src/tracing/perfetto/BUILD.gn index b1b210c2b38dc8..4df589fd278374 100644 --- a/src/tracing/perfetto/BUILD.gn +++ b/src/tracing/perfetto/BUILD.gn @@ -78,7 +78,6 @@ static_library("perfetto") { public_deps = [ ":perfetto_tracing", "${chip_root}/src/lib/address_resolve", - "${chip_root}/src/tracing", "${chip_root}/src/transport", "${chip_root}/third_party/perfetto:sdk", ] diff --git a/src/tracing/perfetto/include/matter/tracing/macros_impl.h b/src/tracing/perfetto/include/matter/tracing/macros_impl.h index 3a08b0b4645def..266ac69f5735a0 100644 --- a/src/tracing/perfetto/include/matter/tracing/macros_impl.h +++ b/src/tracing/perfetto/include/matter/tracing/macros_impl.h @@ -23,7 +23,6 @@ #endif #include -#include PERFETTO_DEFINE_CATEGORIES(perfetto::Category("Matter").SetDescription("Matter trace events")); @@ -31,4 +30,3 @@ PERFETTO_DEFINE_CATEGORIES(perfetto::Category("Matter").SetDescription("Matter t #define MATTER_TRACE_END(label, group) TRACE_EVENT_END("Matter") #define MATTER_TRACE_INSTANT(label, group) TRACE_EVENT_INSTANT("Matter", label, "class_name", group) #define MATTER_TRACE_SCOPE(label, group) TRACE_EVENT("Matter", label, "class_name", group) -#define MATTER_TRACE_COUNTER(label, group) ::chip::Tracing::Internal::Counter(label, group) diff --git a/src/tracing/perfetto/perfetto_tracing.cpp b/src/tracing/perfetto/perfetto_tracing.cpp index 305d1b533afce0..92017d5bc22022 100644 --- a/src/tracing/perfetto/perfetto_tracing.cpp +++ b/src/tracing/perfetto/perfetto_tracing.cpp @@ -21,10 +21,10 @@ #include #include #include -#include - +#include #include #include +#include namespace chip { namespace Tracing { @@ -55,7 +55,7 @@ void PerfettoBackend::LogMessageReceived(MessageReceivedInfo & info) void PerfettoBackend::TraceCounter(const char * label, const char * group) { std::string counterId = std::string(label); - + ChipLogProgress(SecureChannel, "In trace counter"); if (counters.find(counterId) == counters.end()) { counters[counterId] = 1; @@ -65,14 +65,15 @@ void PerfettoBackend::TraceCounter(const char * label, const char * group) counters[counterId]++; } - TRACE_EVENT_INSTANT("Matter", "Counter", // - "Label", label, // - "count", static_cast(counters[counterId]) // + TRACE_EVENT("Matter", "Counter", // + "Label", label, // + "count", counters[counterId] // ); } void PerfettoBackend::LogMessageSend(MessageSendInfo & info) { + ChipLogProgress(SecureChannel, "In trace counter"); const char * messageType = "UNKNOWN"; switch (info.messageType) { diff --git a/src/tracing/perfetto/perfetto_tracing.h b/src/tracing/perfetto/perfetto_tracing.h index 3337fe7c0336b0..a727e990041881 100644 --- a/src/tracing/perfetto/perfetto_tracing.h +++ b/src/tracing/perfetto/perfetto_tracing.h @@ -49,7 +49,7 @@ class PerfettoBackend : public ::chip::Tracing::Backend void LogNodeDiscoveryFailed(NodeDiscoveryFailedInfo &) override; private: - std::unordered_map> counters; + std::unordered_map counters; }; } // namespace Perfetto