@@ -47,8 +47,10 @@ SimpleDebugger::SimpleDebugger(Params& params) :
4747 [this ](std::vector<std::string>& tokens) { cmd_help (tokens); } },
4848 { " verbose" , " v" , " [mask]: set verbosity mask or print if no mask specified" , ConsoleCommandGroup::GENERAL,
4949 [this ](std::vector<std::string>& tokens) { cmd_verbose (tokens); } },
50- { " rankinfo" , " ri" , " print current rank and thread IDs" , ConsoleCommandGroup::GENERAL,
51- [this ](std::vector<std::string>& tokens) { cmd_rankInfo (tokens); } },
50+ { " info" , " info" , " \" current\" |\" all\" print summary for current thread or all threads" , ConsoleCommandGroup::GENERAL,
51+ [this ](std::vector<std::string>& tokens) { cmd_info (tokens); } },
52+ { " thread" , " thd" , " [threadID]: switch to specified thread ID" , ConsoleCommandGroup::GENERAL,
53+ [this ](std::vector<std::string>& tokens) { cmd_thread (tokens); } },
5254 { " confirm" , " cfm" , " <true/false>: set confirmation requests on (default) or off" , ConsoleCommandGroup::GENERAL,
5355 [this ](std::vector<std::string>& tokens) { cmd_setConfirm (tokens); } },
5456 { " pwd" , " pwd" , " print the current working directory in the object map" , ConsoleCommandGroup::NAVIGATION,
@@ -195,22 +197,59 @@ SimpleDebugger::~SimpleDebugger()
195197}
196198
197199void
200+ SimpleDebugger::summary ()
201+ {
202+ #if 0
203+ RankInfo info = getRank();
204+ RankInfo nRanks = getNumRanks();
205+ std::count << "\n(Rank:" << info.rank << " / " << nRanks.rank
206+ << " Thread:" << info.thread << "/" << nRanks.thread
207+ << ")\n";
208+ std::cout << " -- Trigger Status\n";
209+ #endif
210+
211+ std::cout << " -- Component Summary\n " ;
212+ #if 0
213+ std::vector<std::string> tokens;
214+ if (nullptr == obj_) {
215+ obj_ = getComponentObjectMap();
216+ }
217+ cmd_ls(tokens);
218+ #else
219+ SST::Core::Serialization::ObjectMap* baseObj = getComponentObjectMap ();
220+ auto & vars = baseObj->getVariables ();
221+ for (auto & x : vars) {
222+ if (x.second ->isFundamental ()) {
223+ std::cout << x.first << " = " << x.second ->get () << " (" << x.second ->getType () << " )" << std::endl;
224+ }
225+ else {
226+ std::cout << x.first .c_str () << " / (" << x.second ->getType () << " )\n " ;
227+ }
228+ }
229+ #endif
230+ }
231+
232+ int
198233SimpleDebugger::execute (const std::string& msg)
199234{
200- printf (" Entering interactive mode at time %" PRI_SIMTIME " \n " , getCurrentSimCycle ());
235+ RankInfo info = getRank ();
236+ RankInfo nRanks = getNumRanks ();
237+ printf (" \n ---- Rank%d:Thread%d: Entering interactive mode at time %" PRI_SIMTIME " \n " , info.rank , info.thread , getCurrentSimCycle ());
201238 printf (" %s\n " , msg.c_str ());
202239
203240 if ( nullptr == obj_ ) {
204241 obj_ = getComponentObjectMap ();
205242 }
206243 done = false ;
244+ retState = -1 ;
245+
207246
208247 std::string line;
209248 while ( !done ) {
210249
211250 try {
212251 // User input prompt
213- std::cout << " > " << std::flush;
252+ std::cout << " R " << info. rank << " :T " << info. thread << " > " << std::flush;
214253
215254 if ( !injectedCommand.str ().empty () ) {
216255 // Injected command stream (currently just one command)
@@ -252,6 +291,7 @@ SimpleDebugger::execute(const std::string& msg)
252291 std::cout << " Parsing error. Ignoring " << line << std::endl;
253292 }
254293 }
294+ return retState;
255295}
256296
257297// Invoke the command.
@@ -397,12 +437,75 @@ SimpleDebugger::cmd_verbose(std::vector<std::string>& tokens)
397437 }
398438}
399439
400- SimpleDebugger::cmd_rankInfo (std::vector<std::string>& UNUSED (tokens)) {
440+ void
441+ SimpleDebugger::cmd_info (std::vector<std::string>& UNUSED (tokens)) {
442+
443+ if (tokens.size () != 2 ) {
444+ printf (" Invalid format for info command (info \" current\" |\" all\" )\n " );
445+ return ;
446+ }
447+
448+ RankInfo info = getRank ();
449+ RankInfo nRanks = getNumRanks ();
450+ if (tokens[1 ] == " current" ) {
451+ std::cout << " Rank " << info.rank << " /" << nRanks.rank
452+ << " , Thread " << info.thread << " /" << nRanks.thread << std::endl;
453+ }
454+ else if (tokens[1 ] == " all" ) {
455+ if (nRanks.rank == 1 && nRanks.thread == 1 ) {
456+ std::cout << " Rank " << info.rank << " /" << nRanks.rank
457+ << " , Thread " << info.thread << " /" << nRanks.thread << std::endl;
458+ }
459+ else {
460+ // Return to syncmanager to print summary for all threads
461+ retState = -2 ; // summary info
462+ done = true ;
463+ }
464+ }
465+ else {
466+ printf (" Invalid argument for info command: %s (info \" current\" |\" all\" )\n " , tokens[1 ].c_str ());
467+ return ;
468+ }
469+ }
470+
471+ // thread <threadID> : switches to new thread
472+ void
473+ SimpleDebugger::cmd_thread (std::vector<std::string>& tokens) {
474+
475+ if (tokens.size () != 2 ) {
476+ printf (" Invalid format for thread command (thread <threadID>)\n " );
477+ return ;
478+ }
401479
402480 RankInfo info = getRank ();
403481 RankInfo nRanks = getNumRanks ();
404- std::cout << " Rank " << info.rank << " /" << nRanks.rank
405- << " , Thread " << info.thread << " /" << nRanks.thread << std::endl;
482+ int threadID;
483+
484+ // Get threadID
485+ try {
486+ threadID = std::stoi (tokens[1 ]);
487+ }
488+ catch (const std::invalid_argument& e) {
489+ std::cout << " Invalid argument for threadID: " << tokens[1 ] << std::endl;
490+ return ;
491+ }
492+ catch (const std::out_of_range& e) {
493+ std::cout << " Out of range for threadID: " << tokens[1 ] << std::endl;
494+ return ;
495+ }
496+
497+ // Check if valid threadID
498+ if (threadID < 0 || threadID >= nRanks.thread ) {
499+ printf (" ThreadID %d out of range (0:%d)\n " , threadID, nRanks.thread -1 );
500+ return ;
501+ }
502+
503+ // If not current thread, set retState and done flag
504+ if (threadID != info.thread ) {
505+ retState = threadID;
506+ done = true ;
507+ }
508+ return ;
406509}
407510
408511
@@ -457,10 +560,18 @@ SimpleDebugger::get_listing_strings(std::list<std::string>& list)
457560void
458561SimpleDebugger::cmd_cd (std::vector<std::string>& tokens)
459562{
563+ #if 1
460564 if ( tokens.size () != 2 ) {
461565 printf (" Invalid format for cd command (cd <obj>)\n " );
462566 return ;
463567 }
568+ #else
569+ // skk This works but doesn't delete/deactivate like objmap selectParent
570+ if (tokens.size() == 1) {
571+ obj_ = getComponentObjectMap();
572+ return;
573+ }
574+ #endif
464575
465576 // Allow for trailing '/'
466577 std::string selection = tokens[1 ];
0 commit comments