Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ class Builder {
// Adds a string to the profile string table if not already present.
// Returns a unique integer id for this string.
int64_t StringId(absl::string_view str);
[[deprecated("Use StringId instead.")]] ABSL_REFACTOR_INLINE int64_t
StringIdForMigration(absl::string_view str) {
return StringId(str);
}

// Adds a function with these attributes to the profile function
// table, if not already present. Returns a unique integer id for
Expand Down
48 changes: 24 additions & 24 deletions src/perf_data_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,11 @@ ProfileBuilder* PerfDataConverter::GetOrCreateBuilder(
}
auto sample_type = profile->add_sample_type();
sample_type->set_type(UTF8StringId(event_name + "sample", builder));
sample_type->set_unit(builder->StringIdForMigration("count"));
sample_type->set_unit(builder->StringId("count"));
sample_type = profile->add_sample_type();
last_index = UTF8StringId(event_name + "event", builder);
sample_type->set_type(last_index);
sample_type->set_unit(builder->StringIdForMigration("count"));
sample_type->set_unit(builder->StringId("count"));
}
DCHECK_NE(last_index, 0);
profile->set_default_sample_type(last_index);
Expand Down Expand Up @@ -660,100 +660,100 @@ void PerfDataConverter::AddOrUpdateSample(
// Emit any requested labels.
if (IncludePidLabels() && context.sample.has_pid()) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(PidLabelKey));
label->set_key(builder->StringId(PidLabelKey));
label->set_num(static_cast<int64_t>(context.sample.pid()));
}
if (IncludeTidLabels() && context.sample.has_tid()) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(TidLabelKey));
label->set_key(builder->StringId(TidLabelKey));
label->set_num(static_cast<int64_t>(context.sample.tid()));
}
if (IncludeCommLabels() && sample_key.comm != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(CommLabelKey));
label->set_key(builder->StringId(CommLabelKey));
label->set_str(sample_key.comm);
}
if (IncludeTimestampNsLabels() && context.sample.has_sample_time_ns()) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(TimestampNsLabelKey));
label->set_key(builder->StringId(TimestampNsLabelKey));
int64_t timestamp_ns_as_int64 =
static_cast<int64_t>(context.sample.sample_time_ns());
label->set_num(timestamp_ns_as_int64);
}
if (IncludeExecutionModeLabels() &&
sample_key.exec_mode != quipper::AddressContext::kUnknown) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(ExecutionModeLabelKey));
label->set_key(builder->StringId(ExecutionModeLabelKey));
label->set_str(builder->StringId(ExecModeString(sample_key.exec_mode)));
}
if (IncludeThreadTypeLabels() && sample_key.thread_type != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(ThreadTypeLabelKey));
label->set_key(builder->StringId(ThreadTypeLabelKey));
label->set_str(sample_key.thread_type);
}
if (IncludeThreadCommLabels() && sample_key.thread_comm != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(ThreadCommLabelKey));
label->set_key(builder->StringId(ThreadCommLabelKey));
label->set_str(sample_key.thread_comm);
}
if (IncludeCgroupLabels() && sample_key.cgroup != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(CgroupLabelKey));
label->set_key(builder->StringId(CgroupLabelKey));
label->set_str(sample_key.cgroup);
}
if (IncludeCodePageSizeLabels() && sample_key.code_page_size != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(CodePageSizeLabelKey));
label->set_key(builder->StringId(CodePageSizeLabelKey));
label->set_num(sample_key.code_page_size);
}
if (IncludeDataPageSizeLabels() && sample_key.data_page_size != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(DataPageSizeLabelKey));
label->set_key(builder->StringId(DataPageSizeLabelKey));
label->set_num(sample_key.data_page_size);
}
if (IncludeCpuLabels() && context.sample.has_cpu()) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(CpuLabelKey));
label->set_key(builder->StringId(CpuLabelKey));
label->set_num(static_cast<int64_t>(context.sample.cpu()));
label->set_num_unit(builder->StringIdForMigration("cpu"));
label->set_num_unit(builder->StringId("cpu"));
}
if (IncludeCacheLatencyLabel() && sample_key.cache_latency != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(CacheLatencyLabelKey));
label->set_key(builder->StringId(CacheLatencyLabelKey));
label->set_num(sample_key.cache_latency);
label->set_num_unit(builder->StringIdForMigration("cycles"));
label->set_num_unit(builder->StringId("cycles"));
}
if (IncludeDataSrcLabels()) {
if (sample_key.data_src != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(DataSrcLabelKey));
label->set_key(builder->StringId(DataSrcLabelKey));
label->set_str(sample_key.data_src);
}
if (sample_key.snoop_status != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(SnoopStatusLabelKey));
label->set_key(builder->StringId(SnoopStatusLabelKey));
label->set_str(sample_key.snoop_status);
}
}

if (IncludeTotalLatencyLabels() && sample_key.total_latency != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(TotalLatencyLabelKey));
label->set_key(builder->StringId(TotalLatencyLabelKey));
label->set_num(sample_key.total_latency);
label->set_num_unit(builder->StringIdForMigration("cycles"));
label->set_num_unit(builder->StringId("cycles"));
}
if (IncludeIssueLatencyLabels() && sample_key.issue_latency != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(IssueLatencyLabelKey));
label->set_key(builder->StringId(IssueLatencyLabelKey));
label->set_num(sample_key.issue_latency);
label->set_num_unit(builder->StringIdForMigration("cycles"));
label->set_num_unit(builder->StringId("cycles"));
}
if (IncludeTranslationLatencyLabels() &&
sample_key.translation_latency != 0) {
auto* label = sample->add_label();
label->set_key(builder->StringIdForMigration(TranslationLatencyLabelKey));
label->set_key(builder->StringId(TranslationLatencyLabelKey));
label->set_num(sample_key.translation_latency);
label->set_num_unit(builder->StringIdForMigration("cycles"));
label->set_num_unit(builder->StringId("cycles"));
}

