Skip to content
Draft
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
4 changes: 4 additions & 0 deletions host-configs/tpls.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ endif()
if(EXISTS ${GEOS_TPL_DIR}/mathpresso)
set(MATHPRESSO_DIR ${GEOS_TPL_DIR}/mathpresso CACHE PATH "" FORCE)
endif()

if(EXISTS ${GEOS_TPL_DIR}/cpptrace)
set(CPPTRACE_DIR ${GEOS_TPL_DIR}/cpptrace CACHE PATH "" FORCE)
endif()
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ if( ENABLE_HIP )
list( APPEND extraComponentsLinkList blt::hip )
endif()

if( ENABLE_CPPTRACE )
list( APPEND extraComponentsLinkList cpptrace::cpptrace )
endif()

blt_add_executable( NAME geosx
SOURCES main/main.cpp
DEPENDS_ON geosx_core
Expand Down
1 change: 1 addition & 0 deletions src/cmake/GeosxConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set( PREPROCESSOR_DEFINES BOUNDS_CHECK
CALIPER
CPPTRACE
CHAI
CUDA
CUDA_NVTOOLSEXT
Expand Down
36 changes: 36 additions & 0 deletions src/cmake/thirdparty/SetupGeosxThirdParty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ else()
set(ENABLE_PETSC OFF CACHE BOOL "" FORCE)
message(STATUS "Not using PETSc")
endif()

################################
# VTK
################################
Expand Down Expand Up @@ -935,6 +936,41 @@ else()
message(STATUS "Not using VTK")
endif()

################################
# CPPTRACE
################################
if( DEFINED CPPTRACE_DIR )
message( STATUS "CPPTRACE_DIR = ${CPPTRACE_DIR}" )

if( DEFINED ZSTD_DIR )
message( STATUS "ZSTD_DIR = ${ZSTD_DIR}" )
list( PREPEND CMAKE_PREFIX_PATH "${ZSTD_DIR}" )
endif()
if( DEFINED LIBDWARF_DIR )
message( STATUS "LIBDWARF_DIR = ${LIBDWARF_DIR}" )
list( PREPEND CMAKE_PREFIX_PATH "${LIBDWARF_DIR}" )
endif()

find_package( cpptrace REQUIRED
PATHS ${CPPTRACE_DIR}
NO_DEFAULT_PATH )

if( DEFINED cpptrace_VERSION )
message( " ----> cpptrace_VERSION=${cpptrace_VERSION}")
endif()

blt_convert_to_system_includes( TARGET cpptrace::cpptrace )

set( ENABLE_CPPTRACE ON CACHE BOOL "" )
set( thirdPartyLibs ${thirdPartyLibs} cpptrace::cpptrace )
else()
if( ENABLE_CPPTRACE )
message( WARNING "ENABLE_CPPTRACE is ON but CPPTRACE_DIR isn't defined." )
endif()

set( ENABLE_CPPTRACE OFF CACHE BOOL "" )
message( STATUS "Not using cpptrace" )
endif()

################################
# uncrustify
Expand Down
7 changes: 7 additions & 0 deletions src/coreComponents/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ set( common_headers
logger/Logger.hpp
logger/ErrorHandling.hpp
logger/ExternalErrorHandler.hpp
logger/StackTrace.hpp
logger/StackTraceParams.hpp
MpiWrapper.hpp
Path.hpp
Span.hpp
Expand Down Expand Up @@ -82,6 +84,7 @@ set( common_sources
logger/Logger.cpp
logger/ErrorHandling.cpp
logger/ExternalErrorHandler.cpp
logger/StackTrace.cpp
BufferAllocator.cpp
MemoryInfos.cpp
MpiWrapper.cpp
Expand Down Expand Up @@ -136,6 +139,10 @@ if( ENABLE_CALIPER )
endif()
endif()

if( ENABLE_CPPTRACE )
list( APPEND dependencyList cpptrace::cpptrace )
endif()

blt_add_library( NAME common
SOURCES ${common_sources}
HEADERS ${common_headers}
Expand Down
3 changes: 3 additions & 0 deletions src/coreComponents/common/GeosxConfig.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
/// Enables use of CHAI (CMake option ENABLE_CHAI)
#cmakedefine GEOS_USE_CHAI

/// Enables use of Cpptrace (CMake option ENABLE_CPPTRACE)
#cmakedefine GEOS_USE_CPPTRACE

/// Enables use of Mathpresso library (CMake option ENABLE_MATHPRESSO)
#cmakedefine GEOS_USE_MATHPRESSO

Expand Down
7 changes: 3 additions & 4 deletions src/coreComponents/common/initializeEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "logger/ErrorHandling.hpp"
#include "logger/ExternalErrorHandler.hpp"
#include <umpire/TypedAllocator.hpp>
#include "logger/StackTrace.hpp"
// TPL includes
#include <umpire/ResourceManager.hpp>
#include <umpire/Allocator.hpp>
Expand Down Expand Up @@ -86,12 +87,11 @@ void setupLogger()
}
else
{
std::string const stackHistory = LvArray::system::stackTrace( true );
DiagnosticMsg diagnosticMsg;
ErrorLogger::global().flushErrorMsg( DiagnosticMsgBuilder::init( diagnosticMsg,
MsgType::Error, errorMsg,
::geos::logger::internal::g_rank )
.addCallStackInfo( stackHistory )
.addCallStackInfo( StackTrace::stackTrace() )
.addDetectionLocation( detectionLocation )
.getDiagnosticMsg() );

Expand All @@ -109,13 +109,12 @@ void setupLogger()
ExternalErrorHandler::instance().flush( "before signal error output" );

// error message output
std::string const stackHistory = LvArray::system::stackTrace( true );
DiagnosticMsg diagnosticMsg;
ErrorLogger::global().flushErrorMsg( DiagnosticMsgBuilder::init( diagnosticMsg,
MsgType::ExternalError, "",
::geos::logger::internal::g_rank )
.addSignal( signal )
.addCallStackInfo( stackHistory )
.addCallStackInfo( StackTrace::stackTrace() )
.getDiagnosticMsg() );

// call program termination
Expand Down
31 changes: 7 additions & 24 deletions src/coreComponents/common/logger/ErrorHandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
*/

#include "ErrorHandling.hpp"
#include "Logger.hpp"
#include "StackTrace.hpp"
#include "common/DataTypes.hpp"
#include "common/logger/Logger.hpp"
#include "common/logger/StackTrace.hpp"
#include "common/format/StringUtilities.hpp"

#include <fstream>
Expand Down Expand Up @@ -66,7 +69,7 @@ DiagnosticMsgBuilder ErrorLogger::initCurrentExceptionMessage( MsgType msgType,
m_getCurrentExceptionMsg = DiagnosticMsgBuilder::init( diagnosticMsg,
msgType, msgContent,
rank )
.addCallStackInfo( LvArray::system::stackTrace( true ) )
.addCallStackInfo( StackTrace::stackTrace() )
.getDiagnosticMsg();
return DiagnosticMsgBuilder::modify( m_getCurrentExceptionMsg );
}
Expand Down Expand Up @@ -201,30 +204,10 @@ DiagnosticMsgBuilder & DiagnosticMsgBuilder::addRank( integer const rank )
return *this;
}

DiagnosticMsgBuilder & DiagnosticMsgBuilder::addCallStackInfo( std::string_view ossStackTrace )
DiagnosticMsgBuilder & DiagnosticMsgBuilder::addCallStackInfo( StackTrace && stacktrace )
{
std::string str = std::string( ossStackTrace );
std::istringstream iss( str );
std::string stackLine;
std::size_t index;

std::regex pattern( R"(Frame \d+: \S+)" );

while( std::getline( iss, stackLine ) )
{
if( std::regex_search( stackLine, pattern ))
{
m_errorMsg.m_isValidStackTrace = true;
index = stackLine.find( ':' );
m_errorMsg.m_sourceCallStack.push_back( stackLine.substr( index + 1 ) );
}
}

if( !m_errorMsg.m_isValidStackTrace )
{
m_errorMsg.m_sourceCallStack.push_back( str );
}

m_errorMsg.m_isValidStackTrace = stacktrace.isValidStackTrace();
m_errorMsg.m_sourceCallStack = std::move( stacktrace ).frames();
return *this;
}

Expand Down
3 changes: 2 additions & 1 deletion src/coreComponents/common/logger/ErrorHandling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "common/DataTypes.hpp"
#include "common/format/Format.hpp"
#include "common/format/StringUtilities.hpp"
#include "common/logger/StackTrace.hpp"
#include <mutex>

namespace geos
Expand Down Expand Up @@ -252,7 +253,7 @@ class DiagnosticMsgBuilder
* @param stacktrace stack trace information to add
* @return Reference to the current instance for method chaining.
*/
DiagnosticMsgBuilder & addCallStackInfo( std::string_view stacktrace );
DiagnosticMsgBuilder & addCallStackInfo( StackTrace && stacktrace );

/**
* @return Get the DiagnosticMsg
Expand Down
7 changes: 4 additions & 3 deletions src/coreComponents/common/logger/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// Source includes
#include "LvArray/src/Macros.hpp"
#include "common/logger/GeosExceptions.hpp"
#include "common/logger/StackTrace.hpp"

// System includes
#include <stdexcept>
Expand Down Expand Up @@ -161,7 +162,7 @@
::geos::logger::internal::g_rank ) \
.setCodeLocation( __FILE__, __LINE__ ) \
.setCause( __causemsgsoss.str() ) \
.addCallStackInfo( LvArray::system::stackTrace( true ) ) \
.addCallStackInfo( StackTrace::stackTrace() ) \
.addContextInfo( GEOS_DETAIL_REST_ARGS( __VA_ARGS__ )); \
GEOS_GLOBAL_LOGGER.flushCurrentExceptionMessage(); \
LvArray::system::callErrorHandler(); \
Expand Down Expand Up @@ -248,7 +249,7 @@
::geos::logger::internal::g_rank ) \
.setCodeLocation( __FILE__, __LINE__ ) \
.setCause( __causemsgsoss.str() ) \
.addCallStackInfo( LvArray::system::stackTrace( true ) ) \
.addCallStackInfo( StackTrace::stackTrace() ) \
.addContextInfo( GEOS_DETAIL_REST_ARGS( __VA_ARGS__ )) \
.getDiagnosticMsg(); \
auto ex = GEOS_DETAIL_FIRST_ARG( __VA_ARGS__ )(); \
Expand Down Expand Up @@ -341,7 +342,7 @@
::geos::logger::internal::g_rank ) \
.setCodeLocation( __FILE__, __LINE__ ) \
.setCause( __causemsgsoss.str() ) \
.addCallStackInfo( LvArray::system::stackTrace( true ) ) \
.addCallStackInfo( StackTrace::stackTrace() ) \
.addContextInfo( GEOS_DETAIL_REST_ARGS( __VA_ARGS__ )) \
.getDiagnosticMsg() ); \
} \
Expand Down
Loading
Loading