diff options
author | Yabin Cui <yabinc@google.com> | 2021-05-13 17:23:58 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-05-13 17:23:58 +0000 |
commit | fb512beae8e57e202bf021e27e674fb3fccb17ba (patch) | |
tree | 23dc405e6144f3693d16c98a13d525ecde1f3740 | |
parent | 749678151af18e43cdcc62e942f47cb2f441cf8a (diff) | |
parent | 16508f8394b00afb72e14aaa5447db976ca3207e (diff) | |
download | extras-fb512beae8e57e202bf021e27e674fb3fccb17ba.tar.gz |
Merge "simpleperf: move kernel_start_addr into Binary msg." am: 16508f8394
Original change: https://android-review.googlesource.com/c/platform/system/extras/+/1704688
Change-Id: I74ba748980c209705ea63c7b6706e74b696850ee
-rw-r--r-- | simpleperf/cmd_inject.cpp | 19 | ||||
-rw-r--r-- | simpleperf/etm_branch_list.proto | 15 |
2 files changed, 23 insertions, 11 deletions
diff --git a/simpleperf/cmd_inject.cpp b/simpleperf/cmd_inject.cpp index 36332c95..d90bd517 100644 --- a/simpleperf/cmd_inject.cpp +++ b/simpleperf/cmd_inject.cpp @@ -360,7 +360,9 @@ class InjectCommand : public Command { auto branch_map = BuildBranchMap(binary_proto); if (dso_p->type() == DSO_KERNEL) { - ModifyBranchMapForKernel(branch_list_proto, dso_p, branch_map); + if (!ModifyBranchMapForKernel(binary_proto, dso_p, branch_map)) { + return false; + } } if (auto result = ConvertBranchMapToInstrRanges(dso_p, branch_map, callback); !result.ok()) { @@ -386,11 +388,15 @@ class InjectCommand : public Command { return branch_map; } - void ModifyBranchMapForKernel(const proto::ETMBranchList& branch_list_proto, Dso* dso, + bool ModifyBranchMapForKernel(const proto::ETMBranchList_Binary& binary_proto, Dso* dso, BranchMap& branch_map) { - uint64_t kernel_map_start_addr = branch_list_proto.kernel_start_addr(); + if (!binary_proto.has_kernel_info()) { + LOG(ERROR) << "no kernel info"; + return false; + } + uint64_t kernel_map_start_addr = binary_proto.kernel_info().kernel_start_addr(); if (kernel_map_start_addr == 0) { - return; + return true; } // Addresses are still kernel ip addrs in memory. Need to convert them to vaddrs in vmlinux. BranchMap new_branch_map; @@ -399,6 +405,7 @@ class InjectCommand : public Command { new_branch_map[vaddr_in_file] = std::move(p.second); } branch_map = std::move(new_branch_map); + return true; } bool WriteOutput() { @@ -534,11 +541,11 @@ class InjectCommand : public Command { if (dso->GetDebugFilePath() == dso->Path()) { // vmlinux isn't available. We still use kernel ip addr. Put kernel start addr in proto // for address conversion later. - branch_list_proto.set_kernel_start_addr(kernel_map_start_addr_); + binary_proto->mutable_kernel_info()->set_kernel_start_addr(kernel_map_start_addr_); } else { // vmlinux is available. We have converted kernel ip addr to vaddr in vmlinux. So no need // to put kernel start addr in proto. - branch_list_proto.set_kernel_start_addr(0); + binary_proto->mutable_kernel_info()->set_kernel_start_addr(0); } } } diff --git a/simpleperf/etm_branch_list.proto b/simpleperf/etm_branch_list.proto index 396f7525..c66b0d5e 100644 --- a/simpleperf/etm_branch_list.proto +++ b/simpleperf/etm_branch_list.proto @@ -47,15 +47,20 @@ message ETMBranchList { KERNEL_MODULE = 2; } BinaryType type = 4; + + message KernelBinaryInfo { + // kernel_start_addr is used to convert kernel ip address to vaddr in vmlinux. + // If it is zero, the Address in KERNEL binary has been converted to vaddr. Otherwise, + // the Address in KERNEL binary is still ip address, and need to be converted later. + uint64 kernel_start_addr = 1; + } + + KernelBinaryInfo kernel_info = 5; + } // Used to identify format in generated proto files. // Should always be "simpleperf:EtmBranchList". string magic = 1; repeated Binary binaries = 2; - - // kernel_start_addr is used to convert kernel ip address to vaddr in vmlinux. - // If it is zero, the Address in KERNEL binary has been converted to vaddr. - // Otherwise, the Address in KERNEL binary is still ip address, and need to be converted later. - uint64 kernel_start_addr = 3; } |