MCPcopy Index your code
hub / github.com/Marus/cortex-debug / readMemoryRequest

Method readMemoryRequest

src/gdb.ts:1211–1247  ·  view source on GitHub ↗
(response: DebugProtocol.ReadMemoryResponse, args: DebugProtocol.ReadMemoryArguments, request?: DebugProtocol.Request)

Source from the content-addressed store, hash-verified

1209 }
1210
1211 protected readMemoryRequest(response: DebugProtocol.ReadMemoryResponse, args: DebugProtocol.ReadMemoryArguments, request?: DebugProtocol.Request): void {
1212 if (this.isBusy()) {
1213 this.busyError(response, args);
1214 return;
1215 }
1216 const startAddress = parseInt(args.memoryReference);
1217 const length = args.count;
1218 const useAddr = hexFormat(startAddress + (args.offset || 0));
1219 response.body = {
1220 address: useAddr,
1221 data: ''
1222 };
1223 if (length === 0) {
1224 this.sendResponse(response);
1225 return;
1226 }
1227 // const offset = args.offset ? `-o ${args.offset}` : '';
1228 const command = `data-read-memory-bytes "${useAddr}" ${length}`;
1229 this.miDebugger.sendCommand(command).then((node) => {
1230 const results = parseReadMemResults(node);
1231 const numBytes = results.data.length / 2;
1232 const intAry = new Uint8Array(numBytes);
1233 const data = results.data;
1234 for (let ix = 0, dx = 0; ix < numBytes; ix++, dx += 2) {
1235 // const tmp = results.data.substring(ix * 2, 2);
1236 const tmp = data[dx] + data[dx + 1];
1237 intAry[ix] = twoCharsToIntMap[tmp];
1238 }
1239 const buf = Buffer.from(intAry);
1240 const b64Data = buf.toString('base64');
1241 response.body.data = b64Data;
1242 this.sendResponse(response);
1243 }, (error) => {
1244 this.sendErrorResponse(response, 114, `Read memory error: ${error.toString()}`);
1245 this.sendEvent(new TelemetryEvent('Error', 'Reading Memory', command));
1246 });
1247 }
1248
1249 protected writeMemoryRequest(response: DebugProtocol.WriteMemoryResponse, args: DebugProtocol.WriteMemoryArguments, request?: DebugProtocol.Request): void {
1250 if (this.isBusy()) {

Callers

nothing calls this directly

Calls 7

isBusyMethod · 0.95
busyErrorMethod · 0.95
sendEventMethod · 0.95
hexFormatFunction · 0.90
parseReadMemResultsFunction · 0.90
sendCommandMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected