Skip to content

Add PrettyStackTraceSwiftVersion, and use it in the swiftc executable #24235

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 1 commit into from
Apr 24, 2019
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
6 changes: 6 additions & 0 deletions include/swift/Basic/PrettyStackTrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class PrettyStackTraceFileContents : public llvm::PrettyStackTraceEntry {
void print(llvm::raw_ostream &OS) const override;
};

/// A PrettyStackTraceEntry to print the version of the compiler.
class PrettyStackTraceSwiftVersion : public llvm::PrettyStackTraceEntry {
public:
void print(llvm::raw_ostream &OS) const override;
};

} // end namespace swift

#endif // SWIFT_BASIC_PRETTYSTACKTRACE_H
5 changes: 5 additions & 0 deletions lib/Basic/PrettyStackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "swift/Basic/PrettyStackTrace.h"
#include "swift/Basic/QuotedString.h"
#include "swift/Basic/Version.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"

Expand All @@ -33,3 +34,7 @@ void PrettyStackTraceFileContents::print(llvm::raw_ostream &out) const {
out << '\n';
out << "---\n";
}

void PrettyStackTraceSwiftVersion::print(llvm::raw_ostream &out) const {
out << version::getSwiftFullVersion() << '\n';
}
1 change: 1 addition & 0 deletions test/Frontend/crash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Check that we see the contents of the input file list in the crash log.
// CHECK-LABEL: Stack dump
// CHECK-NEXT: Program arguments: {{.*swift(c?)(.EXE)?}} -frontend
// CHECK-NEXT: Swift version
// CHECK-NEXT: Contents of {{.*}}.filelist.txt:
// CHECK-NEXT: ---
// CHECK-NEXT: test{{[\\/]}}Frontend{{[\\/]}}crash.swift{{$}}
Expand Down
3 changes: 3 additions & 0 deletions tools/driver/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "swift/AST/DiagnosticEngine.h"
#include "swift/Basic/LLVMInitialize.h"
#include "swift/Basic/PrettyStackTrace.h"
#include "swift/Basic/Program.h"
#include "swift/Basic/TaskQueue.h"
#include "swift/Basic/SourceManager.h"
Expand Down Expand Up @@ -224,6 +225,8 @@ int main(int argc_, const char **argv_) {
PROGRAM_START(ThrowawayExpandedArgc, ThrowawayExpandedArgv);
ArrayRef<const char *> argv(ExpandedArgs);

PrettyStackTraceSwiftVersion versionStackTrace;

// Check if this invocation should execute a subcommand.
StringRef ExecName = llvm::sys::path::stem(argv[0]);
SmallString<256> SubcommandName;
Expand Down