Always emit positions when having pc-2-pc output
Bug: b/295136314
Bug: b/297970886
Change-Id: I886c43cbc9099ce6f32063931fb5abe0fc3e6134
diff --git a/src/main/java/com/android/tools/r8/graph/DexDebugEventBuilder.java b/src/main/java/com/android/tools/r8/graph/DexDebugEventBuilder.java
index c4eace2..c154471 100644
--- a/src/main/java/com/android/tools/r8/graph/DexDebugEventBuilder.java
+++ b/src/main/java/com/android/tools/r8/graph/DexDebugEventBuilder.java
@@ -57,6 +57,7 @@
private int emittedPc = NO_PC_INFO;
private Position emittedPosition = Position.none();
private Int2ReferenceMap<DebugLocalInfo> emittedLocals;
+ private final boolean isComposing;
// Emitted events.
private final List<DexDebugEvent> events = new ArrayList<>();
@@ -66,9 +67,12 @@
public DexDebugEventBuilder(AppView<?> appView, IRCode code) {
this.appView = appView;
- this.method = code.method();
- this.factory = appView.dexItemFactory();
- this.options = appView.options();
+ method = code.context().getDefinition();
+ factory = appView.dexItemFactory();
+ options = appView.options();
+ isComposing =
+ options.mappingComposeOptions().enableExperimentalMappingComposition
+ && appView.appInfo().app().getProguardMap() != null;
}
/** Add events at pc for instruction. */
@@ -94,7 +98,9 @@
updateLocals(instruction.asDebugLocalsChange());
} else if (pcAdvancing) {
if (!position.isNone() && !position.equals(emittedPosition)) {
- if (options.debug || instruction.instructionInstanceCanThrow(appView, context)) {
+ if (options.debug
+ || instruction.instructionInstanceCanThrow(appView, context)
+ || isComposing) {
emitDebugPosition(pc, position);
}
}
diff --git a/src/test/java/com/android/tools/r8/mappingcompose/ComposeWithMissingDebugInfoTest.java b/src/test/java/com/android/tools/r8/mappingcompose/ComposeWithMissingDebugInfoTest.java
index 950abdc..d042b13 100644
--- a/src/test/java/com/android/tools/r8/mappingcompose/ComposeWithMissingDebugInfoTest.java
+++ b/src/test/java/com/android/tools/r8/mappingcompose/ComposeWithMissingDebugInfoTest.java
@@ -77,8 +77,7 @@
.map(method -> method.getRetracedMethod().getMethodName())
.collect(Collectors.toSet());
Set<String> expectedMethods = new HashSet<>();
- expectedMethods.add("a");
- // TODO(b/297970886): We should observe 'foo' and not 'a'.
+ expectedMethods.add("foo");
assertEquals(expectedMethods, foundMethods);
}