Skip to content

Commit 0c14eea

Browse files
authored
Merge pull request #469 from github0null/dev
v3.25.2 revision
2 parents 25eafbe + 0dd75bf commit 0c14eea

File tree

5 files changed

+160
-45
lines changed

5 files changed

+160
-45
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.2] revision
10+
11+
**Improve**:
12+
- `Debug`: Support one-click to start debugging for `probe-rs` flasher. Require extension [probe-rs.probe-rs-debugger](https://marketplace.visualstudio.com/items?itemName=probe-rs.probe-rs-debugger)
13+
14+
***
15+
916
### [v3.25.1] revision
1017

1118
**Improve**:

package.json

Lines changed: 1 addition & 7 deletions
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.1",
39+
"version": "3.25.2",
4040
"preview": false,
4141
"engines": {
4242
"vscode": "^1.67.0"
@@ -114,12 +114,6 @@
114114
"yaml": "^1.10.2"
115115
},
116116
"contributes": {
117-
"debuggers": [
118-
{
119-
"type": "eide.cortex-debug",
120-
"label": "EIDE (Cortex-Debug)"
121-
}
122-
],
123117
"terminal": {
124118
"profiles": [
125119
{

src/EIDEProject.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,10 +1685,14 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
16851685

16861686
//--
16871687

1688+
/**
1689+
* 检查文件是否已被排除
1690+
* @param path 要执行检查的源文件的路径,可以为虚拟路径,比如 '\<virual_root\>/abc.c'
1691+
*/
16881692
isExcluded(path: string): boolean {
1689-
const excList = this.GetConfiguration().config.excludeList.map((excpath) => this.resolveEnvVar(excpath));
1690-
const rePath = this.toRelativePath(path);
1691-
return excList.findIndex(excluded => rePath === excluded || rePath.startsWith(`${excluded}/`)) !== -1;
1693+
const excList = this.GetConfiguration().config.excludeList.map(p => this.resolveEnvVar(p));
1694+
const rePath = VirtualSource.isVirtualPath(path) ? path : this.toRelativePath(path);
1695+
return excList.findIndex(p => rePath === p || rePath.startsWith(`${p}/`)) !== -1;
16921696
}
16931697

16941698
protected addExclude(path: string): boolean {

src/StringTable.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,16 @@ export const view_str$env_desc$py3_cmd = [
459459

460460
//---------------Other---------------
461461

462+
export const view_str$prompt$requireOtherExtension = [
463+
`请先安装扩展 "{}"`,
464+
`Please install extension "{}" first.`
465+
][langIndex];
466+
467+
export const view_str$prompt$debugCfgNotSupported = [
468+
`仅支持如下类型的动态调试配置 '{0}'. 当前类型 '{1}' 不受支持!`,
469+
`Only the following type of dynamic debugging configurations '{0}' are supported. The current type '{1}' is not supported !`
470+
][langIndex];
471+
462472
export const view_str$prompt$install_dotnet_and_restart_vscode = [
463473
`安装完.NET后,你需要完全重启VSCode以刷新系统环境变量`,
464474
`After installed .NET. You need to close all VSCode instance and restart it to refresh System Environment Variables.`

src/extension.ts

Lines changed: 135 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import {
4343
txt_install_now, txt_yes, view_str$prompt$feedback, rating_text, later_text, sponsor_author_text,
4444
view_str$prompt$install_dotnet_and_restart_vscode,
4545
view_str$prompt$install_dotnet_failed,
46-
view_str$prompt$not_found_compiler
46+
view_str$prompt$not_found_compiler, view_str$prompt$debugCfgNotSupported, not_support_no_arm_project,
47+
view_str$prompt$requireOtherExtension
4748
} from './StringTable';
4849
import { LogDumper } from './LogDumper';
4950
import { StatusBarManager } from './StatusBarManager';
@@ -294,11 +295,17 @@ export async function activate(context: vscode.ExtensionContext) {
294295
subscriptions.push(vscode.commands.registerCommand('_cl.eide.statusbar.build', () => projectExplorer.BuildSolution(undefined, { not_rebuild: true })));
295296
subscriptions.push(vscode.commands.registerCommand('_cl.eide.statusbar.flash', () => projectExplorer.UploadToDevice(undefined)));
296297

298+
// debug config providers
299+
vscode.debug.registerDebugConfigurationProvider('cortex-debug', new ExternalDebugConfigProvider('cortex-debug'),
300+
vscode.DebugConfigurationProviderTriggerKind.Dynamic);
301+
vscode.debug.registerDebugConfigurationProvider('probe-rs-debug', new ExternalDebugConfigProvider('probe-rs-debug'),
302+
vscode.DebugConfigurationProviderTriggerKind.Dynamic);
303+
// vscode.debug.registerDebugConfigurationProvider('stm8-debug', new ExternalDebugConfigProvider('stm8-debug'),
304+
// vscode.DebugConfigurationProviderTriggerKind.Dynamic);
305+
297306
// others
298307
vscode.workspace.registerTextDocumentContentProvider(VirtualDocument.scheme, VirtualDocument.instance());
299308
vscode.workspace.registerTaskProvider(EideTaskProvider.TASK_TYPE_BASH, new EideTaskProvider());
300-
vscode.debug.registerDebugConfigurationProvider('eide.cortex-debug', new CortexDebugConfigProvider(),
301-
vscode.DebugConfigurationProviderTriggerKind.Dynamic);
302309

303310
// auto save project
304311
projectExplorer.enableAutoSave(true);
@@ -1589,7 +1596,10 @@ class EideTerminalProvider implements vscode.TerminalProfileProvider {
15891596

15901597
import { FileWatcher } from '../lib/node-utility/FileWatcher';
15911598
import { ToolchainManager, ToolchainName } from './ToolchainManager';
1592-
import { JLinkOptions, JLinkProtocolType, OpenOCDFlashOptions, PyOCDFlashOptions, STLinkOptions } from './HexUploader';
1599+
import {
1600+
JLinkOptions, JLinkProtocolType, OpenOCDFlashOptions,
1601+
PyOCDFlashOptions, STLinkOptions, ProbeRSFlashOptions, STVPFlasherOptions
1602+
} from './HexUploader';
15931603
import { AbstractProject } from './EIDEProject';
15941604

15951605
type MapViewParserType = 'memap' | 'builtin';
@@ -1890,7 +1900,13 @@ class MapViewEditorProvider implements vscode.CustomTextEditorProvider {
18901900
//- Debug Config Provider
18911901
//------------------------------------------------------------
18921902

1893-
class CortexDebugConfigProvider implements vscode.DebugConfigurationProvider {
1903+
class ExternalDebugConfigProvider implements vscode.DebugConfigurationProvider {
1904+
1905+
private debuggerType: string | undefined;
1906+
1907+
constructor(debugType?: string) {
1908+
this.debuggerType = debugType;
1909+
}
18941910

18951911
provideDebugConfigurations(folder: vscode.WorkspaceFolder | undefined,
18961912
token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration[]> {
@@ -1941,11 +1957,47 @@ class CortexDebugConfigProvider implements vscode.DebugConfigurationProvider {
19411957
return result;
19421958
}
19431959
break;
1960+
// case 'IAR_STM8':
1961+
// case 'COSMIC_STM8':
1962+
// case 'SDCC':
1963+
// break;
19441964
default:
19451965
return result;
19461966
}
19471967

1948-
const newDebugCfg = (prj: AbstractProject) => {
1968+
const toFmtRelativePath = (abspath: string) => {
1969+
let path = prj.ToRelativePath(abspath);
1970+
if (path) {
1971+
path = File.ToLocalPath(path);
1972+
return path.startsWith('.') ? path : `.${File.sep}${path}`;
1973+
}
1974+
return File.ToLocalPath(abspath);
1975+
};
1976+
1977+
const getSvdFile = (prj: AbstractProject) => {
1978+
const device = prj.GetPackManager().getCurrentDevInfo();
1979+
if (device && device.svdPath) {
1980+
const svdpath = toFmtRelativePath(device.svdPath);
1981+
GlobalEvent.log_info(`[debug config] Use svd file: ${svdpath}`);
1982+
return svdpath;
1983+
} else {
1984+
const searchDirs = [
1985+
prj.getRootDir(),
1986+
prj.getEideDir(),
1987+
File.from(prj.getRootDir().path, 'tools')
1988+
];
1989+
for (const d of searchDirs) {
1990+
const r = d.GetList([/\.svd$/i], File.EXCLUDE_ALL_FILTER);
1991+
if (r.length) {
1992+
const svdpath = toFmtRelativePath(r[0].path);
1993+
GlobalEvent.log_info(`[debug config] Use svd file: ${svdpath}`);
1994+
return svdpath;
1995+
}
1996+
}
1997+
}
1998+
};
1999+
2000+
const newCortexDebugCfg = (prj: AbstractProject) => {
19492001

19502002
const dbgCfg: vscode.DebugConfiguration = {
19512003
type: 'cortex-debug',
@@ -1970,32 +2022,14 @@ class CortexDebugConfigProvider implements vscode.DebugConfigurationProvider {
19702022
}
19712023

19722024
dbgCfg['cwd'] = prj.getRootDir().path;
1973-
dbgCfg['executable'] = prj.getExecutablePathWithoutSuffix() + '.elf';
2025+
dbgCfg['executable'] = toFmtRelativePath(prj.getExecutablePathWithoutSuffix() + '.elf');
19742026
dbgCfg['runToEntryPoint'] = 'main';
19752027
dbgCfg['liveWatch'] = {
19762028
'enabled': true,
19772029
'samplesPerSecond': 4
19782030
};
19792031

1980-
const device = prj.GetPackManager().getCurrentDevInfo();
1981-
if (device && device.svdPath) {
1982-
dbgCfg['svdFile'] = prj.ToRelativePath(device.svdPath) || device.svdPath;
1983-
GlobalEvent.log_info(`[debug config] Use svd file: ${dbgCfg['svdFile']}`);
1984-
} else {
1985-
const searchDirs = [
1986-
prj.getRootDir(),
1987-
prj.getEideDir(),
1988-
File.from(prj.getRootDir().path, 'tools')
1989-
];
1990-
for (const d of searchDirs) {
1991-
const r = d.GetList([/\.svd$/i], File.EXCLUDE_ALL_FILTER);
1992-
if (r.length) {
1993-
dbgCfg['svdFile'] = prj.ToRelativePath(r[0].path) || r[0].path;
1994-
GlobalEvent.log_info(`[debug config] Use svd file: ${dbgCfg['svdFile']}`);
1995-
break;
1996-
}
1997-
}
1998-
}
2032+
dbgCfg['svdFile'] = getSvdFile(prj);
19992033

20002034
return dbgCfg;
20012035
};
@@ -2013,7 +2047,7 @@ class CortexDebugConfigProvider implements vscode.DebugConfigurationProvider {
20132047
const flashertype = prj.getUploaderType();
20142048

20152049
if (flashertype == 'JLink') {
2016-
const dbgCfg = newDebugCfg(prj);
2050+
const dbgCfg = newCortexDebugCfg(prj);
20172051
const flasherCfg = (<JLinkOptions>flasherOpts);
20182052
dbgCfg['name'] = 'Debug: JLINK';
20192053
dbgCfg['servertype'] = 'jlink';
@@ -2035,7 +2069,7 @@ class CortexDebugConfigProvider implements vscode.DebugConfigurationProvider {
20352069
}
20362070

20372071
else if (flashertype == 'OpenOCD') {
2038-
const dbgCfg = newDebugCfg(prj);
2072+
const dbgCfg = newCortexDebugCfg(prj);
20392073
const flasherCfg = (<OpenOCDFlashOptions>flasherOpts);
20402074
dbgCfg['name'] = 'Debug: OpenOCD';
20412075
dbgCfg['servertype'] = 'openocd';
@@ -2050,7 +2084,7 @@ class CortexDebugConfigProvider implements vscode.DebugConfigurationProvider {
20502084
}
20512085

20522086
else if (flashertype == 'pyOCD') {
2053-
const dbgCfg = newDebugCfg(prj);
2087+
const dbgCfg = newCortexDebugCfg(prj);
20542088
const flasherCfg = (<PyOCDFlashOptions>flasherOpts);
20552089
dbgCfg['name'] = 'Debug: pyOCD';
20562090
dbgCfg['servertype'] = 'pyocd';
@@ -2104,7 +2138,7 @@ class CortexDebugConfigProvider implements vscode.DebugConfigurationProvider {
21042138
if (p)
21052139
cubeProgramerPath = NodePath.dirname(p);
21062140
}
2107-
const dbgCfg = newDebugCfg(prj);
2141+
const dbgCfg = newCortexDebugCfg(prj);
21082142
dbgCfg['name'] = 'Debug: STLink';
21092143
dbgCfg['servertype'] = 'stlink';
21102144
dbgCfg['interface'] = flasherCfg.proType == 'SWD' ? 'swd' : 'jtag';
@@ -2113,13 +2147,79 @@ class CortexDebugConfigProvider implements vscode.DebugConfigurationProvider {
21132147
result.push(dbgCfg);
21142148
}
21152149

2150+
else if (flashertype == 'probe-rs') {
2151+
const flasherCfg = (<ProbeRSFlashOptions>flasherOpts);
2152+
const dbgCfg: any = {
2153+
"type": "probe-rs-debug",
2154+
"request": "launch",
2155+
"name": "Debug: probe-rs",
2156+
"cwd": prj.getRootDir().path,
2157+
"connectUnderReset": false,
2158+
"chip": flasherCfg.target,
2159+
"wireProtocol": flasherCfg.protocol.toLowerCase() == 'swd' ? 'Swd' : 'Jtag',
2160+
"allowEraseAll": flasherCfg.allowEraseAll,
2161+
"flashingConfig": {
2162+
"flashingEnabled": true,
2163+
"haltAfterReset": true
2164+
},
2165+
"coreConfigs": [
2166+
{
2167+
"coreIndex": 0,
2168+
"svdFile": getSvdFile(prj),
2169+
"programBinary": toFmtRelativePath(
2170+
prj.getExecutablePathWithoutSuffix() + '.elf')
2171+
}
2172+
]
2173+
};
2174+
if (flasherCfg.speed)
2175+
dbgCfg['speed'] = flasherCfg.speed;
2176+
// parse '--probe VID:PID' or '--probe VID:PID:Serial'
2177+
if (flasherCfg.otherOptions) {
2178+
let m = /--probe (\w+\:\w+(?:\:\w+)?)/.exec(flasherCfg.otherOptions);
2179+
if (m && m.length > 1) {
2180+
dbgCfg['probe'] = m[1];
2181+
}
2182+
}
2183+
result.push(dbgCfg);
2184+
}
2185+
2186+
// else if (flashertype == 'STVP') {
2187+
// const flasherCfg = (<STVPFlasherOptions>flasherOpts);
2188+
// const dbgCfg: any = {
2189+
// "type": "stm8-debug",
2190+
// "request": "launch",
2191+
// "name": "Debug: STM8",
2192+
// "serverType": "st7",
2193+
// "executable": toFmtRelativePath(prj.getExecutablePath()),
2194+
// "cpu": flasherCfg.deviceName
2195+
// };
2196+
// const searchDirs = [
2197+
// prj.getRootDir(),
2198+
// prj.getEideDir(),
2199+
// File.from(prj.getRootDir().path, 'tools')
2200+
// ];
2201+
// for (const d of searchDirs) {
2202+
// const r = d.GetList([/\.svd\.json$/i], File.EXCLUDE_ALL_FILTER);
2203+
// if (r.length) {
2204+
// const svdpath = toFmtRelativePath(r[0].path);
2205+
// GlobalEvent.log_info(`[debug config] Use svd file: ${svdpath}`);
2206+
// dbgCfg['svdFile'] = svdpath;
2207+
// }
2208+
// }
2209+
// }
2210+
21162211
else {
2117-
GlobalEvent.emit('msg', newMessage('Warning',
2118-
`Only support 'jlink', 'stlink', 'openocd', 'pyocd'. Not support this flasher: '${flashertype}' !`));
2212+
const supported = ['jlink', 'stlink', 'openocd', 'pyocd', 'probe-rs'];
2213+
const msg = view_str$prompt$debugCfgNotSupported
2214+
.replace('{0}', supported.join(','))
2215+
.replace('{1}', flashertype);
2216+
GlobalEvent.show_msgbox('Warning', msg);
21192217
}
21202218

2121-
// GlobalEvent.log_info(`provide Cortex-Debug DebugConfig`);
2122-
// GlobalEvent.log_info(yaml.stringify(result));
2219+
// filter by debugType
2220+
if (this.debuggerType)
2221+
return result.filter(cfg => cfg.type == this.debuggerType);
2222+
21232223
return result;
21242224
}
21252225
}
@@ -2138,7 +2238,7 @@ async function startDebugging() {
21382238
index: 0
21392239
};
21402240

2141-
const cfgs = await (new CortexDebugConfigProvider())
2241+
const cfgs = await (new ExternalDebugConfigProvider())
21422242
.provideDebugConfigurations(vscWorkspaceFolder);
21432243
if (cfgs && cfgs.length > 0) {
21442244
let cfg = cfgs[0];

0 commit comments

Comments
 (0)