From b9c8a24d04d5e5b3107656d8e03e21d3816c081e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 18 Feb 2010 20:22:25 +0000 Subject: [PATCH] Introduce debugging/testing hook clang_enableStackTraces() into CIndex, so that c-index-test to use it to call lvm::sys::PrintStackTraceOnErrorSignal(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96607 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang-c/Index.h | 4 ++-- tools/CIndex/CIndex.cpp | 5 +++++ tools/CIndex/CIndex.exports | 1 + tools/c-index-test/c-index-test.c | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index eeb76a3429..0130b72b6f 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -507,7 +507,7 @@ CINDEX_LINKAGE void clang_displayDiagnostic(CXDiagnostic Diagnostic, * \returns A set of display options suitable for use with \c * clang_displayDiagnostic(). */ -CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(); +CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void); /** * \brief Print a diagnostic to the given file. @@ -1322,7 +1322,7 @@ CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor, unsigned *startColumn, unsigned *endLine, unsigned *endColumn); - +CINDEX_LINKAGE void clang_enableStackTraces(void); /** * @} */ diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index 128b3b6e99..6e07ece4c3 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -27,6 +27,7 @@ #include "clang/Lex/Preprocessor.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/System/Program.h" +#include "llvm/System/Signals.h" // Needed to define L_TMPNAM on some systems. #include @@ -1935,6 +1936,10 @@ void clang_getDefinitionSpellingAndExtent(CXCursor C, *endColumn = SM.getSpellingColumnNumber(Body->getRBracLoc()); } +void clang_enableStackTraces(void) { + llvm::sys::PrintStackTraceOnErrorSignal(); +} + } // end: extern "C" //===----------------------------------------------------------------------===// diff --git a/tools/CIndex/CIndex.exports b/tools/CIndex/CIndex.exports index 0b4ef21bac..449bb95a94 100644 --- a/tools/CIndex/CIndex.exports +++ b/tools/CIndex/CIndex.exports @@ -13,6 +13,7 @@ _clang_disposeIndex _clang_disposeString _clang_disposeTokens _clang_disposeTranslationUnit +_clang_enableStackTraces _clang_equalCursors _clang_equalLocations _clang_getClangVersion diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index f5492b757d..c5f8431c34 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -1009,6 +1009,7 @@ static void print_usage(void) { } int main(int argc, const char **argv) { + clang_enableStackTraces(); if (argc > 2 && strstr(argv[1], "-code-completion-at=") == argv[1]) return perform_code_completion(argc, argv); if (argc > 2 && strstr(argv[1], "-cursor-at=") == argv[1]) -- 2.40.0