Skip to content

[5.1][Reflection] Switch Remote Mirror back to uintptr_t for pointers on watchOS. #24530

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
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
34 changes: 25 additions & 9 deletions include/swift/SwiftRemoteMirror/SwiftRemoteMirrorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,23 @@
extern "C" {
#endif

typedef uint64_t swift_typeref_t;
// Pointers used here need to be pointer-sized on watchOS for binary
// compatibility. Everywhere else, they are 64-bit so 32-bit processes can
// potentially read from 64-bit processes.
#if defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h>
#if TARGET_OS_WATCH
#define SWIFT_REFLECTION_NATIVE_POINTERS 1
#endif
#endif

#if SWIFT_REFLECTION_NATIVE_POINTERS
typedef uintptr_t swift_reflection_ptr_t;
#else
typedef uint64_t swift_reflection_ptr_t;
#endif

typedef swift_reflection_ptr_t swift_typeref_t;

/// Represents one of the Swift reflection sections of an image.
typedef struct swift_reflection_section {
Expand All @@ -37,37 +53,37 @@ typedef struct swift_reflection_section {
typedef struct swift_reflection_info {
struct {
swift_reflection_section_t section;
uint64_t offset;
swift_reflection_ptr_t offset;
} field;

struct {
swift_reflection_section_t section;
uint64_t offset;
swift_reflection_ptr_t offset;
} associated_types;

struct {
swift_reflection_section_t section;
uint64_t offset;
swift_reflection_ptr_t offset;
} builtin_types;

struct {
swift_reflection_section_t section;
uint64_t offset;
swift_reflection_ptr_t offset;
} capture;

struct {
swift_reflection_section_t section;
uint64_t offset;
swift_reflection_ptr_t offset;
} type_references;

struct {
swift_reflection_section_t section;
uint64_t offset;
swift_reflection_ptr_t offset;
} reflection_strings;

// Start address in local and remote address spaces.
uint64_t LocalStartAddress;
uint64_t RemoteStartAddress;
swift_reflection_ptr_t LocalStartAddress;
swift_reflection_ptr_t RemoteStartAddress;
} swift_reflection_info_t;

/// The layout kind of a Swift type.
Expand Down
4 changes: 2 additions & 2 deletions stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ let RequestStringLength = "l"
let RequestDone = "d"
let RequestPointerSize = "p"

internal func debugLog(_ message: String) {
internal func debugLog(_ message: @autoclosure () -> String) {
#if DEBUG_LOG
fputs("Child: \(message)\n", stderr)
fputs("Child: \(message())\n", stderr)
fflush(stderr)
#endif
}
Expand Down