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

Method cleaupAndCheckInstructions

src/backend/disasm.ts:877–909  ·  view source on GitHub ↗
(instrs: ProtocolInstruction[])

Source from the content-addressed store, hash-verified

875 // Remove location information for any consecutive instructions having the
876 // same location. This will remove lot of redundant source lines from presentation
877 private cleaupAndCheckInstructions(instrs: ProtocolInstruction[]) {
878 if (instrs.length > 0) {
879 let prev = null;
880 let count = 0;
881 for (let ix = 0; ix < instrs.length; ix++ ) {
882 const instr = instrs[ix];
883 if (instr.pvtInstructionBytes && !instr.pvtIsData) {
884 const nBytes = (instr.pvtInstructionBytes.length + 1) / 3;
885 if ((nBytes < this.minInstrSize) || (nBytes > this.maxInstrSize)) {
886 throw new Error(`Bad/corrupted disassembly (too many/few bytes? Please report this problem ${instr.address} ${instr.instruction}`);
887 }
888 }
889 if (prev && (instr.line === prev.line) && instr.location && prev.location && (instr.location.path === prev.location.path)) {
890 // If you remove too many instructions because the source line is same, then VSCode
891 // does not display any source for any line. Real threshold may be more than 10 but
892 // even visually, doesn't hurt to repeat
893 if (count < 10) {
894 // Don't modify the original source as they also exist in the cache. produce a copy
895 const copy = Object.assign({}, instr);
896 count++;
897 delete copy.location;
898 delete copy.line;
899 instrs[ix] = copy;
900 } else {
901 count = 0;
902 }
903 } else {
904 count = 0;
905 }
906 prev = instr;
907 }
908 }
909 }
910
911 public async customDisassembleRequest(response: DebugProtocol.Response, args: any): Promise<void> {
912 if (args.function) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected