Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interpretation of Kotlin SMAP #1525

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Godin
Copy link
Member

@Godin Godin commented Oct 12, 2023

For

src/Example.kt

import a.testInline

fun main() {
    testInline() // line 4
} // line 5

src/a/Example.kt

package a;





inline fun testInline() {} // line 7

execution of

kotlin-compiler-1.9.0/bin/kotlinc -d classes src
java -jar jacoco-0.8.10/lib/jacococli.jar classinfo classes/ExampleKt.class --verbose

produces

  INST   BRAN   LINE   METH   CXTY   ELEMENT
     4      0      3      1      1   class 0x044395679f57425e ExampleKt
     4      0      3      1      1   +- method main()V
     2      0                           +- line 4
     1      0                           +- line 5
     1      0                           +- line 7

but there is no line 7 in src/Example.kt

output of javap -v -p classes/ExampleKt.class

SourceFile: "Example.kt"
SourceDebugExtension:
  SMAP
  Example.kt
  Kotlin
  *S Kotlin
  *F
  + 1 Example.kt
  ExampleKt
  + 2 Example.kt
  a/ExampleKt
  *L
  1#1,6:1
  7#2:7
  *S KotlinDebug
  *F
  + 1 Example.kt
  ExampleKt
  *L
  4#1:7
  *E

ie according to SMAP line 7 corresponds to line in class a/ExampleKt

if (fileName.equals(sourceFileName)) {
sourceFileIds.set(Integer.parseInt(m.group(1)));
}

if (sourceFileIds.get(lineFileID)
&& inputStartLine == outputStartLine) {

interprets this incorrectly

@Godin Godin self-assigned this Oct 12, 2023
@Godin Godin added this to Awaiting triage in Filtering via automation Oct 12, 2023
@Godin Godin moved this from Awaiting triage to To Do in Filtering Oct 12, 2023
@Godin Godin marked this pull request as draft October 12, 2023 20:49
@Godin Godin added this to Implementation in Current work items via automation Oct 12, 2023
@Godin Godin force-pushed the kotlin_SourceDebugExtension branch from 05a14f4 to f61b777 Compare October 12, 2023 20:55
@Godin Godin changed the title Fix interpretation of SMAP Fix interpretation of Kotlin SMAP Oct 12, 2023
@Godin Godin moved this from To Do to In Progress in Filtering Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Current work items
  
Implementation
Filtering
  
In Progress
Development

Successfully merging this pull request may close these issues.

None yet

1 participant