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

Method parseIntruction

src/backend/disasm.ts:393–430  ·  view source on GitHub ↗
(miInstr: MINode, srcInfo?: ParseSourceInfo)

Source from the content-addressed store, hash-verified

391 }
392
393 const parseIntruction = (miInstr: MINode, srcInfo?: ParseSourceInfo) => {
394 const address = MINode.valueOf(miInstr, 'address') as string || '0x????????';
395 const fName = MINode.valueOf(miInstr, 'func-name') as string || undefined;
396 const offset = parseInt(MINode.valueOf(miInstr, 'offset') || '0');
397 const ins = MINode.valueOf(miInstr, 'inst');
398 const opcodes = MINode.valueOf(miInstr, 'opcodes') as string || '';
399 const nAddress = parseInt(address);
400 // If entire range is valid, use that info but otherwise check specifically for this address
401 const flag = entireRangeGood ? '' : this.getMemFlagForAddr(nAddress);
402 const useInstr = (opcodes.replace(/\s/g, '')).padEnd(2 * this.maxInstrSize + 2) + flag + ins;
403 const sym = this.formatSym(fName, offset);
404
405 // const sym = fName ? '<' + (fName.length > 22 ? '..' + fName.substring(fName.length - 20) : fName) + `+${offset}>` : undefined;
406 const instr: ProtocolInstruction = {
407 address: address,
408 pvtAddress: nAddress,
409 instruction: useInstr,
410 // VSCode doesn't do anything with 'symbol'
411 symbol: fName,
412 // symbol: fName ? `<${fName}+${offset === undefined ? '??' : offset}>` : undefined,
413 // The UI is not good when we provide this using `instructionBytes` but we need it
414 pvtInstructionBytes: opcodes
415 };
416 if (sym) {
417 instr.instructionBytes = sym;
418 }
419 if (srcInfo) {
420 instr.location = srcInfo.source;
421 instr.line = srcInfo.startLine;
422 instr.endLine = srcInfo.endLine;
423 }
424
425 if (validationAddr === nAddress) {
426 foundIx = instructions.length;
427 }
428
429 instructions.push(instr);
430 };
431
432 let srcCount = 0;
433 let asmCount = 0;

Callers

nothing calls this directly

Calls 3

getMemFlagForAddrMethod · 0.95
formatSymMethod · 0.95
valueOfMethod · 0.80

Tested by

no test coverage detected