From 39fc2bd9f23e81a0e5789e968ae2c6c5adc9c1cd Mon Sep 17 00:00:00 2001 From: raindroid Date: Mon, 4 Nov 2024 20:42:59 +0000 Subject: [PATCH 1/3] Add support for turn on/off backtrace Added option to disable backtrace (conflicts with other framework like SST) --- sparta/sparta/app/Simulation.hpp | 3 ++- sparta/src/Simulation.cpp | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/sparta/sparta/app/Simulation.hpp b/sparta/sparta/app/Simulation.hpp index fab13b933c..af1143a2a6 100644 --- a/sparta/sparta/app/Simulation.hpp +++ b/sparta/sparta/app/Simulation.hpp @@ -92,8 +92,9 @@ class Simulation * must be made before building/configuring/finalizing. * \param sim_name Name of the simulator * \param scheduler Pointer to the Scheduler that this Simulation operates with + * \param en_backtrace Enable backtrace on error (including SIGSEGV, SIGFPE, SIGILL, SIGABRT, SIGBUS), default is true */ - Simulation(const std::string& sim_name, Scheduler * scheduler); + Simulation(const std::string& sim_name, Scheduler * scheduler, bool en_backtrace=true); /*! * \brief Virtual destructor diff --git a/sparta/src/Simulation.cpp b/sparta/src/Simulation.cpp index 0d5000a802..abb37af78c 100644 --- a/sparta/src/Simulation.cpp +++ b/sparta/src/Simulation.cpp @@ -318,7 +318,8 @@ const DatabaseAccessor * Simulation::getSimulationDatabaseAccessor() const } Simulation::Simulation(const std::string& sim_name, - Scheduler * scheduler) : + Scheduler * scheduler, + bool en_backtrace) : clk_manager_(scheduler), sim_name_(sim_name), scheduler_(scheduler), @@ -335,13 +336,15 @@ Simulation::Simulation(const std::string& sim_name, // Watch for created nodes to which we will apply taps root_.getNodeAttachedNotification().REGISTER_FOR_THIS(rootDescendantAdded_); - // Handle illegal signals. - // Note: Update documentation if these signals are modified - backtrace_.setAsHandler(SIGSEGV); - backtrace_.setAsHandler(SIGFPE); - backtrace_.setAsHandler(SIGILL); - backtrace_.setAsHandler(SIGABRT); - backtrace_.setAsHandler(SIGBUS); + if (en_backtrace) { + // Handle illegal signals. + // Note: Update documentation if these signals are modified + backtrace_.setAsHandler(SIGSEGV); + backtrace_.setAsHandler(SIGFPE); + backtrace_.setAsHandler(SIGILL); + backtrace_.setAsHandler(SIGABRT); + backtrace_.setAsHandler(SIGBUS); + } report_repository_.reset(new sparta::ReportRepository(this)); From 176667bc14fec0fb975343c8f5fa9a7db50c68a7 Mon Sep 17 00:00:00 2001 From: raindroid Date: Mon, 25 Nov 2024 16:50:50 +0000 Subject: [PATCH 2/3] Move backtrce enable handler form Simulation constructor to configuration) --- sparta/sparta/app/Simulation.hpp | 3 +-- sparta/src/Simulation.cpp | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/sparta/sparta/app/Simulation.hpp b/sparta/sparta/app/Simulation.hpp index af1143a2a6..fab13b933c 100644 --- a/sparta/sparta/app/Simulation.hpp +++ b/sparta/sparta/app/Simulation.hpp @@ -92,9 +92,8 @@ class Simulation * must be made before building/configuring/finalizing. * \param sim_name Name of the simulator * \param scheduler Pointer to the Scheduler that this Simulation operates with - * \param en_backtrace Enable backtrace on error (including SIGSEGV, SIGFPE, SIGILL, SIGABRT, SIGBUS), default is true */ - Simulation(const std::string& sim_name, Scheduler * scheduler, bool en_backtrace=true); + Simulation(const std::string& sim_name, Scheduler * scheduler); /*! * \brief Virtual destructor diff --git a/sparta/src/Simulation.cpp b/sparta/src/Simulation.cpp index abb37af78c..7bfe6819c8 100644 --- a/sparta/src/Simulation.cpp +++ b/sparta/src/Simulation.cpp @@ -318,8 +318,7 @@ const DatabaseAccessor * Simulation::getSimulationDatabaseAccessor() const } Simulation::Simulation(const std::string& sim_name, - Scheduler * scheduler, - bool en_backtrace) : + Scheduler * scheduler) : clk_manager_(scheduler), sim_name_(sim_name), scheduler_(scheduler), @@ -336,16 +335,6 @@ Simulation::Simulation(const std::string& sim_name, // Watch for created nodes to which we will apply taps root_.getNodeAttachedNotification().REGISTER_FOR_THIS(rootDescendantAdded_); - if (en_backtrace) { - // Handle illegal signals. - // Note: Update documentation if these signals are modified - backtrace_.setAsHandler(SIGSEGV); - backtrace_.setAsHandler(SIGFPE); - backtrace_.setAsHandler(SIGILL); - backtrace_.setAsHandler(SIGABRT); - backtrace_.setAsHandler(SIGBUS); - } - report_repository_.reset(new sparta::ReportRepository(this)); // Sanity check - simulations cannot exist without a scheduler @@ -489,6 +478,16 @@ void Simulation::configure(const int argc, throw SpartaException("Logging ennoblement is currently not supported with debug-roi. Use --debug or --debug-on-icount"); } + if (SignalMode::ENABLE_BACKTRACE_SIGNALS == signal_mode) { + // Handle illegal signals. + // Note: Update documentation if these signals are modified + backtrace_.setAsHandler(SIGSEGV); + backtrace_.setAsHandler(SIGFPE); + backtrace_.setAsHandler(SIGILL); + backtrace_.setAsHandler(SIGABRT); + backtrace_.setAsHandler(SIGBUS); + } + // If there are nodes already existing in the tree (e.g. root or "") then // there are no notifications for these TreeNodes since they already exist. // Install taps immediately instead of through rootDescendantAdded_ From 0113d28ebb577e8697212d95dafb9e68df481271 Mon Sep 17 00:00:00 2001 From: raindroid Date: Mon, 25 Nov 2024 17:06:33 +0000 Subject: [PATCH 3/3] Fix the backtrace namespace --- sparta/src/Simulation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sparta/src/Simulation.cpp b/sparta/src/Simulation.cpp index 7bfe6819c8..b021caba46 100644 --- a/sparta/src/Simulation.cpp +++ b/sparta/src/Simulation.cpp @@ -478,7 +478,7 @@ void Simulation::configure(const int argc, throw SpartaException("Logging ennoblement is currently not supported with debug-roi. Use --debug or --debug-on-icount"); } - if (SignalMode::ENABLE_BACKTRACE_SIGNALS == signal_mode) { + if (SimulationConfiguration::SignalMode::ENABLE_BACKTRACE_SIGNALS == sim_config_->signal_mode) { // Handle illegal signals. // Note: Update documentation if these signals are modified backtrace_.setAsHandler(SIGSEGV);