mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-02 10:17:32 -06:00
working version
This commit is contained in:
@@ -7,6 +7,9 @@ needsMulti=false
|
||||
buildenvsetup=ceconan
|
||||
buildenvsetup.host=https://conan.compiler-explorer.com
|
||||
|
||||
externalparser=CEAsmParser
|
||||
externalparser.exe=/opt/compiler-explorer/asm-parser/build/bin/asm-parser
|
||||
|
||||
###############################
|
||||
# GCC for x86
|
||||
group.gcc86.compilers=g412:g447:g453:g464:g471:g472:g473:g474:g481:g482:g483:g484:g485:g490:g491:g492:g493:g494:g510:g520:g530:g540:g550:g6:g62:g63:g64:g71:g72:g73:g74:g75:g81:g82:g83:g84:g85:g91:g92:g93:g94:g101:g102:g103:g111:g112:gsnapshot:gcontracts-trunk:gcontract-labels-trunk:gcxx-modules-trunk:gcxx-coroutines-trunk:gcc-embed-trunk:gcc-static-analysis-trunk
|
||||
|
||||
+19
-18
@@ -110,7 +110,7 @@ export class BaseCompiler {
|
||||
this.externalparser = null;
|
||||
if (this.compiler.externalparser && this.compiler.externalparser.id) {
|
||||
const externalparserclass = getExternalParserByKey(this.compiler.externalparser.id);
|
||||
this.externalparser = new externalparserclass(this.compiler, this.env, exec.sandbox);
|
||||
this.externalparser = new externalparserclass(this.compiler, this.env, this.exec);
|
||||
}
|
||||
|
||||
if (!this.compiler.instructionSet) {
|
||||
@@ -324,22 +324,21 @@ export class BaseCompiler {
|
||||
if (demangle) args.push('-C');
|
||||
if (intelAsm) args.push(...objdumper.intelAsmOptions);
|
||||
|
||||
let objResult;
|
||||
if (this.externalparser) {
|
||||
objResult = await this.externalparser.objdumpAndParseAssembly(
|
||||
result = await this.externalparser.objdumpAndParseAssembly(
|
||||
path.dirname(outputFilename),
|
||||
args,
|
||||
filters);
|
||||
} else {
|
||||
const execOptions = {maxOutput: maxSize, customCwd: result.dirPath || path.dirname(outputFilename)};
|
||||
objResult = await this.exec(this.compiler.objdumper, args, execOptions);
|
||||
}
|
||||
const objResult = await this.exec(this.compiler.objdumper, args, execOptions);
|
||||
|
||||
if (objResult.code !== 0) {
|
||||
result.asm = `<No output: objdump returned ${objResult.code}>`;
|
||||
} else {
|
||||
result.objdumpTime = objResult.execTime;
|
||||
result.asm = this.postProcessObjdumpOutput(objResult.stdout);
|
||||
if (objResult.code !== 0) {
|
||||
result.asm = `<No output: objdump returned ${objResult.code}>`;
|
||||
} else {
|
||||
result.objdumpTime = objResult.execTime;
|
||||
result.asm = this.postProcessObjdumpOutput(objResult.stdout);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -1692,14 +1691,16 @@ export class BaseCompiler {
|
||||
}
|
||||
|
||||
if (!backendOptions.skipAsm) {
|
||||
if (result.okToCache) {
|
||||
const res = this.processAsm(result, filters, options);
|
||||
result.asm = res.asm;
|
||||
result.labelDefinitions = res.labelDefinitions;
|
||||
result.parsingTime = res.parsingTime;
|
||||
result.filteredCount = res.filteredCount;
|
||||
} else {
|
||||
result.asm = [{text: result.asm}];
|
||||
if (typeof result.asm === 'string') {
|
||||
if (result.okToCache) {
|
||||
const res = this.processAsm(result, filters, options);
|
||||
result.asm = res.asm;
|
||||
result.labelDefinitions = res.labelDefinitions;
|
||||
result.parsingTime = res.parsingTime;
|
||||
result.filteredCount = res.filteredCount;
|
||||
} else {
|
||||
result.asm = [{text: result.asm}];
|
||||
}
|
||||
}
|
||||
// TODO rephrase this so we don't need to reassign
|
||||
result = filters.demangle ? await this.postProcessAsm(result, filters) : result;
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { TypicalExecutionFunc } from '../../types/execution/execution.interfaces';
|
||||
import { TypicalExecutionFunc, UnprocessedExecResult } from '../../types/execution/execution.interfaces';
|
||||
import { IParseFilters } from '../../types/features/filters.interfaces';
|
||||
import { maskRootdir } from '../utils';
|
||||
|
||||
import { IExternalParser, IParsedAsmResult } from './external-parser.interface';
|
||||
|
||||
const starterScriptName = 'dump-and-parse.sh';
|
||||
|
||||
export class ExternalParserBase implements IExternalParser {
|
||||
private objdumperPath: string;
|
||||
private parserPath: string;
|
||||
private execFunc: TypicalExecutionFunc;
|
||||
private compilerInfo;
|
||||
private envInfo;
|
||||
|
||||
constructor(compilerInfo, envInfo, execFunc: TypicalExecutionFunc) {
|
||||
this.compilerInfo = compilerInfo;
|
||||
this.envInfo = envInfo;
|
||||
this.objdumperPath = compilerInfo.objdumper;
|
||||
this.parserPath = compilerInfo.externalparser.props('exe', '');
|
||||
this.execFunc = execFunc;
|
||||
@@ -34,14 +41,14 @@ export class ExternalParserBase implements IExternalParser {
|
||||
private getObjdumpStarterScriptContent(filters: IParseFilters) {
|
||||
const parserArgs = this.getParserArguments(filters, true);
|
||||
|
||||
return '#!/bin/sh\n' +
|
||||
return '#!/bin/bash\n' +
|
||||
`OBJDUMP=${this.objdumperPath}\n` +
|
||||
`ASMPARSER=${this.parserPath}\n` +
|
||||
`$OBJDUMP "$@" | $ASMPARSER ${parserArgs.join(' ')}\n`;
|
||||
}
|
||||
|
||||
private async writeStarterScriptObjdump(buildfolder: string, filters: IParseFilters): Promise<string> {
|
||||
const scriptFilepath = path.join(buildfolder, 'dump-and-parse.sh');
|
||||
const scriptFilepath = path.join(buildfolder, starterScriptName);
|
||||
|
||||
return new Promise((resolve) => {
|
||||
fs.writeFile(scriptFilepath,
|
||||
@@ -49,31 +56,36 @@ export class ExternalParserBase implements IExternalParser {
|
||||
encoding: 'utf8',
|
||||
mode: 0o777,
|
||||
}, () => {
|
||||
resolve(scriptFilepath);
|
||||
resolve(maskRootdir(scriptFilepath));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private parseAsmExecResult(execResult): IParsedAsmResult {
|
||||
console.log(execResult.stdout);
|
||||
console.log(execResult.stderr);
|
||||
const result = Object.assign({}, JSON.parse(execResult.stdout));
|
||||
if (result.stderr) {
|
||||
throw result.stderr;
|
||||
}
|
||||
private parseAsmExecResult(execResult: UnprocessedExecResult): IParsedAsmResult {
|
||||
const result = Object.assign({}, execResult, JSON.parse(execResult.stdout));
|
||||
delete result.stdout;
|
||||
delete result.stderr;
|
||||
return result;
|
||||
}
|
||||
|
||||
public async objdumpAndParseAssembly(buildfolder: string, objdumpArgs: string[],
|
||||
filters: IParseFilters): Promise<IParsedAsmResult> {
|
||||
const scriptFilepath = await this.writeStarterScriptObjdump(buildfolder, filters);
|
||||
const execOptions = {};
|
||||
const execResult = await this.execFunc(scriptFilepath, objdumpArgs, execOptions);
|
||||
objdumpArgs = objdumpArgs.map((v) => {
|
||||
return maskRootdir(v);
|
||||
});
|
||||
await this.writeStarterScriptObjdump(buildfolder, filters);
|
||||
const execOptions = {
|
||||
env: this.envInfo.getEnv(this.compilerInfo.needsMulti),
|
||||
customCwd: buildfolder,
|
||||
};
|
||||
const execResult = await this.execFunc('./' + starterScriptName, objdumpArgs, execOptions);
|
||||
return this.parseAsmExecResult(execResult);
|
||||
}
|
||||
|
||||
public async parseAssembly(filepath: string, filters: IParseFilters): Promise<IParsedAsmResult> {
|
||||
const execOptions = {};
|
||||
const execOptions = {
|
||||
env: this.envInfo.getEnv(this.compilerInfo.needsMulti),
|
||||
};
|
||||
|
||||
const parserArgs = this.getParserArguments(filters, false);
|
||||
parserArgs.push(filepath);
|
||||
|
||||
@@ -9,4 +9,4 @@ export interface UnprocessedExecResult {
|
||||
execTime: string;
|
||||
}
|
||||
|
||||
export type TypicalExecutionFunc = (executable: string, args: string[], execOptions: object) => UnprocessedExecResult;
|
||||
export type TypicalExecutionFunc = (executable: string, args: string[], execOptions: object) => IUnprocessedExecResult;
|
||||
|
||||
Reference in New Issue
Block a user