Skip to content

Commit

Permalink
Merge "Revert "Add MappingTracker"" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
LalitMaganti authored and Gerrit Code Review committed Mar 4, 2024
2 parents 3fe34e7 + e5df54a commit 9896bdb
Show file tree
Hide file tree
Showing 36 changed files with 414 additions and 1,200 deletions.
26 changes: 12 additions & 14 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,6 @@ cc_test {
":perfetto_src_trace_processor_storage_storage",
":perfetto_src_trace_processor_tables_tables",
":perfetto_src_trace_processor_types_types",
":perfetto_src_trace_processor_util_build_id",
":perfetto_src_trace_processor_util_bump_allocator",
":perfetto_src_trace_processor_util_descriptors",
":perfetto_src_trace_processor_util_glob",
Expand All @@ -2392,6 +2391,7 @@ cc_test {
":perfetto_src_trace_processor_util_protozero_to_text",
":perfetto_src_trace_processor_util_regex",
":perfetto_src_trace_processor_util_sql_argument",
":perfetto_src_trace_processor_util_stack_traces_util",
":perfetto_src_trace_processor_util_stdlib",
":perfetto_src_trace_processor_util_util",
":perfetto_src_trace_processor_util_zip_reader",
Expand Down Expand Up @@ -11110,7 +11110,6 @@ filegroup {
"src/trace_processor/importers/common/event_tracker.cc",
"src/trace_processor/importers/common/flow_tracker.cc",
"src/trace_processor/importers/common/global_args_tracker.cc",
"src/trace_processor/importers/common/mapping_tracker.cc",
"src/trace_processor/importers/common/metadata_tracker.cc",
"src/trace_processor/importers/common/process_tracker.cc",
"src/trace_processor/importers/common/sched_event_tracker.cc",
Expand All @@ -11121,7 +11120,6 @@ filegroup {
"src/trace_processor/importers/common/thread_state_tracker.cc",
"src/trace_processor/importers/common/trace_parser.cc",
"src/trace_processor/importers/common/track_tracker.cc",
"src/trace_processor/importers/common/virtual_memory_mapping.cc",
],
}

Expand Down Expand Up @@ -12325,14 +12323,6 @@ filegroup {
name: "perfetto_src_trace_processor_unittests",
}

// GN: //src/trace_processor/util:build_id
filegroup {
name: "perfetto_src_trace_processor_util_build_id",
srcs: [
"src/trace_processor/util/build_id.cc",
],
}

// GN: //src/trace_processor/util:bump_allocator
filegroup {
name: "perfetto_src_trace_processor_util_bump_allocator",
Expand Down Expand Up @@ -12433,6 +12423,14 @@ filegroup {
],
}

// GN: //src/trace_processor/util:stack_traces_util
filegroup {
name: "perfetto_src_trace_processor_util_stack_traces_util",
srcs: [
"src/trace_processor/util/stack_traces_util.cc",
],
}

// GN: //src/trace_processor/util:stdlib
filegroup {
name: "perfetto_src_trace_processor_util_stdlib",
Expand Down Expand Up @@ -13960,7 +13958,6 @@ cc_test {
":perfetto_src_trace_processor_types_types",
":perfetto_src_trace_processor_types_unittests",
":perfetto_src_trace_processor_unittests",
":perfetto_src_trace_processor_util_build_id",
":perfetto_src_trace_processor_util_bump_allocator",
":perfetto_src_trace_processor_util_descriptors",
":perfetto_src_trace_processor_util_glob",
Expand All @@ -13974,6 +13971,7 @@ cc_test {
":perfetto_src_trace_processor_util_protozero_to_text",
":perfetto_src_trace_processor_util_regex",
":perfetto_src_trace_processor_util_sql_argument",
":perfetto_src_trace_processor_util_stack_traces_util",
":perfetto_src_trace_processor_util_stdlib",
":perfetto_src_trace_processor_util_unittests",
":perfetto_src_trace_processor_util_util",
Expand Down Expand Up @@ -14663,7 +14661,6 @@ cc_binary {
":perfetto_src_trace_processor_storage_storage",
":perfetto_src_trace_processor_tables_tables",
":perfetto_src_trace_processor_types_types",
":perfetto_src_trace_processor_util_build_id",
":perfetto_src_trace_processor_util_bump_allocator",
":perfetto_src_trace_processor_util_descriptors",
":perfetto_src_trace_processor_util_glob",
Expand All @@ -14677,6 +14674,7 @@ cc_binary {
":perfetto_src_trace_processor_util_protozero_to_text",
":perfetto_src_trace_processor_util_regex",
":perfetto_src_trace_processor_util_sql_argument",
":perfetto_src_trace_processor_util_stack_traces_util",
":perfetto_src_trace_processor_util_stdlib",
":perfetto_src_trace_processor_util_util",
":perfetto_src_trace_processor_util_zip_reader",
Expand Down Expand Up @@ -14897,7 +14895,6 @@ cc_binary_host {
":perfetto_src_trace_processor_storage_storage",
":perfetto_src_trace_processor_tables_tables",
":perfetto_src_trace_processor_types_types",
":perfetto_src_trace_processor_util_build_id",
":perfetto_src_trace_processor_util_bump_allocator",
":perfetto_src_trace_processor_util_descriptors",
":perfetto_src_trace_processor_util_glob",
Expand All @@ -14911,6 +14908,7 @@ cc_binary_host {
":perfetto_src_trace_processor_util_protozero_to_text",
":perfetto_src_trace_processor_util_regex",
":perfetto_src_trace_processor_util_sql_argument",
":perfetto_src_trace_processor_util_stack_traces_util",
":perfetto_src_trace_processor_util_stdlib",
":perfetto_src_trace_processor_util_util",
":perfetto_src_trace_processor_util_zip_reader",
Expand Down
33 changes: 14 additions & 19 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ perfetto_cc_library(
":src_trace_processor_tables_tables",
":src_trace_processor_tables_tables_python",
":src_trace_processor_types_types",
":src_trace_processor_util_build_id",
":src_trace_processor_util_bump_allocator",
":src_trace_processor_util_descriptors",
":src_trace_processor_util_glob",
Expand All @@ -280,6 +279,7 @@ perfetto_cc_library(
":src_trace_processor_util_protozero_to_text",
":src_trace_processor_util_regex",
":src_trace_processor_util_sql_argument",
":src_trace_processor_util_stack_traces_util",
":src_trace_processor_util_stdlib",
":src_trace_processor_util_util",
":src_trace_processor_util_zip_reader",
Expand Down Expand Up @@ -1467,7 +1467,6 @@ perfetto_filegroup(
"src/trace_processor/importers/common/clock_converter.h",
"src/trace_processor/importers/common/clock_tracker.cc",
"src/trace_processor/importers/common/clock_tracker.h",
"src/trace_processor/importers/common/create_mapping_params.h",
"src/trace_processor/importers/common/deobfuscation_mapping_table.cc",
"src/trace_processor/importers/common/deobfuscation_mapping_table.h",
"src/trace_processor/importers/common/event_tracker.cc",
Expand All @@ -1476,8 +1475,6 @@ perfetto_filegroup(
"src/trace_processor/importers/common/flow_tracker.h",
"src/trace_processor/importers/common/global_args_tracker.cc",
"src/trace_processor/importers/common/global_args_tracker.h",
"src/trace_processor/importers/common/mapping_tracker.cc",
"src/trace_processor/importers/common/mapping_tracker.h",
"src/trace_processor/importers/common/metadata_tracker.cc",
"src/trace_processor/importers/common/metadata_tracker.h",
"src/trace_processor/importers/common/process_tracker.cc",
Expand All @@ -1498,8 +1495,6 @@ perfetto_filegroup(
"src/trace_processor/importers/common/trace_parser.cc",
"src/trace_processor/importers/common/track_tracker.cc",
"src/trace_processor/importers/common/track_tracker.h",
"src/trace_processor/importers/common/virtual_memory_mapping.cc",
"src/trace_processor/importers/common/virtual_memory_mapping.h",
],
)

Expand Down Expand Up @@ -2703,15 +2698,6 @@ perfetto_filegroup(
],
)

# GN target: //src/trace_processor/util:build_id
perfetto_filegroup(
name = "src_trace_processor_util_build_id",
srcs = [
"src/trace_processor/util/build_id.cc",
"src/trace_processor/util/build_id.h",
],
)

# GN target: //src/trace_processor/util:bump_allocator
perfetto_filegroup(
name = "src_trace_processor_util_bump_allocator",
Expand Down Expand Up @@ -2831,6 +2817,15 @@ perfetto_filegroup(
],
)

# GN target: //src/trace_processor/util:stack_traces_util
perfetto_filegroup(
name = "src_trace_processor_util_stack_traces_util",
srcs = [
"src/trace_processor/util/stack_traces_util.cc",
"src/trace_processor/util/stack_traces_util.h",
],
)

# GN target: //src/trace_processor/util:stdlib
perfetto_filegroup(
name = "src_trace_processor_util_stdlib",
Expand Down Expand Up @@ -5648,7 +5643,6 @@ perfetto_cc_library(
":src_trace_processor_tables_tables",
":src_trace_processor_tables_tables_python",
":src_trace_processor_types_types",
":src_trace_processor_util_build_id",
":src_trace_processor_util_bump_allocator",
":src_trace_processor_util_descriptors",
":src_trace_processor_util_glob",
Expand All @@ -5662,6 +5656,7 @@ perfetto_cc_library(
":src_trace_processor_util_protozero_to_text",
":src_trace_processor_util_regex",
":src_trace_processor_util_sql_argument",
":src_trace_processor_util_stack_traces_util",
":src_trace_processor_util_stdlib",
":src_trace_processor_util_util",
":src_trace_processor_util_zip_reader",
Expand Down Expand Up @@ -5819,7 +5814,6 @@ perfetto_cc_binary(
":src_trace_processor_tables_tables",
":src_trace_processor_tables_tables_python",
":src_trace_processor_types_types",
":src_trace_processor_util_build_id",
":src_trace_processor_util_bump_allocator",
":src_trace_processor_util_descriptors",
":src_trace_processor_util_glob",
Expand All @@ -5833,6 +5827,7 @@ perfetto_cc_binary(
":src_trace_processor_util_protozero_to_text",
":src_trace_processor_util_regex",
":src_trace_processor_util_sql_argument",
":src_trace_processor_util_stack_traces_util",
":src_trace_processor_util_stdlib",
":src_trace_processor_util_util",
":src_trace_processor_util_zip_reader",
Expand Down Expand Up @@ -5910,7 +5905,7 @@ perfetto_cc_library(
":src_profiling_deobfuscator",
":src_profiling_symbolizer_symbolize_database",
":src_profiling_symbolizer_symbolizer",
":src_trace_processor_util_build_id",
":src_trace_processor_util_stack_traces_util",
":src_traceconv_pprofbuilder",
":src_traceconv_utils",
],
Expand Down Expand Up @@ -6042,7 +6037,6 @@ perfetto_cc_binary(
":src_trace_processor_tables_tables",
":src_trace_processor_tables_tables_python",
":src_trace_processor_types_types",
":src_trace_processor_util_build_id",
":src_trace_processor_util_bump_allocator",
":src_trace_processor_util_descriptors",
":src_trace_processor_util_glob",
Expand All @@ -6056,6 +6050,7 @@ perfetto_cc_binary(
":src_trace_processor_util_protozero_to_text",
":src_trace_processor_util_regex",
":src_trace_processor_util_sql_argument",
":src_trace_processor_util_stack_traces_util",
":src_trace_processor_util_stdlib",
":src_trace_processor_util_util",
":src_trace_processor_util_zip_reader",
Expand Down
2 changes: 1 addition & 1 deletion src/profiling/symbolizer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if (enable_perfetto_trace_processor) {
"../../../include/perfetto/trace_processor:trace_processor",
"../../../protos/perfetto/trace:zero",
"../../../protos/perfetto/trace/profiling:zero",
"../../trace_processor/util:build_id",
"../../trace_processor/util:stack_traces_util",
]
sources = [
"symbolize_database.cc",
Expand Down
44 changes: 39 additions & 5 deletions src/profiling/symbolizer/symbolize_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#include "protos/perfetto/trace/profiling/profile_common.pbzero.h"
#include "protos/perfetto/trace/trace.pbzero.h"
#include "protos/perfetto/trace/trace_packet.pbzero.h"
#include "src/trace_processor/util/build_id.h"

#include "src/trace_processor/util/stack_traces_util.h"

namespace perfetto {
namespace profiling {
Expand All @@ -55,17 +56,50 @@ struct UnsymbolizedMapping {
}
};

std::string FromHex(const char* str, size_t size) {
if (size % 2) {
PERFETTO_DFATAL_OR_ELOG("Failed to parse hex %s", str);
return "";
}
std::string result(size / 2, '\0');
for (size_t i = 0; i < size; i += 2) {
char hex_byte[3];
hex_byte[0] = str[i];
hex_byte[1] = str[i + 1];
hex_byte[2] = '\0';
char* end;
long int byte = strtol(hex_byte, &end, 16);
if (*end != '\0') {
PERFETTO_DFATAL_OR_ELOG("Failed to parse hex %s", str);
return "";
}
result[i / 2] = static_cast<char>(byte);
}
return result;
}

std::string FromHex(const std::string& str) {
return FromHex(str.c_str(), str.size());
}

std::map<UnsymbolizedMapping, std::vector<uint64_t>> GetUnsymbolizedFrames(
trace_processor::TraceProcessor* tp) {
std::map<UnsymbolizedMapping, std::vector<uint64_t>> res;
Iterator it = tp->ExecuteQuery(kQueryUnsymbolized);
while (it.Next()) {
int64_t load_bias = it.Get(3).AsLong();
PERFETTO_CHECK(load_bias >= 0);
trace_processor::BuildId build_id =
trace_processor::BuildId::FromHex(it.Get(1).AsString());
UnsymbolizedMapping unsymbolized_mapping{
it.Get(0).AsString(), build_id.raw(), static_cast<uint64_t>(load_bias)};
std::string build_id;
// TODO(b/148109467): Remove workaround once all active Chrome versions
// write raw bytes instead of a string as build_id.
std::string raw_build_id = it.Get(1).AsString();
if (!trace_processor::util::IsHexModuleId(base::StringView(raw_build_id))) {
build_id = FromHex(raw_build_id);
} else {
build_id = raw_build_id;
}
UnsymbolizedMapping unsymbolized_mapping{it.Get(0).AsString(), build_id,
static_cast<uint64_t>(load_bias)};
int64_t rel_pc = it.Get(2).AsLong();
res[unsymbolized_mapping].emplace_back(rel_pc);
}
Expand Down
1 change: 1 addition & 0 deletions src/trace_processor/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ source_set("storage_minimal") {
"util:descriptors",
"util:gzip",
"util:proto_to_args_parser",
"util:stack_traces_util",
]
public_deps = [ "../../include/perfetto/trace_processor:storage" ]
}
Expand Down
7 changes: 1 addition & 6 deletions src/trace_processor/importers/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ source_set("common") {
"clock_converter.h",
"clock_tracker.cc",
"clock_tracker.h",
"create_mapping_params.h",
"deobfuscation_mapping_table.cc",
"deobfuscation_mapping_table.h",
"event_tracker.cc",
Expand All @@ -37,8 +36,6 @@ source_set("common") {
"flow_tracker.h",
"global_args_tracker.cc",
"global_args_tracker.h",
"mapping_tracker.cc",
"mapping_tracker.h",
"metadata_tracker.cc",
"metadata_tracker.h",
"process_tracker.cc",
Expand All @@ -59,8 +56,6 @@ source_set("common") {
"trace_parser.cc",
"track_tracker.cc",
"track_tracker.h",
"virtual_memory_mapping.cc",
"virtual_memory_mapping.h",
]
public_deps = [
":trace_parser_hdr",
Expand All @@ -80,8 +75,8 @@ source_set("common") {
"../../storage",
"../../tables:tables",
"../../types",
"../../util:build_id",
"../../util:profiler_util",
"../../util:stack_traces_util",
"../fuchsia:fuchsia_record",
"../systrace:systrace_line",
]
Expand Down
Loading

0 comments on commit 9896bdb

Please sign in to comment.