Skip to content

Commit 8c2a65f

Browse files
authored
Merge pull request #9294 from augusto2112/test-clang-importer-align
[lldb] Add test with custom alignment on a clang type
2 parents 534793f + 0d4b6a9 commit 8c2a65f

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-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: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
18+
19+
class TestSwiftClangImporterCustomAlignment(lldbtest.TestBase):
20+
21+
mydir = lldbtest.TestBase.compute_mydir(__file__)
22+
23+
@swiftTest
24+
@skipIf(setting=('symbols.use-swift-clangimporter', 'false'))
25+
def test(self):
26+
self.build()
27+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
28+
self, "break here", lldb.SBFileSpec("main.swift")
29+
)
30+
frame = thread.frames[0]
31+
v = frame.FindVariable("v")
32+
s = v.GetChildMemberWithName("s")
33+
34+
field_1 = s.GetChildMemberWithName("field_64_1")
35+
lldbutil.check_variable(self, field_1, False, value="100")
36+
37+
field_2 = s.GetChildMemberWithName("field_32_1")
38+
lldbutil.check_variable(self, field_2, False, value="200")
39+
40+
field_3 = s.GetChildMemberWithName("field_32_2")
41+
lldbutil.check_variable(self, field_3, False, value="300")
42+
43+
field_4 = s.GetChildMemberWithName("field_64_2")
44+
lldbutil.check_variable(self, field_4, False, value="400")
45+
46+
x = v.GetChildMemberWithName("x")
47+
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)