Skip to content

Commit be8fe83

Browse files
authored
Merge pull request swiftlang#28511 from tapthaker/SR-11765-pretty-stack-trace
2 parents 3170017 + 322ad48 commit be8fe83

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,12 @@ static bool processCommandLineAndRunImmediately(CompilerInvocation &Invocation,
13761376
ProcessCmdLine(opts.ImmediateArgv.begin(), opts.ImmediateArgv.end());
13771377
Instance.setSILModule(std::move(SM));
13781378

1379+
1380+
PrettyStackTraceStringAction trace(
1381+
"running user code",
1382+
MSF.is<SourceFile *>() ? MSF.get<SourceFile *>()->getFilename()
1383+
: MSF.get<ModuleDecl *>()->getModuleFilename());
1384+
13791385
ReturnValue =
13801386
RunImmediately(Instance, CmdLine, IRGenOpts, Invocation.getSILOptions());
13811387
return Instance.getASTContext().hadError();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
// RUN: echo %s > %t.filelist.txt
3+
// RUN: not --crash %target-swift-frontend -interpret -filelist %t.filelist.txt 2>&1 | %FileCheck %s
4+
5+
// UNSUPPORTED: OS=ios
6+
// UNSUPPORTED: OS=tvos
7+
// UNSUPPORTED: OS=watchos
8+
9+
// CHECK: Stack dump:
10+
// CHECK-NEXT: Program arguments:
11+
// CHECK-NEXT: Swift version
12+
// CHECK-NEXT: Contents of {{.*}}.filelist.txt:
13+
// CHECK-NEXT: ---
14+
// CHECK-NEXT: crash-in-user-code.swift
15+
// CHECK-NEXT: ---
16+
// CHECK-NEXT: While running user code "{{.*}}crash-in-user-code.swift"
17+
18+
let x: Int? = nil
19+
x!

0 commit comments

Comments
 (0)