MCPcopy Create free account
hub / github.com/Marus/cortex-debug / readRegistersRequest

Method readRegistersRequest

src/gdb.ts:1307–1360  ·  view source on GitHub ↗
(response: DebugProtocol.Response)

Source from the content-addressed store, hash-verified

1305 }
1306
1307 protected readRegistersRequest(response: DebugProtocol.Response) {
1308 try {
1309 if (!this.args.variableUseNaturalFormat) {
1310 // requesting a radix on the register-values does not work unless the output radix is
1311 // decimal. bug in gdb I think. We temporarily force to decimal and then restore later
1312 this.suppressRadixMsgs = true;
1313 for (const cmd of this.formatRadixGdbCommand('0xa')) {
1314 this.miDebugger.sendCommand(cmd);
1315 }
1316 }
1317
1318 const fmt = this.args.registerUseNaturalFormat ? 'N' : 'x';
1319 this.miDebugger.sendCommand(`data-list-register-values ${fmt}`).then((node) => {
1320 if (node.resultRecords.resultClass === 'done') {
1321 const rv = node.resultRecords.results[0][1];
1322 response.body = rv.map((n) => {
1323 const val = {};
1324 n.forEach((x) => {
1325 val[x[0]] = x[1];
1326 });
1327 return val;
1328 });
1329 }
1330 else {
1331 response.body = {
1332 error: 'Unable to parse response'
1333 };
1334 }
1335 this.sendResponse(response);
1336 }, (error) => {
1337 response.body = { error: error };
1338 this.sendErrorResponse(response, 115, `Unable to read registers: ${error.toString()}`);
1339 this.sendEvent(new TelemetryEvent('Error', 'Reading Registers', ''));
1340 });
1341
1342 if (!this.args.variableUseNaturalFormat) {
1343 const cmds = this.formatRadixGdbCommand();
1344 for (let ix = 0; ix < cmds.length; ix++) {
1345 this.miDebugger.sendCommand(cmds[ix]).then((_) => {
1346 if (ix === (cmds.length - 1)) { // Last one
1347 this.suppressRadixMsgs = false;
1348 }
1349 }, (_) => {
1350 if (ix === (cmds.length - 1)) { // Last one
1351 this.suppressRadixMsgs = false;
1352 }
1353 });
1354 }
1355 }
1356 }
1357 catch {
1358 this.suppressRadixMsgs = false;
1359 }
1360 }
1361
1362 protected readRegisterListRequest(response: DebugProtocol.Response) {
1363 this.miDebugger.sendCommand('data-list-register-names').then((node) => {

Callers 1

customRequestMethod · 0.95

Calls 4

formatRadixGdbCommandMethod · 0.95
sendEventMethod · 0.95
sendCommandMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected