CODEGEN: compiler calculates path of compile unit as absolute path
This commit is contained in:
committed by
vvlevchenko
parent
65efdb18cf
commit
a679b05456
+19
-3
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.backend.konan.Context
|
||||
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys
|
||||
import org.jetbrains.kotlin.backend.konan.KonanVersion
|
||||
import org.jetbrains.kotlin.ir.SourceManager.FileEntry
|
||||
import org.jetbrains.kotlin.backend.konan.util.File
|
||||
|
||||
|
||||
internal object DWARF {
|
||||
@@ -50,20 +51,35 @@ internal fun FileEntry.line(offset: Int) = location(offset, this::getLineNumber)
|
||||
|
||||
internal fun FileEntry.column(offset: Int) = location(offset, this::getColumnNumber)
|
||||
|
||||
internal data class FileAndFolder(val file:String, val folder:String) {
|
||||
companion object {
|
||||
val NOFILE = FileAndFolder("-", "")
|
||||
}
|
||||
|
||||
fun path() = if (this == NOFILE) file else "$folder/$file"
|
||||
}
|
||||
|
||||
internal fun String?.toFileAndFolder():FileAndFolder {
|
||||
this ?: return FileAndFolder.NOFILE
|
||||
val file = File(this).absoluteFile
|
||||
return FileAndFolder(file.name, file.parent)
|
||||
}
|
||||
|
||||
internal fun generateDebugInfoHeader(context: Context) {
|
||||
if (context.shouldContainDebugInfo()) {
|
||||
val path = context.config.configuration.get(KonanConfigKeys.BITCODE_FILE).toFileAndFolder()
|
||||
context.debugInfo.module = DICreateModule(
|
||||
builder = context.debugInfo.builder,
|
||||
scope = context.llvmModule as DIScopeOpaqueRef,
|
||||
name = context.config.configuration.get(KonanConfigKeys.BITCODE_FILE)!!,
|
||||
name = path.path(),
|
||||
configurationMacro = "",
|
||||
includePath = "",
|
||||
iSysRoot = "")
|
||||
context.debugInfo.compilationModule = DICreateCompilationUnit(
|
||||
builder = context.debugInfo.builder,
|
||||
lang = DWARF.DW_LANG_kotlin,
|
||||
File = context.config.configuration.get(KonanConfigKeys.BITCODE_FILE)!!,
|
||||
dir = "",
|
||||
File = path.file,
|
||||
dir = path.folder,
|
||||
producer = DWARF.producer,
|
||||
isOptimized = 0,
|
||||
flags = "",
|
||||
|
||||
+2
-2
@@ -1659,8 +1659,8 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
//-------------------------------------------------------------------------//
|
||||
private fun IrFile.file(): DIFileRef {
|
||||
return context.debugInfo.files.getOrPut(this) {
|
||||
val path = this.fileEntry.name.split("/")
|
||||
DICreateFile(context.debugInfo.builder, path.last(), path.dropLast(1).joinToString("/"))!!
|
||||
val path = this.fileEntry.name.toFileAndFolder()
|
||||
DICreateFile(context.debugInfo.builder, path.file, path.folder)!!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user