@@ -18,6 +18,10 @@ using namespace std;
1818 * @brief default debugger parameters
1919 */
2020static constexpr const char * DEBUGGER_NAME_DEFAULT = " CMSIS-DAP" ;
21+ static constexpr const char * LOAD_IMAGE_SYMBOLS = " image+symbols" ;
22+ static constexpr const char * LOAD_IMAGE = " image" ;
23+ static constexpr const char * LOAD_SYMBOLS = " symbols" ;
24+ static constexpr const char * LOAD_NONE = " none" ;
2125
2226ProjMgrRunDebug::ProjMgrRunDebug (void ) {
2327 // Reserved
@@ -219,36 +223,23 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts, cons
219223
220224 // outputs
221225 for (const auto & context : contexts) {
222- // populate load entries from context outputs
223- const map<const string, const OutputType> types = {
224- { RteConstants::OUTPUT_TYPE_ELF, context->outputTypes .elf },
225- { RteConstants::OUTPUT_TYPE_HEX, context->outputTypes .hex },
226- { RteConstants::OUTPUT_TYPE_BIN, context->outputTypes .bin },
227- };
228- for (const auto & [type, output] : types) {
229- const auto & load = SetLoadFromOutput (context, output, type);
230- if (!load.file .empty ()) {
231- m_runDebug.outputs .push_back (load);
232- }
233- }
226+ // populate image entries from context outputs
227+ AddGeneratedImages (context);
234228 }
235229
236- // merge/insert target-set image nodes
237- for (const auto & item : context0->images ) {
238- bool merged = false ;
239- for (auto & output : m_runDebug.outputs ) {
240- if (output.file == item.image ) {
241- output.info = output.info .empty () ? item.info : output.info ;
242- output.type = output.type .empty () ? item.type : output.type ;
243- output.load = output.load .empty () ? item.load : output.load ;
244- output.offset = output.offset .empty () ? item.offset : output.offset ;
245- merged = true ;
246- break ;
247- }
230+ // insert target-set image nodes
231+ for (auto item : context0->images ) {
232+ if (item.type .empty ()) {
233+ item.type = ProjMgrUtils::FileTypeFromExtension (item.image );
248234 }
249- if (!merged) {
250- m_runDebug.outputs .push_back ({ item.image , item.info , item.type , item.load , item.offset });
235+ if (item.load .empty ()) {
236+ // files with 'type: elf' get 'load: image+symbols'
237+ // files with 'type: lib' get 'load: none'
238+ // all other file types get 'load: image'
239+ item.load = item.type == RteConstants::OUTPUT_TYPE_ELF ? LOAD_IMAGE_SYMBOLS :
240+ item.type == RteConstants::OUTPUT_TYPE_LIB ? LOAD_NONE : LOAD_IMAGE;
251241 }
242+ m_runDebug.outputs .push_back ({ item.image , item.info , item.type , item.load , item.offset });
252243 }
253244
254245 // debug vars
@@ -330,11 +321,10 @@ void ProjMgrRunDebug::CollectDebuggerSettings(const ContextItem& context, const
330321 if (adapter.gdbserver ) {
331322 unsigned long long port = adapter.defaults .port .empty () ? 0 : RteUtils::StringToULL (adapter.defaults .port );
332323 for (const auto & [pname, _] : pnames) {
333- GdbCoreItem item;
324+ GdbServerItem item;
334325 item.port = port++;
335326 item.pname = pname;
336- item.start = !pname.empty () && (pname == m_runDebug.debugger .startPname );
337- m_runDebug.debugger .gdbserver .core .push_back (item);
327+ m_runDebug.debugger .gdbserver .push_back (item);
338328 }
339329 }
340330 if (m_runDebug.debugger .protocol .empty ()) {
@@ -345,6 +335,11 @@ void ProjMgrRunDebug::CollectDebuggerSettings(const ContextItem& context, const
345335 }
346336 }
347337 }
338+
339+ // primary processor
340+ if (m_runDebug.debugger .startPname .empty ()) {
341+ m_runDebug.debugger .startPname = context.deviceItem .pname ;
342+ }
348343}
349344
350345void ProjMgrRunDebug::CollectDebugTopology (const ContextItem& context, const vector<pair<const RteItem*, vector<string>>> debugs,
@@ -519,16 +514,42 @@ void ProjMgrRunDebug::SetProtNodes(const RteDeviceProperty* item, AccessPortType
519514 }
520515}
521516
522- FilesType ProjMgrRunDebug::SetLoadFromOutput (const ContextItem* context, OutputType output, const string type) {
523- FilesType load;
524- if (output.on ) {
525- RteFsUtils::NormalizePath (output.filename , context->directories .cprj + ' /' + context->directories .outdir );
526- load.file = output.filename ;
527- load.info = " generate by " + context->name ;
528- load.type = type;
529- load.pname = context->deviceItem .pname ;
517+ void ProjMgrRunDebug::AddGeneratedImage (const ContextItem* context, const string& filename, const string& type, const string& load) {
518+ string file = filename;
519+ RteFsUtils::NormalizePath (file, context->directories .cprj + ' /' + context->directories .outdir );
520+ if (!file.empty ()) {
521+ FilesType image;
522+ image.file = file;
523+ image.info = " generate by " + context->name ;
524+ image.type = type;
525+ image.load = load;
526+ image.pname = context->deviceItem .pname ;
527+ image.offset = type == RteConstants::OUTPUT_TYPE_BIN ? context->loadOffset : RteUtils::EMPTY_STRING;
528+ m_runDebug.outputs .push_back (image);
529+ }
530+ }
531+
532+ void ProjMgrRunDebug::AddGeneratedImages (const ContextItem* context) {
533+ /*
534+ For 'compiler: AC6':
535+ - When only a file with 'type: elf' is generated, the file gets 'load: image+symbols'
536+ - When a file with 'type: elf' and a file with 'type: hex' is generated, the 'type: elf' file gets 'load: symbols' and the 'type: hex' file gets 'load: image'
537+ - All other file types get 'load: none'
538+ For any other compiler:
539+ - Files with 'type: elf' get 'load: image+symbols'
540+ - All other file types get 'load: none'
541+ */
542+ if (context->outputTypes .elf .on ) {
543+ AddGeneratedImage (context, context->outputTypes .elf .filename , RteConstants::OUTPUT_TYPE_ELF,
544+ context->compiler == " AC6" && context->outputTypes .hex .on ? LOAD_SYMBOLS : LOAD_IMAGE_SYMBOLS);
545+ }
546+ if (context->outputTypes .hex .on ) {
547+ AddGeneratedImage (context, context->outputTypes .hex .filename , RteConstants::OUTPUT_TYPE_HEX,
548+ context->compiler == " AC6" ? LOAD_IMAGE : LOAD_NONE);
549+ }
550+ if (context->outputTypes .bin .on ) {
551+ AddGeneratedImage (context, context->outputTypes .bin .filename , RteConstants::OUTPUT_TYPE_BIN, LOAD_NONE);
530552 }
531- return load;
532553}
533554
534555void ProjMgrRunDebug::GetDebugSequenceBlock (const RteItem* item, DebugSequencesBlockType& block) {
0 commit comments