Skip to content

Commit aaa99e5

Browse files
authored
[cbuild-run] Rework gdbserver ports and processors order
1 parent 0933127 commit aaa99e5

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

tools/projmgr/src/ProjMgrRunDebug.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

345347
void 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

tools/projmgr/test/data/TestRunDebug/ref/run-debug+TestHW3.cbuild-run.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ cbuild-run:
5252
start-pname: cm0_core1
5353
gdbserver:
5454
- port: 3333
55-
pname: cm0_core0
56-
- port: 3334
5755
pname: cm0_core1
56+
- port: 3334
57+
pname: cm0_core0
5858
debug-vars:
5959
vars: |
6060
__var DbgMCU_CR = 0x00000007; // DBGMCU_CR: DBG_SLEEP, DBG_STOP, DBG_STANDBY

0 commit comments

Comments
 (0)