Add ripple::FatalErrorReporter

This commit is contained in:
Vinnie Falco
2013-07-30 19:33:14 -07:00
parent 6d83d171c3
commit 3729745fc6
8 changed files with 218 additions and 35 deletions

View File

@@ -175,6 +175,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\main\ripple_FatalErrorReporter.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\main\ripple_LoadManager.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -437,14 +443,54 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt1.cpp" />
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt2.cpp" />
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt3.cpp" />
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt4.cpp" />
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt5.cpp" />
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt6.cpp" />
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt7.cpp" />
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt8.cpp" />
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt1.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt2.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt3.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt4.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt5.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt6.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt7.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\ripple_app_pt8.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\rpc\CallRPC.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1350,6 +1396,7 @@
<ClInclude Include="..\..\modules\ripple_app\ledger\SerializedValidation.h" />
<ClInclude Include="..\..\modules\ripple_app\main\ParameterTable.h" />
<ClInclude Include="..\..\modules\ripple_app\main\ripple_Application.h" />
<ClInclude Include="..\..\modules\ripple_app\main\ripple_FatalErrorReporter.h" />
<ClInclude Include="..\..\modules\ripple_app\main\ripple_ILoadManager.h" />
<ClInclude Include="..\..\modules\ripple_app\main\ripple_LocalCredentials.h" />
<ClInclude Include="..\..\modules\ripple_app\misc\NetworkOPs.h" />
@@ -1609,7 +1656,8 @@
<None Include="..\QtCreator\rippled.pro" />
</ItemGroup>
<ItemGroup>
<Text Include="..\..\TODO.txt" />
<Text Include="..\..\Notes\VFALCO_LOG.txt" />
<Text Include="..\..\Notes\VFALCO_TODO.txt" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B7F39ECD-473C-484D-BC34-31F8362506A5}</ProjectGuid>

View File

@@ -154,6 +154,12 @@
<Filter Include="[1] Ripple\ripple_app\consensus">
<UniqueIdentifier>{82a6d3f3-fa01-4cc6-9730-f928e61b9929}</UniqueIdentifier>
</Filter>
<Filter Include="%28Notes%29">
<UniqueIdentifier>{73c81ca5-1f7e-4ffc-bb42-72306afc78ed}</UniqueIdentifier>
</Filter>
<Filter Include="[2] Build">
<UniqueIdentifier>{c69b07a2-44e5-4b06-99a9-81f5d137ea15}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\Subtrees\sqlite\sqlite3.c">
@@ -873,6 +879,9 @@
<ClCompile Include="..\..\modules\ripple_app\basics\ripple_BuildInfo.cpp">
<Filter>[1] Ripple\ripple_app\basics</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\main\ripple_FatalErrorReporter.cpp">
<Filter>[1] Ripple\ripple_app\main</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Subtrees\sqlite\sqlite3.h">
@@ -881,7 +890,6 @@
<ClInclude Include="..\..\Subtrees\sqlite\sqlite3ext.h">
<Filter>[0] Subtrees\sqlite</Filter>
</ClInclude>
<ClInclude Include="..\..\BeastConfig.h" />
<ClInclude Include="..\..\modules\ripple_app\ripple_app.h">
<Filter>[1] Ripple\ripple_app</Filter>
</ClInclude>
@@ -1659,6 +1667,12 @@
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_BuildInfo.h">
<Filter>[1] Ripple\ripple_app\basics</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\ripple_app\main\ripple_FatalErrorReporter.h">
<Filter>[1] Ripple\ripple_app\main</Filter>
</ClInclude>
<ClInclude Include="..\..\BeastConfig.h">
<Filter>[2] Build</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\modules\ripple_data\protocol\ripple.proto">
@@ -1675,14 +1689,31 @@
<None Include="..\..\modules\ripple_json\json\json_valueiterator.inl">
<Filter>[1] Ripple\ripple_json\json</Filter>
</None>
<None Include="..\..\CheatSheet.md" />
<None Include="..\..\CodingStyle.md" />
<None Include="..\..\Doxyfile" />
<None Include="..\..\SConstruct" />
<None Include="..\QtCreator\rippled.pro" />
<None Include="..\..\rippled-example.cfg" />
<None Include="..\..\CheatSheet.md">
<Filter>%28Notes%29</Filter>
</None>
<None Include="..\..\CodingStyle.md">
<Filter>%28Notes%29</Filter>
</None>
<None Include="..\..\Doxyfile">
<Filter>[2] Build</Filter>
</None>
<None Include="..\..\rippled-example.cfg">
<Filter>[2] Build</Filter>
</None>
<None Include="..\QtCreator\rippled.pro">
<Filter>[2] Build</Filter>
</None>
<None Include="..\..\SConstruct">
<Filter>[2] Build</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\TODO.txt" />
<Text Include="..\..\Notes\VFALCO_LOG.txt">
<Filter>%28Notes%29</Filter>
</Text>
<Text Include="..\..\Notes\VFALCO_TODO.txt">
<Filter>%28Notes%29</Filter>
</Text>
</ItemGroup>
</Project>

6
Notes/VFALCO_LOG.txt Normal file
View File

@@ -0,0 +1,6 @@
Vinnie Falco's Change Log
2013/07/30
- Add FatalErrorReporter to main
- Rewrote the build and protocol version numbering code

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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.
//

View File

@@ -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"