@@ -313,18 +313,25 @@ void ProjMgrRunDebug::CollectDebuggerSettings(const ContextItem& context, const
313313 m_runDebug.debugger = defaultDebugger;
314314 }
315315
316+ // primary processor: pname of first cproject
317+ if (m_runDebug.debugger .startPname .empty ()) {
318+ m_runDebug.debugger .startPname = context.deviceItem .pname ;
319+ }
320+
316321 // add info from debug-adapters
317322 if (!adapters.empty ()) {
318323 DebugAdapterItem adapter;
319324 if (GetDebugAdapter (m_runDebug.debugger .name , adapters, adapter)) {
320325 m_runDebug.debugger .name = adapter.name ;
321326 if (adapter.gdbserver ) {
322327 unsigned long long port = adapter.defaults .port .empty () ? 0 : RteUtils::StringToULL (adapter.defaults .port );
328+ // add primary processor port first
329+ m_runDebug.debugger .gdbserver .push_back ({ port, m_runDebug.debugger .startPname });
323330 for (const auto & [pname, _] : pnames) {
324- GdbServerItem item;
325- item. port = port++;
326- item. pname = pname;
327- m_runDebug. debugger . gdbserver . push_back (item);
331+ // add ports for other processors
332+ if (pname != m_runDebug. debugger . startPname ) {
333+ m_runDebug. debugger . gdbserver . push_back ({ ++port, pname }) ;
334+ }
328335 }
329336 }
330337 if (m_runDebug.debugger .protocol .empty ()) {
@@ -335,11 +342,6 @@ void ProjMgrRunDebug::CollectDebuggerSettings(const ContextItem& context, const
335342 }
336343 }
337344 }
338-
339- // primary processor
340- if (m_runDebug.debugger .startPname .empty ()) {
341- m_runDebug.debugger .startPname = context.deviceItem .pname ;
342- }
343345}
344346
345347void ProjMgrRunDebug::CollectDebugTopology (const ContextItem& context, const vector<pair<const RteItem*, vector<string>>> debugs,
@@ -418,6 +420,7 @@ void ProjMgrRunDebug::CollectDebugTopology(const ContextItem& context, const vec
418420 }
419421 }
420422 // processors
423+ map<unsigned int , ProcessorType> processorMap;
421424 for (const auto & [pname, _] : pnames) {
422425 ProcessorType processor;
423426 processor.pname = pname;
@@ -435,6 +438,12 @@ void ProjMgrRunDebug::CollectDebugTopology(const ContextItem& context, const vec
435438 }
436439 // 'punits': placeholder for future expansion
437440 processor.punits .clear ();
441+ // add processors according to apid order
442+ if (processor.apid .has_value ()) {
443+ processorMap[processor.apid .value ()] = processor;
444+ }
445+ }
446+ for (const auto & [_, processor] : processorMap) {
438447 m_runDebug.debugTopology .processors .push_back (processor);
439448 }
440449 // APv1
0 commit comments