blob: 6cdcfebb783f89842848f7018f4a3eb390f73a6f [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
17
18#ifndef ANDROID_NATIVE_TRACE_H
19#define ANDROID_NATIVE_TRACE_H
20
21#include <stdbool.h>
Dan Albert494ed552016-09-23 15:57:45 -070022#include <sys/cdefs.h>
Chris Craik6a40d672015-06-09 17:28:05 -070023
24#ifdef __cplusplus
25extern "C" {
26#endif
27
Dan Albert494ed552016-09-23 15:57:45 -070028#if __ANDROID_API__ >= 23
29
Chris Craik6a40d672015-06-09 17:28:05 -070030/**
31 * Returns true if tracing is enabled. Use this signal to avoid expensive computation only necessary
32 * when tracing is enabled.
33 */
34bool ATrace_isEnabled();
35
36/**
37 * Writes a tracing message to indicate that the given section of code has begun. This call must be
38 * followed by a corresponding call to endSection() on the same thread.
39 *
40 * Note: At this time the vertical bar character '|' and newline character '\n' are used internally
41 * by the tracing mechanism. If sectionName contains these characters they will be replaced with a
42 * space character in the trace.
43 */
44void ATrace_beginSection(const char* sectionName);
45
46/**
47 * Writes a tracing message to indicate that a given section of code has ended. This call must be
48 * preceeded by a corresponding call to beginSection(char*) on the same thread. Calling this method
49 * will mark the end of the most recently begun section of code, so care must be taken to ensure
50 * that beginSection / endSection pairs are properly nested and called from the same thread.
51 */
52void ATrace_endSection();
53
Dan Albert494ed552016-09-23 15:57:45 -070054#endif /* __ANDROID_API__ >= 23 */
55
Chris Craik6a40d672015-06-09 17:28:05 -070056#ifdef __cplusplus
57};
58#endif
59
60#endif // ANDROID_NATIVE_TRACE_H