Fix line number calculation that deviates from old Dalvik.
In old Dalvik, adjopcode was declared as int instead of uint8. And
it's declared in different scope.
Pass the art-target tests and art-host tests.
Change-Id: Ie65c16a43ca32f1acf425a740bebc02f005f9011
diff --git a/src/dex_file.cc b/src/dex_file.cc
index a11744d..0a18f11 100644
--- a/src/dex_file.cc
+++ b/src/dex_file.cc
@@ -675,10 +675,8 @@
for (;;) {
uint8_t opcode = *stream++;
- uint8_t adjopcode = opcode - DBG_FIRST_SPECIAL;
uint16_t reg;
-
switch (opcode) {
case DBG_END_SEQUENCE:
return;
@@ -755,7 +753,9 @@
case DBG_SET_FILE:
break;
- default:
+ default: {
+ int adjopcode = opcode - DBG_FIRST_SPECIAL;
+
address += adjopcode / DBG_LINE_RANGE;
line += DBG_LINE_BASE + (adjopcode % DBG_LINE_RANGE);
@@ -766,6 +766,7 @@
}
}
break;
+ }
}
}
}
diff --git a/src/dex_file.h b/src/dex_file.h
index 7d9e6f9..7d3fb74 100644
--- a/src/dex_file.h
+++ b/src/dex_file.h
@@ -717,7 +717,7 @@
const String* signature);
static bool LineNumForPcCb(void* cnxt, uint32_t address, uint32_t line_num) {
- LineNumFromPcContext *context = (LineNumFromPcContext *)cnxt;
+ LineNumFromPcContext* context = (LineNumFromPcContext*) cnxt;
// We know that this callback will be called in
// ascending address order, so keep going until we find