Add position information for backport method rewriting

Bug: b/326196974
Change-Id: Ia6375974b7ff8fd98ffa457c4cd98626bdae9838
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java b/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
index 3db1504..025f819 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/BackportedMethodRewriter.java
@@ -1867,11 +1867,7 @@
       CfLabel start = new CfLabel();
       CfLabel end = new CfLabel();
       Position inlinePosition =
-          SourcePosition.builder()
-              .setCallerPosition(position)
-              .setMethod(invoke.getMethod())
-              .setLine(0)
-              .build();
+          SourcePosition.builder().setCallerPosition(position).setMethod(method).setLine(0).build();
       instructionsWithPositions.add(start);
       instructionsWithPositions.add(new CfPosition(start, inlinePosition));
       instructionsWithPositions.addAll(instructions);
@@ -1926,8 +1922,14 @@
                       .setProto(getProto(appView.dexItemFactory()))
                       .setAccessFlags(MethodAccessFlags.createPublicStaticSynthetic())
                       .setCode(
-                          methodSig ->
-                              generateTemplateMethod(appView.dexItemFactory(), methodSig)));
+                          methodSig -> {
+                            Code code = generateTemplateMethod(appView.dexItemFactory(), methodSig);
+                            if (appView.options().hasMappingFileSupport()) {
+                              return code.getCodeAsInlining(
+                                  methodSig, true, method, false, appView.dexItemFactory());
+                            }
+                            return code;
+                          }));
     }
 
     public DexProto getProto(DexItemFactory itemFactory) {
diff --git a/src/test/java/com/android/tools/r8/retrace/RetraceBackportMethodTest.java b/src/test/java/com/android/tools/r8/retrace/RetraceBackportMethodTest.java
index c8d0015..06b8bd8 100644
--- a/src/test/java/com/android/tools/r8/retrace/RetraceBackportMethodTest.java
+++ b/src/test/java/com/android/tools/r8/retrace/RetraceBackportMethodTest.java
@@ -100,8 +100,7 @@
 
   @Test
   public void testD8DebugRetrace() throws Exception {
-    // TODO(b/326196974): Should always have the frame.
-    boolean includeMathFrame = isApiWithFloorDivIntSupport();
+    boolean includeMathFrame = true;
     boolean includeExternalSyntheticFrame = false;
     boolean includeJvmModule = isApiWithFloorDivIntSupport() && isCfVmWithModulePrefix();
     boolean doNotCheckLines = isApiWithFloorDivIntSupport();
@@ -124,8 +123,7 @@
 
   @Test
   public void testD8ReleaseRetrace() throws Exception {
-    // TODO(b/326196974): Should always have the frame.
-    boolean includeMathFrame = isApiWithFloorDivIntSupport();
+    boolean includeMathFrame = true;
     boolean includeExternalSyntheticFrame = false;
     boolean includeJvmModule = isApiWithFloorDivIntSupport() && isCfVmWithModulePrefix();
     boolean doNotCheckLines = isApiWithFloorDivIntSupport();
@@ -149,9 +147,7 @@
   @Test
   public void testR8() throws Exception {
     parameters.assumeR8TestParameters();
-    // TODO(b/326196974): Should always have the frame.
-    boolean includeMathFrame = parameters.isCfRuntime() || isApiWithFloorDivIntSupport();
-    ;
+    boolean includeMathFrame = true;
     boolean includeExternalSyntheticFrame = false;
     boolean includeJvmModule = isCfVmWithModulePrefix();
     boolean doNotCheckLines = parameters.isCfRuntime() || isApiWithFloorDivIntSupport();