Merge "traced: Remove unused vector"
diff --git a/src/traced/probes/filesystem/inode_file_data_source.cc b/src/traced/probes/filesystem/inode_file_data_source.cc
index 3186b3f..fd308ac 100644
--- a/src/traced/probes/filesystem/inode_file_data_source.cc
+++ b/src/traced/probes/filesystem/inode_file_data_source.cc
@@ -223,7 +223,8 @@
BlockDeviceID block_device_id = inodes_pair.second;
inode_file_maps[block_device_id].emplace(inode_number);
}
- PERFETTO_DLOG("Saw %zu block devices.", inode_file_maps.size());
+ if (inode_file_maps.size() > 1)
+ PERFETTO_DLOG("Saw %zu block devices.", inode_file_maps.size());
// Write a TracePacket with an InodeFileMap proto for each block device id
for (const auto& inode_file_map_data : inode_file_maps) {
diff --git a/src/traced/probes/probes_producer.cc b/src/traced/probes/probes_producer.cc
index 5d29fd9..b460971 100644
--- a/src/traced/probes/probes_producer.cc
+++ b/src/traced/probes/probes_producer.cc
@@ -188,7 +188,7 @@
auto trace_writer = endpoint_->CreateTraceWriter(
static_cast<BufferID>(source_config.target_buffer()));
if (system_inodes_.empty())
- CreateStaticDeviceToInodeMap("/system/", &system_inodes_);
+ CreateStaticDeviceToInodeMap("/system", &system_inodes_);
auto file_map_source =
std::unique_ptr<InodeFileDataSource>(new InodeFileDataSource(
session_id, &system_inodes_, &cache_, std::move(trace_writer)));
diff --git a/tools/ftrace_proto_gen/ftrace_proto_gen.cc b/tools/ftrace_proto_gen/ftrace_proto_gen.cc
index 4a1df78..3c25934 100644
--- a/tools/ftrace_proto_gen/ftrace_proto_gen.cc
+++ b/tools/ftrace_proto_gen/ftrace_proto_gen.cc
@@ -103,10 +103,10 @@
}
}
-void PrintTraceToTextMain(const std::set<std::string>& events) {
+void PrintEventFormatterMain(const std::set<std::string>& events) {
printf(
- "\nAdd output to TraceToSystrace for loop in "
- "tools/ftrace_proto_gen/main.cc\n");
+ "\nAdd output to FormatEventText in "
+ "tools/ftrace_proto_gen/ftrace_event_formatter.cc\n");
for (auto event : events) {
printf(
"else if (event.has_%s()) {\nconst auto& inner = event.%s();\nline = "
@@ -115,17 +115,30 @@
}
}
-void PrintTraceToTextUsingStatements(const std::set<std::string>& events) {
- printf("\nAdd output to tools/ftrace_proto_gen/main.cc\n");
+// Add output to ParseInode in ftrace_inode_handler
+void PrintInodeHandlerMain(const std::string& event_name,
+ const perfetto::Proto& proto) {
+ for (const auto& field : proto.fields) {
+ if (Contains(field.name, "ino") && !Contains(field.name, "minor"))
+ printf(
+ "else if (event.has_%s() && event.%s().%s()) {\n*inode = "
+ "static_cast<uint64_t>(event.%s().%s());\n return true;\n} ",
+ event_name.c_str(), event_name.c_str(), field.name.c_str(),
+ event_name.c_str(), field.name.c_str());
+ }
+}
+
+void PrintEventFormatterUsingStatements(const std::set<std::string>& events) {
+ printf("\nAdd output to tools/ftrace_proto_gen/ftrace_event_formatter.cc\n");
for (auto event : events) {
printf("using protos::%sFtraceEvent;\n", ToCamelCase(event).c_str());
}
}
-void PrintTraceToTextFunctions(const std::set<std::string>& events) {
+void PrintEventFormatterFunctions(const std::set<std::string>& events) {
printf(
- "\nAdd output to tools/ftrace_proto_gen/main.cc and then manually go "
- "through format files to match fields\n");
+ "\nAdd output to tools/ftrace_proto_gen/ftrace_event_formatter.cc and "
+ "then manually go through format files to match fields\n");
for (auto event : events) {
printf(
"std::string Format%s(const %sFtraceEvent& event) {"
diff --git a/tools/ftrace_proto_gen/ftrace_proto_gen.h b/tools/ftrace_proto_gen/ftrace_proto_gen.h
index a5be4f4..11cf5cf 100644
--- a/tools/ftrace_proto_gen/ftrace_proto_gen.h
+++ b/tools/ftrace_proto_gen/ftrace_proto_gen.h
@@ -38,9 +38,11 @@
};
void PrintFtraceEventProtoAdditions(const std::set<std::string>& events);
-void PrintTraceToTextMain(const std::set<std::string>& events);
-void PrintTraceToTextUsingStatements(const std::set<std::string>& events);
-void PrintTraceToTextFunctions(const std::set<std::string>& events);
+void PrintEventFormatterMain(const std::set<std::string>& events);
+void PrintEventFormatterUsingStatements(const std::set<std::string>& events);
+void PrintEventFormatterFunctions(const std::set<std::string>& events);
+void PrintInodeHandlerMain(const std::string& event_name,
+ const perfetto::Proto& proto);
bool GenerateProto(const FtraceEvent& format, Proto* proto_out);
std::string InferProtoType(const FtraceEvent::Field& field);
diff --git a/tools/ftrace_proto_gen/main.cc b/tools/ftrace_proto_gen/main.cc
index 33d8abb..c701d39 100644
--- a/tools/ftrace_proto_gen/main.cc
+++ b/tools/ftrace_proto_gen/main.cc
@@ -62,9 +62,12 @@
if (!new_events.empty()) {
perfetto::PrintFtraceEventProtoAdditions(new_events);
- perfetto::PrintTraceToTextMain(new_events);
- perfetto::PrintTraceToTextUsingStatements(new_events);
- perfetto::PrintTraceToTextFunctions(new_events);
+ perfetto::PrintEventFormatterMain(new_events);
+ perfetto::PrintEventFormatterUsingStatements(new_events);
+ perfetto::PrintEventFormatterFunctions(new_events);
+ printf(
+ "\nAdd output to ParseInode in "
+ "tools/ftrace_proto_gen/ftrace_inode_handler.cc\n");
}
for (auto event : events) {
@@ -105,6 +108,9 @@
return 1;
}
+ if (!new_events.empty())
+ PrintInodeHandlerMain(format.name, proto);
+
events_info.push_back(
perfetto::SingleEventInfo(format, proto, group, proto_field_id));
diff --git a/tools/trace_to_text/BUILD.gn b/tools/trace_to_text/BUILD.gn
index 90e1233c..5f1f9e0 100644
--- a/tools/trace_to_text/BUILD.gn
+++ b/tools/trace_to_text/BUILD.gn
@@ -23,6 +23,8 @@
sources = [
"ftrace_event_formatter.cc",
"ftrace_event_formatter.h",
+ "ftrace_inode_handler.cc",
+ "ftrace_inode_handler.h",
"main.cc",
]
}
diff --git a/tools/trace_to_text/ftrace_event_formatter.cc b/tools/trace_to_text/ftrace_event_formatter.cc
index 1120d7a..1af2a1d 100644
--- a/tools/trace_to_text/ftrace_event_formatter.cc
+++ b/tools/trace_to_text/ftrace_event_formatter.cc
@@ -17,6 +17,8 @@
#include "tools/trace_to_text/ftrace_event_formatter.h"
#include <inttypes.h>
+#include <algorithm>
+#include <string>
namespace perfetto {
namespace {
diff --git a/tools/trace_to_text/ftrace_inode_handler.cc b/tools/trace_to_text/ftrace_inode_handler.cc
new file mode 100644
index 0000000..ad0d9b2
--- /dev/null
+++ b/tools/trace_to_text/ftrace_inode_handler.cc
@@ -0,0 +1,333 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#include "tools/trace_to_text/ftrace_inode_handler.h"
+
+namespace perfetto {
+
+bool ParseInode(const protos::FtraceEvent& event, uint64_t* inode) {
+ if (event.has_ext4_alloc_da_blocks() && event.ext4_alloc_da_blocks().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_alloc_da_blocks().ino());
+ return true;
+ } else if (event.has_ext4_allocate_blocks() &&
+ event.ext4_allocate_blocks().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_allocate_blocks().ino());
+ return true;
+ } else if (event.has_ext4_allocate_inode() &&
+ event.ext4_allocate_inode().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_allocate_inode().ino());
+ return true;
+ } else if (event.has_ext4_begin_ordered_truncate() &&
+ event.ext4_begin_ordered_truncate().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_begin_ordered_truncate().ino());
+ return true;
+ } else if (event.has_ext4_collapse_range() &&
+ event.ext4_collapse_range().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_collapse_range().ino());
+ return true;
+ } else if (event.has_ext4_da_release_space() &&
+ event.ext4_da_release_space().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_da_release_space().ino());
+ return true;
+ } else if (event.has_ext4_da_reserve_space() &&
+ event.ext4_da_reserve_space().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_da_reserve_space().ino());
+ return true;
+ } else if (event.has_ext4_da_update_reserve_space() &&
+ event.ext4_da_update_reserve_space().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_da_update_reserve_space().ino());
+ return true;
+ } else if (event.has_ext4_da_write_begin() &&
+ event.ext4_da_write_begin().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_da_write_begin().ino());
+ return true;
+ } else if (event.has_ext4_da_write_end() && event.ext4_da_write_end().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_da_write_end().ino());
+ return true;
+ } else if (event.has_ext4_da_write_pages() &&
+ event.ext4_da_write_pages().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_da_write_pages().ino());
+ return true;
+ } else if (event.has_ext4_da_write_pages_extent() &&
+ event.ext4_da_write_pages_extent().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_da_write_pages_extent().ino());
+ return true;
+ } else if (event.has_ext4_direct_io_enter() &&
+ event.ext4_direct_io_enter().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_direct_io_enter().ino());
+ return true;
+ } else if (event.has_ext4_direct_io_exit() &&
+ event.ext4_direct_io_exit().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_direct_io_exit().ino());
+ return true;
+ } else if (event.has_ext4_discard_preallocations() &&
+ event.ext4_discard_preallocations().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_discard_preallocations().ino());
+ return true;
+ } else if (event.has_ext4_drop_inode() && event.ext4_drop_inode().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_drop_inode().ino());
+ return true;
+ } else if (event.has_ext4_es_cache_extent() &&
+ event.ext4_es_cache_extent().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_es_cache_extent().ino());
+ return true;
+ } else if (event.has_ext4_es_find_delayed_extent_range_enter() &&
+ event.ext4_es_find_delayed_extent_range_enter().ino()) {
+ *inode = static_cast<uint64_t>(
+ event.ext4_es_find_delayed_extent_range_enter().ino());
+ return true;
+ } else if (event.has_ext4_es_find_delayed_extent_range_exit() &&
+ event.ext4_es_find_delayed_extent_range_exit().ino()) {
+ *inode = static_cast<uint64_t>(
+ event.ext4_es_find_delayed_extent_range_exit().ino());
+ return true;
+ } else if (event.has_ext4_es_insert_extent() &&
+ event.ext4_es_insert_extent().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_es_insert_extent().ino());
+ return true;
+ } else if (event.has_ext4_es_lookup_extent_enter() &&
+ event.ext4_es_lookup_extent_enter().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_es_lookup_extent_enter().ino());
+ return true;
+ } else if (event.has_ext4_es_lookup_extent_exit() &&
+ event.ext4_es_lookup_extent_exit().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_es_lookup_extent_exit().ino());
+ return true;
+ } else if (event.has_ext4_es_remove_extent() &&
+ event.ext4_es_remove_extent().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_es_remove_extent().ino());
+ return true;
+ } else if (event.has_ext4_evict_inode() && event.ext4_evict_inode().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_evict_inode().ino());
+ return true;
+ } else if (event.has_ext4_ext_convert_to_initialized_enter() &&
+ event.ext4_ext_convert_to_initialized_enter().ino()) {
+ *inode = static_cast<uint64_t>(
+ event.ext4_ext_convert_to_initialized_enter().ino());
+ return true;
+ } else if (event.has_ext4_ext_convert_to_initialized_fastpath() &&
+ event.ext4_ext_convert_to_initialized_fastpath().ino()) {
+ *inode = static_cast<uint64_t>(
+ event.ext4_ext_convert_to_initialized_fastpath().ino());
+ return true;
+ } else if (event.has_ext4_ext_handle_unwritten_extents() &&
+ event.ext4_ext_handle_unwritten_extents().ino()) {
+ *inode =
+ static_cast<uint64_t>(event.ext4_ext_handle_unwritten_extents().ino());
+ return true;
+ } else if (event.has_ext4_ext_in_cache() && event.ext4_ext_in_cache().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ext_in_cache().ino());
+ return true;
+ } else if (event.has_ext4_ext_load_extent() &&
+ event.ext4_ext_load_extent().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ext_load_extent().ino());
+ return true;
+ } else if (event.has_ext4_ext_map_blocks_enter() &&
+ event.ext4_ext_map_blocks_enter().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ext_map_blocks_enter().ino());
+ return true;
+ } else if (event.has_ext4_ext_map_blocks_exit() &&
+ event.ext4_ext_map_blocks_exit().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ext_map_blocks_exit().ino());
+ return true;
+ } else if (event.has_ext4_ext_put_in_cache() &&
+ event.ext4_ext_put_in_cache().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ext_put_in_cache().ino());
+ return true;
+ } else if (event.has_ext4_ext_remove_space() &&
+ event.ext4_ext_remove_space().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ext_remove_space().ino());
+ return true;
+ } else if (event.has_ext4_ext_remove_space_done() &&
+ event.ext4_ext_remove_space_done().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ext_remove_space_done().ino());
+ return true;
+ } else if (event.has_ext4_ext_rm_idx() && event.ext4_ext_rm_idx().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ext_rm_idx().ino());
+ return true;
+ } else if (event.has_ext4_ext_rm_leaf() && event.ext4_ext_rm_leaf().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ext_rm_leaf().ino());
+ return true;
+ } else if (event.has_ext4_ext_show_extent() &&
+ event.ext4_ext_show_extent().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ext_show_extent().ino());
+ return true;
+ } else if (event.has_ext4_fallocate_enter() &&
+ event.ext4_fallocate_enter().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_fallocate_enter().ino());
+ return true;
+ } else if (event.has_ext4_fallocate_exit() &&
+ event.ext4_fallocate_exit().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_fallocate_exit().ino());
+ return true;
+ } else if (event.has_ext4_find_delalloc_range() &&
+ event.ext4_find_delalloc_range().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_find_delalloc_range().ino());
+ return true;
+ } else if (event.has_ext4_forget() && event.ext4_forget().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_forget().ino());
+ return true;
+ } else if (event.has_ext4_free_blocks() && event.ext4_free_blocks().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_free_blocks().ino());
+ return true;
+ } else if (event.has_ext4_free_inode() && event.ext4_free_inode().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_free_inode().ino());
+ return true;
+ } else if (event.has_ext4_get_reserved_cluster_alloc() &&
+ event.ext4_get_reserved_cluster_alloc().ino()) {
+ *inode =
+ static_cast<uint64_t>(event.ext4_get_reserved_cluster_alloc().ino());
+ return true;
+ } else if (event.has_ext4_ind_map_blocks_enter() &&
+ event.ext4_ind_map_blocks_enter().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ind_map_blocks_enter().ino());
+ return true;
+ } else if (event.has_ext4_ind_map_blocks_exit() &&
+ event.ext4_ind_map_blocks_exit().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_ind_map_blocks_exit().ino());
+ return true;
+ } else if (event.has_ext4_insert_range() && event.ext4_insert_range().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_insert_range().ino());
+ return true;
+ } else if (event.has_ext4_invalidatepage() &&
+ event.ext4_invalidatepage().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_invalidatepage().ino());
+ return true;
+ } else if (event.has_ext4_journalled_invalidatepage() &&
+ event.ext4_journalled_invalidatepage().ino()) {
+ *inode =
+ static_cast<uint64_t>(event.ext4_journalled_invalidatepage().ino());
+ return true;
+ } else if (event.has_ext4_journalled_write_end() &&
+ event.ext4_journalled_write_end().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_journalled_write_end().ino());
+ return true;
+ } else if (event.has_ext4_load_inode() && event.ext4_load_inode().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_load_inode().ino());
+ return true;
+ } else if (event.has_ext4_mark_inode_dirty() &&
+ event.ext4_mark_inode_dirty().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_mark_inode_dirty().ino());
+ return true;
+ } else if (event.has_ext4_mb_new_group_pa() &&
+ event.ext4_mb_new_group_pa().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_mb_new_group_pa().ino());
+ return true;
+ } else if (event.has_ext4_mb_new_inode_pa() &&
+ event.ext4_mb_new_inode_pa().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_mb_new_inode_pa().ino());
+ return true;
+ } else if (event.has_ext4_mb_release_inode_pa() &&
+ event.ext4_mb_release_inode_pa().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_mb_release_inode_pa().ino());
+ return true;
+ } else if (event.has_ext4_mballoc_alloc() &&
+ event.ext4_mballoc_alloc().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_mballoc_alloc().ino());
+ return true;
+ } else if (event.has_ext4_mballoc_discard() &&
+ event.ext4_mballoc_discard().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_mballoc_discard().ino());
+ return true;
+ } else if (event.has_ext4_mballoc_free() && event.ext4_mballoc_free().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_mballoc_free().ino());
+ return true;
+ } else if (event.has_ext4_mballoc_prealloc() &&
+ event.ext4_mballoc_prealloc().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_mballoc_prealloc().ino());
+ return true;
+ } else if (event.has_ext4_other_inode_update_time() &&
+ event.ext4_other_inode_update_time().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_other_inode_update_time().ino());
+ return true;
+ } else if (event.has_ext4_other_inode_update_time() &&
+ event.ext4_other_inode_update_time().orig_ino()) {
+ *inode =
+ static_cast<uint64_t>(event.ext4_other_inode_update_time().orig_ino());
+ return true;
+ } else if (event.has_ext4_punch_hole() && event.ext4_punch_hole().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_punch_hole().ino());
+ return true;
+ } else if (event.has_ext4_readpage() && event.ext4_readpage().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_readpage().ino());
+ return true;
+ } else if (event.has_ext4_releasepage() && event.ext4_releasepage().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_releasepage().ino());
+ return true;
+ } else if (event.has_ext4_remove_blocks() &&
+ event.ext4_remove_blocks().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_remove_blocks().ino());
+ return true;
+ } else if (event.has_ext4_request_blocks() &&
+ event.ext4_request_blocks().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_request_blocks().ino());
+ return true;
+ } else if (event.has_ext4_sync_file_enter() &&
+ event.ext4_sync_file_enter().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_sync_file_enter().ino());
+ return true;
+ } else if (event.has_ext4_sync_file_exit() &&
+ event.ext4_sync_file_exit().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_sync_file_exit().ino());
+ return true;
+ } else if (event.has_ext4_truncate_enter() &&
+ event.ext4_truncate_enter().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_truncate_enter().ino());
+ return true;
+ } else if (event.has_ext4_truncate_exit() &&
+ event.ext4_truncate_exit().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_truncate_exit().ino());
+ return true;
+ } else if (event.has_ext4_unlink_enter() && event.ext4_unlink_enter().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_unlink_enter().ino());
+ return true;
+ } else if (event.has_ext4_unlink_exit() && event.ext4_unlink_exit().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_unlink_exit().ino());
+ return true;
+ } else if (event.has_ext4_write_begin() && event.ext4_write_begin().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_write_begin().ino());
+ return true;
+ } else if (event.has_ext4_write_end() && event.ext4_write_end().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_write_end().ino());
+ return true;
+ } else if (event.has_ext4_writepage() && event.ext4_writepage().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_writepage().ino());
+ return true;
+ } else if (event.has_ext4_writepages() && event.ext4_writepages().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_writepages().ino());
+ return true;
+ } else if (event.has_ext4_writepages_result() &&
+ event.ext4_writepages_result().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_writepages_result().ino());
+ return true;
+ } else if (event.has_ext4_zero_range() && event.ext4_zero_range().ino()) {
+ *inode = static_cast<uint64_t>(event.ext4_zero_range().ino());
+ return true;
+ } else if (event.has_mm_filemap_add_to_page_cache() &&
+ event.mm_filemap_add_to_page_cache().i_ino()) {
+ *inode =
+ static_cast<uint64_t>(event.mm_filemap_add_to_page_cache().i_ino());
+ return true;
+ } else if (event.has_mm_filemap_delete_from_page_cache() &&
+ event.mm_filemap_delete_from_page_cache().i_ino()) {
+ *inode = static_cast<uint64_t>(
+ event.mm_filemap_delete_from_page_cache().i_ino());
+ return true;
+ }
+ return false;
+}
+
+} // namespace perfetto
diff --git a/tools/trace_to_text/ftrace_inode_handler.h b/tools/trace_to_text/ftrace_inode_handler.h
new file mode 100644
index 0000000..77b5a8a
--- /dev/null
+++ b/tools/trace_to_text/ftrace_inode_handler.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#ifndef TOOLS_TRACE_TO_TEXT_FTRACE_INODE_HANDLER_H_
+#define TOOLS_TRACE_TO_TEXT_FTRACE_INODE_HANDLER_H_
+
+#include "tools/trace_to_text/ftrace_inode_handler.h"
+
+#include "perfetto/trace/trace_packet.pb.h"
+
+namespace perfetto {
+
+bool ParseInode(const protos::FtraceEvent&, uint64_t* inode);
+
+} // namespace perfetto
+
+#endif // TOOLS_TRACE_TO_TEXT_FTRACE_INODE_HANDLER_H_
diff --git a/tools/trace_to_text/main.cc b/tools/trace_to_text/main.cc
index 08259e7..da9136d 100644
--- a/tools/trace_to_text/main.cc
+++ b/tools/trace_to_text/main.cc
@@ -22,6 +22,7 @@
#include <algorithm>
#include <fstream>
+#include <functional>
#include <iostream>
#include <istream>
#include <limits>
@@ -29,7 +30,6 @@
#include <memory>
#include <ostream>
#include <sstream>
-#include <string>
#include <utility>
#include <google/protobuf/compiler/importer.h>
@@ -43,6 +43,7 @@
#include "perfetto/trace/trace.pb.h"
#include "perfetto/trace/trace_packet.pb.h"
#include "tools/trace_to_text/ftrace_event_formatter.h"
+#include "tools/trace_to_text/ftrace_inode_handler.h"
namespace perfetto {
namespace {
@@ -279,49 +280,10 @@
return 0;
}
-int TraceToSummary(std::istream* input, std::ostream* output) {
- uint64_t start = std::numeric_limits<uint64_t>::max();
- uint64_t end = 0;
- std::multiset<uint64_t> ftrace_timestamps;
- std::set<pid_t> tids_in_tree;
- std::set<pid_t> tids_in_events;
-
- ForEachPacketInTrace(
- input, [&start, &end, &ftrace_timestamps, &tids_in_tree,
- &tids_in_events](const protos::TracePacket& packet) {
-
- if (packet.has_process_tree()) {
- const ProcessTree& tree = packet.process_tree();
- for (Process process : tree.processes()) {
- for (ProcessTree::Thread thread : process.threads()) {
- tids_in_tree.insert(thread.tid());
- }
- }
- }
-
- if (!packet.has_ftrace_events())
- return;
-
- const FtraceEventBundle& bundle = packet.ftrace_events();
-
- for (const FtraceEvent& event : bundle.event()) {
- if (event.pid()) {
- tids_in_events.insert(event.pid());
- }
- if (event.timestamp()) {
- start = std::min<uint64_t>(start, event.timestamp());
- end = std::max<uint64_t>(end, event.timestamp());
- ftrace_timestamps.insert(event.timestamp());
- }
- }
- });
-
- fprintf(stderr, "\n");
-
- char line[2048];
- sprintf(line, "Duration: %" PRIu64 "ms\n", (end - start) / (1000 * 1000));
- *output << std::string(line);
-
+void PrintFtraceTrack(std::ostream* output,
+ const uint64_t& start,
+ const uint64_t& end,
+ const std::multiset<uint64_t>& ftrace_timestamps) {
constexpr char kFtraceTrackName[] = "ftrace ";
size_t width = GetWidth();
size_t bucket_count = width - strlen(kFtraceTrackName);
@@ -337,7 +299,9 @@
std::vector<std::string> out =
std::vector<std::string>({" ", "▁", "▂", "▃", "▄", "▅", "▆", "▇"});
- *output << kFtraceTrackName;
+ *output << "-------------------- " << kFtraceTrackName
+ << "--------------------\n";
+ char line[2048];
for (size_t i = 0; i < bucket_count; i++) {
sprintf(
line, "%s",
@@ -345,7 +309,24 @@
*output << std::string(line);
}
*output << "\n\n";
+}
+void PrintInodeStats(std::ostream* output,
+ const std::set<uint64_t>& inode_numbers,
+ const uint64_t& events_with_inodes) {
+ *output << "--------------------Inode Stats-------------------\n";
+ char line[2048];
+ sprintf(line, "Unique inodes: %" PRIu64 "\n", inode_numbers.size());
+ *output << std::string(line);
+
+ sprintf(line, "Events with inodes: %" PRIu64 "\n", events_with_inodes);
+ *output << std::string(line);
+ *output << "\n";
+}
+
+void PrintProcessStats(std::ostream* output,
+ const std::set<pid_t>& tids_in_tree,
+ const std::set<pid_t>& tids_in_events) {
*output << "----------------Process Tree Stats----------------\n";
char tid[2048];
@@ -370,6 +351,62 @@
intersect.size(), tids_in_events.size(),
(intersect.size() * 100) / tids_in_events.size());
*output << std::string(matching);
+ *output << "\n";
+}
+
+int TraceToSummary(std::istream* input, std::ostream* output) {
+ uint64_t start = std::numeric_limits<uint64_t>::max();
+ uint64_t end = 0;
+ std::multiset<uint64_t> ftrace_timestamps;
+ std::set<pid_t> tids_in_tree;
+ std::set<pid_t> tids_in_events;
+ std::set<uint64_t> inode_numbers;
+ uint64_t events_with_inodes = 0;
+
+ ForEachPacketInTrace(
+ input,
+ [&start, &end, &ftrace_timestamps, &tids_in_tree, &tids_in_events,
+ &inode_numbers, &events_with_inodes](const protos::TracePacket& packet) {
+
+ if (packet.has_process_tree()) {
+ const ProcessTree& tree = packet.process_tree();
+ for (Process process : tree.processes()) {
+ for (ProcessTree::Thread thread : process.threads()) {
+ tids_in_tree.insert(thread.tid());
+ }
+ }
+ }
+
+ if (!packet.has_ftrace_events())
+ return;
+
+ const FtraceEventBundle& bundle = packet.ftrace_events();
+ uint64_t inode_number = 0;
+ for (const FtraceEvent& event : bundle.event()) {
+ if (ParseInode(event, &inode_number)) {
+ inode_numbers.insert(inode_number);
+ events_with_inodes++;
+ }
+ if (event.pid()) {
+ tids_in_events.insert(event.pid());
+ }
+ if (event.timestamp()) {
+ start = std::min<uint64_t>(start, event.timestamp());
+ end = std::max<uint64_t>(end, event.timestamp());
+ ftrace_timestamps.insert(event.timestamp());
+ }
+ }
+ });
+
+ fprintf(stderr, "\n");
+
+ char line[2048];
+ sprintf(line, "Duration: %" PRIu64 "ms\n", (end - start) / (1000 * 1000));
+ *output << std::string(line);
+
+ PrintFtraceTrack(output, start, end, ftrace_timestamps);
+ PrintProcessStats(output, tids_in_tree, tids_in_events);
+ PrintInodeStats(output, inode_numbers, events_with_inodes);
return 0;
}