Add debug info for link-time generated thunks.
Add debug info for method call thunks (currently unused) and
Baker read barrier thunks. Refactor debug info generation
for trampolines and record their sizes; change their names
to start with upper-case letters, so that they can be easily
generated as `#fn_name`.
This improved debug info must be generated by `dex2oat -g`,
the debug info generated by `oatdump --symbolize` remains
the same as before, except for the renamed trampolines and
an adjustment for "code delta", i.e. the Thumb mode bit.
Cortex-A53 erratum 843419 workaround thunks are not covered
by this CL.
Test: Manual; run-test --gdb -Xcompiler-option -g 160, pull
symbols for gdbclient, break in the introspection
entrypoint, check that gdb knows the new symbols
(and disassembles them) and `backtrace` works when
setting $pc to an address in the thunk.
Bug: 36141117
Change-Id: Id224b72cfa7a0628799c7db65e66e24c8517aabf
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index 4161067..13f7211 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -178,10 +178,32 @@
oat_file_->BssRootsOffset());
builder_->WriteDynamicSection();
+ const OatHeader& oat_header = oat_file_->GetOatHeader();
+ #define DO_TRAMPOLINE(fn_name) \
+ if (oat_header.Get ## fn_name ## Offset() != 0) { \
+ debug::MethodDebugInfo info = {}; \
+ info.trampoline_name = #fn_name; \
+ info.isa = oat_header.GetInstructionSet(); \
+ info.is_code_address_text_relative = true; \
+ size_t code_offset = oat_header.Get ## fn_name ## Offset(); \
+ code_offset -= CompiledCode::CodeDelta(oat_header.GetInstructionSet()); \
+ info.code_address = code_offset - oat_header.GetExecutableOffset(); \
+ info.code_size = 0; /* The symbol lasts until the next symbol. */ \
+ method_debug_infos_.push_back(std::move(info)); \
+ }
+ DO_TRAMPOLINE(InterpreterToInterpreterBridge)
+ DO_TRAMPOLINE(InterpreterToCompiledCodeBridge)
+ DO_TRAMPOLINE(JniDlsymLookup);
+ DO_TRAMPOLINE(QuickGenericJniTrampoline);
+ DO_TRAMPOLINE(QuickImtConflictTrampoline);
+ DO_TRAMPOLINE(QuickResolutionTrampoline);
+ DO_TRAMPOLINE(QuickToInterpreterBridge);
+ #undef DO_TRAMPOLINE
+
Walk();
- for (const auto& trampoline : debug::MakeTrampolineInfos(oat_file_->GetOatHeader())) {
- method_debug_infos_.push_back(trampoline);
- }
+
+ // TODO: Try to symbolize link-time thunks?
+ // This would require disassembling all methods to find branches outside the method code.
debug::WriteDebugInfo(builder_.get(),
ArrayRef<const debug::MethodDebugInfo>(method_debug_infos_),
@@ -282,8 +304,8 @@
// Clear Thumb2 bit.
const void* code_address = EntryPointToCodePointer(reinterpret_cast<void*>(entry_point));
- debug::MethodDebugInfo info = debug::MethodDebugInfo();
- info.trampoline_name = nullptr;
+ debug::MethodDebugInfo info = {};
+ DCHECK(info.trampoline_name.empty());
info.dex_file = &dex_file;
info.class_def_index = class_def_index;
info.dex_method_index = dex_method_index;