Commit Graph

20 Commits

Author SHA1 Message Date
Vasily Levchenko 3dc88795d8 [bindings][llvm][DI] warnings [-Wformat] 2018-02-13 14:15:02 +03:00
Vasily Levchenko 0236868012 [codegen][DI][inline] generation debug info for inlined functions. (#1251)
- We use DILexicalBlock and DILexicalBlockFile for generation debug info for kotlin inline (macro substituion by nature).
-- Note: DILexicalBlock aren't nested in opposite to inline function in C meaning.
- Changed DICompileUnit generation practise, now it generated for each file.
- added DI LLVM bindings.
2018-02-01 20:43:21 +03:00
Vasily Levchenko 56d1881f18 [codegen][debug info] debug info generation do not touch llvm builder in the most cases. 2018-01-12 23:39:58 +03:00
Vasily Levchenko 38069d47ea [build][gradle-4.4] (cpp, c) gradle plugins for native software injects -I/usr/include/x86_64-linux-gnu to compiler (#1189) 2017-12-25 12:52:02 +03:00
Vasily Levchenko 56a214c454 [build][gradle][4.4] upgrade (HACK inside see comment in body)
Gradle native software plugins adds -I/usr/include that inroduce conflict with our --systemroot flags,
so we had to add following hack over it:

 /* HACK over gradle 4.4, it adds /usr/include, that affects our --sysroot flag */
toolChains {
  clang(Clang) {
    eachPlatform {
      cppCompiler.withArguments { args ->
        args.remove /usr/include
      }
    }
  }
}
2017-12-21 11:55:36 +03:00
Vasily Levchenko 3a6cb76dc1 [llvm][update][5.0.0] llvm 5.0.0 2017-12-01 10:36:34 +03:00
Aleksey Kladov b5befcf5d5 [debug] it's possible to inspect array elements in debugger 2017-11-17 16:19:26 +03:00
Aleksey Kladov a118fc5271 [debug] add test for pretty-printers (#994)
* [debug] add test for pretty-printers

* [pretty printer] tuned evaluation of expressions
2017-11-08 13:20:47 +03:00
Vasily Levchenko fea734ec83 [codegen][debug] generation debug info for vals. 2017-10-26 15:45:03 +03:00
Aleksey Kladov e3611ca883 [debug] make lldb printes more robust
`GetValueAsUnsigned` return result as a Python `long`, while *some*
versions of lldb require that an `int` is passed to
`ReadCStringFromMemory` down the line. So let's cast result to `int`,
which is 64 bit wide on Python2 anyway.

Also use nicer accessors and a simpler rule to find Kotlin types.
2017-09-27 05:50:14 +03:00
Vasily Levchenko d6a47c09c6 [build][debug info] fix gradle 'build' 2017-09-25 17:25:09 +03:00
Aleksey Kladov 7f4d14d36e [debug] add Kotlin Object pretty printers for lldb
Now lldb commands like `frame variable` print non-primitive Kotlin
objects nicely if you `command script import dist/tools/konan_lldb.py`
2017-09-21 06:58:46 +03:00
Vasily Levchenko db1a1b029a [codegen][debug info][dwarf] (var) variable inspection in debugger support
- debug location metainformation attached to stack allcated slots.
- python bindings to work such variables.
2017-08-17 14:00:18 +03:00
Vasily Levchenko 98e2405f41 debug info demo: makes demo for complex type use new API 2017-06-06 06:49:04 -07:00
Vasily Levchenko 010360df7d build: disable producing shared library for llvm debug info (gradle version dependent) 2017-06-06 06:49:04 -07:00
Vasily Levchenko c8badb0a38 DEBUGINFO: generate forward declaraion of the type instead of kotlin.Any
Previously in case type wasn't resolved in codegen (debug info wasn't constructed from IR),
we'd use reference to kotlin.Any? as type, from now we're using forward declaration. What next?
- type parameters... how to deal with?

(cherry picked from commit 579acba659fe52afec638fc00e07a320560bd5fa)
2017-05-18 18:39:31 +03:00
Vasily Levchenko b1462f8da6 DEBUGDEMO: refactoring & new demo of structured types.
- extract common part for easier demo introducing.
- fixed warning [-Wincompatible-pointer-types]
- demo-types
- this debug info generated for pseudo structure:
    1 /* smth here... */
    2 A {
    3 int a;
    4 int b;
    5}

    0:b-debugger-types:minamoto@unit-703(0)# llvmDebugInfoC/build/exe/demotypes/demotypes
    define i32 @main() !dbg !3 {
    entry:
      ret i32 42
      }

    !llvm.dbg.cu = !{!0}

    !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "konanc", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
    !1 = !DIFile(filename: "<stdin>", directory: "")
    !2 = !{}
    !3 = distinct !DISubprogram(name: "main", linkageName: "main", scope: null, file: !1, line: 1, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !4 = !DISubroutineType(types: !5)
    !5 = !{!6}
    !6 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 2, size: 64, align: 32, elements: !7)
    !7 = !{!8, !10}
    !8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !1, line: 3, baseType: !9, size: 32, align: 32)
    !9 = !DIBasicType(name: "int", size: 32, align: 4)
    !10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !6, file: !1, line: 4, baseType: !9, size: 32, align: 32, offset: 32)
