diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts index 30d33661e..5c70fde83 100644 --- a/lib/base-compiler.ts +++ b/lib/base-compiler.ts @@ -210,7 +210,7 @@ export class BaseCompiler { protected cmakeBaseEnv: Record; protected buildenvsetup: null | any; protected externalparser: null | ExternalParserBase; - protected supportedLibraries?: Record;n + protected supportedLibraries?: Record; protected packager: Packager; protected defaultRpathFlag = '-Wl,-rpath,'; private static objdumpAndParseCounter = new PromClient.Counter({ diff --git a/lib/cfg/cfg-parsers/base.ts b/lib/cfg/cfg-parsers/base.ts index 51dbd8d7e..38fd6177d 100644 --- a/lib/cfg/cfg-parsers/base.ts +++ b/lib/cfg/cfg-parsers/base.ts @@ -212,10 +212,9 @@ export class BaseCFGParser { return name.substring(0, pos + 1) + suffix; }; const bb = arrBB[bbIdx]; - if (hasName(asmArr, bb)) - return asmArr[bb.end].text; + if (hasName(asmArr, bb)) return asmArr[bb.end].text; const newBbName = generateName(bb.nameId, bb.end); - arrBB[bbIdx+1].nameId = newBbName; + arrBB[bbIdx + 1].nameId = newBbName; return newBbName; } @@ -241,7 +240,11 @@ export class BaseCFGParser { if (actPosSz === 1) return [ {nameId: basicBlock.nameId, start: basicBlock.start, end: actionPos[0] + 1}, - {nameId: basicBlock.nameId + this.getLabelSeparator() + (actionPos[0] + 1), start: actionPos[0] + 1, end: basicBlock.end}, + { + nameId: basicBlock.nameId + this.getLabelSeparator() + (actionPos[0] + 1), + start: actionPos[0] + 1, + end: basicBlock.end, + }, ]; let cur = 0; @@ -258,7 +261,11 @@ export class BaseCFGParser { result.push(_.clone(tmp)); } - tmp = {nameId: blockName + this.getLabelSeparator() + (actionPos[first] + 1), start: actionPos[first] + 1, end: basicBlock.end}; + tmp = { + nameId: blockName + this.getLabelSeparator() + (actionPos[first] + 1), + start: actionPos[first] + 1, + end: basicBlock.end, + }; result.push(_.clone(tmp)); return result; diff --git a/lib/cfg/cfg-parsers/vc.ts b/lib/cfg/cfg-parsers/vc.ts index fd2c55cc2..08abd1530 100644 --- a/lib/cfg/cfg-parsers/vc.ts +++ b/lib/cfg/cfg-parsers/vc.ts @@ -24,7 +24,6 @@ import _ from 'underscore'; - import {AssemblyLine, BaseCFGParser, Range} from './base.js'; export class VcCFGParser extends BaseCFGParser { @@ -42,12 +41,16 @@ export class VcCFGParser extends BaseCFGParser { newText = line.text.substring(0, pos).trimEnd(); } return {...line, text: newText}; - } + }; const noCommentLines = assembly.map(removeComment).filter(line => line.text.length > 0); - const isFuncStart = (line: string) => { return line.endsWith(' PROC'); }; - const isFuncEnd = (line: string) => { return line.endsWith(' ENDP'); }; + const isFuncStart = (line: string) => { + return line.endsWith(' PROC'); + }; + const isFuncEnd = (line: string) => { + return line.endsWith(' ENDP'); + }; - let newRes: AssemblyLine[] = []; + const newRes: AssemblyLine[] = []; let inFunction = false; for (const line of noCommentLines) { if (isFuncStart(line.text)) { @@ -71,9 +74,9 @@ export class VcCFGParser extends BaseCFGParser { const fnRange: Range = {start: 0, end: 0}; do { if (this.isFunctionEnd(asmArr[cur].text)) { - fnRange.end = cur+1; + fnRange.end = cur + 1; result.push(_.clone(fnRange)); - fnRange.start = cur+1; + fnRange.start = cur + 1; } ++cur; } while (cur < last); @@ -95,7 +98,7 @@ export class VcCFGParser extends BaseCFGParser { override extractJmpTargetName(inst: string) { return inst.match(/\$.*/) + ':'; } - + override getLabelSeparator() { // `@` is used natively by MSVC labels, so we use `#` instead return '#'; diff --git a/lib/cfg/cfg.ts b/lib/cfg/cfg.ts index 1d1f8e84a..4c7c597fa 100644 --- a/lib/cfg/cfg.ts +++ b/lib/cfg/cfg.ts @@ -67,12 +67,9 @@ export async function generateStructure( // dex2oat is a special case because it can output different instruction // sets. Create an OAT parser instead of searching by ISA. let parser: BaseCFGParser; - if (compilerGroup?.includes('dex2oat')) - parser = new OatCFGParser(instructionSet); - else if (compilerGroup?.startsWith('vc')) - parser = new (getParserByKey('vc'))(instructionSet) - else - parser = new (getParserByKey(compilerGroup))(instructionSet); + if (compilerGroup?.includes('dex2oat')) parser = new OatCFGParser(instructionSet); + else if (compilerGroup?.startsWith('vc')) parser = new (getParserByKey('vc'))(instructionSet); + else parser = new (getParserByKey(compilerGroup))(instructionSet); let code = parser.filterData(asmArr); code = await parser.processFuncNames(code, fullRes);