Skip to content

swift-reflection-test: Target SwiftRemoteMirror C API #2335

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 3 commits into from
Apr 29, 2016
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
2 changes: 1 addition & 1 deletion include/swift/Remote/CMemoryReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class CMemoryReader final : public MemoryReader {

bool readBytes(RemoteAddress address, uint8_t *dest, uint64_t size) override {
return Impl.readBytes(Impl.reader_context,
address.getAddressData(), dest, size);
address.getAddressData(), dest, size) != 0;
}
};

Expand Down
2 changes: 1 addition & 1 deletion include/swift/SwiftRemoteMirror/MemoryReaderInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef uint64_t addr_t;

typedef uint8_t (*PointerSizeFunction)(void *reader_context);
typedef uint8_t (*SizeSizeFunction)(void * reader_context);
typedef bool (*ReadBytesFunction)(void * reader_context, addr_t address,
typedef int (*ReadBytesFunction)(void * reader_context, addr_t address,
uint8_t *dest, uint64_t size);
typedef uint64_t (*GetStringLengthFunction)(void * reader_context,
addr_t address);
Expand Down
11 changes: 6 additions & 5 deletions include/swift/SwiftRemoteMirror/SwiftRemoteMirror.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef SWIFT_REFLECTION_SWIFT_REFLECTION_H
#define SWIFT_REFLECTION_SWIFT_REFLECTION_H

#include "MemoryReaderInterface.h"
#include "SwiftRemoteMirrorTypes.h"

/// Major version changes when there are ABI or source incompatible changes.
Expand Down Expand Up @@ -117,11 +118,11 @@ swift_reflection_genericArgumentOfTypeRef(swift_typeref_t OpaqueTypeRef,
///
/// Returns true if InstanceTypeRef and StartOfInstanceData contain valid
/// valid values.
bool swift_reflection_projectExistential(SwiftReflectionContextRef ContextRef,
addr_t InstanceAddress,
swift_typeref_t ExistentialTypeRef,
swift_typeref_t *OutInstanceTypeRef,
addr_t *OutStartOfInstanceData);
int swift_reflection_projectExistential(SwiftReflectionContextRef ContextRef,
addr_t InstanceAddress,
swift_typeref_t ExistentialTypeRef,
swift_typeref_t *OutInstanceTypeRef,
addr_t *OutStartOfInstanceData);

/// Dump a brief description of the typeref as a tree to stderr.
void swift_reflection_dumpTypeRef(swift_typeref_t OpaqueTypeRef);
Expand Down
2 changes: 2 additions & 0 deletions include/swift/SwiftRemoteMirror/SwiftRemoteMirrorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef SWIFT_REMOTE_MIRROR_TYPES_H
#define SWIFT_REMOTE_MIRROR_TYPES_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
12 changes: 5 additions & 7 deletions stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include "swift/Remote/CMemoryReader.h"
#include "swift/SwiftRemoteMirror/SwiftRemoteMirror.h"

#include <iostream>

using namespace swift;
using namespace swift::reflection;
using namespace swift::remote;
Expand Down Expand Up @@ -214,11 +212,11 @@ swift_reflection_childOfMetadata(SwiftReflectionContextRef ContextRef,
return convertChild(TI, Index);
}

bool swift_reflection_project_existential(SwiftReflectionContextRef ContextRef,
addr_t InstanceAddress,
swift_typeref_t ExistentialTypeRef,
swift_typeref_t *InstanceTypeRef,
addr_t *StartOfInstanceData) {
int swift_reflection_project_existential(SwiftReflectionContextRef ContextRef,
addr_t InstanceAddress,
swift_typeref_t ExistentialTypeRef,
swift_typeref_t *InstanceTypeRef,
addr_t *StartOfInstanceData) {
// TODO
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ config.substitutions.append(
(subst_target_swift_ide_test_mock_sdk,
subst_target_swift_ide_test_mock_sdk_after)))
config.substitutions.append(('%target-swift-ide-test', config.target_swift_ide_test))
config.substitutions.append(('%target-swift-reflection-test', 'swift-reflection-test{variant_suffix} {arch}'.format(variant_suffix=config.variant_suffix, arch=run_cpu)))
config.substitutions.append(('%target-swift-reflection-test', 'swift-reflection-test{variant_suffix}'.format(variant_suffix=config.variant_suffix)))
config.substitutions.append(('%target-swift-reflection-dump', '{} {} {}'.format(config.swift_reflection_dump, '-arch', run_cpu)))
config.substitutions.append(('%target-swiftc_driver', config.target_swiftc_driver))
config.substitutions.append(('%target-swift-remoteast-test-with-sdk',
Expand Down
5 changes: 2 additions & 3 deletions tools/swift-reflection-test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
add_swift_target_executable(swift-reflection-test BUILD_WITH_STDLIB
swift-reflection-test.cpp
overrides.cpp
swift-reflection-test.c
overrides.c
LINK_FAT_LIBRARIES
swiftReflection
swiftRemoteMirror)

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "overrides.h"

extern "C" {
extern pid_t fork(void);
extern int execv(const char *path, char * const *argv);
}

pid_t _fork(void) {
return fork();
Expand Down
Loading