[pkg-d-commits] [ldc] 62/74: GDB test for class types.

Matthias Klumpp mak at moszumanska.debian.org
Thu Jul 13 20:54:19 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.3.0-beta2
in repository ldc.

commit 9aafb0a9af4155e1ea75b22ba4494784281cb878
Author: Elie Morisse <syniurge at gmail.com>
Date:   Mon May 22 22:07:37 2017 -0300

    GDB test for class types.
---
 tests/debuginfo/classtypes_gdb.d | 76 ++++++++++++++++++++++++++++++++++++++++
 tests/lit.site.cfg.in            | 18 ++++++++++
 2 files changed, 94 insertions(+)

diff --git a/tests/debuginfo/classtypes_gdb.d b/tests/debuginfo/classtypes_gdb.d
new file mode 100644
index 0000000..c29b1d8
--- /dev/null
+++ b/tests/debuginfo/classtypes_gdb.d
@@ -0,0 +1,76 @@
+// REQUIRES: atleast_llvm308
+// REQUIRES: gdb
+// RUN: %ldc %_gdb_dflags -g -of=%t %s
+// RUN: sed -e "/^\\/\\/ GDB:/!d" -e "s,// GDB:,," %s >%t.gdb
+// RUN: gdb %t --batch -x %t.gdb >%t.out 2>&1
+// RUN: FileCheck %s -check-prefix=CHECK < %t.out
+module classtypes_gdb;
+
+class uv
+{
+    uint i;
+}
+
+class xyz : uv
+{
+    float f;
+    double d;
+
+    this(uint i, float f) { this.i = i; this.f = f; }
+}
+
+// There are debug info issues with TLS variables when LDC is built within older environments (incl. Travis).
+__gshared uv gvar;
+static this() { gvar = new xyz(12, 34.56); }
+
+int main()
+{
+    xyz[4] sarr;
+    xyz* ptr;
+    xyz lvar;
+
+    lvar = new xyz(99, 88.77);
+    lvar.d = 624.351;
+    sarr[2] = new xyz(2, 2.0);
+    sarr[2].d = 0.987;
+    ptr = &lvar;
+    // BP
+
+// GDB: b classtypes_gdb.d:37
+// GDB: r
+    return 0;
+// CHECK: D main
+
+// GDB: p lvar
+// CHECK: xyz{{ *}}*)
+
+// GDB: p *lvar
+// CHECK: i = 99}
+// CHECK-SAME: f = 88.7
+// CHECK-SAME: d = 624.35
+
+// GDB: p *ptr
+// CHECK: xyz{{ *}}*)
+
+// GDB: p **ptr
+// CHECK: i = 99}
+// CHECK-SAME: f = 88.7
+// CHECK-SAME: d = 624.35
+
+// GDB: p sarr
+// CHECK: {0x0,{{ *}}0x0,{{ *}}0x{{[0-9a-f][0-9a-f]+}},{{ *}}0x0}
+
+// GDB: p *sarr[2]
+// CHECK: i = 2}
+// CHECK-SAME: f = 2
+// CHECK-SAME: d = 0.98
+
+// GDB: p 'classtypes_gdb.gvar'
+// CHECK: uv{{ *}}*)
+// GDB: p *'classtypes_gdb.gvar'
+// CHECK: i = 12}{{$}}
+}
+
+// GDB: c
+// GDB: q
+// CHECK: exited normally
diff --git a/tests/lit.site.cfg.in b/tests/lit.site.cfg.in
index 9ebd30e..0a13f26 100644
--- a/tests/lit.site.cfg.in
+++ b/tests/lit.site.cfg.in
@@ -1,9 +1,12 @@
 import lit.formats
+import lit.util
 import os
 import sys
 import platform
 import string
+import re
 import subprocess
+from distutils.version import LooseVersion
 
 ## Auto-initialized variables by cmake:
 config.ldc2_bin            = "@LDC2_BIN@"
@@ -129,3 +132,18 @@ if (platform.system() == 'Windows') and (config.default_target_bits == 64):
 if (platform.system() == 'Windows') and os.path.isfile( cdb ):
     config.available_features.add('cdb')
     config.substitutions.append( ('%cdb', '"' + string.replace( cdb, '\\', '\\\\') + '"') )
+
+# Check whether GDB is present
+if lit.util.which('gdb', config.environment['PATH']):
+    config.available_features.add('gdb')
+    gdb_dflags = ''
+    command = ['gdb', '--version']
+    p = subprocess.Popen(command, stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE, universal_newlines=True)
+    text = p.stdout.readline()
+    m = re.compile('[^0-9]*([0-9]+[0-9.]*).*').match(text)
+    if m is not None:
+        gdb_version = m.group(1)
+        if LooseVersion(gdb_version) < LooseVersion('7.8'):
+            gdb_dflags = '-dwarf-version=2'
+    config.substitutions.append( ('%_gdb_dflags', gdb_dflags) )

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list