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 #include "dslm_hitrace.h"
17 
18 #include "hitrace_meter.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
DslmStartProcessTrace(const char * value)24 void DslmStartProcessTrace(const char *value)
25 {
26     StartTrace(HITRACE_TAG_DLSM, std::string(value));
27 }
28 
DslmStartStateMachineTrace(uint32_t machineId,uint32_t event)29 void DslmStartStateMachineTrace(uint32_t machineId, uint32_t event)
30 {
31     std::string traceValue =
32         std::string("StartStateMachine_") + std::to_string(machineId) + "_" + std::to_string(event);
33 
34     StartTrace(HITRACE_TAG_DLSM, traceValue);
35 }
36 
DslmFinishProcessTrace(void)37 void DslmFinishProcessTrace(void)
38 {
39     FinishTrace(HITRACE_TAG_DLSM);
40 }
41 
DslmStartProcessTraceAsync(const char * value,uint32_t owner,uint32_t cookie)42 void DslmStartProcessTraceAsync(const char *value, uint32_t owner, uint32_t cookie)
43 {
44     std::string traceValue = std::string(value) + "_" + std::to_string(owner) + "_" + std::to_string(cookie);
45     StartAsyncTrace(HITRACE_TAG_DLSM, traceValue, cookie);
46 }
47 
DslmFinishProcessTraceAsync(const char * value,uint32_t owner,uint32_t cookie)48 void DslmFinishProcessTraceAsync(const char *value, uint32_t owner, uint32_t cookie)
49 {
50     std::string traceValue = std::string(value) + "_" + std::to_string(owner) + "_" + std::to_string(cookie);
51     FinishAsyncTrace(HITRACE_TAG_DLSM, traceValue, cookie);
52 }
53 
DslmCountTrace(const char * name,int64_t count)54 void DslmCountTrace(const char *name, int64_t count)
55 {
56     CountTrace(HITRACE_TAG_DLSM, std::string(name), count);
57 }
58 
59 #ifdef __cplusplus
60 }
61 #endif
62