mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-12 22:06:34 +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',
|
||||
'default': '${file}',
|
||||
},
|
||||
'runToMain': {
|
||||
'description': 'If enabled the debugger will run until the start of the main function.',
|
||||
'pauseAtMain': {
|
||||
'description': 'If enabled the debugger will pause at the start of the main function.',
|
||||
'type': 'boolean',
|
||||
'default': false
|
||||
},
|
||||
'verbose': {
|
||||
'type': 'boolean',
|
||||
'description': 'Produce verbose log output',
|
||||
'default': false
|
||||
},
|
||||
'debugDebugAdapter': {
|
||||
'type': 'boolean',
|
||||
'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> {
|
||||
const startFunction = config.pauseAtMain ? 'main' : 'setup';
|
||||
const res: ActualDebugConfig = {
|
||||
...config,
|
||||
arduinoCli: await this.arduinoCli.getExecPath(),
|
||||
fqbn: '${fqbn}',
|
||||
uploadPort: '${port}'
|
||||
uploadPort: '${port}',
|
||||
initCommands: [
|
||||
`-break-insert -t --function ${startFunction}`
|
||||
]
|
||||
}
|
||||
if (!res.sketch) {
|
||||
res.sketch = '${file}';
|
||||
|
@ -1,5 +1,6 @@
|
||||
import * as mi from 'cdt-gdb-adapter/dist/mi';
|
||||
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 { ArduinoGDBBackend } from './arduino-gdb-backend';
|
||||
|
||||
@ -16,4 +17,25 @@ export class ArduinoDebugSession extends GDBDebugSession {
|
||||
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 fs from 'arduino-ide-extension/lib/node/fs-extra'
|
||||
import * as mi from './mi';
|
||||
import { spawn } from 'child_process';
|
||||
import { GDBBackend } from 'cdt-gdb-adapter/dist/GDBBackend';
|
||||
import { ArduinoLaunchRequestArguments } from './arduino-debug-session';
|
||||
|
||||
export class ArduinoGDBBackend extends GDBBackend {
|
||||
|
||||
public spawn(requestArgs: ArduinoLaunchRequestArguments) {
|
||||
public spawn(requestArgs: ArduinoLaunchRequestArguments): Promise<void> {
|
||||
if (!requestArgs.sketch) {
|
||||
throw new Error('Missing argument: sketch');
|
||||
}
|
||||
@ -29,8 +28,13 @@ export class ArduinoGDBBackend extends GDBBackend {
|
||||
return this.parser.parse(proc.stdout);
|
||||
}
|
||||
|
||||
public pause() {
|
||||
mi.sendExecInterrupt(this);
|
||||
public sendFileExecAndSymbols(): Promise<void> {
|
||||
// The program file is already sent by `arduino-cli`
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
public pause(): boolean {
|
||||
this.sendCommand('-exec-interrupt');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user