1 ;; This test checks output of the DWARF embedded source.
3 ; REQUIRES: x86-registered-target
5 ; RUN: llc -filetype=obj -o %t.o %s
7 ;; Check LLVM style output.
8 ; RUN: llvm-symbolizer --print-source-context-lines=3 --obj=%t.o 0 | \
9 ; RUN: FileCheck %s --check-prefixes=COMMON,LLVM --strict-whitespace --match-full-lines --implicit-check-not={{.}}
11 ;; Check GNU output style.
12 ; RUN: llvm-symbolizer --print-source-context-lines=3 --obj=%t.o 0 --output-style=GNU | \
13 ; RUN: FileCheck %s --check-prefixes=COMMON,GNU --strict-whitespace --match-full-lines --implicit-check-not={{.}}
16 ; LLVM-NEXT:/source.c:3:13
17 ; GNU-NEXT:/source.c:3
18 ; COMMON-NEXT:2 : // Line 2
19 ; COMMON-NEXT:3 >: void foo() {}
20 ; COMMON-NEXT:4 : // Line 4
22 ;; Check JSON style output.
23 ; RUN: llvm-symbolizer --print-source-context-lines=3 --obj=%t.o 0 --output-style=JSON | \
24 ; RUN: FileCheck %s --check-prefix=JSON --strict-whitespace --match-full-lines --implicit-check-not={{.}}
25 ; JSON:[{"Address":"0x0","ModuleName":"{{.*}}.o","Symbol":[{"Column":13,"Discriminator":0,"FileName":"/source.c","FunctionName":"foo","Line":3,"Source":"2 : // Line 2\n3 >: void foo() {}\n4 : // Line 4\n","StartAddress":"0x0","StartFileName":"/source.c","StartLine":3}]}]
27 ;; Generated from the following source:
33 ;; clang --target=x86_64-pc-linux -gdwarf-5 -gembed-source -g -emit-llvm -S source.c -o source.ll
35 source_filename = "source.c"
36 target triple = "x86_64-pc-linux"
38 define dso_local void @foo() #0 !dbg !7 {
44 !llvm.module.flags = !{!3, !4, !5}
47 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
48 !1 = !DIFile(filename: "source.c", directory: "/", source: "// Line 1\0A// Line 2\0Avoid foo() {}\0A// Line 4\0A// Line 5\0A")
50 !3 = !{i32 7, !"Dwarf Version", i32 5}
51 !4 = !{i32 2, !"Debug Info Version", i32 3}
52 !5 = !{i32 1, !"wchar_size", i32 4}
53 !6 = !{!"clang version 12.0.0"}
54 !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
55 !8 = !DISubroutineType(types: !9)
57 !10 = !DILocation(line: 3, column: 13, scope: !7)