Skip to content

Commit 935e266

Browse files
committed
[lldb] Add test with custom alignment on a clang type
rdar://127785973
1 parent 610530c commit 935e266

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFTFLAGS_EXTRAS = -I$(SRCDIR)
3+
4+
include Makefile.rules
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# TestSwiftClangImporterCustomAlignment.py
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
# ------------------------------------------------------------------------------
12+
import lldb
13+
from lldbsuite.test.decorators import *
14+
import lldbsuite.test.lldbtest as lldbtest
15+
import lldbsuite.test.lldbutil as lldbutil
16+
import os
17+
import unittest2
18+
19+
20+
class TestSwiftClangImporterCustomAlignment(lldbtest.TestBase):
21+
22+
mydir = lldbtest.TestBase.compute_mydir(__file__)
23+
24+
@swiftTest
25+
@skipIf(setting=('symbols.use-swift-clangimporter', 'false'))
26+
def test(self):
27+
self.build()
28+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
29+
self, "break here", lldb.SBFileSpec("main.swift")
30+
)
31+
frame = thread.frames[0]
32+
v = frame.FindVariable("v")
33+
s = v.GetChildMemberWithName("s")
34+
35+
field_1 = s.GetChildMemberWithName("field_64_1")
36+
lldbutil.check_variable(self, field_1, False, value="100")
37+
38+
field_2 = s.GetChildMemberWithName("field_32_1")
39+
lldbutil.check_variable(self, field_2, False, value="200")
40+
41+
field_3 = s.GetChildMemberWithName("field_32_2")
42+
lldbutil.check_variable(self, field_3, False, value="300")
43+
44+
field_4 = s.GetChildMemberWithName("field_64_2")
45+
lldbutil.check_variable(self, field_4, False, value="400")
46+
47+
x = v.GetChildMemberWithName("x")
48+
lldbutil.check_variable(self, x, False, value="1")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "stdlib.h"
2+
#include <stdint.h>
3+
4+
#pragma pack(push, 4)
5+
6+
struct Struct {
7+
int64_t field_64_1;
8+
int32_t field_32_1;
9+
uint32_t field_32_2;
10+
int64_t field_64_2;
11+
};
12+
13+
#pragma pack(pop)
14+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Module
2+
3+
struct Value {
4+
var x: Int32 = 1
5+
var s = Struct()
6+
}
7+
8+
func f() {
9+
var v = Value()
10+
v.s.field_64_1 = 100;
11+
v.s.field_32_1 = 200;
12+
v.s.field_32_2 = 300;
13+
v.s.field_64_2 = 400;
14+
print(v) // break here
15+
}
16+
17+
f()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Module {
2+
header "header.h"
3+
export *
4+
}

0 commit comments

Comments
 (0)