• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "xpower_event.h"
17 #include "xpower_event_common.h"
18 #include <parameters.h>
19 #include "hisysevent.h"
20 #include "backtrace_local.h"
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 
ReportXPowerStackSysEvent(const std::string & tagName,const std::string & info)25 int ReportXPowerStackSysEvent(const std::string &tagName, const std::string &info)
26 {
27     if ((OHOS::system::GetIntParameter(PROP_XPOWER_OPTIMIZE_ENABLE, 0) != 1)) {
28         return ERR_PROP_NOT_ENABLE;
29     }
30     std::string stack = "";
31     bool succ = GetBacktrace(stack, true); // true means fp stack
32     if (!succ) {
33         return ERR_DUMP_STACK_FAILED;
34     }
35     int ret = HiSysEventWrite(HiSysEvent::Domain::HIVIEWDFX, TAG_XPOWER_STACKTRACE,
36         HiSysEvent::EventType::STATISTIC, "TAGNAME", tagName, "INFO", info, "STACKTRACE", stack);
37     return ret; // 0 success or error code in HiSysEventWrite
38 }
39 
40 }
41 }