]> git.mxchange.org Git - flightgear.git/commitdiff
Initial integration of CrashRpt for Windows.
authorJames Turner <zakalawe@mac.com>
Sat, 18 Jan 2014 14:50:31 +0000 (14:50 +0000)
committerJames Turner <zakalawe@mac.com>
Sat, 18 Jan 2014 14:51:19 +0000 (14:51 +0000)
CMakeLists.txt
CMakeModules/FindCrashRpt.cmake [new file with mode: 0644]
src/Include/config_cmake.h.in
src/Main/CMakeLists.txt
src/Main/bootstrap.cxx
src/Main/main.cxx

index f3540fbb6632d255afefe19c43e14169df930478..510d779cb16bc04edb335845e3638cffdf2f1445 100644 (file)
@@ -203,6 +203,15 @@ find_package(OpenGL  REQUIRED)
 find_package(OpenAL  REQUIRED)
 find_package(OpenSceneGraph 3.0.0 REQUIRED osgText osgSim osgDB osgParticle osgFX osgUtil osgViewer osgGA)
 
+if (MSVC)
+       find_package(CrashRpt)
+       if (CRASHRPT_FOUND)
+               set(HAVE_CRASHRPT 1)
+               message(STATUS "Using CrashRpt")
+        include_directories( ${CRASHRPT_INCLUDE_DIR})
+       endif()
+endif()
+
 if(ENABLE_FGADMIN)
     find_package(FLTK)
 
diff --git a/CMakeModules/FindCrashRpt.cmake b/CMakeModules/FindCrashRpt.cmake
new file mode 100644 (file)
index 0000000..c7730a4
--- /dev/null
@@ -0,0 +1,31 @@
+# Find CrashRpt
+# ~~~~~~~~~~~~
+# Copyright (c) 2014, James Turner <zakalawe at mac dot com>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+# CMake module to search for CrashRpt library
+#
+# If it's found it sets CRASHRPT_FOUND to TRUE
+# and following variables are set:
+#    CRASHRPT_FOUND_INCLUDE_DIR
+#    CRASHRPT_FOUND_LIBRARY
+
+FIND_PATH(CRASHRPT_INCLUDE_DIR CrashRpt.h
+    PATH_SUFFIXES include 
+    HINTS $ENV{CRASHRPTDIR}
+    PATHS
+    ${ADDITIONAL_LIBRARY_PATHS}
+  )
+
+set(CRASHRPPT_LIBRARIES "")
+  
+FIND_LIBRARY(CRASHRPT_LIBRARY NAMES CrashRpt1402
+    HINTS $ENV{CRASHRPTDIR}
+    PATH_SUFFIXES lib
+    PATHS ${ADDITIONAL_LIBRARY_PATHS}
+  )
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(CRASHRPT DEFAULT_MSG 
+       CRASHRPT_LIBRARY CRASHRPT_INCLUDE_DIR)
index 1485016ce32f34139935a9954b6eb19ea40f7902..3c8295f651a4d10c8810c75c73e0bd0574236129 100644 (file)
@@ -42,3 +42,6 @@
 #cmakedefine ENABLE_IAX
 
 #cmakedefine HAVE_DBUS
