Skip to content

Commit 475ee9d

Browse files
CarlCarl
authored andcommitted
PSoC 6 support
1 parent 96f82de commit 475ee9d

3 files changed

Lines changed: 59 additions & 37 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ from Version 0.0.5 you can use OpenOCD as GDB server.
152152

153153
# Release Notes
154154

155+
### Version 0.0.7
156+
Added gdbCommands to support PSoC 6.
157+
155158
### Version 0.0.5
156159
OpenOCD support.
157160

package.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"displayName": "gnu-debugger",
44
"description": "JLink GNU debugger for Visual Studio Code.",
55
"icon": "images/GNU-debugger-128x128.png",
6-
"version": "0.0.6",
6+
"version": "0.0.7",
77
"preview": true,
88
"publisher": "metalcode-eu",
99
"engines": {
10-
"vscode": "^1.24.1",
10+
"vscode": "^1.38.0",
1111
"node": "^8.11.2"
1212
},
1313
"categories": [
@@ -65,6 +65,11 @@
6565
"description": "Arguments for GDB client.",
6666
"default": []
6767
},
68+
"gdbCommands": {
69+
"type": "array",
70+
"description": "Commands for GDB MI.",
71+
"default": []
72+
},
6873
"server": {
6974
"type": "string",
7075
"description": "Path to GDB server.",
@@ -132,11 +137,11 @@
132137
"vscode-debugprotocol": "1.35.0"
133138
},
134139
"devDependencies": {
135-
"@types/node": "12.0.7",
136-
"typescript": "3.5.1",
137-
"vscode": "1.1.34",
138-
"vscode-debugadapter-testsupport": "1.35.0",
139-
"tslint": "5.17.0",
140-
"vsce": "1.62.0"
140+
"@types/node": "12.7.5",
141+
"typescript": "3.6.3",
142+
"@types/vscode": "1.38.0",
143+
"vscode-debugadapter-testsupport": "1.37.1",
144+
"tslint": "5.20.0",
145+
"vsce": "1.66.0"
141146
}
142147
}

src/session.ts

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
181181
client: string;
182182
/// Arguments for GDB client.
183183
clientArgs: string[];
184+
/// Commands for GDB MI.
185+
gdbCommands: string[];
184186

