Debug Info! Add basic support for line tables, compilation units, files,

and lexical scopes, which can be enabled through the new -g option.
When -g is enabled, line tables and scopes compile all the way
down to DWARF.

Changes to SIL:
- In addition to a SILLocation, every instruction now also has a pointer
  to a SILDebugScope (its containing lexical scope).
- Added LexicalScope, which is to be used for all Scopes we want to show
  up in the debug info.

Swift SVN r5772
This commit is contained in:
Adrian Prantl
2013-06-23 00:09:17 +00:00
parent 196381780a
commit 0f7533dc7e
13 changed files with 401 additions and 15 deletions

View File

@@ -0,0 +1,28 @@
// A very basic test for debug info.
// Verify that we don't emit any debug info by default.
// RUN: %swift -triple x86_64-apple-darwin10 %s -emit-llvm -o - | FileCheck %s --check-prefix NDEBUG
// NDEBUG-NOT: !dbg
// NDEBUG-NOT: DW_TAG
// Now check that we do generate line+scope info with -g.
// RUN: %swift -triple x86_64-apple-darwin10 %s -emit-llvm -g -o - | FileCheck %s
func f(a: Int, b:Int) -> Int {
// CHECK-DAG: i32 [[@LINE-1]],{{.*}}DW_TAG_lexical_block
if b != 0 {
// CHECK-DAG: i32 [[@LINE-1]],{{.*}}DW_TAG_lexical_block
// CHECK-DAG: ret{{.*}}, !dbg ![[DBG:[0-9]+]]
// CHECK-DAG: [[DBG]] = metadata !{i32 [[@LINE+1]],
return a/b
} else {
// CHECK-DAG: [[PARENT:[0-9]+]] = {{.*}}i32 [[@LINE-1]],{{.*}}DW_TAG_lexical_block
var c = 42
if a == 0 {
// CHECK-DAG: metadata ![[PARENT]], i32 [[@LINE-1]],{{.*}}DW_TAG_lexical_block
// What about a nested scope?
return 0
}
return c
}
}