Hector Dearman | befe55b | 2017-11-24 19:02:59 +0000 | [diff] [blame] | 1 | /* |
| 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 Dearman | befe55b | 2017-11-24 19:02:59 +0000 | [diff] [blame] | 27 | #include "ftrace_reader/ftrace_controller.h" |
Oystein Eftevaag | dd727e4 | 2017-12-05 08:49:55 -0800 | [diff] [blame^] | 28 | #include "perfetto_base/unix_task_runner.h" |
Hector Dearman | befe55b | 2017-11-24 19:02:59 +0000 | [diff] [blame] | 29 | #include "protozero/scattered_stream_writer.h" |
| 30 | #include "scattered_stream_delegate_for_testing.h" |
| 31 | |
Primiano Tucci | 5f48d7b | 2017-11-27 16:57:13 +0000 | [diff] [blame] | 32 | #include "protos/ftrace/ftrace_event_bundle.pbzero.h" |
| 33 | |
Hector Dearman | befe55b | 2017-11-24 19:02:59 +0000 | [diff] [blame] | 34 | int 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 Tucci | 5f48d7b | 2017-11-27 16:57:13 +0000 | [diff] [blame] | 50 | perfetto::protos::pbzero::FtraceEventBundle message; |
Hector Dearman | befe55b | 2017-11-24 19:02:59 +0000 | [diff] [blame] | 51 | message.Reset(&stream_writer); |
| 52 | |
| 53 | return 0; |
| 54 | } |