Skip to content

Commit 2e266d2

Browse files
committed
1. support new debugger eclipse-cdt.cdt-gdb-vscode.
2. remove axf2elf.
1 parent 392e0c7 commit 2e266d2

File tree

10 files changed

+387
-29
lines changed

10 files changed

+387
-29
lines changed

res/data/openocd-helpers.tcl

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#
2+
# Cortex-Debug extension calls this function during initialization. You can copy this
3+
# file, modify it and specifyy it as one of the config files supplied in launch.json
4+
# preferably at the beginning.
5+
#
6+
# Note that this file simply defines a function for use later when it is time to configure
7+
# for SWO.
8+
#
9+
set USE_SWO 0
10+
proc CDSWOConfigure { CDCPUFreqHz CDSWOFreqHz CDSWOOutput } {
11+
# We don't create/configure the entire TPIU which requires advanced knowledge of the device
12+
# like which DAP/AP ports to use, what their bases addresses are, etc. That should already
13+
# be done by the config files from the Silicon Vendor
14+
catch {tpiu init}; # we are allowed to call this multiple times. So, call it just in case
15+
set tipu_names [tpiu names]
16+
if { [llength $tipu_names] == 0 } {
17+
puts stderr "[info script]: Error: Could not find TPIU/SWO names. Perhaps it hasn't been created?"
18+
} else {
19+
set mytpiu [lindex $tipu_names 0]
20+
# We don't create/configure the entire TPIU which requires advanced knowledge of the device
21+
# like which DAP/AP ports to use, what their bases addresses are, etc. That should already
22+
# be done by the config files from the Silicon Vendor
23+
puts "[info script]: $mytpiu configure -protocol uart -output $CDSWOOutput -traceclk $CDCPUFreqHz -pin-freq $CDSWOFreqHz"
24+
$mytpiu configure -protocol uart -output $CDSWOOutput -traceclk $CDCPUFreqHz -pin-freq $CDSWOFreqHz
25+
$mytpiu enable
26+
}
27+
}
28+
29+
#
30+
# The following function may not work in a multi-core setup. You may want to overide this function
31+
# to enable RTOS detection for each core appropriately. This function must be called before `init` and
32+
# after all the targets are created.
33+
#
34+
proc CDRTOSConfigure { rtos } {
35+
set target [target current]
36+
if { $target != "" } {
37+
puts "[info script]: $target configure -rtos $rtos"
38+
$target configure -rtos $rtos
39+
} else {
40+
# Maybe this function was called too early?
41+
puts stderr "[info script]: Error: No current target. Could not configure target for RTOS"
42+
}
43+
}
44+
45+
#
46+
# CDLiveWatchSetup
47+
# This function must be called before the init is called and after all the targets are created. You can create
48+
# a custom version of this function (even empty) if you already setup the gdb-max-connections elsewhere
49+
#
50+
# We increment all gdb-max-connections by one if it is already a non-zero. Note that if it was already set to -1,
51+
# we leave it alone as it means unlimited connections
52+
#
53+
proc CDLiveWatchSetup {} {
54+
try {
55+
foreach tgt [target names] {
56+
set nConn [$tgt cget -gdb-max-connections]
57+
if { $nConn > 0 } {
58+
incr nConn
59+
$tgt configure -gdb-max-connections $nConn
60+
puts "[info script]: Info: Setting gdb-max-connections for target '$tgt' to $nConn"
61+
}
62+
}
63+
} on error {} {
64+
puts stderr "[info script]: Error: Failed to increase gdb-max-connections for current target. Live variables will not work"
65+
}
66+
}

