Pass the debug_info_offset explicitly.
In order to use debug_info_offset for encoding implementation details,
rewrite all indirect users of it to fetch it before calling DexFile
methods.
This allows keeping the DexFile interface clean of runtime
considerations.
Test: test.py
Change-Id: I4591e0039b5f822f4409aae411071ecbe97082b1
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 3784212..1dcd935 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -58,6 +58,7 @@
#include "mirror/throwable.h"
#include "nativehelper/scoped_local_ref.h"
#include "nativehelper/scoped_primitive_array.h"
+#include "oat_file.h"
#include "obj_ptr-inl.h"
#include "reflection.h"
#include "safe_map.h"
@@ -1680,7 +1681,9 @@
context.pReply = pReply;
if (code_item != nullptr) {
- m->GetDexFile()->DecodeDebugPositionInfo(code_item, DebugCallbackContext::Callback, &context);
+ uint32_t debug_info_offset = OatFile::GetDebugInfoOffset(*(m->GetDexFile()), code_item);
+ m->GetDexFile()->DecodeDebugPositionInfo(
+ code_item, debug_info_offset, DebugCallbackContext::Callback, &context);
}
JDWP::Set4BE(expandBufGetBuffer(pReply) + numLinesOffset, context.numItems);
@@ -1737,9 +1740,10 @@
const DexFile::CodeItem* code_item = m->GetCodeItem();
if (code_item != nullptr) {
+ uint32_t debug_info_offset = OatFile::GetDebugInfoOffset(*(m->GetDexFile()), code_item);
m->GetDexFile()->DecodeDebugLocalInfo(
- code_item, m->IsStatic(), m->GetDexMethodIndex(), DebugCallbackContext::Callback,
- &context);
+ code_item, debug_info_offset, m->IsStatic(), m->GetDexMethodIndex(),
+ DebugCallbackContext::Callback, &context);
}
JDWP::Set4BE(expandBufGetBuffer(pReply) + variable_count_offset, context.variable_count);
@@ -3886,7 +3890,9 @@
if (m != nullptr && !m->IsNative()) {
const DexFile::CodeItem* const code_item = m->GetCodeItem();
DebugCallbackContext context(single_step_control, line_number, code_item);
- m->GetDexFile()->DecodeDebugPositionInfo(code_item, DebugCallbackContext::Callback, &context);
+ uint32_t debug_info_offset = OatFile::GetDebugInfoOffset(*(m->GetDexFile()), code_item);
+ m->GetDexFile()->DecodeDebugPositionInfo(
+ code_item, debug_info_offset, DebugCallbackContext::Callback, &context);
}
// Activate single-step in the thread.