From 3729745fc62d43ffefcdab07caa42738221e9281 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Tue, 30 Jul 2013 19:33:14 -0700 Subject: [PATCH] Add ripple::FatalErrorReporter --- Builds/VisualStudio2012/RippleD.vcxproj | 66 ++++++++++++++++--- .../VisualStudio2012/RippleD.vcxproj.filters | 47 ++++++++++--- Notes/VFALCO_LOG.txt | 6 ++ TODO.txt => Notes/VFALCO_TODO.txt | 42 +++++++----- .../main/ripple_FatalErrorReporter.cpp | 55 ++++++++++++++++ .../main/ripple_FatalErrorReporter.h | 33 ++++++++++ modules/ripple_app/main/ripple_Main.cpp | 2 + modules/ripple_app/ripple_app.cpp | 2 + 8 files changed, 218 insertions(+), 35 deletions(-) create mode 100644 Notes/VFALCO_LOG.txt rename TODO.txt => Notes/VFALCO_TODO.txt (97%) create mode 100644 modules/ripple_app/main/ripple_FatalErrorReporter.cpp create mode 100644 modules/ripple_app/main/ripple_FatalErrorReporter.h diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj index 316da8440f..f759967abb 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj +++ b/Builds/VisualStudio2012/RippleD.vcxproj @@ -175,6 +175,12 @@ true true + + true + true + true + true + true true @@ -437,14 +443,54 @@ true true - - - - - - - - + + false + false + false + false + + + false + false + false + false + + + false + false + false + false + + + false + false + false + false + + + false + false + false + false + + + false + false + false + false + + + false + false + false + false + + + false + false + false + false + true true @@ -1350,6 +1396,7 @@ + @@ -1609,7 +1656,8 @@ - + + {B7F39ECD-473C-484D-BC34-31F8362506A5} diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters index 7ebed7d71f..f0fe68b284 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters @@ -154,6 +154,12 @@ {82a6d3f3-fa01-4cc6-9730-f928e61b9929} + + {73c81ca5-1f7e-4ffc-bb42-72306afc78ed} + + + {c69b07a2-44e5-4b06-99a9-81f5d137ea15} + @@ -873,6 +879,9 @@ [1] Ripple\ripple_app\basics + + [1] Ripple\ripple_app\main + @@ -881,7 +890,6 @@ [0] Subtrees\sqlite - [1] Ripple\ripple_app @@ -1659,6 +1667,12 @@ [1] Ripple\ripple_app\basics + + [1] Ripple\ripple_app\main + + + [2] Build + @@ -1675,14 +1689,31 @@ [1] Ripple\ripple_json\json - - - - - - + + %28Notes%29 + + + %28Notes%29 + + + [2] Build + + + [2] Build + + + [2] Build + + + [2] Build + - + + %28Notes%29 + + + %28Notes%29 + \ No newline at end of file diff --git a/Notes/VFALCO_LOG.txt b/Notes/VFALCO_LOG.txt new file mode 100644 index 0000000000..fb0a892f25 --- /dev/null +++ b/Notes/VFALCO_LOG.txt @@ -0,0 +1,6 @@ +Vinnie Falco's Change Log + +2013/07/30 + +- Add FatalErrorReporter to main +- Rewrote the build and protocol version numbering code diff --git a/TODO.txt b/Notes/VFALCO_TODO.txt similarity index 97% rename from TODO.txt rename to Notes/VFALCO_TODO.txt index 75efe6c797..7acb0598a8 100644 --- a/TODO.txt +++ b/Notes/VFALCO_TODO.txt @@ -2,9 +2,31 @@ RIPPLE TODO -------------------------------------------------------------------------------- +REMINDER: KEEP CHANGE LOG UP TO DATE + Vinnie's List: Changes day to day, descending priority (Items marked '*' can be handled by others.) +- Get rid of boost::filesystem +- Deeply create directories specified in config settings +- Finish unit tests and code for Validators +* Document the command line options for the beast unit test framework +- Review boost::asio wrappers and consolidation of network code in ripple_net +- Refactor Section code into ConfigFile +- Improved Mutex to track deadlocks +- Work on KeyvaDB +- Allow skipped/disabled unit tests and reporting. + +David Features: +- override config items from command line +- change config via RPC, this is for debugging + +-------------------------------------------------------------------------------- + +- What the heck is up with site_scons/site_tools/protoc.py? + +- Figure out the right behavior of ProtectedCall + - Do something about the throw() reporting weaknesses: * Make sure all Sconstruct and .pro builds have debug symbols in release * Replace all throw with beast::Throw() @@ -18,21 +40,7 @@ Vinnie's List: Changes day to day, descending priority - Add UnhandledExceptionCatcher to beast - Return EXIT_FAILURE on unhandled exception -- Finish unit tests and code for Validators -* Document the command line options for the beast unit test framework -- Tidy up all the loose files at the root of the repository - - What the heck is up with site_scons/site_tools/protoc.py? -- Review boost::asio wrappers and consolidation of network code in ripple_net -- Refactor Section code into ConfigFile -- Improved Mutex to track deadlocks -- Work on KeyvaDB -- Allow skipped/disabled unit tests and reporting. - -David Features: -- override config items from command line -- change config via RPC, this is for debugging - --------------------------------------------------------------------------------- +- Option to print the list of available unit tests - Add convenience variadic functions to JobQueue that do the bind for you @@ -63,7 +71,7 @@ David Features: * Restyle all the macros in ripple_ConfigSection.h -- Clean up the remainder of src/ +- Move src/protobuf to Subtrees and deal with protobuf_core.cpp - Replace home-made database wrappers with beast::sqdb @@ -78,8 +86,6 @@ David Features: - Rewrite boost program_options in Beast -- Validations unit test - - Replace endian conversion calls with beast calls: htobe32, be32toh, ntohl, etc... Start by removing the system headers which provide these routines, if possible diff --git a/modules/ripple_app/main/ripple_FatalErrorReporter.cpp b/modules/ripple_app/main/ripple_FatalErrorReporter.cpp new file mode 100644 index 0000000000..5be5920c40 --- /dev/null +++ b/modules/ripple_app/main/ripple_FatalErrorReporter.cpp @@ -0,0 +1,55 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. +*/ +//============================================================================== + +FatalErrorReporter::FatalErrorReporter () +{ + FatalError::setReporter (*this); +} + +FatalErrorReporter::~FatalErrorReporter () +{ + FatalError::resetReporter (*this); +} + +void FatalErrorReporter::onFatalError ( + char const* message, + char const* stackBacktrace, + char const* fileName, + int lineNumber) +{ + String s; + + s << "Message = '" << message << "'" << newLine; + s << "File = '" << fileName << "' Line " << String (lineNumber) << newLine; + s << "Stack Trace:" << newLine; + s << stackBacktrace; + + Log::out() << s; +} + +//------------------------------------------------------------------------------ + +class FatalErrorReporterTests : public UnitTest +{ +public: + FatalErrorReporterTests () : UnitTest ("FatalErrorReporter", "ripple", runManual) + { + } + + void runTest () + { + beginTestCase ("report"); + + FatalErrorReporter reporter; + + // We don't really expect the program to run after this + // but the unit test is here so you can manually test it. + + FatalError ("unit test", __FILE__, __LINE__); + } +}; + +static FatalErrorReporterTests fatalErrorReporterTests; diff --git a/modules/ripple_app/main/ripple_FatalErrorReporter.h b/modules/ripple_app/main/ripple_FatalErrorReporter.h new file mode 100644 index 0000000000..282177f0f2 --- /dev/null +++ b/modules/ripple_app/main/ripple_FatalErrorReporter.h @@ -0,0 +1,33 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. +*/ +//============================================================================== + +#ifndef RIPPLE_SCOPEDFATALERRORREPORTER_H_INCLUDED +#define RIPPLE_SCOPEDFATALERRORREPORTER_H_INCLUDED + +/** FatalError reporter. + + This writes the details to standard error and the log. The reporter is + installed for the lifetime of the object so typically you would put this + at the top of main(). + + An alternative is to make it a global variable but for this to cover all + possible cases, there can be no other global variables with non trivial + constructors that can report a fatal error. Also, the Log would need + to be guaranteed to be set up for this handler to work. +*/ +class FatalErrorReporter : public FatalError::Reporter +{ +public: + FatalErrorReporter (); + ~FatalErrorReporter (); + + void onFatalError (char const* message, + char const* stackBacktrace, + char const* fileName, + int lineNumber); +}; + +#endif diff --git a/modules/ripple_app/main/ripple_Main.cpp b/modules/ripple_app/main/ripple_Main.cpp index 37b81bc4f5..076f71f49c 100644 --- a/modules/ripple_app/main/ripple_Main.cpp +++ b/modules/ripple_app/main/ripple_Main.cpp @@ -226,6 +226,8 @@ static int runUnitTests (String const& whichTests, String const& format) int rippleMain (int argc, char** argv) { + FatalErrorReporter reporter; + // // These debug heap calls do nothing in release or non Visual Studio builds. // diff --git a/modules/ripple_app/ripple_app.cpp b/modules/ripple_app/ripple_app.cpp index c6afd1ee78..9e24a0e63b 100644 --- a/modules/ripple_app/ripple_app.cpp +++ b/modules/ripple_app/ripple_app.cpp @@ -376,6 +376,8 @@ static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength) #include "ledger/ripple_AcceptedLedger.cpp" #include "consensus/ripple_DisputedTx.cpp" #include "misc/ripple_HashRouter.cpp" + #include "main/ripple_FatalErrorReporter.h" // private +#include "main/ripple_FatalErrorReporter.cpp" #include "main/ripple_Main.cpp" #include "misc/ripple_Offer.cpp"