-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tracing_functionality for esp32 platform and integrated the tra…
…cing with esp_insights. (#28466) Added a esp32_trace directory to provide esp32 specific basic implementation of the scoped tracing macros. Integrated esp-insights on a config option in the esp32 lighting-app. This is an initial implemenation of the esp32 specific tracing functionality.
- Loading branch information
1 parent
b3d9a5c
commit 1048639
Showing
20 changed files
with
241 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,5 @@ CONFIG_ENABLE_PW_RPC=y | |
|
||
# Enable HKDF in mbedtls | ||
CONFIG_MBEDTLS_HKDF_C=y | ||
|
||
CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,3 +73,5 @@ CONFIG_ENABLE_PW_RPC=y | |
|
||
# Enable HKDF in mbedtls | ||
CONFIG_MBEDTLS_HKDF_C=y | ||
|
||
CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,5 @@ CONFIG_ENABLE_PW_RPC=y | |
|
||
# Enable HKDF in mbedtls | ||
CONFIG_MBEDTLS_HKDF_C=y | ||
|
||
CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,3 +79,5 @@ CONFIG_TCP_SYNMAXRTX=6 | |
|
||
# Enable HKDF in mbedtls | ||
CONFIG_MBEDTLS_HKDF_C=y | ||
|
||
CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,3 +94,5 @@ CONFIG_ENABLE_PW_RPC=y | |
|
||
# Enable HKDF in mbedtls | ||
CONFIG_MBEDTLS_HKDF_C=y | ||
|
||
CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
#Copyright (c) 2023 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/build.gni") | ||
import("//build_overrides/chip.gni") | ||
|
||
config("tracing") { | ||
include_dirs = [ "include" ] | ||
} | ||
|
||
source_set("esp32_trace") { | ||
public = [ "include/matter/tracing/macros_impl.h" ] | ||
sources = [ "include/matter/tracing/macros_impl.cpp" ] | ||
public_configs = [ ":tracing" ] | ||
} |
44 changes: 44 additions & 0 deletions
44
src/tracing/esp32_trace/include/matter/tracing/macros_impl.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "macros_impl.h" | ||
#include <esp_heap_caps.h> | ||
#include <esp_insights.h> | ||
namespace Insights { | ||
|
||
#define LOG_HEAP_INFO(label, group, entry_exit) \ | ||
do \ | ||
{ \ | ||
ESP_DIAG_EVENT("MTR_TRC", "%s - %s - %s Min Free heap - %u - LFB - %u Start free heap - %u", entry_exit, label, group, \ | ||
heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT), \ | ||
heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT), \ | ||
heap_caps_get_free_size(MALLOC_CAP_8BIT)); \ | ||
} while (0) | ||
|
||
ESP32Backend::ESP32Backend(const char * str, ...) | ||
{ | ||
va_list args; | ||
va_start(args, str); | ||
mlabel = str; | ||
mgroup = va_arg(args, const char *); | ||
LOG_HEAP_INFO(mlabel, mgroup, "Entry"); | ||
} | ||
|
||
ESP32Backend::~ESP32Backend() | ||
{ | ||
LOG_HEAP_INFO(mlabel, mgroup, "Exit"); | ||
} | ||
} // namespace Insights |
50 changes: 50 additions & 0 deletions
50
src/tracing/esp32_trace/include/matter/tracing/macros_impl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#pragma once | ||
|
||
/* Ensure we do not have double tracing macros defined */ | ||
#if defined(MATTER_TRACE_BEGIN) | ||
#error "Tracing macros seem to be double defined" | ||
#endif | ||
|
||
namespace Insights { | ||
class ESP32Backend | ||
{ | ||
public: | ||
ESP32Backend(const char * str, ...); | ||
~ESP32Backend(); | ||
|
||
private: | ||
const char * mlabel; | ||
const char * mgroup; | ||
}; | ||
} // namespace Insights | ||
|
||
#define MATTER_TRACE_SCOPE(...) \ | ||
do \ | ||
{ \ | ||
Insights::ESP32Backend backend(__VA_ARGS__); \ | ||
} while (0) | ||
|
||
#define _MATTER_TRACE_DISABLE(...) \ | ||
do \ | ||
{ \ | ||
} while (false) | ||
|
||
#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__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters