Skip to content

Commit

Permalink
Extend tests/debuginfo/args_cdb: Test small and large structs
Browse files Browse the repository at this point in the history
Previously, a single struct was tested, object.Interface. It's a larger
one which is rewritten by ExplicitByvalRewrite if passed by value. Add a
small struct (rewritten as integer) to test register-passing too.
  • Loading branch information
kinke committed Aug 27, 2017
1 parent f05620c commit 5a7f111
Showing 1 changed file with 51 additions and 32 deletions.
83 changes: 51 additions & 32 deletions tests/debuginfo/args_cdb.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ import core.simd;
// enable case sensitive symbol lookup
// CDB: .symopt-1

struct Small { size_t val; }
struct Large { size_t a, b, c, d, e, f, g, h; }

int byValue(ubyte ub, ushort us, uint ui, ulong ul,
float f, double d, real r,
cdouble c, int delegate() dg, int function() fun,
int[] slice, float[int] aa, ubyte[16] fa,
float4 f4, double4 d4,
Interface ifc, TypeInfo_Class ti, typeof(null) np)
Small small, Large large,
TypeInfo_Class ti, typeof(null) np)
{
// CDB: bp `args_cdb.d:25`
// CDB: bp `args_cdb.d:27`
// CDB: g
// arguments implicitly passed by reference on x64 and not shown if unused
float cim = c.im + fa[7] + dg() + ifc.offset;
float cim = c.im + fa[7] + dg() + large.a;
return 1;
// CHECK: !args_cdb.byValue
// CDB: dv /t
Expand All @@ -43,7 +47,8 @@ int byValue(ubyte ub, ushort us, uint ui, ulong ul,
// x86: unsigned char [16] fa
// x86: float [4] f4 = float [4]
// x86: double [4] d4 = double [4]
// x86: Interface ifc
// CHECK: Small small
// x86: Large large
// CHECK: struct TypeInfo_Class * ti = {{0x[0-9a-f`]*}}
// CHECK: void * np = {{0x[0`]*}}

Expand All @@ -54,7 +59,7 @@ int byValue(ubyte ub, ushort us, uint ui, ulong ul,
// x64: cdouble c =
// x64: int delegate() dg =
// x64: unsigned char [16] fa
// x64: Interface ifc
// x64: Large large

// check arguments with indirections
// CDB: ?? c
Expand All @@ -64,14 +69,14 @@ int byValue(ubyte ub, ushort us, uint ui, ulong ul,

// CDB: ?? dg
// CHECK: int delegate()
// CHECK-NEXT: context
// CHECK-NEXT: funcptr
// CHECK-NEXT: context :
// CHECK-NEXT: funcptr :
// CHECK-SAME: args_cdb.main.__lambda

// CDB: ?? slice
// CHECK: struct int[]
// CHECK-NEXT: length : 2
// CHECK-NEXT: ptr
// CHECK-NEXT: ptr :

// CDB: ?? fa[1]
// x64: unsigned char 0x0e
Expand All @@ -80,15 +85,17 @@ int byValue(ubyte ub, ushort us, uint ui, ulong ul,
// CDB: ?? f4[1]
// CHECK: float 16

// CDB: ?? d4[2]
// CDB: ?? d4[1]
// CHECK: double 17

// CDB: ?? ifc
// CDB: ?? small
// CHECK: val : 0x12

// CDB: ?? large
// 'Value unavailable error' on x64
// x86: Interface
// x86-NEXT: classinfo
// x86-NEXT: vtbl
// no-x86-NEXT: offset : 0x12 (displays 0)
// x86: Large
// x86-NEXT: a :
// x86-NEXT: b :

// CDB: ?? ti
// CHECK: TypeInfo_Class
Expand All @@ -100,9 +107,10 @@ int byPtr(ubyte* ub, ushort* us, uint* ui, ulong* ul,
cdouble* c, int delegate()* dg, int function()* fun,
int[]* slice, float[int]* aa, ubyte[16]* fa,
float4* f4, double4* d4,
Interface* ifc, TypeInfo_Class* ti, typeof(null)* np)
Small* small, Large* large,
TypeInfo_Class* ti, typeof(null)* np)
{
// CDB: bp `args_cdb.d:106`
// CDB: bp `args_cdb.d:113`
// CDB: g
return 3;
// CHECK: !args_cdb.byPtr
Expand All @@ -127,8 +135,8 @@ int byPtr(ubyte* ub, ushort* us, uint* ui, ulong* ul,
// CHECK-NEXT: im : 9
// CDB: ?? *dg
// CHECK: int delegate()
// CHECK-NEXT: context
// CHECK-NEXT: funcptr
// CHECK-NEXT: context :
// CHECK-NEXT: funcptr :
// CHECK-SAME: args_cdb.main.__lambda
// CDB: ?? *fun
// CHECK: <function> *
Expand All @@ -145,9 +153,13 @@ int byPtr(ubyte* ub, ushort* us, uint* ui, ulong* ul,
// CHECK: float 16
// CDB: ?? (*d4)[2]
// CHECK: double 17
// CDB: ?? *ifc
// CHECK: struct Interface
// CHECK: offset : 0x12
// CDB: ?? *small
// CHECK: struct Small
// CHECK-NEXT: val : 0x12
// CDB: ?? *large
// CHECK: struct Large
// CHECK-NEXT: a : 0x13
// CHECK-NEXT: b :
// CDB: ?? *ti
// CHECK: struct TypeInfo_Class
// CHECK-NEXT: m_init : byte[]
Expand All @@ -161,9 +173,10 @@ int byRef(ref ubyte ub, ref ushort us, ref uint ui, ref ulong ul,
ref cdouble c, ref int delegate() dg, ref int function() fun,
ref int[] slice, ref float[int] aa, ref ubyte[16] fa,
ref float4 f4, ref double4 d4,
ref Interface ifc, ref TypeInfo_Class ti, ref typeof(null) np)
ref Small small, ref Large large,
ref TypeInfo_Class ti, ref typeof(null) np)
{
// CDB: bp `args_cdb.d:218`
// CDB: bp `args_cdb.d:179`
// CDB: g
// CHECK: !args_cdb.byRef

Expand All @@ -189,7 +202,7 @@ int byRef(ref ubyte ub, ref ushort us, ref uint ui, ref ulong ul,
// CHECK-NEXT: im : 9
// CDB: ?? *dg
// CHECK: int delegate()
// CHECK-NEXT: context
// CHECK-NEXT: context :
// CHECK-NEXT: funcptr : {{0x[0-9a-f`]*}}
// CHECK-SAME: args_cdb.main.__lambda
// CDB: ?? *fun
Expand All @@ -206,9 +219,13 @@ int byRef(ref ubyte ub, ref ushort us, ref uint ui, ref ulong ul,
// CHECK: float 16
// CDB: ?? (*d4)[2]
// CHECK: double 17
// CDB: ?? *ifc
// CHECK: struct Interface
// CHECK: offset : 0x12
// CDB: ?? *small
// CHECK: struct Small
// CHECK-NEXT: val : 0x12
// CDB: ?? *large
// CHECK: struct Large
// CHECK-NEXT: a : 0x13
// CHECK-NEXT: b :
// CDB: ?? *ti
// CHECK: struct TypeInfo_Class * {{0x[0-9a-f`]*}}
// CHECK-NEXT: m_init : byte[]
Expand All @@ -231,7 +248,8 @@ int byRef(ref ubyte ub, ref ushort us, ref uint ui, ref ulong ul,
fa[0]++;
f4.array[0] = f4.array[0] + 1;
d4.array[0] = d4.array[0] + 1;
ifc = Interface(typeid(Object), null, 18);
small.val++;
large.a++;
ti = typeid(TypeInfo);
np = null;
return 2;
Expand All @@ -254,13 +272,14 @@ int main()
ubyte[16] fa; fa[] = 14;
float4 f4 = 16;
double4 d4 = 17;
Interface ifc = Interface(typeid(Object), null, 18);
Small small = Small(18);
Large large = Large(19);
TypeInfo_Class ti = typeid(TypeInfo);
typeof(null) np = null;

byValue(ub, us, ui, ul, f, d, r, c, dg, fun, slice, aa, fa, f4, d4, ifc, ti, np);
byPtr(&ub, &us, &ui, &ul, &f, &d, &r, &c, &dg, &fun, &slice, &aa, &fa, &f4, &d4, &ifc, &ti, &np);
byRef(ub, us, ui, ul, f, d, r, c, dg, fun, slice, aa, fa, f4, d4, ifc, ti, np);
byValue(ub, us, ui, ul, f, d, r, c, dg, fun, slice, aa, fa, f4, d4, small, large, ti, np);
byPtr(&ub, &us, &ui, &ul, &f, &d, &r, &c, &dg, &fun, &slice, &aa, &fa, &f4, &d4, &small, &large, &ti, &np);
byRef(ub, us, ui, ul, f, d, r, c, dg, fun, slice, aa, fa, f4, d4, small, large, ti, np);

return 0;
}
Expand Down

0 comments on commit 5a7f111

Please sign in to comment.