forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
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. 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
c4d95d0
commit 30eb770
Showing
11 changed files
with
201 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ dependencies: | |
version: "2.0.3" | ||
rules: | ||
- if: "idf_version >=4.4" | ||
|
||
espressif/esp_insights: | ||
version: "1.0.0" |
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 |
---|---|---|
@@ -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 { | ||
|
||
ESP32Backend::ESP32Backend(const char * str, ...) | ||
{ | ||
va_list args; | ||
va_start(args, str); | ||
var1 = str; | ||
var2 = va_arg(args, const char *); | ||
|
||
size_t start_min_heap = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT); | ||
size_t largest_free_block = heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); | ||
size_t start_free_heap = heap_caps_get_free_size(MALLOC_CAP_8BIT); | ||
ESP_DIAG_EVENT("MTR_TRC", "Entry - %s - %s - Start Min Free heap - %u - Largest Free Block - %u Start free heap -%u", var1, | ||
var2, start_min_heap, largest_free_block, start_free_heap); | ||
} | ||
|
||
ESP32Backend::~ESP32Backend() | ||
{ | ||
size_t end_minimum_free_heap = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT); | ||
size_t end_largest_free_block = heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); | ||
size_t end_free_heap = heap_caps_get_free_size(MALLOC_CAP_8BIT); | ||
ESP_DIAG_EVENT("MTR_TRC", "Exit - %s - %s - End Min Free heap - %u - End Largest Free Block %u - End free Heap - %u", var1, | ||
var2, end_minimum_free_heap, end_largest_free_block, end_free_heap); | ||
} | ||
} // 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 * var1; | ||
const char * var2; | ||
}; | ||
} // 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
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