• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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  * Description: HitraceOps implements
16  */
17 #include "hitrace_ops.h"
18 
19 #include "logging.h"
20 #include "string_utils.h"
21 
22 FTRACE_NS_BEGIN
HitraceOps()23 HitraceOps::HitraceOps() : TraceOps("/system/bin/hitrace", "hitrace", HITRACE) {}
24 
~HitraceOps()25 HitraceOps::~HitraceOps() {}
26 
PrepareListCategoriesCmd()27 bool HitraceOps::PrepareListCategoriesCmd()
28 {
29     args_.push_back("-l");
30     return true;
31 }
32 
PrepareEnableCategoriesCmd(int traceTime)33 bool HitraceOps::PrepareEnableCategoriesCmd(int traceTime)
34 {
35     if (traceTime == 0) {
36         traceTime = 1;
37     }
38     args_.push_back("--trace_begin");
39     args_.push_back("-t");
40     args_.push_back(std::to_string(traceTime));
41 
42     for (auto& category : targetCategories_) {
43         args_.push_back(category);
44     }
45     return true;
46 }
47 
PrepareDisableCategoriesCmd()48 bool HitraceOps::PrepareDisableCategoriesCmd()
49 {
50     args_.push_back("--trace_finish_nodump");
51     return true;
52 }
53 FTRACE_NS_END
54