Skip to content

Commit e441240

Browse files
committed
Add support for shutdown from interactive console
1 parent 542a50e commit e441240

File tree

6 files changed

+77
-0
lines changed

6 files changed

+77
-0
lines changed

src/sst/core/impl/interactive/simpleDebug.cc

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,44 @@ SimpleDebugger::tokenize(std::vector<std::string>& tokens, const std::string& in
5757
return tokens;
5858
}
5959

60+
void
61+
SimpleDebugger::cmd_help(std::vector<std::string>& UNUSED(tokens))
62+
{
63+
std::string help = "SimpleDebug Console Commands\n";
64+
help.append(" Navigation: Navigate the current object map\n");
65+
help.append(" - pwd: print the current working directory in the object map\n");
66+
help.append(" - cd: change directory level in the object map\n");
67+
help.append(" - ls: list the objects in the current level of the object map\n");
68+
69+
help.append(" Current State: Print information about the current simulation state\n");
70+
help.append(" - time: print current simulation time in cycles\n");
71+
help.append(" - print [-rN][<obj>]: print objects in the current level of the object map;\n");
72+
help.append(" if -rN is provided print recursive N levels (default N=4)\n");
73+
74+
help.append(" Modify State: Modify simulation variables\n");
75+
help.append(" - set <obj> <value>: sets an object in the current scope to the provided value;\n");
76+
help.append(" object must be a \"fundamental type\" e.g. int \n");
77+
78+
help.append(" Watch Points: Manage watch points which break into interactive console when triggered\n");
79+
help.append(" - watch: prints the current list of watch points and their associated indices\n");
80+
help.append(" watch <var>: adds var to the watch list; triggered when value changes\n");
81+
help.append(" watch <var> <comp> <val>: add var to watch list; triggered when comparison with val is true\n");
82+
help.append(" Valid <comp> operators: <, <=, >, >=, ==, !=\n");
83+
help.append(" - unwatch <index>: removes the indexed watch point from the watch list;\n");
84+
help.append(" <index> is the associated index from the list of watch points\n");
85+
86+
help.append(" Execute: Execute the simulation for a specified duration\n");
87+
help.append(" - run [TIME]: runs the simulation from the current point for TIME and then returns to\n");
88+
help.append(" interactive mode; if no time is given, the simulation runs to completion;\n");
89+
help.append(" TIME is of the format <Number><unit> e.g. 4us\n");
90+
91+
help.append(" Exit: Exit the interactive console\n");
92+
help.append(" - exit or quit: exits the interactive console and resumes simulation execution\n");
93+
help.append(" - shutdown: exits the interactive console and does a clean shutdown of the simulation\n");
94+
95+
printf("%s", help.c_str());
96+
}
97+
6098
void
6199
SimpleDebugger::cmd_pwd(std::vector<std::string>& UNUSED(tokens))
62100
{
@@ -378,6 +416,15 @@ SimpleDebugger::cmd_unwatch(std::vector<std::string>& tokens)
378416
watch_points_.erase(watch_points_.begin() + index);
379417
}
380418

419+
void
420+
SimpleDebugger::cmd_shutdown(std::vector<std::string>& UNUSED(tokens))
421+
{
422+
simulationShutdown();
423+
done = true;
424+
printf("Exiting ObjectExplorer and shutting down simulation\n");
425+
return;
426+
}
427+
381428
void
382429
SimpleDebugger::dispatch_cmd(std::string cmd)
383430
{
@@ -415,6 +462,12 @@ SimpleDebugger::dispatch_cmd(std::string cmd)
415462
else if ( tokens[0] == "unwatch" ) {
416463
cmd_unwatch(tokens);
417464
}
465+
else if ( tokens[0] == "shutdown" ) {
466+
cmd_shutdown(tokens);
467+
}
468+
else if ( tokens[0] == "help" ) {
469+
cmd_help(tokens);
470+
}
418471
else {
419472
printf("Unknown command: %s\n", tokens[0].c_str());
420473
}

src/sst/core/impl/interactive/simpleDebug.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class SimpleDebugger : public SST::InteractiveConsole
6666
6767
std::vector<std::string> tokenize(std::vector<std::string>& tokens, const std::string& input);
6868
69+
void cmd_help(std::vector<std::string>& tokens);
6970
void cmd_pwd(std::vector<std::string>& tokens);
7071
void cmd_ls(std::vector<std::string>& tokens);
7172
void cmd_cd(std::vector<std::string>& tokens);
@@ -75,6 +76,7 @@ class SimpleDebugger : public SST::InteractiveConsole
7576
void cmd_run(std::vector<std::string>& tokens);
7677
void cmd_watch(std::vector<std::string>& tokens);
7778
void cmd_unwatch(std::vector<std::string>& tokens);
79+
void cmd_shutdown(std::vector<std::string>& tokens);
7880
7981
void dispatch_cmd(std::string cmd);
8082
};

src/sst/core/interactiveConsole.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,11 @@ InteractiveConsole::getComponentObjectMap()
111111
return Simulation_impl::getSimulation()->getComponentObjectMap();
112112
}
113113

114+
void
115+
InteractiveConsole::simulationShutdown()
116+
{
117+
Simulation_impl::getSimulation()->interactiveShutdown();
118+
}
119+
120+
114121
} // namespace SST

src/sst/core/interactiveConsole.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ class InteractiveConsole
124124

125125
SST::Core::Serialization::ObjectMap* getComponentObjectMap();
126126

127+
void simulationShutdown();
128+
127129
private:
128130
InteractiveConsole(const InteractiveConsole&) = delete;
129131
InteractiveConsole& operator=(const InteractiveConsole&) = delete;

src/sst/core/simulation.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,14 @@ Simulation_impl::signalShutdown(bool abnormal)
10801080
endSim = true;
10811081
}
10821082

1083+
void
1084+
Simulation_impl::interactiveShutdown()
1085+
{
1086+
shutdown_mode_ = SHUTDOWN_CLEAN;
1087+
endSim = true;
1088+
}
1089+
1090+
10831091
// If this version is called, we need to set the end time in the exit
10841092
// object as well
10851093
void

src/sst/core/simulation_impl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ class Simulation_impl
459459
*/
460460
void signalShutdown(bool abnormal);
461461

462+
/** Interactive Shutdown
463+
* Called when an interactive console needs to terminate SST
464+
*/
465+
void interactiveShutdown();
466+
462467
/** Normal Shutdown
463468
*/
464469
void endSimulation();

0 commit comments

Comments
 (0)