185187
/// Path to GDB server.
186188
server: string;
@@ -216,7 +218,9 @@ export class GnuDebugSession extends DebugSession {
216218
/// Server promise reject
217219
private serverReject: (error: string) => void;
218220
/// Test for server success
219-
private serverSuccess: RegExp;
221+
private serverSuccess0: RegExp;
222+
/// Test for server success
223+
private serverSuccess1: RegExp;
220224
/// Test for server failure
221225
private serverFailure: RegExp;
222226

@@ -332,7 +336,21 @@ export class GnuDebugSession extends DebugSession {
332336
args.clientArgs.push(args.program);
333337
args.clientArgs.push('-q');
334338
args.clientArgs.push('--interpreter=mi');
339+
if (!args.gdbCommands) {
340+
args.gdbCommands =
341+
[
342+
// `-gdb-version`,
343+
`-gdb-set target-async on`,
344+
`-enable-pretty-printing`,
345+
`-target-select extended-remote ${args.serverHost}:${args.serverPort}`,
346+
`-file-exec-and-symbols "${args.program}"`,
347+
`-interpreter-exec console "monitor halt"`,
348+
`-interpreter-exec console "monitor reset"`,
349+
`-target-download`,
350+
];
351+
}
335352

353+
336354
if (!args.server) {
337355
args.server = 'JLinkGDBServer';
338356
}
@@ -353,21 +371,18 @@ export class GnuDebugSession extends DebugSession {
353371
this.debugOutput = args.debugOutput;
354372
}
355373

356-
this.stdout('program = ' + args.program + '\n');
357-
this.stdout('Toolchain = ' + args.toolchain + '\n');
358-
this.stdout('Client = ' + args.client + '\n');
359-
this.stdout('Server = ' + args.server + '\n');
360-
this.stdout('Server host = ' + args.serverHost + '\n');
361-
this.stdout('Server port = ' + args.serverPort + '\n');
374+
this.stdout('program = ' + args.program + '\n');
375+
this.stdout('Toolchain = ' + args.toolchain + '\n');
376+
this.stdout('Client = ' + args.client + '\n');
377+
this.stdout('Server = ' + args.server + '\n');
378+
this.stdout('Server host = ' + args.serverHost + '\n');
379+
this.stdout('Server port = ' + args.serverPort + '\n');
362380

363-
this.serverSuccess = /Connected to target/;
381+
this.serverSuccess0 = /Connected to target/;
382+
this.serverSuccess1 = /Info : Listening/;
364383
this.serverFailure = /Error:|ERROR:/;
365384
this.clientSuccess = /\(gdb\)/;
366385
this.clientFailure = /Error:|ERROR:/;
367-
if (args.server == "openocd")
368-
{
369-
this.serverSuccess = /Info : Listening/;
370-
}
371386

372387
this.halt = false;
373388
this.starting = true;
@@ -398,8 +413,7 @@ export class GnuDebugSession extends DebugSession {
398413
() => {
399414
this.stdout('Client success\n');
400415
this.starting = false;
401-
this.launchCommands
402-
(args.serverHost, args.serverPort, args.program);
416+
this.launchCommands(args.gdbCommands);
403417
this.sendResponse(response);
404418
},
405419
// Client failure
@@ -445,22 +459,33 @@ export class GnuDebugSession extends DebugSession {
445459

446460
let end = this.serverBuffer.lastIndexOf('\n');
447461
if (end !== -1) {
448-
let lines = this.serverBuffer.substr(0, end).split('\n') as string[];
462+
let lines = this.serverBuffer.substr(0, end).split(/\r\n|\r|\n/) as string[];
449463
this.serverBuffer = this.serverBuffer.substring(end + 1);
450464

451465
for (let line of lines) {
452466
// Display in vscode debug console
453467
this.debugServer(line + '\n');
454468
if (this.starting) {
455-
if ((line.match(this.serverSuccess))) {
469+
if
470+
(
471+
line.match(this.serverSuccess0) ||
472+
line.match(this.serverSuccess1)
473+
) {
456474
this.serverResolve();
457475
}
458476
if ((line.match(this.serverFailure))) {
459477
this.serverReject(line);
460478
}
461479
}
462480
}
463-
if (this.starting && this.serverBuffer.match(this.serverSuccess)) {
481+
if
482+
(
483+
this.starting &&
484+
(
485+
this.serverBuffer.match(this.serverSuccess0) ||
486+
this.serverBuffer.match(this.serverSuccess1)
487+
)
488+
) {
464489
// Display in vscode debug console
465490
this.debugServer(this.serverBuffer + '\n');
466491
this.serverBuffer = '';
@@ -1418,18 +1443,7 @@ export class GnuDebugSession extends DebugSession {
14181443
this.debugServer('customRequest\n');
14191444
}
14201445

1421-
private launchCommands(host: string, port: number, program: string) {
1422-
const commands = [
1423-
// `-gdb-version`,
1424-
`-gdb-set target-async on`,
1425-
`-enable-pretty-printing`,
1426-
`-target-select extended-remote ${host}:${port}`,
1427-
`-file-exec-and-symbols "${program}"`,
1428-
`-interpreter-exec console "monitor halt"`,
1429-
`-interpreter-exec console "monitor reset"`,
1430-
`-target-download`,
1431-
];
1432-
1446+
private launchCommands(commands: string[]) {
14331447
const promises = commands.map((c) => this.sendCommand(c));
14341448

14351449
Promise.all(promises).then(() => {

0 commit comments

Comments
 (0)