Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacktrace with backtrace to display files and lines #2298

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ set (NANO_ROCKSDB OFF CACHE BOOL "")
set (NANO_WARN_TO_ERR OFF CACHE BOOL "")
set (NANO_TIMED_LOCKS 0 CACHE INTEGER "")

option (NANO_STACKTRACE_BACKTRACE "Use BOOST_STACKTRACE_USE_BACKTRACE in stacktraces, for POSIX" OFF)
if (NANO_STACKTRACE_BACKTRACE)
add_definitions(-DNANO_STACKTRACE_BACKTRACE=1)
endif ()

if (${NANO_TIMED_LOCKS} GREATER 0)
add_definitions (-DNANO_TIMED_LOCKS=${NANO_TIMED_LOCKS})
endif ()
Expand Down
4 changes: 4 additions & 0 deletions nano/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ target_link_libraries (nano_lib
${timed_locks_boost_libs}
Boost::boost)

if (NANO_STACKTRACE_BACKTRACE)
target_link_libraries(nano_lib backtrace)
endif ()

target_compile_definitions(nano_lib
PUBLIC
-DACTIVE_NETWORK=${ACTIVE_NETWORK}
Expand Down
3 changes: 3 additions & 0 deletions nano/lib/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

// Some builds (mac) fail due to "Boost.Stacktrace requires `_Unwind_Backtrace` function".
#ifndef _WIN32
#ifdef NANO_STACKTRACE_BACKTRACE
#define BOOST_STACKTRACE_USE_BACKTRACE
#endif
#ifndef _GNU_SOURCE
#define BEFORE_GNU_SOURCE 0
#define _GNU_SOURCE
Expand Down
4 changes: 4 additions & 0 deletions nano/nano_node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ target_link_libraries (nano_node
${PLATFORM_LIBS}
)

if (NANO_STACKTRACE_BACKTRACE)
target_link_libraries(nano_node backtrace)
endif ()

target_compile_definitions(nano_node
PRIVATE
-DTAG_VERSION_STRING=${TAG_VERSION_STRING}
Expand Down
8 changes: 8 additions & 0 deletions nano/nano_node/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

// Some builds (mac) fail due to "Boost.Stacktrace requires `_Unwind_Backtrace` function".
#ifndef _WIN32
#ifdef NANO_STACKTRACE_BACKTRACE
#define BOOST_STACKTRACE_USE_BACKTRACE
#endif
#ifndef _GNU_SOURCE
#define BEFORE_GNU_SOURCE 0
#define _GNU_SOURCE
Expand Down Expand Up @@ -130,6 +133,7 @@ int main (int argc, char * const * argv)
("debug_validate_blocks", "Check all blocks for correct hash, signature, work value")
("debug_peers", "Display peer IPv6:port connections")
("debug_cemented_block_count", "Displays the number of cemented (confirmed) blocks")
("debug_stacktrace", "Display an example stacktrace")
("platform", boost::program_options::value<std::string> (), "Defines the <platform> for OpenCL commands")
("device", boost::program_options::value<std::string> (), "Defines <device> for OpenCL command")
("threads", boost::program_options::value<std::string> (), "Defines <threads> count for OpenCL command")
Expand Down Expand Up @@ -1078,6 +1082,10 @@ int main (int argc, char * const * argv)
nano::inactive_node node (data_path, 24000, node_flags);
std::cout << "Total cemented block count: " << node.node->ledger.cemented_count << std::endl;
}
else if (vm.count ("debug_stacktrace"))
{
std::cout << boost::stacktrace::stacktrace ();
}
else if (vm.count ("debug_sys_logging"))
{
#ifdef BOOST_WINDOWS
Expand Down
4 changes: 4 additions & 0 deletions nano/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ target_link_libraries (node
${psapi_lib}
)

if (NANO_STACKTRACE_BACKTRACE)
target_link_libraries(node backtrace)
endif ()

target_compile_definitions(node
PRIVATE
-DTAG_VERSION_STRING=${TAG_VERSION_STRING}
Expand Down
3 changes: 3 additions & 0 deletions nano/node/lmdb/lmdb_txn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

// Some builds (mac) fail due to "Boost.Stacktrace requires `_Unwind_Backtrace` function".
#ifndef _WIN32
#ifdef NANO_STACKTRACE_BACKTRACE
#define BOOST_STACKTRACE_USE_BACKTRACE
#endif
#ifndef _GNU_SOURCE
#define BEFORE_GNU_SOURCE 0
#define _GNU_SOURCE
Expand Down