From 53fae99b6092e2e047d77c4a0420e85da03f89ea Mon Sep 17 00:00:00 2001 From: Marcus Rockwell Date: Sat, 7 Sep 2024 18:23:54 -0400 Subject: [PATCH 1/9] disallow dumping checkpoint in step mode --- .../src/main/java/trick/simcontrol/SimControlApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java b/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java index b6b0ae9c6..ee0efe357 100644 --- a/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java +++ b/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java @@ -1319,7 +1319,7 @@ private void updateGUI() { disableAllCommands(); setActionsEnabled("freezeSim,lite", true); if (debug_flag != 0) { - setActionsEnabled("stepSim,dumpChkpntASCII", true); + getAction("stepSim").setEnabled(true); } logoImagePanel.resume(); break; From f9b2b2525ad98131ffed78aa2dbaaae5575100ff Mon Sep 17 00:00:00 2001 From: Marcus Rockwell Date: Sat, 7 Sep 2024 19:03:04 -0400 Subject: [PATCH 2/9] Removed the mention of toggling instrumentation jobs off from the documentation --- docs/howto_guides/Realtime-Best-Practices.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/howto_guides/Realtime-Best-Practices.md b/docs/howto_guides/Realtime-Best-Practices.md index b451d133c..a8ee3fe87 100644 --- a/docs/howto_guides/Realtime-Best-Practices.md +++ b/docs/howto_guides/Realtime-Best-Practices.md @@ -274,7 +274,6 @@ Inserting one or more of the ```#define``` statements listed below to the top of #define TRICK_NO_REALTIME #define TRICK_NO_FRAMELOG #define TRICK_NO_MASTERSLAVE -#define TRICK_NO_INSTRUMENTATION #define TRICK_NO_INTEGRATE #define TRICK_NO_REALTIMEINJECTOR #define TRICK_NO_ZEROCONF @@ -292,7 +291,6 @@ LIBRARY DEPENDENCIES: *************************************************************/ #define TRICK_NO_MONTE_CARLO #define TRICK_NO_MASTERSLAVE -#define TRICK_NO_INSTRUMENTATION #define TRICK_NO_REALTIMEINJECTOR #define TRICK_NO_ZEROCONF #define TRICK_NO_UNITTEST From b928e5adb37b8b001f144d967a9c76b611be2dbe Mon Sep 17 00:00:00 2001 From: Marcus Rockwell Date: Sat, 7 Sep 2024 19:03:28 -0400 Subject: [PATCH 3/9] Added a check to disable the step button if the instrumentation jobs are off --- .../main/java/trick/simcontrol/SimControlApplication.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java b/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java index ee0efe357..1b0f01227 100644 --- a/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java +++ b/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java @@ -1334,6 +1334,11 @@ private void updateGUI() { break; } + // Disable the step button if instrumentation jobs are off. + if (debug_present == 0) { + getAction("stepSim").setEnabled(false); + } + runtimeStatePanel.setTitle(newStatusDesc); currentSimStatusDesc = runtimeStatePanel.getTitle(); } From 0186f8569cfe56b83a0c00342d2330a3ef2a6cb8 Mon Sep 17 00:00:00 2001 From: Marcus Rockwell Date: Mon, 23 Sep 2024 14:33:32 -0400 Subject: [PATCH 4/9] Implemented STEP mode --- include/trick/Executive.hh | 8 ++++++++ include/trick/debug_pause_proto.h | 1 + include/trick/exec_proto.h | 1 + include/trick/sim_mode.h | 1 + .../utils/SimControlActionController.java | 3 +-- .../DebugPause/DebugPause_c_intf.cpp | 7 +++++++ .../Executive/Executive_c_intf.cpp | 12 ++++++++++++ .../Executive/Executive_freeze_loop.cpp | 11 +++++++++++ .../sim_services/Executive/Executive_step.cpp | 19 +++++++++++++++++++ 9 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 trick_source/sim_services/Executive/Executive_step.cpp diff --git a/include/trick/Executive.hh b/include/trick/Executive.hh index 2be2d27ee..66d0110d7 100644 --- a/include/trick/Executive.hh +++ b/include/trick/Executive.hh @@ -1221,6 +1221,14 @@ namespace Trick { */ virtual int run() ; + /** + @userdesc Command to step the simulation, pausing after each job. Set exec_command to StepCmd. + @par Python Usage: + @code trick.step() @endcode + @return always 0 + */ + virtual int step() ; + /** @userdesc Command to freeze the simulation now. Set exec_command to FreezeCmd. @par Python Usage: diff --git a/include/trick/debug_pause_proto.h b/include/trick/debug_pause_proto.h index cc0308f4d..b270e939c 100644 --- a/include/trick/debug_pause_proto.h +++ b/include/trick/debug_pause_proto.h @@ -9,6 +9,7 @@ extern "C" { int debug_pause_on(void) ; int debug_pause_off(void) ; int debug_signal(void) ; +int debug_pause_flag(void) ; #ifdef __cplusplus } diff --git a/include/trick/exec_proto.h b/include/trick/exec_proto.h index d536c79eb..3b298ff5d 100644 --- a/include/trick/exec_proto.h +++ b/include/trick/exec_proto.h @@ -77,6 +77,7 @@ extern "C" { int exec_freeze(void) ; int exec_run(void) ; + int exec_step(void) ; void exec_signal_terminate(void) ; int exec_terminate(const char *, const char *) ; diff --git a/include/trick/sim_mode.h b/include/trick/sim_mode.h index 1bdbd2ace..60b2b7465 100644 --- a/include/trick/sim_mode.h +++ b/include/trick/sim_mode.h @@ -19,6 +19,7 @@ typedef enum { NoCmd = 0 , /* NoCmd */ FreezeCmd = 2 , /* freeze */ RunCmd = 3 , /* run */ + StepCmd = 4, /* step */ ExitCmd = 10 , /* exit */ } SIM_COMMAND; diff --git a/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java b/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java index dea9d703d..bf6b9c7c6 100644 --- a/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java +++ b/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java @@ -245,8 +245,7 @@ public void actionPerformed(ActionEvent e) { public void handleStep( int debug_flag ) { try { if ( debug_flag == 0 ) { - simcom.put("trick.debug_pause_on()\n" + - "trick.exec_run()\n") ; + simcom.put("trick.exec_step()\n") ; } else { simcom.put("trick.debug_signal()\n") ; } diff --git a/trick_source/sim_services/DebugPause/DebugPause_c_intf.cpp b/trick_source/sim_services/DebugPause/DebugPause_c_intf.cpp index b4b1e252e..4ec52e910 100644 --- a/trick_source/sim_services/DebugPause/DebugPause_c_intf.cpp +++ b/trick_source/sim_services/DebugPause/DebugPause_c_intf.cpp @@ -38,3 +38,10 @@ extern "C" int debug_signal(void) { } return(0) ; } + +extern "C" int debug_pause_flag(void) { + if (the_debug_pause != NULL) { + return the_debug_pause->debug_pause_flag ; + } + return(0) ; +} diff --git a/trick_source/sim_services/Executive/Executive_c_intf.cpp b/trick_source/sim_services/Executive/Executive_c_intf.cpp index 8e88f0c05..7792220e0 100644 --- a/trick_source/sim_services/Executive/Executive_c_intf.cpp +++ b/trick_source/sim_services/Executive/Executive_c_intf.cpp @@ -801,6 +801,18 @@ extern "C" int exec_run() { return -1 ; } +/** + * @relates Trick::Executive + * @copydoc Trick::Executive::step + * C wrapper for Trick::Executive::step + */ +extern "C" int exec_step() { + if ( the_exec != NULL ) { + return the_exec->step() ; + } + return -1 ; +} + /** * @relates Trick::Executive @userdesc C wrapper to add an instrumentation job before all initialization, integration, diff --git a/trick_source/sim_services/Executive/Executive_freeze_loop.cpp b/trick_source/sim_services/Executive/Executive_freeze_loop.cpp index 19d5ef4bd..9d948eb8b 100644 --- a/trick_source/sim_services/Executive/Executive_freeze_loop.cpp +++ b/trick_source/sim_services/Executive/Executive_freeze_loop.cpp @@ -5,6 +5,7 @@ #include "trick/Executive.hh" #include "trick/ExecutiveException.hh" #include "trick/exec_proto.h" +#include "trick/debug_pause_proto.h" #include "trick/message_proto.h" #include "trick/message_type.h" @@ -25,6 +26,11 @@ int Trick::Executive::freeze_loop() { /* Set the mode to Freeze */ mode = Freeze; + if (debug_pause_flag()) { + debug_pause_off(); + } + + /* Execute the Freeze Init Jobs. */ freeze_init_queue.reset_curr_index() ; while ( (curr_job = freeze_init_queue.get_next_job()) != NULL ) { @@ -77,6 +83,11 @@ int Trick::Executive::freeze_loop() { } else if ( exec_command == FreezeCmd ) { /* redundant freeze command. Clear it. */ exec_command = NoCmd ; + } else if ( exec_command == StepCmd ) { + mode = Step ; + exec_command = NoCmd ; + + debug_pause_on(); } /* Call Executive::exec_terminate_with_return(int , const char * , int , const char *) diff --git a/trick_source/sim_services/Executive/Executive_step.cpp b/trick_source/sim_services/Executive/Executive_step.cpp new file mode 100644 index 000000000..5715e160f --- /dev/null +++ b/trick_source/sim_services/Executive/Executive_step.cpp @@ -0,0 +1,19 @@ + +#include +#include + +#include "trick/Executive.hh" +#include "trick/Message_proto.hh" +#include "trick/message_proto.h" +#include "trick/message_type.h" +#include "trick/DebugPause.hh" + +int Trick::Executive::step() { + + /** @par Detailed Design */ + /** @li Set exec_command to RunCmd. Requirement [@ref r_exec_mode_5] */ + exec_command = StepCmd ; + + return(0) ; + +} From c420c54d6c2bba632576f3f6d908c602e3bacbbf Mon Sep 17 00:00:00 2001 From: Marcus Rockwell Date: Tue, 24 Sep 2024 17:44:23 -0500 Subject: [PATCH 5/9] Cleaned up basic Step mode implementation --- .../simcontrol/utils/SimControlActionController.java | 10 +++++----- trick_source/sim_services/Executive/Executive_step.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java b/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java index bf6b9c7c6..66addfb0e 100644 --- a/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java +++ b/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java @@ -244,11 +244,11 @@ public void actionPerformed(ActionEvent e) { */ public void handleStep( int debug_flag ) { try { - if ( debug_flag == 0 ) { - simcom.put("trick.exec_step()\n") ; - } else { - simcom.put("trick.debug_signal()\n") ; - } + // if ( debug_flag == 0 ) { + simcom.put("trick.exec_step()\n") ; + // } else { + // simcom.put("trick.debug_signal()\n") ; + // } } catch (IOException e) { } diff --git a/trick_source/sim_services/Executive/Executive_step.cpp b/trick_source/sim_services/Executive/Executive_step.cpp index 5715e160f..45a5c8b42 100644 --- a/trick_source/sim_services/Executive/Executive_step.cpp +++ b/trick_source/sim_services/Executive/Executive_step.cpp @@ -7,12 +7,17 @@ #include "trick/message_proto.h" #include "trick/message_type.h" #include "trick/DebugPause.hh" +#include "trick/debug_pause_proto.h" int Trick::Executive::step() { /** @par Detailed Design */ /** @li Set exec_command to RunCmd. Requirement [@ref r_exec_mode_5] */ - exec_command = StepCmd ; + if(debug_pause_flag()) { + debug_signal(); + } else { + exec_command = StepCmd ; + } return(0) ; From c0c67bea9d1fe64aa829bfcec9bb812b0325020c Mon Sep 17 00:00:00 2001 From: Marcus Rockwell Date: Wed, 25 Sep 2024 17:21:02 -0400 Subject: [PATCH 6/9] Fixed semaphore name --- trick_source/sim_services/DebugPause/DebugPause.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trick_source/sim_services/DebugPause/DebugPause.cpp b/trick_source/sim_services/DebugPause/DebugPause.cpp index b95bcbd20..75f618748 100644 --- a/trick_source/sim_services/DebugPause/DebugPause.cpp +++ b/trick_source/sim_services/DebugPause/DebugPause.cpp @@ -68,7 +68,7 @@ int Trick::DebugPause::debug_pause_on() { debug_pause_flag = true ; - sem_name_stream << "itimersepmaphore_" << getpid() ; + sem_name_stream << "debugsemaphore_" << getpid() ; sem_name = sem_name_stream.str() ; debug_sem = sem_open(sem_name.c_str(), O_CREAT, S_IRWXU , 0); From c6c38d1919bfa14670a749e13230e86d15cd4336 Mon Sep 17 00:00:00 2001 From: Mrockwell2 <120338765+Mrockwell2@users.noreply.github.com> Date: Thu, 26 Sep 2024 08:11:32 -0500 Subject: [PATCH 7/9] Cleaned up handleStep function --- .../simcontrol/utils/SimControlActionController.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java b/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java index 66addfb0e..bf1d13cad 100644 --- a/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java +++ b/trick_source/java/src/main/java/trick/simcontrol/utils/SimControlActionController.java @@ -244,14 +244,8 @@ public void actionPerformed(ActionEvent e) { */ public void handleStep( int debug_flag ) { try { - // if ( debug_flag == 0 ) { - simcom.put("trick.exec_step()\n") ; - // } else { - // simcom.put("trick.debug_signal()\n") ; - // } - } catch (IOException e) { - - } + simcom.put("trick.exec_step()\n") ; + } catch (IOException e) {} } /** From 08ca15471a34a7b17e89d7327c0a815495359816 Mon Sep 17 00:00:00 2001 From: Marcus Rockwell Date: Tue, 1 Oct 2024 21:55:17 -0500 Subject: [PATCH 8/9] Shifted debug pause into executive. --- CMakeLists.txt | 1 - Makefile | 1 - include/trick/DebugPause.hh | 76 ------------------- include/trick/Executive.hh | 37 +++++++++ .../DebugPause/include/DebugPause.hh | 1 - .../DebugPause/include/debug_pause_proto.h | 1 - include/trick/debug_pause_proto.h | 18 ----- include/trick/exec_proto.h | 4 + include/trick/files_to_ICG.hh | 1 - share/trick/sim_objects/default_trick_sys.sm | 5 +- .../simcontrol/SimControlApplication.java | 4 +- trick_source/sim_services/CMakeLists.txt | 2 - .../DebugPause/DebugPause_c_intf.cpp | 47 ------------ trick_source/sim_services/DebugPause/Makefile | 3 - .../sim_services/DebugPause/Makefile_deps | 22 ------ .../sim_services/Executive/Executive.cpp | 3 + .../Executive/Executive_c_intf.cpp | 31 ++++++++ .../Executive_debug_pause.cpp} | 30 +++----- .../Executive/Executive_freeze_loop.cpp | 3 +- .../sim_services/Executive/Executive_step.cpp | 4 +- trick_source/trick_swig/sim_services.i | 2 - 21 files changed, 92 insertions(+), 204 deletions(-) delete mode 100644 include/trick/DebugPause.hh delete mode 100644 include/trick/compat/sim_services/DebugPause/include/DebugPause.hh delete mode 100644 include/trick/compat/sim_services/DebugPause/include/debug_pause_proto.h delete mode 100644 include/trick/debug_pause_proto.h delete mode 100644 trick_source/sim_services/DebugPause/DebugPause_c_intf.cpp delete mode 100644 trick_source/sim_services/DebugPause/Makefile delete mode 100644 trick_source/sim_services/DebugPause/Makefile_deps rename trick_source/sim_services/{DebugPause/DebugPause.cpp => Executive/Executive_debug_pause.cpp} (68%) diff --git a/CMakeLists.txt b/CMakeLists.txt index aab776230..fd502bd6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,7 +146,6 @@ set( IO_SRC ${CMAKE_BINARY_DIR}/temp_src/io_src/io_DRHDF5.cpp ${CMAKE_BINARY_DIR}/temp_src/io_src/io_DataRecordDispatcher.cpp ${CMAKE_BINARY_DIR}/temp_src/io_src/io_DataRecordGroup.cpp - ${CMAKE_BINARY_DIR}/temp_src/io_src/io_DebugPause.cpp ${CMAKE_BINARY_DIR}/temp_src/io_src/io_EchoJobs.cpp ${CMAKE_BINARY_DIR}/temp_src/io_src/io_EnumAttributesMap.cpp ${CMAKE_BINARY_DIR}/temp_src/io_src/io_Environment.cpp diff --git a/Makefile b/Makefile index f219d3e29..0d23a4dd7 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,6 @@ SIM_SERV_DIRS = \ ${TRICK_HOME}/trick_source/sim_services/Collect \ ${TRICK_HOME}/trick_source/sim_services/CommandLineArguments \ ${TRICK_HOME}/trick_source/sim_services/DataRecord \ - ${TRICK_HOME}/trick_source/sim_services/DebugPause \ ${TRICK_HOME}/trick_source/sim_services/EchoJobs \ ${TRICK_HOME}/trick_source/sim_services/Environment \ ${TRICK_HOME}/trick_source/sim_services/EventManager \ diff --git a/include/trick/DebugPause.hh b/include/trick/DebugPause.hh deleted file mode 100644 index 9ab94b874..000000000 --- a/include/trick/DebugPause.hh +++ /dev/null @@ -1,76 +0,0 @@ -/* - PURPOSE: - (Trick runtime simulation executive parameter definition.) - REFERENCE: - (((Bailey, R.W, and Paddock, E.J.) (Trick Simulation Environment) - (NASA:JSC #37943) - (JSC / Engineering Directorate / Automation and Robotics Division) - (June 1994) (--))) - ASSUMPTIONS AND LIMITATIONS: - ((Only 64 levels of nested input data file inclusion.)) - PROGRAMMERS: - (((Robert W. Bailey) (LinCom) (4/92) (--) (Realtime)) - ((Robert W. Bailey) (LinCom) (6/1/91) (Trick-CR-00000) (Initial Release))) -*/ - -#ifndef DEBUGPAUSE_HH -#define DEBUGPAUSE_HH - -#include -#include - -#include "trick/JobData.hh" - -namespace Trick { - - class DebugPause { - - public: - /** Set to true to pause before every job call during sim execution.\n */ - bool debug_pause_flag ; /**< trick_units(--) */ - - /** - @brief This is the constructor of the DebugPause class. - */ - DebugPause() ; - - /** - @brief Instrumentation class job that pauses before each job when debug_pause is on. - Waits on a semapahore before execution continues. - @param curr_job - pointer to current instrument job that points to the job to pause at - @return always 0 - */ - int debug_pause(Trick::JobData * curr_job) ; - - /** - @brief Command to post the semaphore so that execution continues after pause. - @return always 0 - */ - int debug_signal() ; - - /** - @brief Command to set debug_pause_flag to true which turns on the debug pausing. - Calls Trick::Executive::instrument_job_before to insert the debug_pause routine before every job to pause at. - @return always 0 - */ - int debug_pause_on() ; - - /** - @brief Command to set debug_pause_flag to false which turns off the debug pausing. - Calls Trick::Executive::instrument_job_remove to remove the debug_pause routine from all job queues that it was inserted in. - @return always 0 - */ - int debug_pause_off() ; - - private: - /** Semaphore used to control pausing.\n */ - sem_t * debug_sem ; /**< trick_io(**) trick_units(--) */ - /** Semaphore name for debug_sem.\n */ - std::string sem_name ; /**< trick_io(**) trick_units(--) */ - - } ; - -} - -#endif - diff --git a/include/trick/Executive.hh b/include/trick/Executive.hh index 66d0110d7..b9cfb5de4 100644 --- a/include/trick/Executive.hh +++ b/include/trick/Executive.hh @@ -47,6 +47,9 @@ namespace Trick { /** gets #except_return */ virtual int get_except_return() const; + /** Set to true to pause before every job call during sim execution.\n */ + bool debug_pause_flag ; /**< trick_units(--) */ + protected: /** Attempts to attach a debugger in the event a signal shuts down the simulation.\n */ bool attach_debugger; /**< trick_units(--) */ @@ -174,6 +177,12 @@ namespace Trick { /** Next scheduled jobs call time.\n */ long long job_call_time_tics; /**< trick_units(--) */ + /** Semaphore used to control pausing.\n */ + sem_t * debug_sem ; /**< trick_io(**) trick_units(--) */ + + /** Semaphore name for debug_sem.\n */ + std::string debug_sem_name ; /**< trick_io(**) trick_units(--) */ + /** stream to record elapsed time of default_data, input_processor, and initialization queues \n */ std::ofstream init_log_stream; /**< trick_units(--) */ @@ -1338,6 +1347,34 @@ namespace Trick { @return always 0 */ virtual int exec_terminate(const char *file_name, const char *error); + + /** + @brief Instrumentation class job that pauses before each job when debug_pause is on. + Waits on a semapahore before execution continues. + @param curr_job - pointer to current instrument job that points to the job to pause at + @return always 0 + */ + int debug_pause(Trick::JobData * curr_job) ; + + /** + @brief Command to post the semaphore so that execution continues after pause. + @return always 0 + */ + int debug_signal() ; + + /** + @brief Command to set debug_pause_flag to true which turns on the debug pausing. + Calls Trick::Executive::instrument_job_before to insert the debug_pause routine before every job to pause at. + @return always 0 + */ + int debug_pause_on() ; + + /** + @brief Command to set debug_pause_flag to false which turns off the debug pausing. + Calls Trick::Executive::instrument_job_remove to remove the debug_pause routine from all job queues that it was inserted in. + @return always 0 + */ + int debug_pause_off() ; /* deleted functions */ private: diff --git a/include/trick/compat/sim_services/DebugPause/include/DebugPause.hh b/include/trick/compat/sim_services/DebugPause/include/DebugPause.hh deleted file mode 100644 index 57a716dbc..000000000 --- a/include/trick/compat/sim_services/DebugPause/include/DebugPause.hh +++ /dev/null @@ -1 +0,0 @@ -#include "trick/DebugPause.hh" diff --git a/include/trick/compat/sim_services/DebugPause/include/debug_pause_proto.h b/include/trick/compat/sim_services/DebugPause/include/debug_pause_proto.h deleted file mode 100644 index 7ca4babd6..000000000 --- a/include/trick/compat/sim_services/DebugPause/include/debug_pause_proto.h +++ /dev/null @@ -1 +0,0 @@ -#include "trick/debug_pause_proto.h" diff --git a/include/trick/debug_pause_proto.h b/include/trick/debug_pause_proto.h deleted file mode 100644 index b270e939c..000000000 --- a/include/trick/debug_pause_proto.h +++ /dev/null @@ -1,18 +0,0 @@ - -#ifndef DEBUGPAUSE_PROTO_H -#define DEBUGPAUSE_PROTO_H - -#ifdef __cplusplus -extern "C" { -#endif - -int debug_pause_on(void) ; -int debug_pause_off(void) ; -int debug_signal(void) ; -int debug_pause_flag(void) ; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/trick/exec_proto.h b/include/trick/exec_proto.h index 3b298ff5d..f92d25ca8 100644 --- a/include/trick/exec_proto.h +++ b/include/trick/exec_proto.h @@ -90,6 +90,10 @@ extern "C" { int exec_add_scheduled_job_class(const char * in_name) ; int exec_add_depends_on_job( const char * target_job_string , unsigned int t_instance , const char * depend_job_string , unsigned int d_instance ) ; + int debug_pause_on(void) ; + int debug_pause_off(void) ; + int debug_signal(void) ; + #ifdef __cplusplus } #endif diff --git a/include/trick/files_to_ICG.hh b/include/trick/files_to_ICG.hh index 19dd0071b..7e60845ba 100644 --- a/include/trick/files_to_ICG.hh +++ b/include/trick/files_to_ICG.hh @@ -81,7 +81,6 @@ #include "trick/DRAscii.hh" #include "trick/DRBinary.hh" #include "trick/DRHDF5.hh" -#include "trick/DebugPause.hh" #include "trick/EchoJobs.hh" #include "trick/FrameLog.hh" #include "trick/UnitTest.hh" diff --git a/share/trick/sim_objects/default_trick_sys.sm b/share/trick/sim_objects/default_trick_sys.sm index 24a5c8da3..a3d38e0c2 100644 --- a/share/trick/sim_objects/default_trick_sys.sm +++ b/share/trick/sim_objects/default_trick_sys.sm @@ -72,7 +72,6 @@ a replacement SimObject will create an uncompilable sim. ##include "trick/JSONVariableServer.hh" ##include "trick/data_record_proto.h" ##include "trick/DataRecordDispatcher.hh" -##include "trick/DebugPause.hh" ##include "trick/EchoJobs.hh" ##include "trick/FrameLog.hh" ##include "trick/UnitTest.hh" @@ -157,6 +156,8 @@ class SysSimObject : public Trick::SimObject { {TRK} ("system_advance_sim_time") sched.advance_sim_time() ; {TRK} ("system_thread_sync") sched.thread_sync() ; + + {TRK} ("instrumentation") sched.debug_pause(curr_job) ; } private: @@ -665,12 +666,10 @@ class InstrumentationSimObject : public Trick::SimObject { public: Trick::EchoJobs echo_jobs ; - Trick::DebugPause debug_pause ; InstrumentationSimObject() { // Instrumentation class jobs. Not scheduled by default {TRK} ("instrumentation") echo_jobs.echo_job(curr_job) ; - {TRK} ("instrumentation") debug_pause.debug_pause(curr_job) ; } } diff --git a/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java b/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java index 1b0f01227..921ba01e4 100644 --- a/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java +++ b/trick_source/java/src/main/java/trick/simcontrol/SimControlApplication.java @@ -527,7 +527,7 @@ public void getInitializationPacket() { simRunDirField[i].setText("Slave " + i); } - commandSimcom.put("trick.var_exists(\"trick_instruments.debug_pause.debug_pause_flag\")\n") ; + commandSimcom.put("trick.var_exists(\"trick_sys.sched.debug_pause_flag\")\n") ; results = commandSimcom.get().split("\t"); debug_present = Integer.parseInt(results[1]); @@ -832,7 +832,7 @@ private void scheduleGetSimState() { "trick.var_add(\"trick_real_time.rt_sync.active\") \n"; if ( debug_present != 0 ) { - status_vars += "trick.var_add(\"trick_instruments.debug_pause.debug_pause_flag\")\n" ; + status_vars += "trick.var_add(\"trick_sys.sched.debug_pause_flag\")\n" ; } if ( overrun_present != 0 ) { status_vars += "trick.var_add(\"trick_real_time.rt_sync.total_overrun\")\n" ; diff --git a/trick_source/sim_services/CMakeLists.txt b/trick_source/sim_services/CMakeLists.txt index f251bcce4..e4e2a3a48 100644 --- a/trick_source/sim_services/CMakeLists.txt +++ b/trick_source/sim_services/CMakeLists.txt @@ -23,8 +23,6 @@ set( SS_SRC DataRecord/DataRecordDispatcher DataRecord/DataRecordGroup DataRecord/data_record_utilities - DebugPause/DebugPause - DebugPause/DebugPause_c_intf EchoJobs/EchoJobs EchoJobs/EchoJobs_c_intf Environment/Environment diff --git a/trick_source/sim_services/DebugPause/DebugPause_c_intf.cpp b/trick_source/sim_services/DebugPause/DebugPause_c_intf.cpp deleted file mode 100644 index 4ec52e910..000000000 --- a/trick_source/sim_services/DebugPause/DebugPause_c_intf.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include "trick/DebugPause.hh" - -/* Global singleton pointer to the echo jobs class */ -extern Trick::DebugPause * the_debug_pause ; - -/*************************************************************************/ -/* These routines are the "C" interface to echo jobs instrumentation */ -/*************************************************************************/ - -/** - * @relates Trick::DebugPause - * @copydoc Trick::DebugPause::debug_pause_on - * C wrapper for Trick::DebugPause::debug_pause_on - */ -extern "C" int debug_pause_on(void) { - if (the_debug_pause != NULL) { - return the_debug_pause->debug_pause_on() ; - } - return(0) ; -} - -/** - * @relates Trick::DebugPause - * @copydoc Trick::DebugPause::debug_pause_off - * C wrapper for Trick::DebugPause::debug_pause_off - */ -extern "C" int debug_pause_off(void) { - if (the_debug_pause != NULL) { - return the_debug_pause->debug_pause_off() ; - } - return(0) ; -} - -extern "C" int debug_signal(void) { - if (the_debug_pause != NULL) { - return the_debug_pause->debug_signal() ; - } - return(0) ; -} - -extern "C" int debug_pause_flag(void) { - if (the_debug_pause != NULL) { - return the_debug_pause->debug_pause_flag ; - } - return(0) ; -} diff --git a/trick_source/sim_services/DebugPause/Makefile b/trick_source/sim_services/DebugPause/Makefile deleted file mode 100644 index 6f722048e..000000000 --- a/trick_source/sim_services/DebugPause/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -include $(dir $(lastword $(MAKEFILE_LIST)))../../../share/trick/makefiles/Makefile.common -include ${TRICK_HOME}/share/trick/makefiles/Makefile.tricklib --include Makefile_deps diff --git a/trick_source/sim_services/DebugPause/Makefile_deps b/trick_source/sim_services/DebugPause/Makefile_deps deleted file mode 100644 index 58670972a..000000000 --- a/trick_source/sim_services/DebugPause/Makefile_deps +++ /dev/null @@ -1,22 +0,0 @@ -object_${TRICK_HOST_CPU}/DebugPause.o: DebugPause.cpp \ - ${TRICK_HOME}/include/trick/DebugPause.hh \ - ${TRICK_HOME}/include/trick/JobData.hh \ - ${TRICK_HOME}/include/trick/InstrumentBase.hh \ - ${TRICK_HOME}/include/trick/message_proto.h \ - ${TRICK_HOME}/include/trick/message_type.h \ - ${TRICK_HOME}/include/trick/exec_proto.h \ - ${TRICK_HOME}/include/trick/sim_mode.h \ - ${TRICK_HOME}/include/trick/exec_proto.hh \ - ${TRICK_HOME}/include/trick/Executive.hh \ - ${TRICK_HOME}/include/trick/Scheduler.hh \ - ${TRICK_HOME}/include/trick/ScheduledJobQueue.hh \ - ${TRICK_HOME}/include/trick/SimObject.hh \ - ${TRICK_HOME}/include/trick/ScheduledJobQueue.hh \ - ${TRICK_HOME}/include/trick/SimObject.hh \ - ${TRICK_HOME}/include/trick/Threads.hh \ - ${TRICK_HOME}/include/trick/ThreadBase.hh \ - ${TRICK_HOME}/include/trick/sim_mode.h -object_${TRICK_HOST_CPU}/DebugPause_c_intf.o: DebugPause_c_intf.cpp \ - ${TRICK_HOME}/include/trick/DebugPause.hh \ - ${TRICK_HOME}/include/trick/JobData.hh \ - ${TRICK_HOME}/include/trick/InstrumentBase.hh diff --git a/trick_source/sim_services/Executive/Executive.cpp b/trick_source/sim_services/Executive/Executive.cpp index 5b4759a7e..140f905cd 100644 --- a/trick_source/sim_services/Executive/Executive.cpp +++ b/trick_source/sim_services/Executive/Executive.cpp @@ -51,6 +51,9 @@ Trick::Executive::Executive() { software_frame = 1.0; frame_count = 0 ; stack_trace = true ; + + debug_pause_flag = false ; + /** @li (if on new-enough Linux) allow any process to ptrace this one. * This allows stack trace / debugger attach when ptrace is * restricted (e.g. on Ubuntu 16). diff --git a/trick_source/sim_services/Executive/Executive_c_intf.cpp b/trick_source/sim_services/Executive/Executive_c_intf.cpp index 7792220e0..13dad889a 100644 --- a/trick_source/sim_services/Executive/Executive_c_intf.cpp +++ b/trick_source/sim_services/Executive/Executive_c_intf.cpp @@ -1108,3 +1108,34 @@ int exec_register_scheduler( Trick::Scheduler * scheduler ) { return -1 ; } +/** + * @relates Trick::DebugPause + * @copydoc Trick::DebugPause::debug_pause_on + * C wrapper for Trick::DebugPause::debug_pause_on + */ +extern "C" int debug_pause_on(void) { + if (the_exec != NULL) { + return the_exec->debug_pause_on() ; + } + return(0) ; +} + +/** + * @relates Trick::DebugPause + * @copydoc Trick::DebugPause::debug_pause_off + * C wrapper for Trick::DebugPause::debug_pause_off + */ +extern "C" int debug_pause_off(void) { + if (the_exec != NULL) { + return the_exec->debug_pause_off() ; + } + return(0) ; +} + +extern "C" int debug_signal(void) { + if (the_exec != NULL) { + return the_exec->debug_signal() ; + } + return(0) ; +} + diff --git a/trick_source/sim_services/DebugPause/DebugPause.cpp b/trick_source/sim_services/Executive/Executive_debug_pause.cpp similarity index 68% rename from trick_source/sim_services/DebugPause/DebugPause.cpp rename to trick_source/sim_services/Executive/Executive_debug_pause.cpp index 75f618748..f7e697fcc 100644 --- a/trick_source/sim_services/DebugPause/DebugPause.cpp +++ b/trick_source/sim_services/Executive/Executive_debug_pause.cpp @@ -7,21 +7,13 @@ #include #include -#include "trick/DebugPause.hh" +#include "trick/Executive.hh" #include "trick/message_proto.h" #include "trick/message_type.h" #include "trick/exec_proto.h" #include "trick/exec_proto.hh" - -Trick::DebugPause * the_debug_pause = NULL ; - -Trick::DebugPause::DebugPause() { - debug_pause_flag = false ; - the_debug_pause = this ; -} - -int Trick::DebugPause::debug_pause(Trick::JobData * curr_job) { +int Trick::Executive::debug_pause(Trick::JobData * curr_job) { // The target job was copied to sup_class_data in Trick::ScheduledJobQueueInstrument::call() Trick::JobData * target_job = (Trick::JobData *)curr_job->sup_class_data ; @@ -51,14 +43,14 @@ int Trick::DebugPause::debug_pause(Trick::JobData * curr_job) { } -int Trick::DebugPause::debug_signal() { +int Trick::Executive::debug_signal() { sem_post(debug_sem); return(0) ; } -int Trick::DebugPause::debug_pause_on() { +int Trick::Executive::debug_pause_on() { std::stringstream sem_name_stream ; @@ -68,12 +60,12 @@ int Trick::DebugPause::debug_pause_on() { debug_pause_flag = true ; - sem_name_stream << "debugsemaphore_" << getpid() ; - sem_name = sem_name_stream.str() ; + sem_name_stream << "debugstepmaphore_" << getpid() ; + debug_sem_name = sem_name_stream.str() ; - debug_sem = sem_open(sem_name.c_str(), O_CREAT, S_IRWXU , 0); + debug_sem = sem_open(debug_sem_name.c_str(), O_CREAT, S_IRWXU , 0); - exec_instrument_before("trick_instruments.debug_pause.debug_pause") ; + exec_instrument_before("trick_sys.sched.debug_pause") ; //TODO: turn off real-time clock if on. @@ -81,18 +73,18 @@ int Trick::DebugPause::debug_pause_on() { } -int Trick::DebugPause::debug_pause_off() { +int Trick::Executive::debug_pause_off() { if ( debug_pause_flag == false ) { return(0) ; } debug_pause_flag = false ; - exec_instrument_remove("trick_instruments.debug_pause.debug_pause") ; + exec_instrument_remove("trick_sys.sched.debug_pause") ; debug_signal() ; - sem_unlink(sem_name.c_str()) ; + sem_unlink(debug_sem_name.c_str()) ; //TODO: turn back on real-time clock if on before debug_pause started. return(0); diff --git a/trick_source/sim_services/Executive/Executive_freeze_loop.cpp b/trick_source/sim_services/Executive/Executive_freeze_loop.cpp index 9d948eb8b..e7847bb94 100644 --- a/trick_source/sim_services/Executive/Executive_freeze_loop.cpp +++ b/trick_source/sim_services/Executive/Executive_freeze_loop.cpp @@ -5,7 +5,6 @@ #include "trick/Executive.hh" #include "trick/ExecutiveException.hh" #include "trick/exec_proto.h" -#include "trick/debug_pause_proto.h" #include "trick/message_proto.h" #include "trick/message_type.h" @@ -26,7 +25,7 @@ int Trick::Executive::freeze_loop() { /* Set the mode to Freeze */ mode = Freeze; - if (debug_pause_flag()) { + if (debug_pause_flag) { debug_pause_off(); } diff --git a/trick_source/sim_services/Executive/Executive_step.cpp b/trick_source/sim_services/Executive/Executive_step.cpp index 45a5c8b42..8b874f080 100644 --- a/trick_source/sim_services/Executive/Executive_step.cpp +++ b/trick_source/sim_services/Executive/Executive_step.cpp @@ -6,14 +6,12 @@ #include "trick/Message_proto.hh" #include "trick/message_proto.h" #include "trick/message_type.h" -#include "trick/DebugPause.hh" -#include "trick/debug_pause_proto.h" int Trick::Executive::step() { /** @par Detailed Design */ /** @li Set exec_command to RunCmd. Requirement [@ref r_exec_mode_5] */ - if(debug_pause_flag()) { + if(debug_pause_flag) { debug_signal(); } else { exec_command = StepCmd ; diff --git a/trick_source/trick_swig/sim_services.i b/trick_source/trick_swig/sim_services.i index 2732e36a8..727fcc3d9 100644 --- a/trick_source/trick_swig/sim_services.i +++ b/trick_source/trick_swig/sim_services.i @@ -50,8 +50,6 @@ #endif #include "trick/DataRecordDispatcher.hh" #include "trick/data_record_proto.h" -#include "trick/DebugPause.hh" -#include "trick/debug_pause_proto.h" #include "trick/EchoJobs.hh" #include "trick/echojobs_proto.h" #include "trick/Environment.hh" From c7cd17eb2f80f0831e1c019af05559091791d92f Mon Sep 17 00:00:00 2001 From: Marcus Rockwell Date: Wed, 2 Oct 2024 14:52:23 -0400 Subject: [PATCH 9/9] implemented debug pause with internal executive functions --- .../sim_services/Executive/Executive_debug_pause.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trick_source/sim_services/Executive/Executive_debug_pause.cpp b/trick_source/sim_services/Executive/Executive_debug_pause.cpp index f7e697fcc..fab192f65 100644 --- a/trick_source/sim_services/Executive/Executive_debug_pause.cpp +++ b/trick_source/sim_services/Executive/Executive_debug_pause.cpp @@ -24,7 +24,7 @@ int Trick::Executive::debug_pause(Trick::JobData * curr_job) { // Pause for all job classes that are not initialization or for init jobs greater than phase 1. if ( target_job->job_class_name.compare("initialization") or target_job->phase > 1 ) { - message_publish(MSG_NORMAL, "%12.6f pausing before %s\n" , exec_get_sim_time() , + message_publish(MSG_NORMAL, "%12.6f pausing before %s\n" , get_sim_time() , target_job->name.c_str() ) ; do { @@ -65,7 +65,7 @@ int Trick::Executive::debug_pause_on() { debug_sem = sem_open(debug_sem_name.c_str(), O_CREAT, S_IRWXU , 0); - exec_instrument_before("trick_sys.sched.debug_pause") ; + instrument_job_before("trick_sys.sched.debug_pause") ; //TODO: turn off real-time clock if on. @@ -80,7 +80,7 @@ int Trick::Executive::debug_pause_off() { } debug_pause_flag = false ; - exec_instrument_remove("trick_sys.sched.debug_pause") ; + instrument_job_remove("trick_sys.sched.debug_pause") ; debug_signal() ;