FastLED 3.9.15
Loading...
Searching...
No Matches
trace.h
Go to the documentation of this file.
1#pragma once
2
38
39#include "fl/stl/tuple.h"
40#include "fl/stl/chrono.h" // IWYU pragma: keep
41#include "fl/stl/stdint.h"
42#include "fl/stl/string.h" // IWYU pragma: keep
43#include "fl/stl/vector.h"
44#include "fl/stl/compiler_control.h" // For FL_FUNCTION // IWYU pragma: keep
45#include "fl/stl/noexcept.h"
46
47namespace fl {
48
52
60public:
64 explicit ScopedTrace(const char* function, int line) FL_NOEXCEPT;
65
68
69 // Non-copyable, non-movable
73 ScopedTrace& operator=(ScopedTrace&&) FL_NOEXCEPT = delete;
74
78 static void push(const char* function, int line) FL_NOEXCEPT;
79
81 static void pop() FL_NOEXCEPT;
82
85 static fl::size depth() FL_NOEXCEPT;
86
89 static fl::string dump() FL_NOEXCEPT;
90
93 static void dump(fl::vector<TracePoint>* out) FL_NOEXCEPT;
94
96 static void clear() FL_NOEXCEPT;
97};
98
99} // namespace fl
100
102#define FL_TRACE fl::make_tuple(__FILE__, int(__LINE__), fl::millis())
103
104#ifdef FASTLED_DEBUG_STACK_TRACE
106#define FL_SCOPED_TRACE_CONCAT(name, line) fl::ScopedTrace __fl_trace_##line(name, line)
107
109#define FL_SCOPED_TRACE_IMPL(name, line) FL_SCOPED_TRACE_CONCAT(name, line)
110
114#define FL_SCOPED_TRACE_NAMED(name) FL_SCOPED_TRACE_IMPL(name, __LINE__)
115
119#define FL_SCOPED_TRACE FL_SCOPED_TRACE_IMPL(FL_FUNCTION, __LINE__)
120
123#define FL_TRACE_DUMP() FL_DBG(fl::ScopedTrace::dump())
124
125#else
126// No-op macros when stack tracing is disabled
127#define FL_SCOPED_TRACE_NAMED(name) do {} while(0)
128#define FL_SCOPED_TRACE do {} while(0)
129#define FL_TRACE_DUMP() do {} while(0)
130#endif // FASTLED_DEBUG_STACK_TRACE
FastLED chrono implementation - duration types for time measurements.
static void push(const char *function, int line) FL_NOEXCEPT
Push a function name onto the call stack.
Definition trace.cpp.hpp:53
static void pop() FL_NOEXCEPT
Pop the most recent function from the call stack.
Definition trace.cpp.hpp:70
ScopedTrace(ScopedTrace &&) FL_NOEXCEPT=delete
ScopedTrace(const char *function, int line) FL_NOEXCEPT
Construct and push function name onto stack.
static void clear() FL_NOEXCEPT
Clear the entire call stack (primarily for testing)
ScopedTrace & operator=(const ScopedTrace &) FL_NOEXCEPT=delete
static fl::size depth() FL_NOEXCEPT
Get the current stack depth.
Definition trace.cpp.hpp:91
~ScopedTrace() FL_NOEXCEPT
Destructor - automatically pops from stack.
static fl::string dump() FL_NOEXCEPT
Dump the current call stack to a string.
Definition trace.cpp.hpp:95
ScopedTrace(const ScopedTrace &) FL_NOEXCEPT=delete
fl::tuple< const char *, int, fl::u32 > TracePoint
A structure to hold source trace information.
Definition trace.h:51
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT