From ae0abfdfd37e1702eec6de0687e3236519ffca02 Mon Sep 17 00:00:00 2001 From: partouf Date: Fri, 24 Nov 2017 18:02:05 +0100 Subject: [PATCH] added objdump preprocessor to remove non-user code, added preprocesser for asm to add .file, .loc and .cfi_endproc tags --- lib/compilers/fpc.js | 91 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/lib/compilers/fpc.js b/lib/compilers/fpc.js index ab6fb611e..f89c6651e 100644 --- a/lib/compilers/fpc.js +++ b/lib/compilers/fpc.js @@ -185,10 +185,6 @@ function compileFPC(info, env) { compiler.postProcessAsm = function (result) { if (!result.okToCache) return result; - for (var i = 0; i < result.asm.length; ++i) { - addDemangleToCache(result.asm[i].text); - } - buildOrderedCache(); for (var j = 0; j < result.asm.length; ++j) @@ -198,7 +194,15 @@ function compileFPC(info, env) { }; compiler.optionsForFilter = function (filters, outputFilename, userOptions) { - return ['@/opt/compiler-explorer/fpc/fpc.cfg', '-a', '-g']; + options = ['-g']; + + if (this.compiler.intelAsm && filters.intel && !filters.binary) { + options = options.concat(this.compiler.intelAsm.split(" ")); + } + + filters.preProcessLines = preProcessLines; + + return options; }; var saveDummyProjectFile = function (filename) { @@ -209,6 +213,65 @@ function compileFPC(info, env) { "end."); }; + var preProcessBinaryAsm = function (input) { + var relevantAsmStartsAt = input.indexOf("\""; + } else { + return false; + } + } else if (asm.startsWith(".Le")) { + return " .cfi_endproc"; + } else { + return false; + } + }; + + var preProcessLines = function(asmLines) { + var i = 0; + + while (i < asmLines.length) { + var extraHint = getExtraAsmHint(asmLines[i]); + if (extraHint) { + i++; + asmLines.splice(i, 0, extraHint); + } else { + addDemangleToCache(asmLines[i]); + } + + i++; + } + + return asmLines; + }; + compiler.objdump = function (outputFilename, result, maxSize, intelAsm, demangle) { outputFilename = path.join(path.dirname(outputFilename), "prog"); @@ -217,24 +280,12 @@ function compileFPC(info, env) { if (intelAsm) args = args.concat(["-M", "intel"]); return this.exec(this.compiler.objdumper, args, {maxOutput: maxSize}) .then(function (objResult) { - result.asm = objResult.stdout; - var relevantAsmStartsAt = result.asm.indexOf(""; + } else { + result.asm = preProcessBinaryAsm(objResult.stdout); } + return result; }); };