Skip to content

Commit 2406af6

Browse files
committed
Add full Child DAP type & new Memory Read for Memory Inspector
Add full Child DAP type to capture more complete information including the name and DAP index. Add readMemory() query to match Memory Inspector requirements.
1 parent af9b3bd commit 2406af6

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/AmalgamatorSession.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,21 @@ export interface ChildDapContents {
7979
children?: string[];
8080
}
8181

82+
export interface ChildDapFull {
83+
children?: {
84+
name: string;
85+
id: number;
86+
}[];
87+
}
88+
8289
export interface ChildDapResponse extends Response {
8390
body: ChildDapContents;
8491
}
8592

93+
export interface ChildDapFullResponse extends Response {
94+
body: ChildDapFull;
95+
}
96+
8697
export class StoppedEvent extends Event implements DebugProtocol.StoppedEvent {
8798
public body: {
8899
reason: string;
@@ -689,6 +700,15 @@ export class AmalgamatorSession extends LoggingDebugSession {
689700
children: this.childDapNames,
690701
} as ChildDapContents;
691702
this.sendResponse(response);
703+
} else if (command === 'cdt-amalgamator/getChildDaps') {
704+
const fullDapResponse = response as ChildDapFullResponse;
705+
fullDapResponse.body = {
706+
children: this.childDapNames.map((child, index) => ({
707+
name: child,
708+
id: index,
709+
})),
710+
};
711+
this.sendResponse(fullDapResponse);
692712
} else if (command === 'cdt-amalgamator/Memory') {
693713
if (typeof args.address !== 'string') {
694714
throw new Error(
@@ -710,6 +730,26 @@ export class AmalgamatorSession extends LoggingDebugSession {
710730
].customRequest('cdt-gdb-adapter/Memory', args);
711731
response.body = childResponse.body;
712732
this.sendResponse(response);
733+
} else if (command === 'cdt-amalgamator/readMemory') {
734+
try {
735+
const childIndex = args.child?.id;
736+
if (typeof childIndex !== 'number') {
737+
throw new Error(
738+
`Invalid type for 'child.id', expected number, got ${typeof childIndex}`
739+
);
740+
}
741+
const childResponse = await this.childDaps[
742+
childIndex
743+
].customRequest('readMemory', args);
744+
response.body = childResponse.body;
745+
this.sendResponse(response);
746+
} catch (err) {
747+
this.sendErrorResponse(
748+
response,
749+
1,
750+
err instanceof Error ? err.message : String(err)
751+
);
752+
}
713753
} else if (
714754
command === 'cdt-amalgamator/resumeAll' ||
715755
command === 'cdt-amalgamator/suspendAll'

0 commit comments

Comments
 (0)