From 5a0877ae54070d2237fe373fa9ca8787fab907e5 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Thu, 8 Feb 2018 08:02:42 +0100 Subject: [PATCH] backtrace on SalomeException and SALOME_SalomeException (unexpected exceptions) --- src/Utils/Utils_ExceptHandlers.cxx | 61 ++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/src/Utils/Utils_ExceptHandlers.cxx b/src/Utils/Utils_ExceptHandlers.cxx index e77e7d898..e8778229b 100644 --- a/src/Utils/Utils_ExceptHandlers.cxx +++ b/src/Utils/Utils_ExceptHandlers.cxx @@ -29,15 +29,70 @@ #include "Utils_CorbaException.hxx" #include "Utils_SALOME_Exception.hxx" +#include +#include +#include +#include + #include #include CORBA_SERVER_HEADER(SALOME_Exception) +//#define NBLINES_BACKTRACE 64 + void SalomeException () { - throw SALOME_Exception("Salome Exception"); + void *stacklines[64]; + char **stackSymbols; + size_t nbLines; + nbLines = backtrace(stacklines, 64); + stackSymbols = backtrace_symbols(stacklines, nbLines); + std::stringstream txt; + txt << "Salome Exception" << std::endl; + for (int i=0; i 0) + txt << infodl.dli_sname; + } + } + txt << " " << infodl.dli_saddr; + + txt << std::endl; + free(demangled); + } + else + txt << i << " " << stackSymbols[i] << std::endl; + } + THROW_SALOME_CORBA_EXCEPTION(txt.str().c_str(), SALOME::INTERNAL_ERROR); } -- 2.39.2