Skip to content

Commit 6bd2e12

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents e8dd2fe + 56a73c9 commit 6bd2e12

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class ReflectionContext
288288
}
289289

290290
#elif defined(_WIN32)
291-
bool addImage(RemoteAddress ImageStart) {
291+
bool readPECOFFSections(RemoteAddress ImageStart) {
292292
auto DOSHdrBuf = this->getReader().readBytes(
293293
ImageStart, sizeof(llvm::object::dos_header));
294294
auto DOSHdr =
@@ -380,6 +380,29 @@ class ReflectionContext
380380
return true;
381381
}
382382

383+
bool addImage(RemoteAddress ImageStart) {
384+
auto Buf = this->getReader().readBytes(ImageStart,
385+
sizeof(llvm::object::dos_header));
386+
if (!Buf)
387+
return false;
388+
389+
auto DOSHdr = reinterpret_cast<const llvm::object::dos_header *>(Buf.get());
390+
if (!(DOSHdr->Magic[0] == 'M' && DOSHdr->Magic[1] == 'Z'))
391+
return false;
392+
393+
auto PEHeaderAddress =
394+
ImageStart.getAddressData() + DOSHdr->AddressOfNewExeHeader;
395+
396+
Buf = this->getReader().readBytes(RemoteAddress(PEHeaderAddress),
397+
sizeof(llvm::COFF::PEMagic));
398+
if (!Buf)
399+
return false;
400+
401+
if (memcmp(Buf.get(), llvm::COFF::PEMagic, sizeof(llvm::COFF::PEMagic)))
402+
return false;
403+
404+
return readPECOFFSections(ImageStart);
405+
}
383406
#else // ELF platforms.
384407
template <typename T> bool readELFSections(RemoteAddress ImageStart) {
385408
auto Buf =

lib/Basic/Default/TaskQueue.inc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,22 @@ bool TaskQueue::execute(TaskBeganCallback Began, TaskFinishedCallback Finished,
143143
stderrContents = stderrBuffer.get()->getBuffer();
144144
}
145145

146-
if (ReturnCode == -2) {
146+
#if defined(_WIN32)
147+
// Wait() sets the upper two bits of the return code to indicate warnings
148+
// (10) and errors (11).
149+
//
150+
// This isn't a true signal on Windows, but we'll treat it as such so that
151+
// we clean up after it properly
152+
bool crashed = ReturnCode & 0xC0000000;
153+
#else
147154
// Wait() returning a return code of -2 indicates the process received
148155
// a signal during execution.
156+
bool crashed = ReturnCode == -2;
157+
#endif
158+
if (crashed) {
149159
if (Signalled) {
150160
TaskFinishedResponse Response =
151-
Signalled(PI.Pid, ErrMsg, stdoutContents, stderrContents, T->Context, None, TaskProcessInformation(PI.Pid));
161+
Signalled(PI.Pid, ErrMsg, stdoutContents, stderrContents, T->Context, ReturnCode, TaskProcessInformation(PI.Pid));
152162
ContinueExecution = Response != TaskFinishedResponse::StopExecution;
153163
} else {
154164
// If we don't have a Signalled callback, unconditionally stop.

test/Driver/assert.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Windows programs cannot fail due to a signal
2-
// UNSUPPORTED: windows
31
// RUN: not %swiftc_driver -emit-executable -o %t.exe %s -Xfrontend -debug-assert-immediately 2>&1 | %FileCheck %s
42
// RUN: not %swiftc_driver -emit-executable -o %t.exe %s -Xfrontend -debug-assert-after-parse 2>&1 | %FileCheck %s
53

test/Driver/crash.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Windows programs cannot fail due to a signal
2-
// UNSUPPORTED: windows
31
// RUN: not %swiftc_driver -emit-executable -o %t.exe %s -Xfrontend -debug-crash-immediately 2>&1 | %FileCheck %s
42

53
// RUN: not %swiftc_driver -emit-executable -o %t.exe %s -Xfrontend -debug-crash-after-parse 2>&1 | %FileCheck %s

0 commit comments

Comments
 (0)