Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle Add instructions on how to add trace events #16394

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/trace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Matter tracing

Matter tracing provides a tool for applications to trace information about the
execution of the application. It depends on
[pw_trace module](https://pigweed.dev/pw_trace/).

## How to add trace events

1. Include "trace/trace.h" in the source file.
2. Add "\${chip_root}/src/trace" as deps in BUILD.gn.
3. Add MATTER*TRACE_EVENT*\* in functions to be traced.

## Example

```
#include "pw_trace/trace.h"

void SendButton() {
MATTER_TRACE_EVENT_FUNCTION();
// do something
}

void InputLoop() {
while(1) {
auto event = WaitNewInputEvent()
MATTER_TRACE_EVENT_SCOPE("Handle Event"); // measure until loop finished
if (event == kNewButton){
SendButton();
MATTER_TRACE_EVENT_END("button"); // Trace event was started in ButtonIsr
} else {
MATTER_TRACE_EVENT_INSTANT("Unknown event");
}
}
}

void ButtonIsr() {
MATTER_TRACE_EVENT_START("button");
SendNewInputEvent(kNewButton);
}
```