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

Method findDisasmRanges

src/backend/disasm.ts:810–873  ·  view source on GitHub ↗
(trueStart: number, trueEnd: number, referenceAddress: number)

Source from the content-addressed store, hash-verified

808 // information when there are gaps between functions. There is also a problem with functions
809 // that do not have a size
810 private findDisasmRanges(trueStart: number, trueEnd: number, referenceAddress: number): DisasmRange[] {
811 const doDbgPrint = false;
812 const printFunc = (item: SymbolNode) => {
813 if (doDbgPrint) {
814 const file = item.symbol.file || '<unknown-file>';
815 const msg = `(${hexFormat(item.low)}, ${item.low}), (${hexFormat(item.high)}, ${item.high}) ${item.symbol.name} ${file}`;
816 this.handleMsg('stdout', msg + '\n');
817 console.log(msg);
818 }
819 };
820
821 if (doDbgPrint) {
822 this.handleMsg('stdout', `${hexFormat(trueStart)}, ${hexFormat(trueEnd)} Search range\n`);
823 this.handleMsg('stdout', '-'.repeat(80) + '\n');
824 }
825 trueStart = this.clipLow(referenceAddress, trueStart);
826 trueEnd = this.clipHigh(referenceAddress, trueEnd);
827
828 const ret: DisasmRange[] = [];
829 const functions = this.gdbSession.symbolTable.symbolsAsIntervalTree.search(trueStart, trueEnd);
830 let range: DisasmRange = {
831 qStart: Math.min(trueStart, referenceAddress),
832 qEnd: Math.max(trueEnd, referenceAddress + this.maxInstrSize),
833 verify: referenceAddress,
834 isKnownStart: false
835 };
836 ret.push(range);
837 if (functions.length > 0) {
838 let prev = functions[0];
839 printFunc(prev);
840 let high = prev.high + 1;
841 range.qEnd = high;
842 range.verify = range.qStart = prev.low;
843 range.symNode = prev;
844 range.isKnownStart = true;
845 for (let ix = 1; ix < functions.length; ix++ ) {
846 const item = functions[ix];
847 if ((prev.low !== item.low) || (prev.high !== item.high)) { // Yes, duplicates are possible
848 const diff = item.low - high;
849 high = item.high + 1;
850 if (diff === 0) {
851 range.qEnd = high; // extend the range
852 } else {
853 range.qEnd = Math.max(range.qEnd, item.low /*- 1*/);
854 // If we want to deal with gaps between functions as if they are data, this is the place to do it
855 range = { // Start a new range
856 qStart: item.low,
857 qEnd: high,
858 verify: item.low,
859 isKnownStart: true,
860 symNode: item
861 };
862 ret.push(range);
863 }
864 }
865 printFunc(item);
866 prev = item;
867 }

Callers 1

Calls 4

handleMsgMethod · 0.95
clipLowMethod · 0.95
clipHighMethod · 0.95
hexFormatFunction · 0.90

Tested by

no test coverage detected