Skip to content

Commit

Permalink
Revert "Add MappingTracker"
Browse files Browse the repository at this point in the history
  • Loading branch information
LalitMaganti authored and Gerrit Code Review committed Mar 4, 2024
1 parent a861cf6 commit e5df54a
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 @@ -2369,7 +2369,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 @@ -2383,6 +2382,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 @@ -11098,7 +11098,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/slice_tracker.cc",
Expand All @@ -11107,7 +11106,6 @@ filegroup {
"src/trace_processor/importers/common/system_info_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 @@ -12305,14 +12303,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 @@ -12413,6 +12403,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 @@ -13936,7 +13934,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 @@ -13950,6 +13947,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 @@ -14637,7 +14635,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 @@ -14651,6 +14648,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 @@ -14870,7 +14868,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 @@ -14884,6 +14881,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 @@ -1459,7 +1459,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 @@ -1468,8 +1467,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 @@ -1485,8 +1482,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 @@ -2678,15 +2673,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 @@ -2806,6 +2792,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 @@ -5622,7 +5617,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 @@ -5636,6 +5630,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 @@ -5792,7 +5787,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 @@ -5806,6 +5800,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 @@ -5883,7 +5878,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 @@ -6014,7 +6009,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 @@ -6028,6 +6022,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 @@ -52,7 +52,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 @@ -54,8 +51,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 @@ -75,8 +70,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 e5df54a

Please sign in to comment.