src/CodeBuilder.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,17 +1126,18 @@ export class ARMCodeBuilder extends CodeBuilder {
11261126

11271127
const extraCommands: any[] = [];
11281128

1129+
//! deprecated. 现在我们可以通过在调试配置中设置 'loadFiles' 和 'symbolFiles' 来实现同样效果
11291130
// convert axf to elf
11301131
// why we need this ? see: https://stackoverflow.com/questions/49508277/warning-loadable-section-my-section-outside-of-elf-segments
1131-
if (['AC5', 'AC6'].includes(config.toolchain) &&
1132-
settingManager.IsConvertAxf2Elf() &&
1133-
options['linker']['$disableOutputTask'] != true) {
1134-
const axf2elf_log = `\${OutDir}/axf2elf.log`;
1135-
extraCommands.push({
1136-
name: 'axf to elf',
1137-
command: `axf2elf -d "\${ToolchainRoot}" -i "\${OutDir}/\${ProjectName}.axf" -o "\${OutDir}/\${ProjectName}.elf" > "${axf2elf_log}"`
1138-
});
1139-
}
1132+
// if (['AC5', 'AC6'].includes(config.toolchain) &&
1133+
// settingManager.IsConvertAxf2Elf() &&
1134+
// options['linker']['$disableOutputTask'] != true) {
1135+
// const axf2elf_log = `\${OutDir}/axf2elf.log`;
1136+
// extraCommands.push({
1137+
// name: 'axf to elf',
1138+
// command: `axf2elf -d "\${ToolchainRoot}" -i "\${OutDir}/\${ProjectName}.axf" -o "\${OutDir}/\${ProjectName}.elf" > "${axf2elf_log}"`
1139+
// });
1140+
// }
11401141

11411142
// insert command lines
11421143
if (settingManager.isInsertCommandsAtBegin()) {

src/EIDEProject.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,11 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
15411541

15421542
//////////////////////// project targets //////////////////////////
15431543

1544+
getTargetInfo(): ProjectTargetInfo {
1545+
const prjConfig = this.GetConfiguration<any>().config;
1546+
return prjConfig.targets[prjConfig.mode];
1547+
}
1548+
15441549
getCurrentTarget(): string {
15451550
return this.GetConfiguration().config.mode;
15461551
}

src/EIDEProjectExplorer.ts

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ import {
9090
view_str$prompt$filesOptionsComment,
9191
view_str$virual_doc_provider_banner,
9292
view_str$missed_stubs_added,
93-
view_str$keil_export_path_warning
93+
view_str$keil_export_path_warning,
94+
view_str$settings$debugger
9495
} from './StringTable';
9596
import { CodeBuilder, BuildOptions } from './CodeBuilder';
9697
import { ExceptionToMessage, newMessage } from './Message';
@@ -113,7 +114,8 @@ import {
113114
pyocd_getTargetList,
114115
generateDotnetProgramCmd,
115116
isGccFamilyToolchain,
116-
cxxDemangle
117+
cxxDemangle,
118+
DEBUGGER_MAPS
117119
} from './utility';
118120
import { concatSystemEnvPath, DeleteDir, exeSuffix, kill, osType, DeleteAllChildren, userhome, getGlobalState } from './Platform';
119121
import { KeilARMOption, KeilC51Option, KeilParser, KeilRteDependence } from './KeilXmlParser';
@@ -1372,6 +1374,16 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
13721374
projectIndex: element.val.projectIndex
13731375
}));
13741376

1377+
// setting: debugger
1378+
const debuggerId = project.getTargetInfo().settings.debugger || 'unknown';
1379+
iList.push(new ProjTreeItem(TreeItemType.SETTINGS_ITEM, {
1380+
key: 'debugger',
1381+
value: DEBUGGER_MAPS[debuggerId].name,
1382+
keyAlias: view_str$settings$debugger,
1383+
tooltip: newMarkdownString(`**${view_str$settings$debugger}**: \`${DEBUGGER_MAPS[debuggerId].name}\``),
1384+
projectIndex: element.val.projectIndex
1385+
}));
1386+
13751387
// setting: project env
13761388
iList.push(new ProjTreeItem(TreeItemType.SETTINGS_ITEM, {
13771389
key: 'project.env',
@@ -1970,6 +1982,7 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
19701982
libList: []
19711983
},
19721984
builderOptions: {},
1985+
settings: {}
19731986
};
19741987
eidePrjCfg.targets[targetName] = nEideTarget;
19751988

@@ -2207,7 +2220,8 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
22072220
incList: [],
22082221
defineList: [],
22092222
libList: []
2210-
}
2223+
},
2224+
settings: {}
22112225
};
22122226

