CODEGEN: conversion IR line/column numbering to dwarf one
This commit is contained in:
committed by
vvlevchenko
parent
4cf27e44ec
commit
ee116b1a91
+14
@@ -23,6 +23,7 @@ import llvm.LLVMAddNamedMetadataOperand
|
||||
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
|
||||
|
||||
|
||||
internal object DWARF {
|
||||
@@ -36,6 +37,19 @@ internal object DWARF {
|
||||
val debugInfoVersion = 3 /* TODO: configurable? */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* File entry starts offsets from zero while dwarf number lines/column starting from 1.
|
||||
*/
|
||||
private fun FileEntry.location(offset:Int, offsetToNumber:(Int) -> Int):Int {
|
||||
return if (offset < 0) -1
|
||||
else offsetToNumber(offset) + 1
|
||||
}
|
||||
|
||||
internal fun FileEntry.line(offset: Int) = location(offset, this::getLineNumber)
|
||||
|
||||
internal fun FileEntry.column(offset: Int) = location(offset, this::getColumnNumber)
|
||||
|
||||
internal fun generateDebugInfoHeader(context: Context) {
|
||||
if (context.shouldContainDebugInfo()) {
|
||||
context.debugInfo.module = DICreateModule(
|
||||
|
||||
+2
-12
@@ -1643,20 +1643,10 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
private fun IrElement.line(): Int {
|
||||
return if (this.startOffset < 0)
|
||||
-1
|
||||
else
|
||||
file().fileEntry.getLineNumber(this.startOffset)
|
||||
}
|
||||
private fun IrElement.line() = file().fileEntry.line(this.startOffset)
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
private fun IrElement.column(): Int {
|
||||
return if (this.startOffset < 0)
|
||||
-1
|
||||
else
|
||||
file().fileEntry.getColumnNumber(this.startOffset)
|
||||
}
|
||||
private fun IrElement.column() = file().fileEntry.column(this.startOffset)
|
||||
|
||||
//-------------------------------------------------------------------------//
|
||||
private inline fun <T> debugInfo(element: IrElement, body:() -> T): T {
|
||||
|
||||
Reference in New Issue
Block a user