blob: d3b1fb6dcfab5113f46fc37317a3a82e6c44a86e [file] [log] [blame]
Chris Craik6a40d672015-06-09 17:28:05 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Quddus Chong0e40c142017-02-23 14:51:09 -080017/**
18 * @file trace.h
19 * @brief Writes trace events to the system trace buffer.
20 *
21 * These trace events can be collected and visualized using the Systrace tool.
22 * For information about using the Systrace tool, read <a href="https://developer.android.com/studio/profile/systrace.html">Analyzing UI Performance with Systrace</a>.
23 */
Chris Craik6a40d672015-06-09 17:28:05 -070024
25#ifndef ANDROID_NATIVE_TRACE_H
26#define ANDROID_NATIVE_TRACE_H
27
28#include <stdbool.h>
Dan Albert494ed552016-09-23 15:57:45 -070029#include <sys/cdefs.h>
Chris Craik6a40d672015-06-09 17:28:05 -070030
31#ifdef __cplusplus
32extern "C" {
33#endif
34
Dan Albert494ed552016-09-23 15:57:45 -070035#if __ANDROID_API__ >= 23
36
Chris Craik6a40d672015-06-09 17:28:05 -070037/**
38 * Returns true if tracing is enabled. Use this signal to avoid expensive computation only necessary
39 * when tracing is enabled.
40 */
41bool ATrace_isEnabled();
42
43/**
44 * Writes a tracing message to indicate that the given section of code has begun. This call must be
45 * followed by a corresponding call to endSection() on the same thread.
46 *
47 * Note: At this time the vertical bar character '|' and newline character '\n' are used internally
48 * by the tracing mechanism. If sectionName contains these characters they will be replaced with a
49 * space character in the trace.
50 */
51void ATrace_beginSection(const char* sectionName);
52
53/**
54 * Writes a tracing message to indicate that a given section of code has ended. This call must be
55 * preceeded by a corresponding call to beginSection(char*) on the same thread. Calling this method
56 * will mark the end of the most recently begun section of code, so care must be taken to ensure
57 * that beginSection / endSection pairs are properly nested and called from the same thread.
58 */
59void ATrace_endSection();
60
Dan Albert494ed552016-09-23 15:57:45 -070061#endif /* __ANDROID_API__ >= 23 */
62
Chris Craik6a40d672015-06-09 17:28:05 -070063#ifdef __cplusplus
64};
65#endif
66
67#endif // ANDROID_NATIVE_TRACE_H