mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-13 14:26:37 +00:00
Added initial commands
This commit is contained in:
parent
a427cf94f1
commit
486f110c80
@ -23,16 +23,11 @@ export class ArduinoDebugAdapterContribution implements DebugAdapterContribution
|
|||||||
'description': 'path to the sketch root ino file',
|
'description': 'path to the sketch root ino file',
|
||||||
'default': '${file}',
|
'default': '${file}',
|
||||||
},
|
},
|
||||||
'runToMain': {
|
'pauseAtMain': {
|
||||||
'description': 'If enabled the debugger will run until the start of the main function.',
|
'description': 'If enabled the debugger will pause at the start of the main function.',
|
||||||
'type': 'boolean',
|
'type': 'boolean',
|
||||||
'default': false
|
'default': false
|
||||||
},
|
},
|
||||||
'verbose': {
|
|
||||||
'type': 'boolean',
|
|
||||||
'description': 'Produce verbose log output',
|
|
||||||
'default': false
|
|
||||||
},
|
|
||||||
'debugDebugAdapter': {
|
'debugDebugAdapter': {
|
||||||
'type': 'boolean',
|
'type': 'boolean',
|
||||||
'description': 'Start the debug adapter in debug mode (with --inspect-brk)',
|
'description': 'Start the debug adapter in debug mode (with --inspect-brk)',
|
||||||
@ -68,11 +63,15 @@ export class ArduinoDebugAdapterContribution implements DebugAdapterContribution
|
|||||||
}
|
}
|
||||||
|
|
||||||
async resolveDebugConfiguration(config: DebugConfiguration): Promise<DebugConfiguration> {
|
async resolveDebugConfiguration(config: DebugConfiguration): Promise<DebugConfiguration> {
|
||||||
|
const startFunction = config.pauseAtMain ? 'main' : 'setup';
|
||||||
const res: ActualDebugConfig = {
|
const res: ActualDebugConfig = {
|
||||||
...config,
|
...config,
|
||||||
arduinoCli: await this.arduinoCli.getExecPath(),
|
arduinoCli: await this.arduinoCli.getExecPath(),
|
||||||
fqbn: '${fqbn}',
|
fqbn: '${fqbn}',
|
||||||
uploadPort: '${port}'
|
uploadPort: '${port}',
|
||||||
|
initCommands: [
|
||||||
|
`-break-insert -t --function ${startFunction}`
|
||||||
|
]
|
||||||
}
|
}
|
||||||
if (!res.sketch) {
|
if (!res.sketch) {
|
||||||
res.sketch = '${file}';
|
res.sketch = '${file}';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
import * as mi from 'cdt-gdb-adapter/dist/mi';
|
||||||
import { DebugProtocol } from 'vscode-debugprotocol';
|
import { DebugProtocol } from 'vscode-debugprotocol';
|
||||||
import { GDBDebugSession } from 'cdt-gdb-adapter/dist/GDBDebugSession';
|
import { GDBDebugSession, LaunchRequestArguments } from 'cdt-gdb-adapter/dist/GDBDebugSession';
|
||||||
import { GDBBackend } from 'cdt-gdb-adapter/dist/GDBBackend';
|
import { GDBBackend } from 'cdt-gdb-adapter/dist/GDBBackend';
|
||||||
import { ArduinoGDBBackend } from './arduino-gdb-backend';
|
import { ArduinoGDBBackend } from './arduino-gdb-backend';
|
||||||
|
|
||||||
@ -16,4 +17,25 @@ export class ArduinoDebugSession extends GDBDebugSession {
|
|||||||
return new ArduinoGDBBackend();
|
return new ArduinoGDBBackend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): Promise<void> {
|
||||||
|
const additionalCommands = [
|
||||||
|
'-interpreter-exec console "monitor reset halt"'
|
||||||
|
];
|
||||||
|
if (!args.initCommands) {
|
||||||
|
args.initCommands = additionalCommands;
|
||||||
|
} else {
|
||||||
|
args.initCommands.push(...additionalCommands);
|
||||||
|
}
|
||||||
|
return super.launchRequest(response, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async configurationDoneRequest(response: DebugProtocol.ConfigurationDoneResponse): Promise<void> {
|
||||||
|
try {
|
||||||
|
await mi.sendExecContinue(this.gdb);
|
||||||
|
this.sendResponse(response);
|
||||||
|
} catch (err) {
|
||||||
|
this.sendErrorResponse(response, 100, err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'arduino-ide-extension/lib/node/fs-extra'
|
import * as fs from 'arduino-ide-extension/lib/node/fs-extra'
|
||||||
import * as mi from './mi';
|
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import { GDBBackend } from 'cdt-gdb-adapter/dist/GDBBackend';
|
import { GDBBackend } from 'cdt-gdb-adapter/dist/GDBBackend';
|
||||||
import { ArduinoLaunchRequestArguments } from './arduino-debug-session';
|
import { ArduinoLaunchRequestArguments } from './arduino-debug-session';
|
||||||
|
|
||||||
export class ArduinoGDBBackend extends GDBBackend {
|
export class ArduinoGDBBackend extends GDBBackend {
|
||||||
|
|
||||||
public spawn(requestArgs: ArduinoLaunchRequestArguments) {
|
public spawn(requestArgs: ArduinoLaunchRequestArguments): Promise<void> {
|
||||||
if (!requestArgs.sketch) {
|
if (!requestArgs.sketch) {
|
||||||
throw new Error('Missing argument: sketch');
|
throw new Error('Missing argument: sketch');
|
||||||
}
|
}
|
||||||
@ -29,8 +28,13 @@ export class ArduinoGDBBackend extends GDBBackend {
|
|||||||
return this.parser.parse(proc.stdout);
|
return this.parser.parse(proc.stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public pause() {
|
public sendFileExecAndSymbols(): Promise<void> {
|
||||||
mi.sendExecInterrupt(this);
|
// The program file is already sent by `arduino-cli`
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
public pause(): boolean {
|
||||||
|
this.sendCommand('-exec-interrupt');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user