Debugging tests: fix breakpoint setup when line table is empty
When we set a breakpoint on the first line of a method, we request
its line table then select the first line in this table and set the
breakpoint on the corresponding instruction index.
If a method has no line table (which is the case for synthesized
methods), then we just need to set the breakpoint on the first
instruction.
Change-Id: I9d00f06d22bc5f2c604d41199710c569662f7c53
diff --git a/src/test/java/com/android/tools/r8/debug/DebugTestBase.java b/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
index 685e8f7..f65e204 100644
--- a/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
+++ b/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
@@ -1482,10 +1482,16 @@
ReplyPacket replyPacket = getMirror().getLineTable(classId, breakpointMethodId);
checkReplyPacket(replyPacket, "Failed to get method line table");
long start = replyPacket.getNextValueAsLong(); // start
- long end = replyPacket.getNextValueAsLong(); // end
+ replyPacket.getNextValueAsLong(); // end
int linesCount = replyPacket.getNextValueAsInt();
if (linesCount == 0) {
- pcs.add(-1L);
+ if (lineToSearch == FIRST_LINE) {
+ // There is no line table but we are not looking for a specific line. Therefore just
+ // set the breakpoint on the 1st instruction.
+ pcs.add(start);
+ } else {
+ pcs.add(-1L);
+ }
} else {
if (lineToSearch == FIRST_LINE) {
// Read only the 1st line because code indices are in ascending order