summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-04-17 15:20:13 (GMT)
committerBrad King <brad.king@kitware.com>2014-04-17 15:25:19 (GMT)
commit3de4c2956539a4251b65b88bff477d5866e98510 (patch)
tree72aa8f8d41f245603fe21778ef63221849c6a7d6
parent5265a5dc2aa5b870ad6b85b7ffe2a831c6dba0d9 (diff)
downloadCMake-3de4c2956539a4251b65b88bff477d5866e98510.zip
CMake-3de4c2956539a4251b65b88bff477d5866e98510.tar.gz
CMake-3de4c2956539a4251b65b88bff477d5866e98510.tar.bz2
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.
-rw-r--r--Source/cmake.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 71ea3f5..7aada4b 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 <cmsys/SystemInformation.hxx>
#endif
#include <cmsys/Glob.hxx>
@@ -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)
{