Skip to content

Commit 2fd0b39

Browse files
committed
SwiftRemoteMirror: move dump APIs to print to stdout instead of stderr
Rather than move file descriptors around in the tools, just tell the underlying ::dump methods to print to stdout instead.
1 parent c90ee3c commit 2fd0b39

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ int swift_reflection_projectExistential(SwiftReflectionContextRef ContextRef,
273273
void swift_reflection_dumpTypeRef(swift_typeref_t OpaqueTypeRef) {
274274
auto TR = reinterpret_cast<const TypeRef *>(OpaqueTypeRef);
275275
if (TR == nullptr) {
276-
std::cerr << "<null type reference>\n";
276+
std::cout << "<null type reference>\n";
277277
} else {
278-
TR->dump();
278+
TR->dump(std::cout);
279279
}
280280
}
281281

@@ -285,9 +285,9 @@ void swift_reflection_dumpInfoForTypeRef(SwiftReflectionContextRef ContextRef,
285285
auto TR = reinterpret_cast<const TypeRef *>(OpaqueTypeRef);
286286
auto TI = Context->getTypeInfo(TR);
287287
if (TI == nullptr) {
288-
std::cerr << "<null type info>\n";
288+
std::cout << "<null type info>\n";
289289
} else {
290-
TI->dump();
290+
TI->dump(std::cout);
291291
}
292292
}
293293

@@ -296,9 +296,9 @@ void swift_reflection_dumpInfoForMetadata(SwiftReflectionContextRef ContextRef,
296296
auto Context = reinterpret_cast<NativeReflectionContext *>(ContextRef);
297297
auto TI = Context->getMetadataTypeInfo(Metadata);
298298
if (TI == nullptr) {
299-
std::cerr << "<null type info>\n";
299+
std::cout << "<null type info>\n";
300300
} else {
301-
TI->dump();
301+
TI->dump(std::cout);
302302
}
303303
}
304304

@@ -307,9 +307,9 @@ void swift_reflection_dumpInfoForInstance(SwiftReflectionContextRef ContextRef,
307307
auto Context = reinterpret_cast<NativeReflectionContext *>(ContextRef);
308308
auto TI = Context->getInstanceTypeInfo(Object);
309309
if (TI == nullptr) {
310-
std::cerr << "<null type info>\n";
310+
std::cout << "<null type info>\n";
311311
} else {
312-
TI->dump();
312+
TI->dump(std::cout);
313313
}
314314
}
315315

tools/swift-reflection-test/swift-reflection-test.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,13 @@ int doDumpHeapInstance(const char *BinaryFilename) {
394394
close(PipeMemoryReader_getParentWriteFD(&Pipe));
395395
close(PipeMemoryReader_getParentReadFD(&Pipe));
396396
dup2(PipeMemoryReader_getChildReadFD(&Pipe), STDIN_FILENO);
397-
dup2(PipeMemoryReader_getChildWriteFD(&Pipe), STDERR_FILENO);
398397
dup2(PipeMemoryReader_getChildWriteFD(&Pipe), STDOUT_FILENO);
399398
_execv(BinaryFilename, NULL);
400399
exit(EXIT_SUCCESS);
401400
}
402401
default: { // Parent
403402
close(PipeMemoryReader_getChildReadFD(&Pipe));
404403
close(PipeMemoryReader_getChildWriteFD(&Pipe));
405-
dup2(STDOUT_FILENO, STDERR_FILENO);
406404
SwiftReflectionContextRef RC = swift_reflection_createReflectionContext(
407405
(void*)&Pipe,
408406
PipeMemoryReader_getPointerSize,
@@ -414,7 +412,7 @@ int doDumpHeapInstance(const char *BinaryFilename) {
414412
uint8_t PointerSize = PipeMemoryReader_getPointerSize((void*)&Pipe);
415413
if (PointerSize != sizeof(uintptr_t))
416414
errorAndExit("Child process had unexpected architecture");
417-
415+
418416
PipeMemoryReader_receiveReflectionInfo(RC, &Pipe);
419417

420418
while (1) {

validation-test/Reflection/example.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: rm -rf %t && mkdir -p %t
22
// RUN: %target-build-swift -Xfrontend -enable-reflection-metadata -Xfrontend -enable-reflection-names -lswiftSwiftReflectionTest %s -o %t/example
3-
// RUN: %target-run %target-swift-reflection-test %t/example 2>&1 | FileCheck %s --check-prefix=CHECK-%target-ptrsize
3+
// RUN: %target-run %target-swift-reflection-test %t/example | FileCheck %s --check-prefix=CHECK-%target-ptrsize
44
// REQUIRES: objc_interop
55

66
import SwiftReflectionTest

validation-test/Reflection/existentials.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: rm -rf %t && mkdir -p %t
22
// RUN: %target-build-swift -Xfrontend -enable-reflection-metadata -Xfrontend -enable-reflection-names -lswiftSwiftReflectionTest %s -o %t/existentials
3-
// RUN: %target-run %target-swift-reflection-test %t/existentials 2>&1 | FileCheck %s --check-prefix=CHECK-%target-ptrsize
3+
// RUN: %target-run %target-swift-reflection-test %t/existentials | FileCheck %s --check-prefix=CHECK-%target-ptrsize
44
// REQUIRES: objc_interop
55

66
/*

0 commit comments

Comments
 (0)