blob: 068c0464a5e9592f2d0777502cd156635a711f9b [file] [log] [blame]
Hector Dearmanbefe55b2017-11-24 19:02:59 +00001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdio.h>
18#include <unistd.h>
19
20#include <iomanip>
21#include <memory>
22#include <sstream>
23#include <string>
24#include <utility>
25#include <vector>
26
Hector Dearmanbefe55b2017-11-24 19:02:59 +000027#include "ftrace_reader/ftrace_controller.h"
Oystein Eftevaagdd727e42017-12-05 08:49:55 -080028#include "perfetto_base/unix_task_runner.h"
Hector Dearmanbefe55b2017-11-24 19:02:59 +000029#include "protozero/scattered_stream_writer.h"
30#include "scattered_stream_delegate_for_testing.h"
31
Primiano Tucci5f48d7b2017-11-27 16:57:13 +000032#include "protos/ftrace/ftrace_event_bundle.pbzero.h"
33
Hector Dearmanbefe55b2017-11-24 19:02:59 +000034int main(int argc, const char** argv) {
35 perfetto::base::UnixTaskRunner runner;
36 auto ftrace = perfetto::FtraceController::Create(&runner);
37
38 perfetto::FtraceConfig config;
39 for (int i = 1; i < argc; i++) {
40 config.AddEvent(argv[i]);
41 }
42 std::unique_ptr<perfetto::FtraceSink> sink =
43 ftrace->CreateSink(std::move(config), nullptr);
44
45 // Sleep for one second so we get some events
46 sleep(10);
47
48 perfetto::ScatteredStreamDelegateForTesting buffer(4096);
49 protozero::ScatteredStreamWriter stream_writer(&buffer);
Primiano Tucci5f48d7b2017-11-27 16:57:13 +000050 perfetto::protos::pbzero::FtraceEventBundle message;
Hector Dearmanbefe55b2017-11-24 19:02:59 +000051 message.Reset(&stream_writer);
52
53 return 0;
54}