Expose PrettyMethod's with_signature in GetMethodInfoForOffset.
This isn't strictly necessary for the current use case in libunwindstack.
The reason for it is symmetry with GetAllMethodInfos.
Also drop the default for with_signature.
This is an incompatible C++ API change, so let's do it now.
Test: mmma art/ system/core/{libunwindstack,libbacktrace} system/extras/{simpleperf,perfprofd}
Test: Run out/host/linux-x86/nativetest*/libunwindstack_test/*
Test: mmma system/extras/simpleperf && adb root && adb shell rm -rf /data/test && adb push out/target/product/taimen/testcases/simpleperf_unit_test /data/test && adb shell /data/test/arm64/simpleperf_unit_test && adb shell /data/test/arm/simpleperf_unit_test
Bug: 119632407
Change-Id: I01345bd1b07554f70976cb8536f1304a3a739bf9
diff --git a/libdexfile/external/dex_file_ext.cc b/libdexfile/external/dex_file_ext.cc
index 5c353b5..a1a9a52 100644
--- a/libdexfile/external/dex_file_ext.cc
+++ b/libdexfile/external/dex_file_ext.cc
@@ -226,7 +226,10 @@
if (length < offset + sizeof(art::DexFile::Header)) {
*ext_error_msg = new ExtDexFileString{android::base::StringPrintf(
- "Offset %" PRId64 " too large for '%s' of size %zu", int64_t{offset}, location, length)};
+ "Offset %" PRId64 " too large for '%s' of size %zu",
+ int64_t{offset},
+ location,
+ length)};
return false;
}
@@ -282,6 +285,7 @@
int ExtDexFileGetMethodInfoForOffset(ExtDexFile* ext_dex_file,
int64_t dex_offset,
+ int with_signature,
/*out*/ ExtDexFileMethodInfo* method_info) {
if (!ext_dex_file->dex_file_->IsInDataSection(ext_dex_file->dex_file_->Begin() + dex_offset)) {
return false; // The DEX offset is not within the bytecode of this dex file.
@@ -304,7 +308,7 @@
method_info->offset = entry->offset;
method_info->len = entry->len;
method_info->name =
- new ExtDexFileString{ext_dex_file->dex_file_->PrettyMethod(entry->index, false)};
+ new ExtDexFileString{ext_dex_file->dex_file_->PrettyMethod(entry->index, with_signature)};
return true;
}
diff --git a/libdexfile/external/include/art_api/ext_dex_file.h b/libdexfile/external/include/art_api/ext_dex_file.h
index 4a52a2b..8a1f18d 100644
--- a/libdexfile/external/include/art_api/ext_dex_file.h
+++ b/libdexfile/external/include/art_api/ext_dex_file.h
@@ -76,6 +76,7 @@
// See art_api::dex::DexFile::GetMethodInfoForOffset. Returns true on success.
int ExtDexFileGetMethodInfoForOffset(ExtDexFile* ext_dex_file,
int64_t dex_offset,
+ int with_signature,
/*out*/ ExtDexFileMethodInfo* method_info);
typedef void ExtDexFileMethodInfoCallback(const ExtDexFileMethodInfo* ext_method_info,
@@ -211,10 +212,15 @@
// Given an offset relative to the start of the dex file header, if there is a
// method whose instruction range includes that offset then returns info about
- // it, otherwise returns a struct with offset == 0.
- MethodInfo GetMethodInfoForOffset(int64_t dex_offset) {
+ // it, otherwise returns a struct with offset == 0. MethodInfo.name receives
+ // the full function signature if with_signature is set, otherwise it gets the
+ // class and method name only.
+ MethodInfo GetMethodInfoForOffset(int64_t dex_offset, bool with_signature) {
ExtDexFileMethodInfo ext_method_info;
- if (ExtDexFileGetMethodInfoForOffset(ext_dex_file_, dex_offset, &ext_method_info)) {
+ if (ExtDexFileGetMethodInfoForOffset(ext_dex_file_,
+ dex_offset,
+ with_signature,
+ &ext_method_info)) {
return AbsorbMethodInfo(ext_method_info);
}
return {/*offset=*/0, /*len=*/0, /*name=*/DexString()};
@@ -223,10 +229,12 @@
// Returns info structs about all methods in the dex file. MethodInfo.name
// receives the full function signature if with_signature is set, otherwise it
// gets the class and method name only.
- std::vector<MethodInfo> GetAllMethodInfos(bool with_signature = true) {
+ std::vector<MethodInfo> GetAllMethodInfos(bool with_signature) {
MethodInfoVector res;
- ExtDexFileGetAllMethodInfos(
- ext_dex_file_, with_signature, AddMethodInfoCallback, static_cast<void*>(&res));
+ ExtDexFileGetAllMethodInfos(ext_dex_file_,
+ with_signature,
+ AddMethodInfoCallback,
+ static_cast<void*>(&res));
return res;
}