Refactor debug info position visiting
Move logic to CodeItemDebugInfoAccessor, makes it easier to modify
the debug info format.
Test: test-art-host
Bug: 112311591
Bug: 77709234
Change-Id: Ice56a88951efa54dc07d88f2c228c01be4670e73
diff --git a/openjdkjvmti/ti_method.cc b/openjdkjvmti/ti_method.cc
index 6764538..742a9fa 100644
--- a/openjdkjvmti/ti_method.cc
+++ b/openjdkjvmti/ti_method.cc
@@ -446,16 +446,6 @@
return ERR(NONE);
}
-using LineNumberContext = std::vector<jvmtiLineNumberEntry>;
-
-static bool CollectLineNumbers(void* void_context, const art::DexFile::PositionInfo& entry) {
- LineNumberContext* context = reinterpret_cast<LineNumberContext*>(void_context);
- jvmtiLineNumberEntry jvmti_entry = { static_cast<jlocation>(entry.address_),
- static_cast<jint>(entry.line_) };
- context->push_back(jvmti_entry);
- return false; // Collect all, no early exit.
-}
-
jvmtiError MethodUtil::GetLineNumberTable(jvmtiEnv* env,
jmethodID method,
jint* entry_count_ptr,
@@ -486,9 +476,11 @@
DCHECK(accessor.HasCodeItem()) << art_method->PrettyMethod() << " " << dex_file->GetLocation();
}
- LineNumberContext context;
- bool success = dex_file->DecodeDebugPositionInfo(
- accessor.DebugInfoOffset(), CollectLineNumbers, &context);
+ std::vector<jvmtiLineNumberEntry> context;
+ bool success = accessor.DecodeDebugPositionInfo([&](const art::DexFile::PositionInfo& entry) {
+ context.push_back({static_cast<jlocation>(entry.address_), static_cast<jint>(entry.line_)});
+ return false;
+ });
if (!success) {
return ERR(ABSENT_INFORMATION);
}