From bb814c57b1883e870a77e288d62cee596f551ecd Mon Sep 17 00:00:00 2001 From: Partouf Date: Wed, 21 Nov 2018 00:15:20 +0100 Subject: [PATCH 01/44] see if pahole will work for fpc --- lib/base-compiler.js | 8 +++++--- lib/tooling/pahole-tool.js | 12 ++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/base-compiler.js b/lib/base-compiler.js index 31c4a9455..7b071a892 100644 --- a/lib/base-compiler.js +++ b/lib/base-compiler.js @@ -242,7 +242,7 @@ class BaseCompiler { .then(() => this.postProcess(asmResult, outputFilename, filters)); } - runToolsOfType(sourcefile, tools, type, compilerExe, outputFilename, options, filters, asm) { + runToolsOfType(sourcefile, tools, type, compilerExe, outputFilename, options, filters, asm, executableFilename) { let tooling = []; if (tools) { tools.forEach((tool) => { @@ -253,7 +253,7 @@ class BaseCompiler { if (matches[0]) { const toolPromise = matches[0].runTool(sourcefile, tool.args, - compilerExe, outputFilename, options, filters, asm); + compilerExe, outputFilename, options, filters, asm, executableFilename); tooling.push(toolPromise); } }); @@ -467,10 +467,12 @@ class BaseCompiler { .then(result => { const outputFilebase = "output"; const outputFilename = this.getOutputFilename(result.dirPath, outputFilebase); + const executableFilename = this.getExecutableFilename(result.dirPath, outputFilebase); const postToolsPromise = this.runToolsOfType( result.inputFilename, tools, "postcompilation", - this.compiler.exe, outputFilename, options, filters, result.asm); + this.compiler.exe, outputFilename, options, filters, result.asm, + executableFilename); return Promise.all([Promise.all(postToolsPromise)]).then(([postToolsResult]) => { result.tools = _.union(result.tools, postToolsResult); diff --git a/lib/tooling/pahole-tool.js b/lib/tooling/pahole-tool.js index 4192fde72..f02b28a92 100644 --- a/lib/tooling/pahole-tool.js +++ b/lib/tooling/pahole-tool.js @@ -25,6 +25,7 @@ const utils = require('../utils'), + fs = require('fs-extra'), BaseTool = require('./base-tool'); class PaholeTool extends BaseTool { @@ -32,7 +33,7 @@ class PaholeTool extends BaseTool { super(toolInfo, env); } - runTool(sourcefile, args, compilerExe, outputFilename, option, filters) { + runTool(sourcefile, args, compilerExe, outputFilename, options, filters, asm, executableFilename) { if(!filters.binary) { return { @@ -42,7 +43,14 @@ class PaholeTool extends BaseTool { stdout: utils.parseOutput("Pahole requires a binary output") }; } - return super.runTool(outputFilename, args); + + return fs.stat(executableFilename, (err, fd) => { + if (fd) { + return super.runTool(executableFilename, args); + } else { + return super.runTool(outputFilename, args); + } + }); } } From 8366c08c5b1965cec58c3e60f6edf45472ca0abb Mon Sep 17 00:00:00 2001 From: Partouf Date: Wed, 21 Nov 2018 00:19:58 +0100 Subject: [PATCH 02/44] denodeify --- lib/tooling/pahole-tool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/tooling/pahole-tool.js b/lib/tooling/pahole-tool.js index f02b28a92..ced6594ca 100644 --- a/lib/tooling/pahole-tool.js +++ b/lib/tooling/pahole-tool.js @@ -26,11 +26,14 @@ const utils = require('../utils'), fs = require('fs-extra'), + denodeify = require('denodeify'), BaseTool = require('./base-tool'); class PaholeTool extends BaseTool { constructor(toolInfo, env) { super(toolInfo, env); + + this.stat = denodeify(fs.stat); } runTool(sourcefile, args, compilerExe, outputFilename, options, filters, asm, executableFilename) { @@ -44,7 +47,7 @@ class PaholeTool extends BaseTool { }; } - return fs.stat(executableFilename, (err, fd) => { + return this.stat(executableFilename).then((err, fd) => { if (fd) { return super.runTool(executableFilename, args); } else { From 484370f230b5fef83487bf5e321269c0b967bbf8 Mon Sep 17 00:00:00 2001 From: Partouf Date: Wed, 21 Nov 2018 00:25:23 +0100 Subject: [PATCH 03/44] . --- lib/tooling/pahole-tool.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/tooling/pahole-tool.js b/lib/tooling/pahole-tool.js index ced6594ca..81f89a5cc 100644 --- a/lib/tooling/pahole-tool.js +++ b/lib/tooling/pahole-tool.js @@ -47,12 +47,10 @@ class PaholeTool extends BaseTool { }; } - return this.stat(executableFilename).then((err, fd) => { - if (fd) { - return super.runTool(executableFilename, args); - } else { - return super.runTool(outputFilename, args); - } + return this.stat(executableFilename).then(() => { + return super.runTool(executableFilename, args); + }).catch(() => { + return super.runTool(outputFilename, args); }); } } From 53e488366839a1dbe0b9058ad77f490c2eefb1e6 Mon Sep 17 00:00:00 2001 From: Partouf Date: Wed, 21 Nov 2018 00:27:29 +0100 Subject: [PATCH 04/44] enable pahole for fpc --- etc/config/pascal.amazon.properties | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/etc/config/pascal.amazon.properties b/etc/config/pascal.amazon.properties index 3cc812368..b91f7cd82 100644 --- a/etc/config/pascal.amazon.properties +++ b/etc/config/pascal.amazon.properties @@ -27,9 +27,14 @@ libs= ################################# # Installed tools -tools=llvm-mcatrunk +tools=llvm-mcatrunk:pahole tools.llvm-mcatrunk.name=llvm-mca tools.llvm-mcatrunk.exe=/opt/compiler-explorer/clang-trunk/bin/llvm-mca tools.llvm-mcatrunk.type=postcompilation tools.llvm-mcatrunk.class=llvm-mca-tool + +tools.pahole.name=pahole +tools.pahole.exe=/opt/compiler-explorer/pahole/bin/pahole +tools.pahole.type=postcompilation +tools.pahole.class=pahole-tool From 85764bf488b80cef89ee4ca8024505ae39e00635 Mon Sep 17 00:00:00 2001 From: Partouf Date: Thu, 18 Jul 2019 21:52:33 +0200 Subject: [PATCH 05/44] add togglebuttons for tool input, autopopulate tool dropdown --- static/panes/compiler.js | 80 +++++++++++++++++++++++------------- static/panes/tool.js | 89 ++++++++++++++++++++++++++++++++++++---- views/templates.pug | 22 +++++----- 3 files changed, 142 insertions(+), 49 deletions(-) diff --git a/static/panes/compiler.js b/static/panes/compiler.js index 0a3b461b2..e06118d3b 100644 --- a/static/panes/compiler.js +++ b/static/panes/compiler.js @@ -99,6 +99,7 @@ function Compiler(hub, container, state) { this.alertSystem.prefixMessage = "Compiler #" + this.id + ": "; this.linkedFadeTimeoutId = -1; + this.toolsMenu = null; this.initButtons(state); @@ -425,7 +426,8 @@ Compiler.prototype.findTools = function (content, tools) { (content.componentState.compiler === this.id)) { tools.push({ id: content.componentState.toolId, - args: content.componentState.args + args: content.componentState.args, + stdin: content.componentState.stdin }); } } else if (content.content) { @@ -444,7 +446,8 @@ Compiler.prototype.getActiveTools = function (newToolSettings) { if (newToolSettings) { tools.push({ id: newToolSettings.toolId, - args: newToolSettings.args + args: newToolSettings.args, + stdin: newToolSettings.stdin }); } @@ -723,13 +726,15 @@ Compiler.prototype.onEditorChange = function (editor, source, langId, compilerId Compiler.prototype.onToolOpened = function (compilerId, toolSettings) { if (this.id === compilerId) { var toolId = toolSettings.toolId; - if (toolId === "clangtidytrunk") { - this.clangtidyToolButton.prop('disabled', true); - } else if (toolId === "llvm-mcatrunk") { - this.llvmmcaToolButton.prop('disabled', true); - } else if (toolId === "pahole") { - this.paholeToolButton.prop('disabled', true); - } + + var buttons = this.toolsMenu.find('button'); + $(buttons).each(_.bind(function (idx, button) { + var toolButton = $(button); + var toolName = toolButton.data('toolname'); + if (toolId === toolName) { + toolButton.prop('disabled', true); + } + }, this)); this.compile(false, toolSettings); } @@ -738,13 +743,15 @@ Compiler.prototype.onToolOpened = function (compilerId, toolSettings) { Compiler.prototype.onToolClosed = function (compilerId, toolSettings) { if (this.id === compilerId) { var toolId = toolSettings.toolId; - if (toolId === "clangtidytrunk") { - this.clangtidyToolButton.prop('disabled', !this.supportsTool(toolId)); - } else if (toolId === "llvm-mcatrunk") { - this.llvmmcaToolButton.prop('disabled', !this.supportsTool(toolId)); - } else if (toolId === "pahole") { - this.paholeToolButton.prop('disabled', !this.supportsTool(toolId)); - } + + var buttons = this.toolsMenu.find('button'); + $(buttons).each(_.bind(function (idx, button) { + var toolButton = $(button); + var toolName = toolButton.data('toolname'); + if (toolId === toolName) { + toolButton.prop('disabled', !this.supportsTool(toolId)); + } + }, this)); } }; @@ -993,13 +1000,34 @@ Compiler.prototype.initToolButton = function (togglePannerAdder, button, toolId) }; Compiler.prototype.initToolButtons = function (togglePannerAdder) { - this.clangtidyToolButton = this.domRoot.find('.view-clangtidytool'); - this.llvmmcaToolButton = this.domRoot.find('.view-llvmmcatool'); - this.paholeToolButton = this.domRoot.find('.view-pahole'); + this.toolsMenu = this.domRoot.find('.toolsmenu'); - this.initToolButton(togglePannerAdder, this.clangtidyToolButton, "clangtidytrunk"); - this.initToolButton(togglePannerAdder, this.llvmmcaToolButton, "llvm-mcatrunk"); - this.initToolButton(togglePannerAdder, this.paholeToolButton, "pahole"); + var addTool = _.bind(function (toolName, title) { + var btn = $("