[KLIB] Add extra debug information for Local signatures
This commit is contained in:
committed by
TeamCityServer
parent
b5c28c1912
commit
b8e5185b61
@@ -64,6 +64,7 @@ interface IrLibrary {
|
||||
fun signature(index: Int, fileIndex: Int): ByteArray
|
||||
fun string(index: Int, fileIndex: Int): ByteArray
|
||||
fun body(index: Int, fileIndex: Int): ByteArray
|
||||
fun debugInfo(index: Int, fileIndex: Int): ByteArray?
|
||||
fun file(index: Int): ByteArray
|
||||
fun fileCount(): Int
|
||||
}
|
||||
|
||||
@@ -70,11 +70,14 @@ interface IrKotlinLibraryLayout : KotlinLibraryLayout {
|
||||
get() = File(irDir, "files.knf")
|
||||
val dataFlowGraphFile
|
||||
get() = File(irDir, "module_data_flow_graph")
|
||||
val irDebugInfo
|
||||
get() = File(irDir, "debugInfo.knd")
|
||||
|
||||
fun irDeclarations(file: File): File = File(file, "irCombined.knd")
|
||||
fun irDeclarations(file: File): File = File(file, "irDeclarations.knd")
|
||||
fun irTypes(file: File): File = File(file, "types.knt")
|
||||
fun irSignatures(file: File): File = File(file, "signatures.knt")
|
||||
fun irStrings(file: File): File = File(file, "strings.knt")
|
||||
fun irBodies(file: File): File = File(file, "body.knb")
|
||||
fun irFile(file: File): File = File(file, "file.knf")
|
||||
fun irDebugInfo(file: File): File = File(file, "debugInfo.knd")
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ class SerializedIrFile(
|
||||
val signatures: ByteArray,
|
||||
val strings: ByteArray,
|
||||
val bodies: ByteArray,
|
||||
val declarations: ByteArray
|
||||
val declarations: ByteArray,
|
||||
val debugInfo: ByteArray?
|
||||
)
|
||||
|
||||
class SerializedIrModule(val files: Collection<SerializedIrFile>)
|
||||
@@ -5,7 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.library.impl
|
||||
|
||||
import org.jetbrains.kotlin.library.*
|
||||
import org.jetbrains.kotlin.library.IrKotlinLibraryLayout
|
||||
import org.jetbrains.kotlin.library.IrWriter
|
||||
import org.jetbrains.kotlin.library.SerializedIrFile
|
||||
import org.jetbrains.kotlin.library.SerializedIrModule
|
||||
|
||||
abstract class IrWriterImpl(val irLayout: IrKotlinLibraryLayout) : IrWriter {
|
||||
override fun addDataFlowGraph(dataFlowGraph: ByteArray) {
|
||||
@@ -25,6 +28,7 @@ class IrMonoliticWriterImpl(_irLayout: IrKotlinLibraryLayout) : IrWriterImpl(_ir
|
||||
IrArrayWriter(map { it.signatures }).writeIntoFile(irLayout.irSignatures.absolutePath)
|
||||
IrArrayWriter(map { it.strings }).writeIntoFile(irLayout.irStrings.absolutePath)
|
||||
IrArrayWriter(map { it.bodies }).writeIntoFile(irLayout.irBodies.absolutePath)
|
||||
IrArrayWriter(mapNotNull { it.debugInfo }).writeIntoFile(irLayout.irDebugInfo.absolutePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +108,8 @@ class IrMonoliticLibraryImpl(_access: IrLibraryAccess<IrKotlinLibraryLayout>) :
|
||||
|
||||
override fun body(index: Int, fileIndex: Int) = bodies.tableItemBytes(fileIndex, index)
|
||||
|
||||
override fun debugInfo(index: Int, fileIndex: Int) = debugInfos?.tableItemBytes(fileIndex, index)
|
||||
|
||||
override fun file(index: Int) = files.tableItemBytes(index)
|
||||
|
||||
private fun loadIrDeclaration(index: Int, fileIndex: Int) =
|
||||
@@ -143,6 +145,12 @@ class IrMonoliticLibraryImpl(_access: IrLibraryAccess<IrKotlinLibraryLayout>) :
|
||||
})
|
||||
}
|
||||
|
||||
private val debugInfos: IrMultiArrayFileReader? by lazy {
|
||||
access.realFiles {
|
||||
it.irDebugInfo.let { diFile -> if (diFile.exists) IrMultiArrayFileReader(diFile) else null }
|
||||
}
|
||||
}
|
||||
|
||||
private val files: IrArrayFileReader by lazy {
|
||||
IrArrayFileReader(access.realFiles {
|
||||
it.irFiles
|
||||
@@ -212,6 +220,23 @@ class IrPerFileLibraryImpl(_access: IrLibraryAccess<IrKotlinLibraryLayout>) : Ir
|
||||
return dataReader.tableItemBytes(index)
|
||||
}
|
||||
|
||||
|
||||
private val fileToDebugInfoMap = mutableMapOf<Int, IrArrayFileReader?>()
|
||||
override fun debugInfo(index: Int, fileIndex: Int): ByteArray? {
|
||||
val dataReader = fileToDebugInfoMap.getOrPut(fileIndex) {
|
||||
val fileDirectory = directories[fileIndex]
|
||||
access.realFiles {
|
||||
it.irDebugInfo(fileDirectory).let { diFile ->
|
||||
if (diFile.exists) {
|
||||
IrArrayFileReader(diFile)
|
||||
} else null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return dataReader?.tableItemBytes(index)
|
||||
}
|
||||
|
||||
override fun file(index: Int): ByteArray {
|
||||
return access.realFiles {
|
||||
it.irFile(directories[index]).readBytes()
|
||||
|
||||
@@ -150,6 +150,8 @@ class ExtractingIrLibraryImpl(val zipped: IrLibraryLayoutImpl) :
|
||||
override val irBodies: File by lazy { zipped.extract(zipped.irBodies) }
|
||||
|
||||
override val irFiles: File by lazy { zipped.extract(zipped.irFiles) }
|
||||
|
||||
override val irDebugInfo: File by lazy { zipped.extract(zipped.irDebugInfo) }
|
||||
}
|
||||
|
||||
internal fun zippedKotlinLibraryChecks(klibFile: File) {
|
||||
|
||||
Reference in New Issue
Block a user