// Two values per collected event: the first is sample counts, the second is
Expand Down
31 changes: 27 additions & 4 deletions src/quipper/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ cc_library(
hdrs = ["dso.h"],
visibility = ["//src:__subpackages__"],
deps = [
":binary_data_utils",
":data_reader",
":file_reader",
":kernel",
":base",
],
linkopts = ["-lelf"],
Expand Down Expand Up @@ -210,6 +212,7 @@ cc_library(
":binary_data_utils",
":buffer_reader",
":buffer_writer",
":byte_swap_utils",
":compat",
":file_reader",
":file_utils",
Expand All @@ -218,6 +221,7 @@ cc_library(
":perf_data_utils",
":perf_serializer",
":sample_info_reader",
":string_utils",
":base",
],
)
Expand Down Expand Up @@ -261,6 +265,16 @@ cc_library(
],
)

cc_library(
name = "byte_swap_utils",
srcs = ["byte_swap_utils.cc"],
hdrs = ["byte_swap_utils.h"],
visibility = ["//visibility:public"],
deps = [
":base",
],
)

cc_library(
name = "binary_data_utils",
srcs = ["binary_data_utils.cc"],
Expand Down Expand Up @@ -309,7 +323,7 @@ cc_library(
srcs = ["data_reader.cc"],
hdrs = ["data_reader.h"],
deps = [
":binary_data_utils",
":byte_swap_utils",
":base",
],
)
Expand Down Expand Up @@ -437,7 +451,7 @@ cc_library(
],
visibility = ["//src:__subpackages__"],
deps = [
":binary_data_utils",
":byte_swap_utils",
":compat",
":compat_gunit",
":file_reader",
Expand Down Expand Up @@ -502,7 +516,7 @@ cc_library(
hdrs = ["arm_spe_decoder.h"],
visibility = ["//visibility:public"],
deps = [
":binary_data_utils",
":byte_swap_utils",
],
)

Expand All @@ -514,7 +528,6 @@ cc_test(
":compat_gunit",
":test_runner",
":test_utils",
"@com_google_googletest//:gtest_main",
],
)

Expand Down Expand Up @@ -572,6 +585,16 @@ cc_test(
],
)

cc_test(
name = "byte_swap_utils_test",
srcs = ["byte_swap_utils_test.cc"],
deps = [
":byte_swap_utils",
":compat_gunit",
":test_runner",
],
)

cc_test(
name = "binary_data_utils_test",
srcs = ["binary_data_utils_test.cc"],
Expand Down
2 changes: 2 additions & 0 deletions src/quipper/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static_library("common") {
"binary_data_utils.cc",
"buffer_reader.cc",
"buffer_writer.cc",
"byte_swap_utils.cc",
"compat/log_level.cc",
"data_reader.cc",
"data_writer.cc",
Expand Down Expand Up @@ -180,6 +181,7 @@ if (use.test) {
"binary_data_utils_test.cc",
"buffer_reader_test.cc",
"buffer_writer_test.cc",
"byte_swap_utils_test.cc",
"dso_test.cc",
"file_reader_test.cc",
"perf_buildid_test.cc",
Expand Down
27 changes: 20 additions & 7 deletions src/quipper/arm_spe_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string_view>

#include "base/logging.h"
#include "binary_data_utils.h"
#include "byte_swap_utils.h"

namespace quipper {

Expand Down Expand Up @@ -140,8 +140,9 @@ bool ArmSpeDecoder::NextRecord(struct Record* ret_record) {
return false;
}

p.size =
alignment - (((uintptr_t)(buf_.data() + buf_i_)) & (alignment - 1));
p.size = alignment -
((reinterpret_cast<uintptr_t>(buf_.GetPointer(buf_i_))) &
(alignment - 1));
continue;
}
}
Expand Down Expand Up @@ -394,26 +395,38 @@ bool ArmSpeDecoder::SetPayloadAndSize(struct Packet* p) {
switch (payload_size) {
case 1: {
uint8_t payload;
memcpy(&payload, buf_.data() + pos, sizeof(payload));
if (!buf_.ReadBytes(pos, sizeof(payload), &payload)) {
LOG(ERROR) << "Error reading payload of size 1";
return false;
}
// No need to swap when there is only one byte.
p->payload = payload;
break;
}
case 2: {
uint16_t payload;
memcpy(&payload, buf_.data() + pos, sizeof(payload));
if (!buf_.ReadBytes(pos, sizeof(payload), &payload)) {
LOG(ERROR) << "Error reading payload of size 2";
return false;
}
p->payload = MaybeSwap<uint16_t>(payload, is_cross_endian_);
break;
}
case 4: {
uint32_t payload;
memcpy(&payload, buf_.data() + pos, sizeof(payload));
if (!buf_.ReadBytes(pos, sizeof(payload), &payload)) {
LOG(ERROR) << "Error reading payload of size 4";
return false;
}
p->payload = MaybeSwap<uint32_t>(payload, is_cross_endian_);
break;
}
case 8: {
uint64_t payload;
memcpy(&payload, buf_.data() + pos, sizeof(payload));
if (!buf_.ReadBytes(pos, sizeof(payload), &payload)) {
LOG(ERROR) << "Error reading payload of size 8";
return false;
}
p->payload = MaybeSwap<uint64_t>(payload, is_cross_endian_);
break;
}
Expand Down
Loading
Loading