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
8 changes: 6 additions & 2 deletions tools/projmgr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ include(FetchContent)
FetchContent_Declare(
debug-adapter-registry
DOWNLOAD_EXTRACT_TIMESTAMP ON
URL https://github.com/Open-CMSIS-Pack/debug-adapter-registry/releases/download/v2.12.0/debug-adapter-registry.zip
URL_HASH SHA256=bb372b97264496bbcb483d2e6d746427974ccdb8a9b91f42f5f8f2ee274742b0
URL https://github.com/Open-CMSIS-Pack/debug-adapter-registry/releases/download/v2.12.1/debug-adapter-registry.zip
URL_HASH SHA256=cdba4704cbc8f0d8815508e733b9eb2180c87f749312a6b6938ad5dbe3ace3fa
)
FetchContent_MakeAvailable(debug-adapter-registry)
file(COPY ${debug-adapter-registry_SOURCE_DIR}/schemas/debug-adapters.schema.json DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/schemas)
Expand Down Expand Up @@ -52,6 +52,10 @@ SET(PROJMGR_HEADER_FILES ProjMgr.h ProjMgrKernel.h ProjMgrCallback.h
list(TRANSFORM PROJMGR_SOURCE_FILES PREPEND src/)
list(TRANSFORM PROJMGR_HEADER_FILES PREPEND include/)

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif()

add_library(projmgrlib OBJECT
${PROJMGR_SOURCE_FILES}
${PROJMGR_HEADER_FILES}
Expand Down
45 changes: 42 additions & 3 deletions tools/projmgr/include/ProjMgrParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ struct MemoryItem {
std::string algorithm;
};

/**
* @brief telnet item containing
* mode
* port
* file
* pname
*/
struct TelnetItem {
std::string mode;
std::string port;
std::string file;
std::string pname;
};

/**
* @brief custom item containing
* scalar
Expand All @@ -147,6 +161,7 @@ struct CustomItem {
* debug clock speed
* debug configuration file
* start pname
* telnet options
* custom properties
*/
struct DebuggerItem {
Expand All @@ -155,6 +170,7 @@ struct DebuggerItem {
std::string clock;
std::string dbgconf;
std::string startPname;
std::vector<TelnetItem> telnet;
CustomItem custom;
};

Expand Down Expand Up @@ -634,14 +650,38 @@ struct CbuildSetItem {
std::string compiler;
};

/**
* @brief gdbserver defaults item containing
* gdbserver port
* active flag
*/
struct GdbServerDefaults {
std::string port;
bool active = false;
};

/**
* @brief telnet defaults item containing
* telnet port
* telnet mode
* active flag
*/
struct TelnetDefaults {
std::string port;
std::string mode;
bool active = false;
};

/**
* @brief debug-adapter defaults item containing
* port number of processor
* gdbserver defaults
* telnet defaults
* debug protocol(jtag or swd)
* debug clock speed
*/
struct DebugAdapterDefaultsItem {
std::string port;
GdbServerDefaults gdbserver;
TelnetDefaults telnet;
std::string protocol;
std::string clock;
CustomItem custom;
Expand All @@ -659,7 +699,6 @@ struct DebugAdapterItem {
std::string name;
std::vector<std::string> alias;
std::string templateFile;
bool gdbserver = false;
DebugAdapterDefaultsItem defaults;
};

Expand Down
2 changes: 2 additions & 0 deletions tools/projmgr/include/ProjMgrRunDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class ProjMgrRunDebug {
const std::map<std::string, RteDeviceProperty*>& pnames);
void CollectDebugTopology(const ContextItem& context, std::vector<std::pair<const RteItem*, std::vector<std::string>>> debugs,
const std::map<std::string, RteDeviceProperty*>& pnames);
void CollectTelnetOptions(const ContextItem& context, DebugAdapterItem& adapter,
const std::map<std::string, RteDeviceProperty*>& pnames);
CustomItem& CustomMapFind(std::vector<std::pair<std::string, CustomItem>>& customMap, const std::string& key);
void MergeCustomItems(const CustomItem& src, CustomItem& dst);
};
Expand Down
10 changes: 10 additions & 0 deletions tools/projmgr/include/ProjMgrWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ struct GdbServerItem {
std::string pname;
};

/**
* @brief telnet port item extends TelnetItem containing
resolved port number
*/
struct TelnetOptionsItem : TelnetItem {
unsigned long long ullPort;
};

/**
* @brief example environment item containing
* project file with extension
Expand Down Expand Up @@ -355,6 +363,7 @@ struct TemplateItem {
* debug configuration file
* start pname
* list of gdbserver items
* list of telnet options items
* custom options
*/
struct DebuggerType {
Expand All @@ -365,6 +374,7 @@ struct DebuggerType {
std::string dbgconf;
std::string startPname;
std::vector<GdbServerItem> gdbserver;
std::map<std::string, TelnetOptionsItem> telnet;
CustomItem custom;
};

Expand Down
4 changes: 4 additions & 0 deletions tools/projmgr/include/ProjMgrYamlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
static constexpr const char* YAML_ACCESS = "access";
static constexpr const char* YAML_ACCESSPORTS = "accessports";
static constexpr const char* YAML_ACTIVE = "active";
static constexpr const char* YAML_ALGORITHM = "algorithm";
static constexpr const char* YAML_ALIAS = "alias";
static constexpr const char* YAML_ALIAS_NAME = "alias-name";
Expand Down Expand Up @@ -164,6 +165,7 @@ static constexpr const char* YAML_MISC_LIBRARY = "Library";
static constexpr const char* YAML_MISC_LINK = "Link";
static constexpr const char* YAML_MISC_LINK_C = "Link-C";
static constexpr const char* YAML_MISC_LINK_CPP = "Link-CPP";
static constexpr const char* YAML_MODE = "mode";
static constexpr const char* YAML_MVE = "mve";
static constexpr const char* YAML_NAME = "name";
static constexpr const char* YAML_NOTFORCONTEXT = "not-for-context";
Expand Down Expand Up @@ -234,6 +236,7 @@ static constexpr const char* YAML_TARGET_SET = "target-set";
static constexpr const char* YAML_TARGETTYPE = "target-type";
static constexpr const char* YAML_TARGETTYPES = "target-types";
static constexpr const char* YAML_TEMPLATE = "template";
static constexpr const char* YAML_TELNET = "telnet";
static constexpr const char* YAML_TIMEOUT = "timeout";
static constexpr const char* YAML_TRUSTZONE = "trustzone";
static constexpr const char* YAML_TITLE = "title";
Expand Down Expand Up @@ -359,6 +362,7 @@ class ProjMgrYamlParser {
bool ParseLinker(const YAML::Node& parent, const std::string& file, std::vector<LinkerItem>& linker);
void ParseRte(const YAML::Node& parent, std::string& rteBaseDir);
void ParseDebugDefaults(const YAML::Node& parent, const std::string& file, DebugAdapterDefaultsItem& defaults);
void ParseTelnet(const YAML::Node& parent, const std::string& file, std::vector<TelnetItem>& telnet);
void ParseCustom(const YAML::Node& parent, const std::vector<std::string>& skip, CustomItem& custom);
bool GetTypes(const std::string& type, std::string& buildType, std::string& targetType, std::string& pattern);
bool ValidateCdefault(const std::string& input, const YAML::Node& root);
Expand Down
24 changes: 22 additions & 2 deletions tools/projmgr/schemas/common.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2217,11 +2217,30 @@
"clock": { "type": "number", "description": "Selected debug clock speed (in Hz)." },
"dbgconf": { "type": "string", "description": "Debugger configuration file (pinout, trace)." },
"start-pname": { "type": "string", "description": "Debugger connects at start to this processor." },
"gdbserver": { "$ref": "#/definitions/GdbServersType" }
"gdbserver": { "$ref": "#/definitions/GdbServersType" },
"telnet": { "$ref": "#/definitions/TelnetOptionsType" }
},
"additionalProperties": true,
"required": ["name"]
},
"TelnetOptionsType": {
"title": "telnet:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#telnet-for-pyocd",
"description": "Telnet port for connecting remote tools.",
"type": "array",
"uniqueItems": true,
"items": { "$ref": "#/definitions/TelnetOptionType" }
},
"TelnetOptionType": {
"type": "object",
"properties": {
"mode": { "enum": [ "off", "server", "file", "console", "monitor" ], "description": "Redirect output mode." },
"pname": { "type": "string", "description": "Processor name of the processor (only required for multi-core systems)." },
"port": { "type": "number", "description": "Set TCP/IP port number of Telnet Server." },
"file": { "type": "string", "description": "Base path and name of the telnet output file (without extension)."}
},
"additionalProperties": false,
"required": ["mode"]
},
"GdbServersType": {
"title": "gdbserver:\nDocumentation: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-CBuild-Format/#gdbserver",
"description": "Information for GDB server option of debugger.",
Expand Down Expand Up @@ -2431,7 +2450,8 @@
"protocol": { "enum": [ "jtag", "swd" ], "description": "Selected debug protocol (jtag or swd)." },
"clock": { "type": "number", "description": "Selected debug clock speed (in Hz)." },
"dbgconf": { "type": "string", "description": "Debugger configuration file (pinout, trace)." },
"start-pname": { "type": "string", "description": "Debugger connects at start to this processor." }
"start-pname": { "type": "string", "description": "Debugger connects at start to this processor." },
"telnet": { "$ref": "#/definitions/TelnetOptionsType" }
},
"additionalProperties": true,
"required": ["name"]
Expand Down
15 changes: 15 additions & 0 deletions tools/projmgr/src/ProjMgrCbuildRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ProjMgrCbuildRun : public ProjMgrCbuildBase {
void SetAccessPortsNode(YAML::Node node, const std::vector<AccessPortType>& accessPorts);
void SetDatapatchNode(YAML::Node node, const std::vector<DatapatchType>& datapatch);
void SetGdbServerNode(YAML::Node node, const std::vector<GdbServerItem>& gdbserver);
void SetTelnetNode(YAML::Node node, const std::map<std::string, TelnetOptionsItem>& telnet);
void SetCustomNodes(YAML::Node node, const CustomItem& debugger);
YAML::Node GetCustomNode(const CustomItem& value);
};
Expand Down Expand Up @@ -112,6 +113,7 @@ void ProjMgrCbuildRun::SetDebuggerNode(YAML::Node node, const DebuggerType& debu
}
SetNodeValue(node[YAML_START_PNAME], debugger.startPname);
SetGdbServerNode(node[YAML_GDBSERVER], debugger.gdbserver);
SetTelnetNode(node[YAML_TELNET], debugger.telnet);
SetCustomNodes(node, debugger.custom);
}
}
Expand Down Expand Up @@ -149,6 +151,19 @@ void ProjMgrCbuildRun::SetGdbServerNode(YAML::Node node, const std::vector<GdbSe
}
}

