Skip to content

Commit

Permalink
Support SteppingGranularity & instructtion stepping
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-grant-work committed Oct 30, 2023
1 parent 1dc3d63 commit 5d8ad17
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/GDBDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export class GDBDebugSession extends LoggingDebugSession {
response.body.supportsDisassembleRequest = true;
response.body.supportsReadMemoryRequest = true;
response.body.supportsWriteMemoryRequest = true;
response.body.supportsSteppingGranularity = true;
this.sendResponse(response);
}

Expand Down Expand Up @@ -1003,7 +1004,7 @@ export class GDBDebugSession extends LoggingDebugSession {
args: DebugProtocol.NextArguments
): Promise<void> {
try {
await mi.sendExecNext(this.gdb, args.threadId);
await (args.granularity === 'instruction' ? mi.sendExecNextInstruction(this.gdb, args.threadId) : mi.sendExecNext(this.gdb, args.threadId));
this.sendResponse(response);
} catch (err) {
this.sendErrorResponse(
Expand All @@ -1019,7 +1020,7 @@ export class GDBDebugSession extends LoggingDebugSession {
args: DebugProtocol.StepInArguments
): Promise<void> {
try {
await mi.sendExecStep(this.gdb, args.threadId);
await (args.granularity === 'instruction' ? mi.sendExecStepInstruction(this.gdb, args.threadId) : mi.sendExecStep(this.gdb, args.threadId));
this.sendResponse(response);
} catch (err) {
this.sendErrorResponse(
Expand Down
16 changes: 16 additions & 0 deletions src/mi/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ export function sendExecNext(gdb: GDBBackend, threadId?: number) {
return gdb.sendCommand(command);
}

export function sendExecNextInstruction(gdb: GDBBackend, threadId?: number) {
let command = '-exec-next-instruction';
if (threadId !== undefined) {
command += ` --thread ${threadId}`;
}
return gdb.sendCommand(command);
}

export function sendExecStep(gdb: GDBBackend, threadId?: number) {
let command = '-exec-step';
if (threadId !== undefined) {
Expand All @@ -47,6 +55,14 @@ export function sendExecStep(gdb: GDBBackend, threadId?: number) {
return gdb.sendCommand(command);
}

export function sendExecStepInstruction(gdb: GDBBackend, threadId?: number) {
let command = '-exec-step-instruction';
if (threadId !== undefined) {
command += ` --thread ${threadId}`;
}
return gdb.sendCommand(command);
}

export function sendExecFinish(gdb: GDBBackend, threadId?: number) {
let command = '-exec-finish';
if (threadId !== undefined) {
Expand Down

0 comments on commit 5d8ad17

Please sign in to comment.