99#include " ProjMgrYamlEmitter.h"
1010#include " RteFsUtils.h"
1111
12+ #include < regex>
13+
1214using namespace std ;
1315
1416ProjMgrRunDebug::ProjMgrRunDebug (void ) {
@@ -39,6 +41,8 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
3941 Collection<RteItem*> algorithms;
4042 // debug infos
4143 Collection<RteItem*> debugs;
44+ // debug sequences
45+ Collection<RteItem*> debugSequences;
4246
4347 // device collections
4448 if (context->devicePack ) {
@@ -51,6 +55,10 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
5155 for (const auto & deviceDebug : deviceDebugs) {
5256 debugs.push_back (deviceDebug);
5357 }
58+ const auto & deviceDebugSequences = context->rteDevice ->GetEffectiveProperties (" sequence" , context->deviceItem .pname );
59+ for (const auto & deviceDebugSequence : deviceDebugSequences) {
60+ debugSequences.push_back (deviceDebugSequence);
61+ }
5462 }
5563
5664 // board collections
@@ -103,5 +111,53 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
103111 m_runDebug.outputs .push_back ({ output.hex .filename , RteConstants::OUTPUT_TYPE_HEX });
104112 }
105113 }
114+
115+ // debug sequences
116+ for (const auto & debugSequence : debugSequences) {
117+ DebugSequencesType sequence;
118+ sequence.name = debugSequence->GetName ();
119+ sequence.info = debugSequence->GetAttribute (" info" );
120+ for (const auto & debugSequenceBlock : debugSequence->GetChildren ()) {
121+ DebugSequencesBlockType block;
122+ GetDebugSequenceBlock (debugSequenceBlock, block);
123+ sequence.blocks .push_back (block);
124+ }
125+ m_runDebug.debugSequences .push_back (sequence);
126+ }
127+
106128 return true ;
107129}
130+
131+ void ProjMgrRunDebug::GetDebugSequenceBlock (const RteItem* item, DebugSequencesBlockType& block) {
132+ // get 'block' attributes
133+ if (item->GetTag () == " block" ) {
134+ block.info = block.info .empty () ? item->GetAttribute (" info" ) : block.info ;
135+ block.atomic = item->GetAttributeAsBool (" atomic" );
136+ const string execute = RteUtils::EnsureLf (item->GetText ());
137+ block.execute = regex_replace (execute, regex (" \n +" ), " \n " );
138+ // 'block' doesn't have children, stop here
139+ return ;
140+ }
141+
142+ // get 'control' attributes
143+ if (item->GetTag () == " control" ) {
144+ block.info = item->GetAttribute (" info" );
145+ block.control_if = item->GetAttribute (" if" );
146+ block.control_while = item->GetAttribute (" while" );
147+ block.timeout = item->GetAttribute (" timeout" );
148+ }
149+
150+ const auto & children = item->GetChildren ();
151+ if ((children.size () == 1 ) && (children.front ()->GetTag () == " block" )) {
152+ // last child block
153+ GetDebugSequenceBlock (children.front (), block);
154+ return ;
155+ }
156+
157+ for (const auto & child : children) {
158+ // get children blocks recursively
159+ DebugSequencesBlockType childBlock;
160+ GetDebugSequenceBlock (child, childBlock);
161+ block.blocks .push_back (childBlock);
162+ }
163+ }
0 commit comments