Skip to content

Commit

Permalink
Approach 2
Browse files Browse the repository at this point in the history
  • Loading branch information
shripad621git committed Oct 3, 2023
1 parent ae1136b commit b9d8674
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/lib/support/CHIPCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,9 @@ class MonotonicallyIncreasingCounter : public Counter<T>
T mCounterValue;
};

#define CHIP_GENERIC_COUNTER(label, group) \
do \
{ \
} while (false)

} // namespace chip
10 changes: 10 additions & 0 deletions src/protocols/secure_channel/CASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <lib/support/SafeInt.h>
#include <lib/support/ScopedBuffer.h>
#include <lib/support/TypeTraits.h>
#include <lib/support/LabeledCounter.h>
#include <lib/support/CHIPCounter.h>
#include <platform/PlatformManager.h>
#include <protocols/Protocols.h>
#include <protocols/secure_channel/CASEDestinationId.h>
Expand All @@ -50,6 +52,9 @@

namespace {

chip::AdvanceCounter<int> sigma1cnt("sigma1cnt","CASE");
chip::AdvanceCounter<int> sigma2cnt("sigma2cnt","CASE");

enum
{
kTag_TBEData_SenderNOC = 1,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions src/tracing/esp32_trace/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "macros_impl.h"
#include <esp_heap_caps.h>
#include <esp_insights.h>


namespace Insights {

#define LOG_HEAP_INFO(label, group, entry_exit) \
Expand All @@ -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
8 changes: 8 additions & 0 deletions src/tracing/esp32_trace/include/matter/tracing/macros_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#error "Tracing macros seem to be double defined"
#endif

#include "counter.h"


namespace Insights {
class ESP32Backend
{
Expand Down Expand Up @@ -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

0 comments on commit b9d8674

Please sign in to comment.