@@ -49,6 +49,10 @@ SimpleDebugger::SimpleDebugger(Params& params) :
4949 [this ](std::vector<std::string>& tokens) { cmd_verbose (tokens); } },
5050 { " rankinfo" , " ri" , " print current rank and thread IDs" , ConsoleCommandGroup::GENERAL,
5151 [this ](std::vector<std::string>& tokens) { cmd_rankInfo (tokens); } },
52+ { " info" , " info" , " \" current\" |\" all\" print summary for current thread or all threads" , ConsoleCommandGroup::GENERAL,
53+ [this ](std::vector<std::string>& tokens) { cmd_info (tokens); } },
54+ { " thread" , " thd" , " [threadID]: switch to specified thread ID" , ConsoleCommandGroup::GENERAL,
55+ [this ](std::vector<std::string>& tokens) { cmd_thread (tokens); } },
5256 { " confirm" , " cfm" , " <true/false>: set confirmation requests on (default) or off" , ConsoleCommandGroup::GENERAL,
5357 [this ](std::vector<std::string>& tokens) { cmd_setConfirm (tokens); } },
5458 { " pwd" , " pwd" , " print the current working directory in the object map" , ConsoleCommandGroup::NAVIGATION,
@@ -195,22 +199,59 @@ SimpleDebugger::~SimpleDebugger()
195199}
196200
197201void
202+ SimpleDebugger::summary ()
203+ {
204+ #if 0
205+ RankInfo info = getRank();
206+ RankInfo nRanks = getNumRanks();
207+ std::count << "\n(Rank:" << info.rank << " / " << nRanks.rank
208+ << " Thread:" << info.thread << "/" << nRanks.thread
209+ << ")\n";
210+ std::cout << "-- Trigger Status\n";
211+ #endif
212+
213+ std::cout << " -- Component Summary\n " ;
214+ #if 0
215+ std::vector<std::string> tokens;
216+ if (nullptr == obj_) {
217+ obj_ = getComponentObjectMap();
218+ }
219+ cmd_ls(tokens);
220+ #else
221+ SST::Core::Serialization::ObjectMap* baseObj = getComponentObjectMap ();
222+ auto & vars = baseObj->getVariables ();
223+ for (auto & x : vars) {
224+ if (x.second ->isFundamental ()) {
225+ std::cout << x.first << " = " << x.second ->get () << " (" << x.second ->getType () << " )" << std::endl;
226+ }
227+ else {
228+ std::cout << x.first .c_str () << " / (" << x.second ->getType () << " )\n " ;
229+ }
230+ }
231+ #endif
232+ }
233+
234+ int
198235SimpleDebugger::execute (const std::string& msg)
199236{
200- printf (" Entering interactive mode at time %" PRI_SIMTIME " \n " , getCurrentSimCycle ());
237+ RankInfo info = getRank ();
238+ RankInfo nRanks = getNumRanks ();
239+ printf (" \n ---- Rank%d:Thread%d: Entering interactive mode at time %" PRI_SIMTIME " \n " , info.rank , info.thread , getCurrentSimCycle ());
201240 printf (" %s\n " , msg.c_str ());
202241
203242 if ( nullptr == obj_ ) {
204243 obj_ = getComponentObjectMap ();
205244 }
206245 done = false ;
246+ retState = -1 ;
247+
207248
208249 std::string line;
209250 while ( !done ) {
210251
211252 try {
212253 // User input prompt
213- std::cout << " > " << std::flush;
254+ std::cout << " R " << info. rank << " :T " << info. thread << " > " << std::flush;
214255
215256 if ( !injectedCommand.str ().empty () ) {
216257 // Injected command stream (currently just one command)
@@ -252,6 +293,7 @@ SimpleDebugger::execute(const std::string& msg)
252293 std::cout << " Parsing error. Ignoring " << line << std::endl;
253294 }
254295 }
296+ return retState;
255297}
256298
257299// Invoke the command.
@@ -397,6 +439,7 @@ SimpleDebugger::cmd_verbose(std::vector<std::string>& tokens)
397439 }
398440}
399441
442+ void
400443SimpleDebugger::cmd_rankInfo (std::vector<std::string>& UNUSED (tokens)) {
401444
402445 RankInfo info = getRank ();
@@ -405,6 +448,77 @@ SimpleDebugger::cmd_rankInfo(std::vector<std::string>& UNUSED(tokens)) {
405448 << " , Thread " << info.thread << " /" << nRanks.thread << std::endl;
406449}
407450
451+ void
452+ SimpleDebugger::cmd_info (std::vector<std::string>& UNUSED (tokens)) {
453+
454+ if (tokens.size () != 2 ) {
455+ printf (" Invalid format for info command (info \" current\" |\" all\" )\n " );
456+ return ;
457+ }
458+
459+ RankInfo info = getRank ();
460+ RankInfo nRanks = getNumRanks ();
461+ if (tokens[1 ] == " current" ) {
462+ std::cout << " Rank " << info.rank << " /" << nRanks.rank
463+ << " , Thread " << info.thread << " /" << nRanks.thread << std::endl;
464+ }
465+ else if (tokens[1 ] == " all" ) {
466+ if (nRanks.rank == 1 && nRanks.thread == 1 ) {
467+ std::cout << " Rank " << info.rank << " /" << nRanks.rank
468+ << " , Thread " << info.thread << " /" << nRanks.thread << std::endl;
469+ }
470+ else {
471+ // Return to syncmanager to print summary for all threads
472+ retState = -2 ; // summary info
473+ done = true ;
474+ }
475+ }
476+ else {
477+ printf (" Invalid argument for info command: %s (info \" current\" |\" all\" )\n " , tokens[1 ].c_str ());
478+ return ;
479+ }
480+ }
481+
482+ // thread <threadID> : switches to new thread
483+ void
484+ SimpleDebugger::cmd_thread (std::vector<std::string>& tokens) {
485+
486+ if (tokens.size () != 2 ) {
487+ printf (" Invalid format for thread command (thread <threadID>)\n " );
488+ return ;
489+ }
490+
491+ RankInfo info = getRank ();
492+ RankInfo nRanks = getNumRanks ();
493+ int threadID;
494+
495+ // Get threadID
496+ try {
497+ threadID = std::stoi (tokens[1 ]);
498+ }
499+ catch (const std::invalid_argument& e) {
500+ std::cout << " Invalid argument for threadID: " << tokens[1 ] << std::endl;
501+ return ;
502+ }
503+ catch (const std::out_of_range& e) {
504+ std::cout << " Out of range for threadID: " << tokens[1 ] << std::endl;
505+ return ;
506+ }
507+
508+ // Check if valid threadID
509+ if (threadID < 0 || threadID >= nRanks.thread ) {
510+ printf (" ThreadID %d out of range (0:%d)\n " , threadID, nRanks.thread -1 );
511+ return ;
512+ }
513+
514+ // If not current thread, set retState and done flag
515+ if (threadID != info.thread ) {
516+ retState = threadID;
517+ done = true ;
518+ }
519+ return ;
520+ }
521+
408522
409523// pwd: print current working directory
410524void
@@ -457,10 +571,20 @@ SimpleDebugger::get_listing_strings(std::list<std::string>& list)
457571void
458572SimpleDebugger::cmd_cd (std::vector<std::string>& tokens)
459573{
574+ #if 0
460575 if ( tokens.size() != 2 ) {
461576 printf("Invalid format for cd command (cd <obj>)\n");
462577 return;
463578 }
579+ #else
580+ // skk This works but does it leave anything hanging around?
581+ // I see in objmap selectParent it does a deactivate, so not sure if I need
582+ // to deactivate everything on the way back up the hierarchy.
583+ if (tokens.size () == 1 ) {
584+ obj_ = getComponentObjectMap ();
585+ return ;
586+ }
587+ #endif
464588
465589 // Allow for trailing '/'
466590 std::string selection = tokens[1 ];
0 commit comments