Skip to content

[lldb] Add test with custom alignment on a clang type #9294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SWIFT_SOURCES := main.swift
SWIFTFLAGS_EXTRAS = -I$(SRCDIR)

include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# TestSwiftClangImporterCustomAlignment.py
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# ------------------------------------------------------------------------------
import lldb
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbtest as lldbtest
import lldbsuite.test.lldbutil as lldbutil
import os


class TestSwiftClangImporterCustomAlignment(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@swiftTest
@skipIf(setting=('symbols.use-swift-clangimporter', 'false'))
def test(self):
self.build()
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
self, "break here", lldb.SBFileSpec("main.swift")
)
frame = thread.frames[0]
v = frame.FindVariable("v")
s = v.GetChildMemberWithName("s")

field_1 = s.GetChildMemberWithName("field_64_1")
lldbutil.check_variable(self, field_1, False, value="100")

field_2 = s.GetChildMemberWithName("field_32_1")
lldbutil.check_variable(self, field_2, False, value="200")

field_3 = s.GetChildMemberWithName("field_32_2")
lldbutil.check_variable(self, field_3, False, value="300")

field_4 = s.GetChildMemberWithName("field_64_2")
lldbutil.check_variable(self, field_4, False, value="400")

x = v.GetChildMemberWithName("x")
lldbutil.check_variable(self, x, False, value="1")
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "stdlib.h"
#include <stdint.h>

#pragma pack(push, 4)

struct Struct {
int64_t field_64_1;
int32_t field_32_1;
uint32_t field_32_2;
int64_t field_64_2;
};

#pragma pack(pop)

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Module

struct Value {
var x: Int32 = 1
var s = Struct()
}

func f() {
var v = Value()
v.s.field_64_1 = 100;
v.s.field_32_1 = 200;
v.s.field_32_2 = 300;
v.s.field_64_2 = 400;
print(v) // break here
}

f()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Module {
header "header.h"
export *
}