From 3de4c2956539a4251b65b88bff477d5866e98510 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Apr 2014 11:20:13 -0400 Subject: [PATCH] cmake: Print C++ stack trace after INTERNAL_ERROR messages Since an INTERNAL_ERROR is always a bug, it will be useful to have the program stack trace available in the report. --- Source/cmake.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 71ea3f51f..7aada4b6a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -24,6 +24,7 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmGraphVizWriter.h" # include "cmVariableWatch.h" +# include #endif #include @@ -2601,6 +2602,22 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, // Add a terminating blank line. msg << "\n"; +#if defined(CMAKE_BUILD_WITH_CMAKE) + // Add a C++ stack trace to internal errors. + if(t == cmake::INTERNAL_ERROR) + { + std::string stack = cmsys::SystemInformation::GetProgramStack(0,0); + if(!stack.empty()) + { + if(cmHasLiteralPrefix(stack, "WARNING:")) + { + stack = "Note:" + stack.substr(8); + } + msg << stack << "\n"; + } + } +#endif + // Output the message. if(isError) {