1 /*
2 * Copyright (C) 2024 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 <cinttypes>
18 #include <cstdint>
19 #include <cstdio>
20 #include <memory>
21
22 #include "perfetto/base/status.h"
23 #include "perfetto/trace_processor/basic_types.h"
24 #include "perfetto/trace_processor/read_trace.h"
25 #include "perfetto/trace_processor/trace_processor.h"
26 #include "src/trace_processor/util/status_macros.h"
27
28 namespace perfetto::trace_processor {
29 namespace {
30
31 // This binary exists just for the purpose of debugging the binary size of
32 // trace processor. To that end, we just run some basic trace processor
33 // functions to ensure that the linker does not strip the TP symbols.
MinimalMain(int,char **)34 base::Status MinimalMain(int, char**) {
35 std::unique_ptr<TraceProcessor> tp = TraceProcessor::CreateInstance({});
36 RETURN_IF_ERROR(tp->Parse(std::unique_ptr<uint8_t[]>(new uint8_t[0]), 0));
37 RETURN_IF_ERROR(tp->NotifyEndOfFile());
38
39 auto it = tp->ExecuteQuery("SELECT id FROM slice");
40 while (it.Next()) {
41 SqlValue value = it.Get(0);
42 fprintf(stderr, "%" PRId64, value.AsLong());
43 }
44 return it.Status();
45 }
46
47 } // namespace
48 } // namespace perfetto::trace_processor
49
main(int argc,char ** argv)50 int main(int argc, char** argv) {
51 auto status = perfetto::trace_processor::MinimalMain(argc, argv);
52 if (!status.ok()) {
53 fprintf(stderr, "%s\n", status.c_message());
54 return 1;
55 }
56 return 0;
57 }
58