diff options
Diffstat (limited to 'lib/base-compiler.js')
-rw-r--r-- | lib/base-compiler.js | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/lib/base-compiler.js b/lib/base-compiler.js index 9730bc1a7..86f23c0f0 100644 --- a/lib/base-compiler.js +++ b/lib/base-compiler.js @@ -809,22 +809,45 @@ export class BaseCompiler { } async processGnatDebugOutput(inputFilename, result) { - const content = []; + const contentDebugExpanded = []; + const contentDebugTree = []; + const keep_stdout = []; - // Everything before this stays in stdout. - // Everything after is considered expanded code and is moved to the - // corresponding pane. - const startOfExpandedCode = /^Source recreated/; + // stdout layout: + // + // ----- start + // everything here stays + // ... in stdout + // ... until : + // Source recreated from tree... + // everything here is + // ... sent in expanded + // ... pane... until : + // Tree created for ... + // everything after is + // ... sent in Tree pane + // ----- EOF + const startOfExpandedCode = /^Source recreated from tree/; + const startOfTree = /^Tree created for/; + let isInExpandedCode = false; + let isInTree = false; for (const obj of Object.values(result.stdout)) { if (!isInExpandedCode && startOfExpandedCode.test(obj.text)) { isInExpandedCode = true; } + if (!isInTree && startOfTree.test(obj.text)) { + isInExpandedCode = false; + isInTree = true; + } + if (isInExpandedCode) - content.push(obj); + contentDebugExpanded.push(obj); + else if (isInTree) + contentDebugTree.push(obj); else keep_stdout.push(obj); } @@ -833,15 +856,23 @@ export class BaseCompiler { // compiler may exit with an error after the emission. This dump is also // very usefull to debug error message. - if (content.length === 0) + if (contentDebugExpanded.length === 0) if (result.code !== 0) { return [{text: 'GNAT exited with an error and did not create the expanded code'}]; } else { return [{text: 'GNAT exited successfully but the expanded code is missing, something is wrong'}]; } + if (contentDebugTree.length === 0) + if (result.code !== 0) { + return [{text: 'GNAT exited with an error and did not create the Tree'}]; + } else { + return [{text: 'GNAT exited successfully but the Tree is missing, something is wrong'}]; + } + result.stdout = keep_stdout; - return content; + + return [contentDebugExpanded, contentDebugTree]; } /** @@ -1216,7 +1247,8 @@ export class BaseCompiler { execOptions.ldPath = this.getSharedLibraryPathsAsLdLibraryPaths([]); const makeAst = backendOptions.produceAst && this.compiler.supportsAstView; - const makeGnatDebug = backendOptions.produceGnatDebug && this.compiler.supportsGnatDebugView; + const makeGnatDebug = backendOptions.produceGnatDebug && this.compiler.supportsGnatDebugViews; + const makeGnatDebugTree = backendOptions.produceGnatDebugTree && this.compiler.supportsGnatDebugViews; const makeIr = backendOptions.produceIr && this.compiler.supportsIrView; const makeRustMir = backendOptions.produceRustMir && this.compiler.supportsRustMirView; const makeRustMacroExp = backendOptions.produceRustMacroExp && this.compiler.supportsRustMacroExpView; @@ -1247,9 +1279,10 @@ export class BaseCompiler { // GNAT, GCC and rustc can produce their extra output files along // with the main compilation command. - const gnatDebugResult = (makeGnatDebug ? - await this.processGnatDebugOutput(inputFilenameSafe, asmResult) - : ''); + const [gnatDebugResult, gnatDebugTreeResult] = (makeGnatDebug || makeGnatDebugTree ? + await this.processGnatDebugOutput(inputFilenameSafe, asmResult) + : ['', '']); + const gccDumpResult = (makeGccDump ? await this.processGccDumpOutput(backendOptions.produceGccDump, asmResult, this.compiler.removeEmptyGccDump, @@ -1267,9 +1300,16 @@ export class BaseCompiler { asmResult.gccDumpOutput = gccDumpResult; } - if (this.compiler.supportsGnatDebugView && gnatDebugResult) { - asmResult.hasGnatDebugOutput = true; - asmResult.gnatDebugOutput = gnatDebugResult; + if (this.compiler.supportsGnatDebugViews) { + if (gnatDebugResult) { + asmResult.hasGnatDebugOutput = true; + asmResult.gnatDebugOutput = gnatDebugResult; + } + + if (gnatDebugTreeResult) { + asmResult.hasGnatDebugTreeOutput = true; + asmResult.gnatDebugTreeOutput = gnatDebugTreeResult; + } } asmResult.tools = toolsResult; |