mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-01 10:56:09 -06:00
Make gccDump output process filename agnostic
This commit is contained in:
+24
-25
@@ -934,7 +934,6 @@ class BaseCompiler {
|
||||
async processGccDumpOutput(opts, result) {
|
||||
const rootDir = path.dirname(result.inputFilename);
|
||||
const allFiles = await fs.readdir(rootDir);
|
||||
const base = path.basename(result.inputFilename);
|
||||
|
||||
if (opts.treeDump === false && opts.rtlDump === false) {
|
||||
return {
|
||||
@@ -945,38 +944,38 @@ class BaseCompiler {
|
||||
};
|
||||
}
|
||||
|
||||
const allPasses = [];
|
||||
|
||||
for (let file of allFiles) {
|
||||
if (file.includes(`${base}.`)) {
|
||||
allPasses.push(file.substring(base.length + 1));
|
||||
}
|
||||
}
|
||||
|
||||
const output = {
|
||||
all: allPasses,
|
||||
all: [],
|
||||
selectedPass: opts.pass,
|
||||
currentPassOutput: '<No pass selected>',
|
||||
syntaxHighlight: false
|
||||
};
|
||||
|
||||
if (opts.pass) {
|
||||
const passDump = `${result.inputFilename}.${opts.pass}`;
|
||||
|
||||
if (await fs.pathExists(passDump) && (await fs.stat(passDump)).isFile()) {
|
||||
output.currentPassOutput = await fs.readFile(passDump, 'utf-8');
|
||||
if (output.currentPassOutput.match(/^\s*$/)) {
|
||||
output.currentPassOutput = 'File for selected pass is empty.';
|
||||
} else {
|
||||
output.syntaxHighlight = true;
|
||||
let passFound = false;
|
||||
// Phase letter is one of {i, l, r, t}
|
||||
// {outpufilename}.{extension}.{passNumber}{phaseLetter}.{phaseName}
|
||||
const dumpFilenameRegex = /^.+?\..+?\.(\d+?[ilrt]\..+)$/;
|
||||
for (let filename of allFiles) {
|
||||
const match = dumpFilenameRegex.exec(filename);
|
||||
if (match) {
|
||||
const pass = match[1];
|
||||
output.all.push(pass);
|
||||
const filePath = path.join(rootDir, filename);
|
||||
if (opts.pass === pass && (await fs.stat(filePath)).isFile()) {
|
||||
passFound = true;
|
||||
output.currentPassOutput = await fs.readFile(filePath, 'utf-8');
|
||||
if (output.currentPassOutput.match(/^\s*$/)) {
|
||||
output.currentPassOutput = 'File for selected pass is empty.';
|
||||
} else {
|
||||
output.syntaxHighlight = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// most probably filter has changed and the request is outdated.
|
||||
output.currentPassOutput = `Pass '${output.selectedPass}' was requested
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.pass && !passFound) {
|
||||
output.currentPassOutput = `Pass '${opts.pass}' was requested
|
||||
but is not valid anymore with current filters.
|
||||
Please select another pass or change filters.`;
|
||||
output.selectedPass = "";
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
Reference in New Issue
Block a user