void ProjMgrCbuildRun::SetTelnetNode(YAML::Node node, const std::map<std::string, TelnetOptionsItem>& telnet) {
for (const auto& [pname, item] : telnet) {
YAML::Node telnetNode;
SetNodeValue(telnetNode[YAML_MODE], item.mode);
SetNodeValue(telnetNode[YAML_PNAME], pname);
telnetNode[YAML_PORT] = item.ullPort;
if (!item.file.empty()) {
SetNodeValue(telnetNode[YAML_FILE], FormatPath(item.file, m_directory));
}
node.push_back(telnetNode);
}
}

void ProjMgrCbuildRun::SetDebugVarsNode(YAML::Node node, const DebugVarsType& debugVars) {
if (!debugVars.vars.empty()) {
SetNodeValue(node[YAML_VARS], "|\n" + debugVars.vars);
Expand Down
75 changes: 72 additions & 3 deletions tools/projmgr/src/ProjMgrRunDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,12 @@ void ProjMgrRunDebug::CollectDebuggerSettings(const ContextItem& context, const
}

// add info from debug-adapters
DebugAdapterItem adapter;
if (!adapters.empty()) {
DebugAdapterItem adapter;
if (GetDebugAdapter(m_runDebug.debugger.name, adapters, adapter)) {
m_runDebug.debugger.name = adapter.name;
if (adapter.gdbserver) {
unsigned long long port = adapter.defaults.port.empty() ? 0 : RteUtils::StringToULL(adapter.defaults.port);
if (adapter.defaults.gdbserver.active) {
unsigned long long port = adapter.defaults.gdbserver.port.empty() ? 0 : RteUtils::StringToULL(adapter.defaults.gdbserver.port);
// add primary processor port first
m_runDebug.debugger.gdbserver.push_back({ port, m_runDebug.debugger.startPname });
for (const auto& [pname, _] : pnames) {
Expand All @@ -348,8 +348,77 @@ void ProjMgrRunDebug::CollectDebuggerSettings(const ContextItem& context, const
}
}

// collect telnet options
CollectTelnetOptions(context, adapter, pnames);

// merge custom options
MergeCustomItems(context.debugger.custom, m_runDebug.debugger.custom);

}

void ProjMgrRunDebug::CollectTelnetOptions(const ContextItem& context, DebugAdapterItem& adapter,
const std::map<std::string, RteDeviceProperty*>& pnames) {
if (!context.debugger.telnet.empty() || adapter.defaults.telnet.active) {
set<unsigned long long> usedPorts;
const string fileBase = context.directories.cprj + "/" + context.directories.outBaseDir + "/" +
m_runDebug.solutionName + "+" + m_runDebug.targetType;

// get values from user definitions
for (const auto& [pname, value] : context.debugger.telnet) {
if (pnames.size() > 1 && value.pname.empty()) {
ProjMgrLogger::Get().Warn("'telnet:' pname is required (multicore device)");
continue;
}
if (pnames.find(pname) == pnames.end()) {
ProjMgrLogger::Get().Warn("pname '" + pname + "' does not match any device pname");
continue;
}
m_runDebug.debugger.telnet[pname] = { value };
if (!value.port.empty()) {
m_runDebug.debugger.telnet[pname].ullPort = RteUtils::StringToULL(value.port);
usedPorts.insert(m_runDebug.debugger.telnet[pname].ullPort);
}
if (value.mode.empty()) {
m_runDebug.debugger.telnet[pname].mode = adapter.defaults.telnet.mode.empty() ? "monitor" : adapter.defaults.telnet.mode;
}
if (value.mode == "file" && value.file.empty()) {
m_runDebug.debugger.telnet[pname].file = fileBase + (pname.empty() ? "" : '.' + pname);
}
}
// active flag: enable telnet options for all cores
if (adapter.defaults.telnet.active) {
for (const auto& [pname, _] : pnames) {
auto& telnet = m_runDebug.debugger.telnet[pname];
if (telnet.mode.empty() || telnet.mode == "off") {
telnet.mode = adapter.defaults.telnet.mode.empty() ? "monitor" : adapter.defaults.telnet.mode;
}
}
}
// port number handling
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);
}
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;
}
}
}
}

void ProjMgrRunDebug::CollectDebugTopology(const ContextItem& context, const vector<pair<const RteItem*, vector<string>>> debugs,
Expand Down
8 changes: 8 additions & 0 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2646,6 +2646,14 @@ bool ProjMgrWorker::ProcessDebuggers(ContextItem& context) {
}
}
context.debugger.startPname = m_activeTargetSet.debugger.startPname;
for (auto telnet : m_activeTargetSet.debugger.telnet) {
if (!telnet.file.empty()) {
if (!ProcessSequenceRelative(context, telnet.file, context.csolution->directory)) {
return false;
}
}
context.debugger.telnet[telnet.pname] = { telnet };
}
context.debugger.custom = m_activeTargetSet.debugger.custom;
}
for (const auto& [filename, fi] : context.rteActiveProject->GetFileInstances()) {
Expand Down
Loading
Loading