1 /*
2 * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
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 "bytrace_module.h"
17 #include "bytrace_plugin_config.pb.h"
18 #include "logging.h"
19
20 namespace {
21 constexpr uint32_t TRACE_TIME = 8;
22 constexpr uint32_t WAIT_TIME = 9;
23 constexpr uint32_t BUFFE_SIZE = 1024;
24 }
25
main()26 int main()
27 {
28 BytracePluginConfig config;
29 config.set_outfile_name("/data/local/tmp/bytrace.txt");
30 config.set_clock("boot");
31 config.set_time(TRACE_TIME);
32 config.set_buffe_size(BUFFE_SIZE);
33 config.add_categories("sched");
34 config.add_categories("freq");
35 config.add_categories("idle");
36 config.add_categories("workq");
37
38 std::vector<char> buffer(config.ByteSizeLong());
39 CHECK_TRUE(config.SerializeToArray(buffer.data(), buffer.size()), 0, "Serialize config FAILED!");
40 CHECK_TRUE(BytracePluginSessionStart(reinterpret_cast<uint8_t*>(buffer.data()), buffer.size()) == 0, 0,
41 "call start callback FAILED!");
42 sleep(WAIT_TIME);
43 BytracePluginSessionStop();
44 return 0;
45 }
46