Skip to content

Commit 1a442ed

Browse files
committed
Add pretty stack trace entry for all index operations
In case we hit a crash during indexing, this will make it easier to identify the crash as coming from indexing vs from compilation.
1 parent d1227fb commit 1a442ed

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ static void emitIndexDataForSourceFile(SourceFile *PrimarySourceFile,
830830

831831
/// Emits index data for all primary inputs, or the main module.
832832
static void emitIndexData(const CompilerInstance &Instance) {
833+
llvm::PrettyStackTraceFormat trace("While emitting index data");
833834
if (Instance.getPrimarySourceFiles().empty()) {
834835
emitIndexDataForSourceFile(nullptr, Instance);
835836
} else {

lib/Index/Index.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,6 +2330,7 @@ void IndexSwiftASTWalker::collectRecursiveModuleImports(
23302330
//===----------------------------------------------------------------------===//
23312331

23322332
void index::indexDeclContext(DeclContext *DC, IndexDataConsumer &consumer) {
2333+
PrettyStackTraceDeclContext trace("indexing decl context", DC);
23332334
assert(DC);
23342335
SourceFile *SF = DC->getParentSourceFile();
23352336
IndexSwiftASTWalker walker(consumer, DC->getASTContext(), SF);
@@ -2338,6 +2339,7 @@ void index::indexDeclContext(DeclContext *DC, IndexDataConsumer &consumer) {
23382339
}
23392340

23402341
void index::indexSourceFile(SourceFile *SF, IndexDataConsumer &consumer) {
2342+
PrettyStackTraceDeclContext trace("indexing source file", SF);
23412343
assert(SF);
23422344
IndexSwiftASTWalker walker(consumer, SF->getASTContext(), SF);
23432345
walker.visitModule(*SF->getParentModule());

0 commit comments

Comments
 (0)