Skip to content

Commit

Permalink
Fix dev build following stacktrace add
Browse files Browse the repository at this point in the history
  • Loading branch information
riordant committed Jul 14, 2020
1 parent 42e79ff commit 333a337
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ else
LDFLAGS_WRAP_EXCEPTIONS += -Wl,-wrap,__assert_fail
endif
endif
endif

if TARGET_WINDOWS
BACKTRACE_LIB = -ldbghelp -lbacktrace
else
BACKTRACE_LIB = -lbacktrace
endif
endif

if EMBEDDED_UNIVALUE
LIBUNIVALUE = univalue/libunivalue.la
Expand Down Expand Up @@ -566,7 +566,6 @@ libbitcoin_consensus_a_SOURCES = \
script/script_error.h \
serialize.h \
spork.h \
stacktraces.h \
tinyformat.h \
uint256.cpp \
uint256.h \
Expand Down Expand Up @@ -643,7 +642,6 @@ libbitcoin_util_a_SOURCES = \
fs.cpp \
random.cpp \
rpc/protocol.cpp \
stacktraces.cpp \
support/cleanse.cpp \
sync.cpp \
threadinterrupt.cpp \
Expand Down Expand Up @@ -716,6 +714,11 @@ libbitcoin_util_a_SOURCES += compat/glibc_compat.cpp
AM_LDFLAGS += $(COMPAT_LDFLAGS)
endif

if ENABLE_CRASH_HOOKS
libbitcoin_util_a_SOURCES += stacktraces.cpp
libbitcoin_consensus_a_SOURCES += stacktraces.h
endif

# cli: shared between zcoin-cli and zcoin-qt
libbitcoin_cli_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libbitcoin_cli_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
Expand Down
3 changes: 2 additions & 1 deletion src/bench/bench_bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
int
main(int argc, char** argv)
{
#ifdef ENABLE_CRASH_HOOKS
RegisterPrettySignalHandlers();
RegisterPrettyTerminateHander();

#endif
ECC_Start();
SetupEnvironment();
fPrintToDebugLog = false; // don't want to write to debug.log file
Expand Down
4 changes: 4 additions & 0 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ static int AppInitRPC(int argc, char* argv[])
//
ParseParameters(argc, argv);

#ifdef ENABLE_CRASH_HOOKS
if (IsArgSet("-printcrashinfo")) {
std::cout << GetCrashInfoStrFromSerializedStr(GetArg("-printcrashinfo", "")) << std::endl;
return true;
}
#endif

if (argc<2 || IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version")) {
std::string strUsage = strprintf(_("%s RPC client version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n";
Expand Down Expand Up @@ -363,8 +365,10 @@ int CommandLineRPC(int argc, char *argv[])

int main(int argc, char* argv[])
{
#ifdef ENABLE_CRASH_HOOKS
RegisterPrettySignalHandlers();
RegisterPrettyTerminateHander();
#endif

SetupEnvironment();
if (!SetupNetworking()) {
Expand Down
4 changes: 4 additions & 0 deletions src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ static int AppInitRawTx(int argc, char* argv[])
//
ParseParameters(argc, argv);

#ifdef ENABLE_CRASH_HOOKS
if (IsArgSet("-printcrashinfo")) {
std::cout << GetCrashInfoStrFromSerializedStr(GetArg("-printcrashinfo", "")) << std::endl;
return true;
}
#endif

// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
try {
Expand Down Expand Up @@ -828,8 +830,10 @@ static int CommandLineRawTx(int argc, char* argv[])

int main(int argc, char* argv[])
{
#ifdef ENABLE_CRASH_HOOKS
RegisterPrettyTerminateHander();
RegisterPrettySignalHandlers();
#endif

SetupEnvironment();

Expand Down
6 changes: 4 additions & 2 deletions src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ bool AppInit(int argc, char* argv[])
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
ParseParameters(argc, argv);

#ifdef ENABLE_CRASH_HOOKS
if (IsArgSet("-printcrashinfo")) {
std::cout << GetCrashInfoStrFromSerializedStr(GetArg("-printcrashinfo", "")) << std::endl;
return true;
}

#endif
// Process help and version before taking care about datadir
if (IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version"))
{
Expand Down Expand Up @@ -201,9 +202,10 @@ bool AppInit(int argc, char* argv[])

int main(int argc, char* argv[])
{
#ifdef ENABLE_CRASH_HOOKS
RegisterPrettyTerminateHander();
RegisterPrettySignalHandlers();

#endif
SetupEnvironment();

// Connect bitcoind signal handlers
Expand Down
5 changes: 4 additions & 1 deletion src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,10 @@ WId BitcoinApplication::getMainWinId() const
#ifndef BITCOIN_QT_TEST
int main(int argc, char *argv[])
{
#ifdef ENABLE_CRASH_HOOKS
RegisterPrettyTerminateHander();
RegisterPrettySignalHandlers();

#endif
SetupEnvironment();

/// 1. Parse command-line options. These take precedence over anything else.
Expand Down Expand Up @@ -591,12 +592,14 @@ int main(int argc, char *argv[])
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
translationInterface.Translate.connect(Translate);

#ifdef ENABLE_CRASH_HOOKS
if (IsArgSet("-printcrashinfo")) {
auto crashInfo = GetCrashInfoStrFromSerializedStr(GetArg("-printcrashinfo", ""));
std::cout << crashInfo << std::endl;
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME), QString::fromStdString(crashInfo));
return EXIT_SUCCESS;
}
#endif

// Show help message immediately after parsing command-line options (for "-lang") and setting locale,
// but before showing splash screen.
Expand Down
2 changes: 2 additions & 0 deletions src/test/test_bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ bool ShutdownRequested()
}
*/

#ifdef ENABLE_CRASH_HOOKS
template<typename T>
void translate_exception(const T &e)
{
Expand Down Expand Up @@ -342,3 +343,4 @@ struct ExceptionInitializer {
};

BOOST_GLOBAL_FIXTURE( ExceptionInitializer );
#endif
6 changes: 5 additions & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,20 @@ std::string HelpMessageOpt(const std::string &option, const std::string &message
std::string("\n\n");
}

#ifdef ENABLE_CRASH_HOOKS
static std::string FormatException(const std::exception_ptr pex, const char* pszThread)
{
return strprintf("EXCEPTION: %s", GetPrettyExceptionStr(pex));
}
#endif

void PrintExceptionContinue(const std::exception_ptr pex, const char* pszThread)
{
#ifdef ENABLE_CRASH_HOOKS
std::string message = FormatException(pex, pszThread);
LogPrintf("\n\n************************\n%s\n", message);
fprintf(stderr, "\n\n************************\n%s\n", message.c_str());
#endif
}

boost::filesystem::path GetDefaultDataDir()
Expand Down Expand Up @@ -970,4 +974,4 @@ std::string CopyrightHolders(const std::string& strPrefix)
+ '\n' + strPrefix + "The Zcoin Core developers";
}
return strCopyrightHolders;
}
}

0 comments on commit 333a337

Please sign in to comment.