summaryrefslogtreecommitdiffstats
path: root/compiler/debug
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2018-09-11 12:35:30 -0700
committerMathieu Chartier <mathieuc@google.com>2018-09-12 11:32:40 -0700
commit3e2e123239952c80e1b37431bf2efbbe07a41940 (patch)
tree153be0dafdbce55b5e5432cb10025b802a637402 /compiler/debug
parent68851b53e4152d3edaea977573af8bdc0bd23313 (diff)
downloadart-3e2e123239952c80e1b37431bf2efbbe07a41940.tar.gz
art-3e2e123239952c80e1b37431bf2efbbe07a41940.tar.bz2
art-3e2e123239952c80e1b37431bf2efbbe07a41940.zip
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
Diffstat (limited to 'compiler/debug')
-rw-r--r--compiler/debug/elf_debug_info_writer.h14
-rw-r--r--compiler/debug/elf_debug_line_writer.h14
2 files changed, 10 insertions, 18 deletions
diff --git a/compiler/debug/elf_debug_info_writer.h b/compiler/debug/elf_debug_info_writer.h
index bda7108c74..233f61cec3 100644
--- a/compiler/debug/elf_debug_info_writer.h
+++ b/compiler/debug/elf_debug_info_writer.h
@@ -49,18 +49,12 @@ static void LocalInfoCallback(void* ctx, const DexFile::LocalInfo& entry) {
static std::vector<const char*> GetParamNames(const MethodDebugInfo* mi) {
std::vector<const char*> names;
+ DCHECK(mi->dex_file != nullptr);
CodeItemDebugInfoAccessor accessor(*mi->dex_file, mi->code_item, mi->dex_method_index);
if (accessor.HasCodeItem()) {
- DCHECK(mi->dex_file != nullptr);
- const uint8_t* stream = mi->dex_file->GetDebugInfoStream(accessor.DebugInfoOffset());
- if (stream != nullptr) {
- DecodeUnsignedLeb128(&stream); // line.
- uint32_t parameters_size = DecodeUnsignedLeb128(&stream);
- for (uint32_t i = 0; i < parameters_size; ++i) {
- uint32_t id = DecodeUnsignedLeb128P1(&stream);
- names.push_back(mi->dex_file->StringDataByIdx(dex::StringIndex(id)));
- }
- }
+ accessor.VisitParameterNames([&](const dex::StringIndex& id) {
+ names.push_back(mi->dex_file->StringDataByIdx(id));
+ });
}
return names;
}
diff --git a/compiler/debug/elf_debug_line_writer.h b/compiler/debug/elf_debug_line_writer.h
index 3d78943cd0..0a13a92d07 100644
--- a/compiler/debug/elf_debug_line_writer.h
+++ b/compiler/debug/elf_debug_line_writer.h
@@ -34,11 +34,6 @@ namespace debug {
typedef std::vector<DexFile::PositionInfo> PositionInfos;
-static bool PositionInfoCallback(void* ctx, const DexFile::PositionInfo& entry) {
- static_cast<PositionInfos*>(ctx)->push_back(entry);
- return false;
-}
-
template<typename ElfTypes>
class ElfDebugLineWriter {
using Elf_Addr = typename ElfTypes::Addr;
@@ -154,11 +149,14 @@ class ElfDebugLineWriter {
Elf_Addr method_address = base_address + mi->code_address;
PositionInfos dex2line_map;
- DCHECK(mi->dex_file != nullptr);
const DexFile* dex = mi->dex_file;
+ DCHECK(dex != nullptr);
CodeItemDebugInfoAccessor accessor(*dex, mi->code_item, mi->dex_method_index);
- const uint32_t debug_info_offset = accessor.DebugInfoOffset();
- if (!dex->DecodeDebugPositionInfo(debug_info_offset, PositionInfoCallback, &dex2line_map)) {
+ if (!accessor.DecodeDebugPositionInfo(
+ [&](const DexFile::PositionInfo& entry) {
+ dex2line_map.push_back(entry);
+ return false;
+ })) {
continue;
}