Skip to content

Commit 392ffb0

Browse files
authored
Merge pull request #471 from github0null/dev
v3.25.3 revision
2 parents 0c14eea + bf5580a commit 392ffb0

File tree

7 files changed

+103
-11
lines changed

7 files changed

+103
-11
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ All notable version changes will be recorded in this file.
66

77
***
88

9+
### [v3.25.3] revision
10+
11+
**Improve**:
12+
- `Debug`: Support 'attach' mode for 'one-click' debugging.
13+
14+
***
15+
916
### [v3.25.2] revision
1017

1118
**Improve**:

lang/stc.flash.verify.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
]
6969
},
7070
"oscFreq": {
71-
"markdownDescription": "`[可忽略]` 芯片时钟速度 KHz,**只用于 STC15 系列**",
71+
"markdownDescription": "`[可忽略]` 芯片时钟速度 KHz",
7272
"anyOf": [
7373
{
7474
"type": "string",

package.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"homepage": "https://em-ide.com",
3737
"license": "MIT",
3838
"description": "A mcu development environment for 8051/AVR/STM8/Cortex-M/MIPS/RISC-V",
39-
"version": "3.25.2",
39+
"version": "3.25.3",
4040
"preview": false,
4141
"engines": {
4242
"vscode": "^1.67.0"
@@ -550,6 +550,15 @@
550550
"light": "./res/icon/Run_16x.svg"
551551
}
552552
},
553+
{
554+
"command": "eide.debug.start.attach",
555+
"category": "eide",
556+
"title": "%eide.project.debug.start.attach%",
557+
"icon": {
558+
"dark": "./res/icon/Run_blue_16x.svg",
559+
"light": "./res/icon/Run_blue_16x.svg"
560+
}
561+
},
553562
{
554563
"command": "eide.refresh.external_tools_index",
555564
"category": "eide",
@@ -1344,6 +1353,11 @@
13441353
"when": "viewItem == SOLUTION && view == cl.eide.view.projects",
13451354
"group": "2_build@3"
13461355
},
1356+
{
1357+
"command": "eide.debug.start.attach",
1358+
"when": "viewItem == SOLUTION && view == cl.eide.view.projects",
1359+
"group": "2_build@4"
1360+
},
13471361
{
13481362
"command": "eide.project.uploadToDevice",
13491363
"when": "viewItem == SOLUTION && view == cl.eide.view.projects",

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"eide.project.modify.files.options": "Show Extra Options Of All Source Files",
3333
"eide.project.import.ext.project.src.struct": "Import SourceFile Tree From Other Project",
3434
"eide.project.generate_builder_params": "Generate builder.params",
35-
"eide.project.debug.start": "Start Debugging (Cortex-Debug)",
35+
"eide.project.debug.start": "Start Debugging",
36+
"eide.project.debug.start.attach": "Start Debugging (attach)",
3637

3738
"eide.prj.menus.main.static-check": "Static Check",
3839
"eide.prj.menus.sub.static-check.cppcheck": "Run Cppcheck",

package.nls.zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"eide.project.modify.files.options": "查看所有源文件的附加编译参数",
3333
"eide.project.import.ext.project.src.struct": "从其他 IDE 的项目中导入源文件树",
3434
"eide.project.generate_builder_params": "生成 builder.params",
35-
"eide.project.debug.start": "启动调试(Cortex-Debug)",
35+
"eide.project.debug.start": "启动调试",
36+
"eide.project.debug.start.attach": "启动调试 (附加)",
3637

3738
"eide.prj.menus.main.static-check": "静态检查",
3839
"eide.prj.menus.sub.static-check.cppcheck": "执行 Cppcheck",

src/extension.ts

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ export async function activate(context: vscode.ExtensionContext) {
133133
startDebugging()
134134
.catch(err => GlobalEvent.emit('error', err));
135135
}));
136+
subscriptions.push(vscode.commands.registerCommand('eide.debug.start.attach', () => {
137+
startDebugging(true)
138+
.catch(err => GlobalEvent.emit('error', err));
139+
}));
136140

137141
// internal command
138142
// TODO
@@ -1911,7 +1915,7 @@ class ExternalDebugConfigProvider implements vscode.DebugConfigurationProvider {
19111915
provideDebugConfigurations(folder: vscode.WorkspaceFolder | undefined,
19121916
token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration[]> {
19131917

1914-
const result: vscode.DebugConfiguration[] = [];
1918+
let result: vscode.DebugConfiguration[] = [];
19151919

19161920
if (!folder)
19171921
return result;
@@ -2034,6 +2038,16 @@ class ExternalDebugConfigProvider implements vscode.DebugConfigurationProvider {
20342038
return dbgCfg;
20352039
};
20362040

2041+
const newAttachDebugCfg = (cfgtocopy: any) => {
2042+
const nCfg = JSON.parse(JSON.stringify(cfgtocopy));
2043+
nCfg['name'] += '(attach)';
2044+
nCfg['request'] = 'attach';
2045+
if (nCfg['type'] === 'cortex-debug') {
2046+
nCfg['runToEntryPoint'] = undefined;
2047+
}
2048+
return nCfg;
2049+
};
2050+
20372051
const fmtOpenocdCfgPath = (type: 'interface' | 'target', path: string) => {
20382052
let cfgpath = path.startsWith('${workspaceFolder}/')
20392053
? path.replace('${workspaceFolder}/', '')
@@ -2066,6 +2080,7 @@ class ExternalDebugConfigProvider implements vscode.DebugConfigurationProvider {
20662080
dbgCfg['serialNumber'] = m[1];
20672081
}
20682082
result.push(dbgCfg);
2083+
result.push(newAttachDebugCfg(dbgCfg));
20692084
}
20702085

20712086
else if (flashertype == 'OpenOCD') {
@@ -2081,6 +2096,7 @@ class ExternalDebugConfigProvider implements vscode.DebugConfigurationProvider {
20812096
dbgCfg['configFiles'] = ocdCfgs;
20822097
dbgCfg['serverpath'] = settingManager.getOpenOCDExePath();
20832098
result.push(dbgCfg);
2099+
result.push(newAttachDebugCfg(dbgCfg));
20842100
}
20852101

20862102
else if (flashertype == 'pyOCD') {
@@ -2098,13 +2114,17 @@ class ExternalDebugConfigProvider implements vscode.DebugConfigurationProvider {
20982114
}
20992115
}
21002116
if (flasherCfg.otherCmds)
2101-
cliArgs.push(flasherCfg.otherCmds);
2117+
utility.parseCliArgs(flasherCfg.otherCmds)
2118+
.forEach(s => cliArgs.push(s))
21022119
if (flasherCfg.speed) {
21032120
cliArgs.push('-f');
21042121
cliArgs.push(flasherCfg.speed);
21052122
}
21062123
dbgCfg['serverArgs'] = cliArgs;
2124+
// pyocd not support livewatch
2125+
dbgCfg['liveWatch']['enabled'] = false;
21072126
result.push(dbgCfg);
2127+
result.push(newAttachDebugCfg(dbgCfg));
21082128
}
21092129

21102130
else if (flashertype == 'STLink') {
@@ -2145,6 +2165,7 @@ class ExternalDebugConfigProvider implements vscode.DebugConfigurationProvider {
21452165
dbgCfg['stlinkPath'] = gdbserverPath;
21462166
dbgCfg['stm32cubeprogrammer'] = cubeProgramerPath;
21472167
result.push(dbgCfg);
2168+
result.push(newAttachDebugCfg(dbgCfg));
21482169
}
21492170

21502171
else if (flashertype == 'probe-rs') {
@@ -2181,6 +2202,7 @@ class ExternalDebugConfigProvider implements vscode.DebugConfigurationProvider {
21812202
}
21822203
}
21832204
result.push(dbgCfg);
2205+
result.push(newAttachDebugCfg(dbgCfg));
21842206
}
21852207

21862208
// else if (flashertype == 'STVP') {
@@ -2218,13 +2240,13 @@ class ExternalDebugConfigProvider implements vscode.DebugConfigurationProvider {
22182240

22192241
// filter by debugType
22202242
if (this.debuggerType)
2221-
return result.filter(cfg => cfg.type == this.debuggerType);
2243+
result = result.filter(cfg => cfg.type == this.debuggerType);
22222244

22232245
return result;
22242246
}
22252247
}
22262248

2227-
async function startDebugging() {
2249+
async function startDebugging(attach?: boolean) {
22282250

22292251
const prj = projectExplorer.getActiveProject();
22302252
if (!prj) {
@@ -2238,9 +2260,17 @@ async function startDebugging() {
22382260
index: 0
22392261
};
22402262

2241-
const cfgs = await (new ExternalDebugConfigProvider())
2242-
.provideDebugConfigurations(vscWorkspaceFolder);
2243-
if (cfgs && cfgs.length > 0) {
2263+
const provider = new ExternalDebugConfigProvider();
2264+
let cfgs = await provider.provideDebugConfigurations(vscWorkspaceFolder);
2265+
if (!cfgs)
2266+
return;
2267+
2268+
if (attach)
2269+
cfgs = cfgs.filter(cfg => cfg.request === 'attach');
2270+
else
2271+
cfgs = cfgs.filter(cfg => cfg.request === 'launch');
2272+
2273+
if (cfgs.length > 0) {
22442274
let cfg = cfgs[0];
22452275
if (cfgs.length > 1) {
22462276
const val = await vscode.window.showQuickPick(cfgs.map(e => e.name), {

src/utility.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,45 @@ export const TIME_ONE_MINUTE = 60 * 1000;
4949
export const TIME_ONE_HOUR = 3600 * 1000;
5050
export const TIME_ONE_DAY = 24 * 3600 * 1000;
5151

52+
export function parseCliArgs(cliStr: string): string[] {
53+
54+
let argsLi: string[] = [];
55+
let inQuote = false;
56+
let curArg = '';
57+
58+
for(let char_ of cliStr) {
59+
// is a "..." start or end
60+
if (char_ === '"' && (curArg.length === 0 || curArg[curArg.length - 1] !== '\\')) {
61+
if (inQuote) {
62+
inQuote = false;
63+
if (curArg && curArg.trim() !== '')
64+
argsLi.push(curArg);
65+
curArg = '';
66+
} else {
67+
inQuote = true;
68+
}
69+
continue; // skip '"'
70+
}
71+
// in "..." region
72+
if (inQuote) {
73+
curArg += char_;
74+
} else { // out "..." region
75+
if (char_ === ' ' || char_ === '\t') {
76+
if (curArg && curArg.trim() !== '')
77+
argsLi.push(curArg);
78+
curArg = '';
79+
} else {
80+
curArg += char_;
81+
}
82+
}
83+
}
84+
85+
if (curArg && curArg.trim() !== '')
86+
argsLi.push(curArg);
87+
88+
return argsLi;
89+
}
90+
5291
export async function probers_install(cwd?: string) {
5392

5493
let commandLine: string;

0 commit comments

Comments
 (0)