Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/projmgr/include/ProjMgrRunDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class ProjMgrRunDebug {
const std::map<std::string, RteDeviceProperty*>& pnames);
void CollectTelnetOptions(const ContextItem& context, DebugAdapterItem& adapter,
const std::map<std::string, RteDeviceProperty*>& pnames);
void SetTelnetPort(TelnetOptionsItem& item, unsigned long long& port, std::set<unsigned long long>& usedPorts);
CustomItem& CustomMapFind(std::vector<std::pair<std::string, CustomItem>>& customMap, const std::string& key);
void MergeCustomItems(const CustomItem& src, CustomItem& dst);
};
Expand Down
33 changes: 19 additions & 14 deletions tools/projmgr/src/ProjMgrRunDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,29 +410,34 @@ void ProjMgrRunDebug::CollectTelnetOptions(const ContextItem& context, DebugAdap
unsigned long long port = adapter.defaults.telnet.port.empty() ? 0 : RteUtils::StringToULL(adapter.defaults.telnet.port);
if (m_runDebug.debugger.telnet.find(m_runDebug.debugger.startPname) != m_runDebug.debugger.telnet.end()) {
// add primary processor port first
auto& startPort = m_runDebug.debugger.telnet[m_runDebug.debugger.startPname].ullPort;
if (startPort == 0) {
startPort = port;
} else {
port = startPort;
}
usedPorts.insert(port);
auto& start = m_runDebug.debugger.telnet[m_runDebug.debugger.startPname];
// set next available port
SetTelnetPort(start, port, usedPorts);
// set starting port for other processors
port = start.ullPort;
}
for (auto& [pname, telnet] : m_runDebug.debugger.telnet) {
// add ports for other processors
if (pname != m_runDebug.debugger.startPname) {
// get customized port if set
port = telnet.port.empty() ? port : telnet.ullPort;
while (usedPorts.find(port) != usedPorts.end()) {
// skip port number if it has already been used
port++;
}
telnet.ullPort = port;
// set next available port
SetTelnetPort(telnet, port, usedPorts);
}
}
}
}

void ProjMgrRunDebug::SetTelnetPort(TelnetOptionsItem& item, unsigned long long& port, std::set<unsigned long long>& usedPorts) {
// only assign a port number if it has not been already specified
if (item.port.empty()) {
while (usedPorts.find(port) != usedPorts.end()) {
// skip port number if it has already been used
port++;
}
item.ullPort = port;
usedPorts.insert(port);
}
}

void ProjMgrRunDebug::CollectDebugTopology(const ContextItem& context, const vector<pair<const RteItem*, vector<string>>> debugs,
const std::map<std::string, RteDeviceProperty*>& pnames) {
// debug topology
Expand Down
14 changes: 14 additions & 0 deletions tools/projmgr/test/data/TestRunDebug/telnet.csolution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ solution:
name: J-Link Server
start-pname: cm0_core1

- set: CustomPorts
images:
- project-context: core0
- project-context: core1
debugger:
name: CMSIS-DAP
telnet:
- mode: monitor
pname: cm0_core1
port: 1234
- mode: monitor
pname: cm0_core0
port: 5678

- set: Warnings
images:
- project-context: core0
Expand Down
14 changes: 14 additions & 0 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6904,6 +6904,20 @@ R"(- mode: off
pname: cm0_core1
port: 4444)", sstream3.str());

// dual core with custom port numbers
argv[6] = (char*)"DualCore@CustomPorts";
EXPECT_EQ(0, RunProjMgr(7, argv, m_envp));
const YAML::Node& cbuildrun4 = YAML::LoadFile(testoutput_folder + "/out/telnet+DualCore.cbuild-run.yml");
stringstream sstream4;
sstream4 << cbuildrun4["cbuild-run"]["debugger"]["telnet"];
EXPECT_EQ(
R"(- mode: monitor
pname: cm0_core0
port: 5678
- mode: monitor
pname: cm0_core1
port: 1234)", sstream4.str());

// warnings
StdStreamRedirect streamRedirect;
argv[6] = (char*)"DualCore@Warnings";
Expand Down
Loading