Debugging
Inspecting compiled output
Section titled “Inspecting compiled output”JVM class files
Section titled “JVM class files”Use javap (from the JDK) to disassemble compiled class files:
skotch emit --target jvm hello.kt -o HelloKt.classjavap -c HelloKt.classDEX files
Section titled “DEX files”Use dexdump (from the Android SDK build-tools) to inspect DEX output:
skotch emit --target dex hello.kt -o classes.dexdexdump -d classes.dexLLVM IR
Section titled “LLVM IR”The LLVM IR output is human-readable text:
skotch emit --target llvm hello.kt -o hello.llcat hello.llNormalized output
Section titled “Normalized output”Use --norm-out to write a normalized text form alongside binary output.
This strips cosmetic differences and makes the structure easier to read:
skotch emit --target jvm hello.kt -o HelloKt.class --norm-out hello.norm.txtcat hello.norm.txtUsing the REPL for debugging
Section titled “Using the REPL for debugging”The REPL is useful for testing individual functions and expressions:
skotch replskotch> fun double(x: Int): Int = x * 2skotch> println(double(21))42Declarations accumulate across turns, so you can build up state incrementally and test as you go.
Compiler errors
Section titled “Compiler errors”Skotch prints diagnostics to stderr when compilation fails. Common categories:
| Error | Meaning |
|---|---|
| Parse error | Syntax not recognized (check for unsupported features) |
| Unresolved reference | Function or variable name not found |
| Type mismatch | Argument type doesn’t match parameter type |
| Feature not yet supported | Using a Kotlin feature that Skotch doesn’t compile yet |