22132227
nEideTarget.cppPreprocessAttrs.defineList = eTarget.builldArgs.cMacros;
@@ -6213,6 +6227,36 @@ export class ProjectExplorer implements CustomConfigurationProvider {
62136227
}
62146228
}
62156229
break;
6230+
case 'debugger':
6231+
{
6232+
const selections: any[] = [];
6233+
6234+
if (prj.getProjectType() !== 'C51') {
6235+
6236+
selections.push({
6237+
value: 'cortex-debug',
6238+
label: DEBUGGER_MAPS['cortex-debug'].name,
6239+
detail: `extension id: ${DEBUGGER_MAPS['cortex-debug'].extension_id}`
6240+
});
6241+
6242+
selections.push({
6243+
value: 'cdt-gdb-debug',
6244+
label: DEBUGGER_MAPS['cdt-gdb-debug'].name,
6245+
detail: `extension id: ${DEBUGGER_MAPS['cdt-gdb-debug'].extension_id}`
6246+
});
6247+
}
6248+
6249+
const res = await vscode.window.showQuickPick(selections, {placeHolder: 'Select debugger type'});
6250+
if (res) {
6251+
const targetInfo = prj.getTargetInfo();
6252+
if (targetInfo.settings.debugger !== res.value) {
6253+
targetInfo.settings.debugger = res.value;
6254+
this.updateSettingsView(prj);
6255+
prj.Save(true);
6256+
}
6257+
}
6258+
}
6259+
break;
62166260
// 'project.env'
62176261
case 'project.env':
62186262
{
@@ -7243,7 +7287,8 @@ export class ProjectExplorer implements CustomConfigurationProvider {
72437287
type: 'jlink' | 'openocd' | 'pyocd',
72447288
prj: AbstractProject, old_cfgs: any[]): Promise<{ debug_config: any, override_idx: number } | undefined> {
72457289

7246-
const _elfPath = File.ToUnixPath(prj.getOutputDir()) + '/' + `${prj.getProjectName()}.elf`;
7290+
const _outFullName = File.ToUnixPath(prj.getOutputDir()) + '/' + `${prj.getProjectName()}`
7291+
const _elfPath = `${_outFullName}.elf`;
72477292
const _debugConfigTemplates = {
72487293
'jlink': {
72497294
cwd: '${workspaceRoot}',
@@ -7281,9 +7326,15 @@ export class ProjectExplorer implements CustomConfigurationProvider {
72817326
};
72827327

72837328
const debugConfig: any = _debugConfigTemplates[type];
7329+
const toolchain = prj.getToolchain();
7330+
7331+
if (toolchain.name == 'AC5' || toolchain.name == 'AC6') {
7332+
debugConfig['executable'] = undefined;
7333+
debugConfig['loadFiles'] = [ `${_outFullName}.hex` ];
7334+
debugConfig['symbolFiles'] = [ `${_outFullName}.axf` ];
7335+
}
72847336

72857337
/* set gdb toolchain */
7286-
const toolchain = prj.getToolchain();
72877338
if (toolchain.getToolchainPrefix) {
72887339
debugConfig.toolchainPrefix = toolchain.getToolchainPrefix().trim().replace(/-$/, '');
72897340
} else if (debugConfig.toolchainPrefix) {

src/EIDETypeDefine.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ export interface ProjectTargetInfo {
129129
uploadConfigMap: { [uploader: string]: any };
130130
cppPreprocessAttrs: Dependence;
131131
builderOptions: { [toolchain: string]: BuilderOptions };
132+
settings: {
133+
debugger?: string; // @ref DEBUGGER_MAPS
134+
[name: string]: any;
135+
};
132136
}
133137

134138
export interface VirtualFile {
@@ -1352,6 +1356,12 @@ export class ProjectConfiguration<T extends BuilderConfigData>
13521356
builderOpts = utility.deepCloneObject(target.targets[target.mode].builderOptions);
13531357
}
13541358

1359+
let settings: any = {};
1360+
if (target.targets[target.mode] &&
1361+
target.targets[target.mode].settings) {
1362+
settings = utility.deepCloneObject(target.targets[target.mode].settings);
1363+
}
1364+
13551365
return {
13561366
excludeList: Array.from(target.excludeList),
13571367
toolchain: target.toolchain,
@@ -1361,7 +1371,8 @@ export class ProjectConfiguration<T extends BuilderConfigData>
13611371
uploadConfig: utility.deepCloneObject(target.uploadConfig),
13621372
uploadConfigMap: utility.deepCloneObject(target.uploadConfigMap),
13631373
cppPreprocessAttrs: custom_dep,
1364-
builderOptions: builderOpts
1374+
builderOptions: builderOpts,
1375+
settings: settings
13651376
};
13661377
}
13671378

@@ -1518,6 +1529,34 @@ export class ProjectConfiguration<T extends BuilderConfigData>
15181529
};
15191530
}
15201531

1532+
// init targets default value
1533+
const defTargetInfo: ProjectTargetInfo = {
1534+
excludeList: [],
1535+
toolchain: this.config.toolchain,
1536+
toolchainConfig: {},
1537+
toolchainConfigMap: {},
1538+
uploader: this.config.uploader,
1539+
uploadConfig: {},
1540+
uploadConfigMap: {},
1541+
cppPreprocessAttrs: {
1542+
name: 'default',
1543+
incList: [],
1544+
libList: [],
1545+
defineList: []
1546+
},
1547+
builderOptions: {},
1548+
settings: {
1549+
debugger: this.config.type === 'C51' ? 'unknown' : 'cortex-debug'
1550+
}
1551+
};
1552+
for (const name in this.config.targets) {
1553+
const target = this.config.targets[name];
1554+
for (const key in defTargetInfo) {
1555+
if ((<any>target)[key] === undefined)
1556+
(<any>target)[key] = utility.deepCloneObject((<any>defTargetInfo)[key]);
1557+
}
1558+
}
1559+
15211560
// old project(ver < 3.3) have 'mode' field
15221561
// new project(ver >= 3.3) not have 'mode' field
15231562
if (this.config.mode == undefined) {

src/KeilXmlParser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,10 @@ class ARMParser extends KeilParser<KeilARMOption> {
846846
eideOption.linker['output-format'] = 'lib';
847847
}
848848
if (!mdk_CreateHexFile) {
849-
// Make eide Don't output hex/bin
849+
// Make eide Don't output s19/bin
850850
if (eideOption.linker == undefined) eideOption.linker = {};
851-
eideOption.linker['$disableOutputTask'] = true;
851+
eideOption.linker['$disableOutputTask'] = false;
852+
eideOption.linker['$outputTaskExcludes'] = ['.bin', '.s19'];
852853
}
853854
}
854855
}

src/SettingManager.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,10 @@ export class SettingManager {
556556
return num;
557557
}
558558

559-
IsConvertAxf2Elf(): boolean {
560-
return this.getConfiguration().get<boolean>('ARM.Option.AxfToElf') || false;
561-
}
559+
//! deprecated.
560+
// IsConvertAxf2Elf(): boolean {
561+
// return this.getConfiguration().get<boolean>('ARM.Option.AxfToElf') || false;
562+
// }
562563

563564
IsAutoGenerateRTEHeader(): boolean {
564565
return this.getConfiguration().get<boolean>('ARM.Option.AutoGenerateRTE_Components') || false;

src/StringTable.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export const view_str$settings$outFolderName = [
6565
'Output Folder Name'
6666
][langIndex];
6767

68+
export const view_str$settings$debugger = [
69+
'调试器',
70+
'Debugger'
71+
][langIndex];
72+
6873
export const view_str$settings$prj_name = [
6974
'项目名称',
7075
'Project Name'

0 commit comments

Comments
 (0)