1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FRAME_TRACE_HPP
17 #define FRAME_TRACE_HPP
18 
19 #include <functional>
20 #include <string>
21 
22 namespace FRAME_TRACE {
23 
24 struct TraceHandle;
25 struct TidHandle;
26 
27 enum class TraceType {
28     QUICK_TRACE,
29     SLOW_TRACE
30 };
31 
32 struct TraceHandle *CreateTraceTag(const std::string traceTag);
33 void SetTraceLimit(struct TraceHandle *traceHandle, unsigned int traceLimit);
34 void EnableTraceForThread(struct TraceHandle *traceHandle);
35 void StartFrameTrace(struct TraceHandle *traceHandle);
36 void StopFrameTrace(struct TraceHandle *traceHandle);
37 void TraceAndExecute(std::function<void()> &&func, TraceType traceType);
38 bool JudgeUnequalFrameTrace(struct TidHandle *tidHandle);
39 void UpdateFrameTraceTid(struct TidHandle *tidHandle);
40 bool FrameAwareTraceEnable(const std::string &traceTag);
41 void QuickStartFrameTrace(const std::string &traceTag);
42 void QuickEndFrameTrace(const std::string &traceTag);
43 bool FrameAwareTraceIsOpen();
44 bool FrameAwareTraceOpen();
45 bool FrameAwareTraceClose();
46 bool IsEnabled();
47 }
48 
49 #endif
50