Tracing

#include <trace.h>

Summary

Functions

ATrace_beginAsyncSection(const char *sectionName, int32_t cookie)
void
Writes a trace message to indicate that a given section of code has begun.
ATrace_beginSection(const char *sectionName)
void
Writes a tracing message to indicate that the given section of code has begun.
ATrace_endAsyncSection(const char *sectionName, int32_t cookie)
void
Writes a trace message to indicate that the current method has ended.
ATrace_endSection()
void
Writes a tracing message to indicate that a given section of code has ended.
ATrace_isEnabled()
bool
Returns true if tracing is enabled.
ATrace_setCounter(const char *counterName, int64_t counterValue)
void
Writes trace message to indicate the value of a given counter.

Functions

ATrace_beginAsyncSection

void ATrace_beginAsyncSection(
  const char *sectionName,
  int32_t cookie
)

Writes a trace message to indicate that a given section of code has begun.

Must be followed by a call to ATrace_endAsyncSection with the same methodName and cookie. Unlike ATrace_beginSection and ATrace_endSection, asynchronous events do not need to be nested. The name and cookie used to begin an event must be used to end it.

Available since API level 29.

Details
Parameters
sectionName
The method name to appear in the trace.
cookie
Unique identifier for distinguishing simultaneous events

ATrace_beginSection

void ATrace_beginSection(
  const char *sectionName
)

Writes a tracing message to indicate that the given section of code has begun.

This call must be followed by a corresponding call to ATrace_endSection on the same thread.

Note: At this time the vertical bar character '|' and newline character '\n' are used internally by the tracing mechanism. If sectionName contains these characters they will be replaced with a space character in the trace.

Available since API level 23.

ATrace_endAsyncSection

void ATrace_endAsyncSection(
  const char *sectionName,
  int32_t cookie
)

Writes a trace message to indicate that the current method has ended.

Must be called exactly once for each call to ATrace_beginAsyncSection using the same name and cookie.

Available since API level 29.

Details
Parameters
sectionName
The method name to appear in the trace.
cookie
Unique identifier for distinguishing simultaneous events

ATrace_endSection

void ATrace_endSection()

Writes a tracing message to indicate that a given section of code has ended.

This call must be preceeded by a corresponding call to ATrace_beginSection on the same thread. Calling this method will mark the end of the most recently begun section of code, so care must be taken to ensure that ATrace_beginSection/ATrace_endSection pairs are properly nested and called from the same thread.

Available since API level 23.

ATrace_isEnabled

bool ATrace_isEnabled()

Returns true if tracing is enabled.

Use this to avoid expensive computation only necessary when tracing is enabled.

Available since API level 23.

ATrace_setCounter

void ATrace_setCounter(
  const char *counterName,
  int64_t counterValue
)

Writes trace message to indicate the value of a given counter.

Available since API level 29.

Details
Parameters
counterName
The counter name to appear in the trace.
counterValue
The counter value.