2017-05-04 20:35:44 +03:00
Vasily Levchenko dc8bcc677a DEBUGINFO: binding enchancement && composite type support
- structured datatypes usable in debug info
- bindings for llvm/Support/Dwarf.h (llvm 3.9) makes easier introducing dwarf constants from LLVM
- added HANDLE_DW_LANG generating sequence DW_LANGs (DW_LANG_Kotlin equals DW_LANG_C89 for now).
- refactoring : g/c typo
- tag (DwarfTag) of the type added as parameter in DICreateReplaceableCompositeType
- binding for creating reference type
- binding for creating array type.
2017-05-04 20:35:44 +03:00
Vasily Levchenko 84d62eb471 DEBUGINFO: makes debug info stab usable from konan compiler 2017-04-19 09:52:05 +03:00
Vasily Levchenko 89ebbaeb6c DEBUGINFO: initial C bindings to debug info llvm
- support DICompileUnit
- support DIFIle
- support DISubroutine
- support DIBasicType
- support DILocation
- added gradle build
- debug info bindings are involved in kotlin build
- added binding to DIGetSubprogramLinkName
- added binding to LLVMBuilderGetCurrentFunction
- added reset location
- simple demo added (buildable with gradle)
  produces folowing output:
    Following pseudo code in sources.
     0:123456789012345678901
     1: fun main():Int {
     2:   {foo()}()
     3:   return 0
     4: }
     5  fun foo() {}

    0:b-backend-dwarf:minamoto@unit-703(0)# ./demo
    ; ModuleID = 'test'
    source_filename = "test"

    define i32 @foo(i32) !dbg !3 {
    entry:
      ret i32 %0, !dbg !7
    }

    !llvm.dbg.cu = !{!0}

    !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "konanc", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
    !1 = !DIFile(filename: "1.kt", directory: "src")
    !2 = !{}
    !3 = distinct !DISubprogram(name: "foo", linkageName: "foo:link", scope: null, file: !1, line: 66, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !4 = !DISubroutineType(types: !5)
    !5 = !{!6}
    !6 = !DIBasicType(name: "int", size: 32, align: 4)
    !7 = !DILocation(line: 42, column: 15, scope: !3)
- demo sharing debug information between several bitcode artifacts
    0:b-backend-dwarf:minamoto@unit-703(0)# llvmDebugInfoC/build/exe/demogenerated/demogenerated
    ; ModuleID = 'test'
    source_filename = "test"

    define void @foo() !dbg !3 {
    entry:
      ret void, !dbg !5
    }

    define void @"main$caller$foo"() !dbg !6 {
    entry:
      call void @foo(), !dbg !7
      ret void
    }

    define void @main() !dbg !8 {
    entry:
      call void @"main$caller$foo"(), !dbg !9
      ret void, !dbg !10
    }

    !llvm.dbg.cu = !{!0}

    !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "konanc", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
    !1 = !DIFile(filename: "<stdin>", directory: "")
    !2 = !{}
    !3 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 5, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !4 = !DISubroutineType(types: !2)
    !5 = !DILocation(line: 5, column: 14, scope: !3)
    !6 = distinct !DISubprogram(name: "main$caller$foo", linkageName: "main$caller$foo", scope: null, file: !1, line: 2, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !7 = !DILocation(line: 5, column: 2, scope: !6)
    !8 = distinct !DISubprogram(name: "main", linkageName: "main", scope: null, file: !1, line: 1, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !9 = !DILocation(line: 2, column: 12, scope: !8)
    !10 = !DILocation(line: 3, column: 4, scope: !8)
- local variables support
- demo for local variable suppor (TBD some out put here).
    ; ModuleID = 'test'
    source_filename = "test"

    define i32 @main() !dbg !3 {
    entry:
    %0 = alloca i32
    call void @llvm.dbg.declare(metadata i32* %0, metadata !5, metadata !7), !dbg !8
    store i32 42, i32* %0, !dbg !8
    %1 = load i32, i32* %0, !dbg !8
    ret i32 %1, !dbg !8
    }

    ; Function Attrs: nounwind readnone
    declare void @llvm.dbg.declare(metadata, metadata, metadata) #0

    attributes #0 = { nounwind readnone }

    !llvm.dbg.cu = !{!0}

    !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "konanc", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
    !1 = !DIFile(filename: "<stdin>", directory: "")
    !2 = !{}
    !3 = distinct !DISubprogram(name: "main", linkageName: "main", scope: null, file: !1, line: 1, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !2)
    !4 = !DISubroutineType(types: !2)
    !5 = !DILocalVariable(name: "a", scope: !3, file: !1, line: 2, type: !6)
    !6 = !DIBasicType(name: "int", size: 32, align: 4)
    !7 = !DIExpression()
    !8 = !DILocation(line: 2, column: 1, scope: !3)
2017-04-14 11:39:51 +03:00