Skip to content
Merged
22 changes: 19 additions & 3 deletions src/gdb/GDBDebugSessionBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2004,14 +2004,15 @@ export abstract class GDBDebugSessionBase extends LoggingDebugSession {

if (isCliCommand) {
const expressionNoPrefix = expression.slice(1).trim();
const regexCommands = new RegExp('^\\s*(?:commands)\\s*$');
const regexDisable = new RegExp(
'^\\s*(?:dis|disa|disable)\\s*(?:(?:breakpoint|count|delete|once)\\d*)?\\s*\\d*\\s*$'
'^\\s*(?:dis|disa|disab|disabl|disable)\\s*(?:(?:breakpoint|count|delete|once)\\d*)?\\s*\\d*\\s*$'
);
const regexEnable = new RegExp(
'^\\s*(?:en|enable)\\s*(?:(?:breakpoint|count|delete|once)\\d*)?\\s*\\d*\\s*$'
'^\\s*(?:en|ena|enab|enabl|enable)\\s*(?:(?:breakpoint|count|delete|once)\\d*)?\\s*\\d*\\s*$'
);
const regexDelete = new RegExp(
'^\\s*(?:d|del|delete)\\s+(?:breakpoints\\s+)?(\\d+)?\\s*$'
'^\\s*(?:d|de|del|dele|delet|delete)\\s+(?:breakpoints\\s+)?(\\d+)?\\s*$'
);
if (
expressionNoPrefix.search(regexDisable) != -1 ||
Expand All @@ -2037,6 +2038,21 @@ export abstract class GDBDebugSessionBase extends LoggingDebugSession {
);
}
}
if (expressionNoPrefix.search(regexCommands) != -1) {
this.sendEvent(
new OutputEvent(
'warning: commands command is not supported via GDB/MI interface',
'stdout'
)
);
response.body = {
result: '',
variablesReference: 0,
};
this.sendResponse(response);
// Avoid sending the command to GDB
return;
}
return await this.evaluateRequestGdbCommand(
response,
expressionNoPrefix,
Expand Down
16 changes: 16 additions & 0 deletions src/integration-tests/evaluate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import {
standardBeforeEach,
testProgramsDir,
} from './utils';
import * as chai from 'chai';
import * as chaistring from 'chai-string';
chai.use(chaistring);

describe('evaluate request', function () {
let dc: CdtDebugClient;
Expand Down Expand Up @@ -97,6 +100,19 @@ describe('evaluate request', function () {
await event;
});

it('should send a warning when the commands command is sent', async function () {
const event = dc.waitForOutputEvent(
'stdout',
'warning: commands command is not supported via GDB/MI interface'
);
await dc.evaluateRequest({
context: 'repl',
expression: '> commands',
frameId: scope.frame.id,
});
await event;
});

it('should send a warning when evaluating a delete instruction breakpoint command is sent', async function () {
// set instruction breakpoint
await dc.setInstructionBreakpointsRequest({
Expand Down