mirror of
https://github.com/esphome/esphome.git
synced 2025-08-03 17:07:54 +00:00
Fix heap tracing function scope issues
- Add extern \C\ linkage to heap tracing functions - Forward declare the functions in the API server implementation - Ensures the heap tracing functions are accessible from any namespace
This commit is contained in:
parent
35238c1437
commit
00e128bdd5
@ -221,18 +221,19 @@ async def to_code(config):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add helper functions for heap tracing
|
# Add helper functions for heap tracing with extern "C" to make them globally accessible
|
||||||
cg.add_global(
|
cg.add_global(
|
||||||
cg.RawStatement(
|
cg.RawStatement(
|
||||||
"""
|
"""
|
||||||
void start_heap_trace() {
|
// Global heap tracing functions that can be called from any context
|
||||||
|
extern "C" void start_heap_trace() {
|
||||||
heap_trace_init_standalone(trace_record, """
|
heap_trace_init_standalone(trace_record, """
|
||||||
+ str(num_records)
|
+ str(num_records)
|
||||||
+ """);
|
+ """);
|
||||||
heap_trace_start(HEAP_TRACE_LEAKS);
|
heap_trace_start(HEAP_TRACE_LEAKS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop_and_dump_heap_trace() {
|
extern "C" void stop_and_dump_heap_trace() {
|
||||||
heap_trace_stop();
|
heap_trace_stop();
|
||||||
heap_trace_dump();
|
heap_trace_dump();
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,14 @@
|
|||||||
#include "esphome/components/logger/logger.h"
|
#include "esphome/components/logger/logger.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_API_HEAP_TRACE
|
||||||
|
#include "esp_heap_trace.h"
|
||||||
|
|
||||||
|
// Forward declare heap tracing functions that will be used in the API class
|
||||||
|
extern "C" void start_heap_trace();
|
||||||
|
extern "C" void stop_and_dump_heap_trace();
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user