diff --git a/debug_attributes.md b/debug_attributes.md index a87a0532..2ff0c333 100644 --- a/debug_attributes.md +++ b/debug_attributes.md @@ -52,6 +52,29 @@ If the type is marked as `{...}` it means that it is a complex item can have mul | overrideLaunchCommands | string[] | Launch | You can use this to property to override the commands that are normally executed as part of flashing and launching the target. In most cases it is preferable to use preLaunchCommands and postLaunchCommands to customize the GDB launch sequence. | | overrideResetCommands | string[] | Both | You can use this to property to override the commands that are normally executed as part of reset the target. When not defined this will have the same value of overrideRestartCommands. In most cases it is preferable to use preResetCommands and postResetCommands to customize the GDB reset sequence. | | overrideRestartCommands | string[] | Both | You can use this to property to override the commands that are normally executed as part of restarting the target. In most cases it is preferable to use preRestartCommands and postRestartCommands to customize the GDB restart sequence. | +| pemicro | object | Both | PEMicro GDB server specific configuration | +| pemicro
.exception_catching | object | Both | Set catching of hardware exceptions | +| pemicro
.exception_catching
.busfault | boolean | Both | Enable BusFault Catch | +| pemicro
.exception_catching
.checking_error | boolean | Both | Enable Checking Error Catch | +| pemicro
.exception_catching
.exception_entry_or_return | boolean | Both | Enable Exception Entry/Return Catch | +| pemicro
.exception_catching
.hardfault | boolean | Both | Enable HardFault Catch | +| pemicro
.exception_catching
.memmanage | boolean | Both | Enable MemManage Catch | +| pemicro
.exception_catching
.no_coprocessor | boolean | Both | Enable No-Coproessor Catch | +| pemicro
.exception_catching
.reset_vector | boolean | Both | Enable Reset Vector Catch | +| pemicro
.exception_catching
.state_info_error | boolean | Both | Enable StateInformation Error Catch | +| pemicro
.preserve_ranges | object | Both | Allows setting up to 3 memory areas to retain during reflashing | +| pemicro
.preserve_ranges
.preserve0 | object | Both | Memory area 0 conf | +| pemicro
.preserve_ranges
.preserve0
.enable | boolean | Both | Set to true to retain data in memory area | +| pemicro
.preserve_ranges
.preserve0
.start | number | Both | Start address of memory range | +| pemicro
.preserve_ranges
.preserve0
.stop | number | Both | End address of memory range | +| pemicro
.preserve_ranges
.preserve1 | object | Both | Memory area 1 conf | +| pemicro
.preserve_ranges
.preserve1
.enable | boolean | Both | Set to true to retain data in memory area | +| pemicro
.preserve_ranges
.preserve1
.start | number | Both | Start address of memory range | +| pemicro
.preserve_ranges
.preserve1
.stop | number | Both | End address of memory range | +| pemicro
.preserve_ranges
.preserve2 | object | Both | Memory area 2 conf | +| pemicro
.preserve_ranges
.preserve2
.enable | boolean | Both | Set to true to retain data in memory area | +| pemicro
.preserve_ranges
.preserve2
.start | number | Both | Start address of memory range | +| pemicro
.preserve_ranges
.preserve2
.stop | number | Both | End address of memory range | | postAttachCommands | string[] | Attach | Additional GDB Commands to be executed after the main attach sequence has finished. | | postLaunchCommands | string[] | Launch | Additional GDB Commands to be executed after the main launch sequence has finished. | | postResetCommands | string[] | Both | Additional GDB Commands to be executed at the end of the reset sequence. When not defined this will have the same value of postRestartCommands. | diff --git a/package-lock.json b/package-lock.json index f8d20d29..f8a7c97b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cortex-debug", - "version": "1.12.1-pre5", + "version": "1.12.2-pre", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cortex-debug", - "version": "1.12.1-pre5", + "version": "1.12.2-pre", "license": "MIT", "dependencies": { "@vscode/extension-telemetry": "^0.4.7", @@ -1733,10 +1733,13 @@ } }, "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/get-caller-file": { "version": "1.0.3", @@ -5164,9 +5167,9 @@ "optional": true }, "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", "dev": true }, "get-caller-file": { diff --git a/package.json b/package.json index c22be7ca..5bf26e24 100644 --- a/package.json +++ b/package.json @@ -784,6 +784,56 @@ "samplesPerSecond": 4 } }, + "pemicro": { + "properties":{ + "exception_catching":{ + "properties": { + "hardfault": { + "type":"boolean", + "default" : true, + "description": "Enable HardFault Catch" + }, + "exception_entry_or_return": { + "type":"boolean", + "default" : true, + "description": "Enable Exception Entry/Return Catch" + }, + "busfault": { + "type":"boolean", + "default" : true, + "description": "Enable BusFault Catch" + }, + "state_info_error": { + "type":"boolean", + "default" : true, + "description": "Enable StateInformation Error Catch" + }, + "checking_error": { + "type":"boolean", + "default" : true, + "description": "Enable Checking Error Catch" + }, + "no_coprocessor": { + "type":"boolean", + "default" : true, + "description": "Enable No-Coproessor Catch" + }, + "memmanage": { + "type":"boolean", + "default" : true, + "description": "Enable MemManage Catch" + }, + "reset_vector": { + "type":"boolean", + "default" : true, + "description": "Enable Reset Vector Catch" + } + }, + "description": "Set catching of hardware exceptions" + } + }, + "description": "PEMicro GDB server specific configuration" + }, "chainedConfigurations": { "description": "An object describing how additional configurations should be launched", "properties": { @@ -1632,6 +1682,127 @@ "external" ] }, + "pemicro": { + "properties":{ + "preserve_ranges": { + "properties" : { + "preserve0" : { + "properties" :{ + "enable": { + "type": "boolean", + "description": "Set to true to retain data in memory area" + }, + "start": { + "type": "number", + "description": "Start address of memory range" + }, + "stop":{ + "type": "number", + "description": "End address of memory range" + } + }, + "description": "Memory area 0 conf", + "default": { + "enable": false, + "start":0, + "stop":0 + } + }, + "preserve1" : { + "properties" :{ + "enable": { + "type": "boolean", + "description": "Set to true to retain data in memory area" + }, + "start": { + "type": "number", + "description": "Start address of memory range" + }, + "stop":{ + "type": "number", + "description": "End address of memory range" + } + }, + "description": "Memory area 1 conf", + "default": { + "enable": false, + "start":0, + "stop":0 + } + }, + "preserve2" : { + "properties" :{ + "enable": { + "type": "boolean", + "description": "Set to true to retain data in memory area" + }, + "start": { + "type": "number", + "description": "Start address of memory range" + }, + "stop":{ + "type": "number", + "description": "End address of memory range" + } + }, + "description": "Memory area 2 conf", + "default": { + "enable": false, + "start":0, + "stop":0 + } + } + }, + "description": "Allows setting up to 3 memory areas to retain during reflashing" + }, + "exception_catching":{ + "properties": { + "hardfault": { + "type":"boolean", + "default" : true, + "description": "Enable HardFault Catch" + }, + "exception_entry_or_return": { + "type":"boolean", + "default" : true, + "description": "Enable Exception Entry/Return Catch" + }, + "busfault": { + "type":"boolean", + "default" : true, + "description": "Enable BusFault Catch" + }, + "state_info_error": { + "type":"boolean", + "default" : true, + "description": "Enable StateInformation Error Catch" + }, + "checking_error": { + "type":"boolean", + "default" : true, + "description": "Enable Checking Error Catch" + }, + "no_coprocessor": { + "type":"boolean", + "default" : true, + "description": "Enable No-Coproessor Catch" + }, + "memmanage": { + "type":"boolean", + "default" : true, + "description": "Enable MemManage Catch" + }, + "reset_vector": { + "type":"boolean", + "default" : true, + "description": "Enable Reset Vector Catch" + } + }, + "description": "Set catching of hardware exceptions" + } + }, + "description": "PEMicro GDB server specific configuration" + }, "cwd": { "description": "Directory to run commands from", "type": "string" @@ -3033,6 +3204,6 @@ "test-compile": "tsc -p ./", "package": "node ./release.js --package", "publish": "node ./release.js --publish --vsx-also", - "lint": "./node_modules/tslint/bin/tslint --project ." + "lint": "node ./node_modules/tslint/bin/tslint --project ." } } diff --git a/src/common.ts b/src/common.ts index ab58f0ff..953568e6 100644 --- a/src/common.ts +++ b/src/common.ts @@ -343,6 +343,37 @@ export interface ConfigurationArguments extends DebugProtocol.LaunchRequestArgum cpu: string; machine: string; + // PEMicro specific + pemicro: { + preserve_ranges: { + preserve0: { + enable: boolean, + start: number, + stop: number + }, + preserve1: { + enable: boolean, + start: number, + stop: number + }, + preserve2: { + enable: boolean, + start: number, + stop: number + } + }, + exception_catching: { + hardfault: boolean, + exception_entry_or_return: boolean, + busfault: boolean, + state_info_error: boolean, + checking_error: boolean, + no_coprocessor: boolean, + memmanage: boolean, + reset_vector: boolean + } + }; + // External gdbTarget: string; } diff --git a/src/pemicro.ts b/src/pemicro.ts index b22b2ced..a70be0d3 100644 --- a/src/pemicro.ts +++ b/src/pemicro.ts @@ -36,9 +36,60 @@ export class PEServerController extends EventEmitter implements GDBServerControl ]; } + public preserveRanges(): string[] { + const allowedRanges = ['preserve0', 'preserve1', 'preserve2']; + const ranges = this.args.pemicro.preserve_ranges; + const preserveRangesCmds = []; + for (const range of allowedRanges) + { + try { + const tmp = `interpreter-exec console "monitor ${range} ${ranges[range].enable ? 1 : 0} ${ranges[range].start} ${ranges[range].stop}"`; + preserveRangesCmds.push(tmp); + } + catch (err) { + // nop + } + } + return preserveRangesCmds; + } + + public setExceptionCatching(): string { + const exceptionBitOffsets = { + hardfault: 10, + exception_entry_or_return: 9, + busfault: 8, + state_info_error: 7, + checking_error: 6, + no_coprocessor: 5, + memmanage: 4, + reset_vector: 0 + }; + const conf = this.args.pemicro.exception_catching; + let enableBits = 0; + for (const exception of Object.keys(exceptionBitOffsets)) + { + try{ + enableBits |= conf[exception] ? 1 << exceptionBitOffsets[exception] : 0; + } + catch (err) + { + // nop + } + } + return `interpreter-exec console "monitor setexceptioncatching ${enableBits}"`; + } + public launchCommands(): string[] { + const extraLaunchCmds = []; + + extraLaunchCmds.push(this.setExceptionCatching()); + extraLaunchCmds.push(...this.preserveRanges()); + const commands = [ - ...genDownloadCommands(this.args, ['interpreter-exec console "monitor _reset"']), + 'interpreter-exec console "monitor _reset"', + 'interpreter-exec console "monitor startmultiload"', + ...genDownloadCommands(this.args, extraLaunchCmds), + 'interpreter-exec console "monitor endmultiload"', 'interpreter-exec console "monitor _reset"' ];