+
+#cmakedefine HAVE_CRASHRPT
+
index 9167ec960d99d744b4ad6082e42a93cdbfc4253a..eb072b47d804b9d12aa34a5ae92a90788e237a3b 100644 (file)
@@ -109,6 +109,7 @@ target_link_libraries(fgfs
        ${JPEG_LIBRARY}
        ${HLA_LIBRARIES}
        ${EVENT_INPUT_LIBRARIES}
+       ${CRASHRPT_LIBRARY}
        ${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
        ${SIMGEAR_SCENE_LIBRARY_DEPENDENCIES}
        ${PLATFORM_LIBS}
index fe988d7e34f37552406b16ab6a82934b5fb15324..96b053b61b2830afe4127bcfe6a767e3992e63d0 100644 (file)
@@ -60,6 +60,7 @@ using std::endl;
 
 #include <Viewer/fgviewer.hxx>
 #include "main.hxx"
+#include <Include/version.h>
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <GUI/MessageBox.hxx>
@@ -70,6 +71,10 @@ using std::endl;
     #include <GUI/CocoaHelpers.h> // for transformToForegroundApp
 #endif
 
+#if defined(HAVE_CRASHRPT)
+       #include <CrashRpt.h>
+#endif
+
 std::string homedir;
 std::string hostname;
 
@@ -176,6 +181,41 @@ int main ( int argc, char **argv )
 #endif
     _bootstrap_OSInit = 0;
 
+#if defined(HAVE_CRASHRPT)
+       // Define CrashRpt configuration parameters
+       CR_INSTALL_INFO info;  
+       memset(&info, 0, sizeof(CR_INSTALL_INFO));  
+       info.cb = sizeof(CR_INSTALL_INFO);    
+       info.pszAppName = "FlightGear";
+       info.pszAppVersion = FLIGHTGEAR_VERSION;
+       info.pszEmailSubject = "FlightGear " FLIGHTGEAR_VERSION " crash report";
+       info.pszEmailTo = "fgcrash@goneabitbursar.com";
+       info.pszUrl = "http://fgfs.goneabitbursar.com/crashreporter/crashrpt.php";
+       info.uPriorities[CR_HTTP] = 3; 
+       info.uPriorities[CR_SMTP] = 2;  
+       info.uPriorities[CR_SMAPI] = 1;
+
+       // Install all available exception handlers
+       info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS;
+  
+       // Restart the app on crash 
+       info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS; 
+
+       // autoamticallty install handlers for all threads
+       info.dwFlags |= CR_INST_AUTO_THREAD_HANDLERS;
+
+       // Define the Privacy Policy URL 
+       info.pszPrivacyPolicyURL = "http://flightgear.org/crash-privacypolicy.html"; 
+  
+       // Install crash reporting
+       int nResult = crInstall(&info);    
+       if(nResult!=0) {
+               std::cerr << "failed to install crash reporting engine" << std::endl;
+       } else {
+               crAddProperty("hudson-build-id", HUDSON_BUILD_ID); 
+       }
+#endif
+
 #if defined(__FreeBSD__)
     // Ignore floating-point exceptions on FreeBSD
     signal(SIGFPE, SIG_IGN); 
@@ -224,8 +264,7 @@ int main ( int argc, char **argv )
             fgviewerMain(argc, argv);
         else
             fgMainInit(argc, argv);
-            
-        
+           
     } catch (const sg_throwable &t) {
         std::string info;
         if (std::strlen(t.getOrigin()) != 0)
@@ -245,6 +284,10 @@ int main ( int argc, char **argv )
             perror("Possible cause");
     }
 
+#if defined(HAVE_CRASHRPT)
+       crUninstall();
+#endif
+
     return 0;
 }
 
index a3b1338b3605cd0de75aaa337d32b9713c571c8f..2062a3796d74afb9a03b69cdfa8e9b252bcf380d 100644 (file)
 #include <osg/GraphicsContext>
 #include <osgDB/Registry>
 
+#if defined(HAVE_CRASHRPT)
+       #include <CrashRpt.h>
+#endif
+
 // Class references
 #include <simgear/canvas/VGInitOperation.hxx>
 #include <simgear/scene/model/modellib.hxx>
@@ -339,6 +343,10 @@ static void logToFile()
         logPath.append("fgfs.log");
     }
     sglog().logToFile(logPath, SG_ALL, SG_INFO);
+
+#if defined(HAVE_CRASHRPT)
+       crAddFile2(logPath.c_str(), NULL, "FlightGear Log File", CR_AF_MAKE_FILE_COPY);
+#endif
 }
 
 // Main top level initialization