Add FtraceEventBundle and FtraceEvent protos
Change-Id: Ia3789340eb89dcb8355ff5491721e41746ad23f7
diff --git a/BUILD.gn b/BUILD.gn
index ed2f9b7..6a3ff90 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -19,6 +19,7 @@
"//buildtools:protobuf_lite",
"//buildtools:protoc($host_toolchain)",
"//ftrace_reader:ftrace_reader_demo",
+ "//protos/ftrace",
"//protozero/src/protoc_plugin($host_toolchain)",
"//tools/ftrace_proto_gen:ftrace_proto_gen",
]
diff --git a/ftrace_reader/BUILD.gn b/ftrace_reader/BUILD.gn
index 8b60cd3..98837c6 100644
--- a/ftrace_reader/BUILD.gn
+++ b/ftrace_reader/BUILD.gn
@@ -57,6 +57,9 @@
"//base",
"//protozero",
]
+ public_deps = [
+ "//protos/ftrace",
+ ]
sources = [
"include/ftrace_reader/ftrace_controller.h",
"include/ftrace_reader/ftrace_cpu_reader.h",
diff --git a/protos/ftrace/BUILD.gn b/protos/ftrace/BUILD.gn
new file mode 100644
index 0000000..e8e1cd5
--- /dev/null
+++ b/protos/ftrace/BUILD.gn
@@ -0,0 +1,25 @@
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//protozero//protozero_library.gni")
+
+protozero_library("ftrace") {
+ sources = [
+ "ftrace_event.proto",
+ "ftrace_event_bundle.proto",
+ "print.proto",
+ "sched_switch.proto",
+ ]
+ proto_in_dir = "."
+}
diff --git a/protos/ftrace/ftrace_event.proto b/protos/ftrace/ftrace_event.proto
new file mode 100644
index 0000000..25cfaa1
--- /dev/null
+++ b/protos/ftrace/ftrace_event.proto
@@ -0,0 +1,13 @@
+syntax = "proto3";
+option optimize_for = LITE_RUNTIME;
+
+import "print.proto";
+import "sched_switch.proto";
+
+message FtraceEvent {
+ uint32 pid = 1;
+ oneof event {
+ PrintFtraceEvent print = 2;
+ SchedSwitchFtraceEvent sched_switch = 3;
+ }
+}
diff --git a/protos/ftrace/ftrace_event_bundle.proto b/protos/ftrace/ftrace_event_bundle.proto
new file mode 100644
index 0000000..fedcc0b
--- /dev/null
+++ b/protos/ftrace/ftrace_event_bundle.proto
@@ -0,0 +1,9 @@
+syntax = "proto3";
+option optimize_for = LITE_RUNTIME;
+
+import "ftrace_event.proto";
+
+message FtraceEventBundle {
+ uint32 cpu = 1;
+ repeated FtraceEvent event = 2;
+}
diff --git a/protos/ftrace/print.proto b/protos/ftrace/print.proto
index 84e03f1..c4c8642 100644
--- a/protos/ftrace/print.proto
+++ b/protos/ftrace/print.proto
@@ -1,5 +1,6 @@
// Autogenerated by ../../tools/ftrace_proto_gen/ftrace_to_proto.cc do not edit.
syntax = "proto3";
+option optimize_for = LITE_RUNTIME;
message PrintFtraceEvent {
uint32 ip = 1;
uint32 buf = 2;
diff --git a/protos/ftrace/sched_switch.proto b/protos/ftrace/sched_switch.proto
index bcb77e9..a61463d 100644
--- a/protos/ftrace/sched_switch.proto
+++ b/protos/ftrace/sched_switch.proto
@@ -1,5 +1,6 @@
// Autogenerated by ../../tools/ftrace_proto_gen/ftrace_to_proto.cc do not edit.
syntax = "proto3";
+option optimize_for = LITE_RUNTIME;
message SchedSwitchFtraceEvent {
string prev_comm = 1;
int32 prev_pid = 2;
diff --git a/tools/ftrace_proto_gen/ftrace_to_proto.cc b/tools/ftrace_proto_gen/ftrace_to_proto.cc
index eaefe31..c5d1077 100644
--- a/tools/ftrace_proto_gen/ftrace_to_proto.cc
+++ b/tools/ftrace_proto_gen/ftrace_to_proto.cc
@@ -34,9 +34,9 @@
}
std::string ToCamelCase(const std::string& s) {
- std::string result = s;
+ std::string result;
+ result.reserve(s.size());
bool upperCaseNextChar = true;
- size_t j = 0;
for (size_t i = 0; i < s.size(); i++) {
char c = s[i];
if (c == '_') {
@@ -47,10 +47,8 @@
upperCaseNextChar = false;
c = static_cast<char>(toupper(c));
}
- result[j] = c;
- j++;
+ result.push_back(c);
}
- result.resize(j);
return result;
}
@@ -133,6 +131,8 @@
std::stringstream s;
s << "// Autogenerated by " << __FILE__ << " do not edit.\n";
s << "syntax = \"proto3\";\n";
+ s << "option optimize_for = LITE_RUNTIME;\n";
+ s << "\n";
s << "message " << name << " {\n";
for (const Proto::Field& field : fields) {
s << " " << field.type << " " << field.name << " = " << field.number