From 75fb2a8e5c900ee27ba5201b669cac48c2e91492 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Thu, 24 Feb 2022 09:47:34 -0600 Subject: [PATCH] worker: debuginfo passed thru to link step --- src/common/baseplatform.ts | 5 ++++- src/common/ecs/ecs.ts | 7 ++++++- src/worker/tools/ecs.ts | 16 +++++++++------- src/worker/workermain.ts | 8 ++++++++ 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/common/baseplatform.ts b/src/common/baseplatform.ts index 7e0aad13..763f37bc 100644 --- a/src/common/baseplatform.ts +++ b/src/common/baseplatform.ts @@ -223,7 +223,10 @@ export abstract class BasePlatform { return inspectSymbol((this as any) as Platform, sym); } getDebugTree() : {} { - return this.saveState(); + var o : any = { }; + o.state = this.saveState(); + if (this.debugSymbols.debuginfo) o.debuginfo = this.debugSymbols.debuginfo; + return o; } readFile(path: string) : FileData { return this.internalFiles[path]; diff --git a/src/common/ecs/ecs.ts b/src/common/ecs/ecs.ts index 8c3b0fef..f15588ea 100644 --- a/src/common/ecs/ecs.ts +++ b/src/common/ecs/ecs.ts @@ -1410,7 +1410,6 @@ export class EntityScope implements SourceLocated { if (action.critical) this.inCritical--; if (!this.inCritical && codeeval.isSubroutineSized(eventcode)) { let normcode = this.normalizeCode(eventcode, action); - // TODO: label rewriting messes this up let estats = this.eventCodeStats[normcode]; if (!estats) { estats = this.eventCodeStats[normcode] = new EventCodeStats( @@ -1730,4 +1729,10 @@ export class EntityManager { } } } + getDebugTree() : {} { + let scopes = this.topScopes; + let components = this.components; + let systems = this.systems; + return { scopes, components, systems }; + } } diff --git a/src/worker/tools/ecs.ts b/src/worker/tools/ecs.ts index 0ca641f1..443daac7 100644 --- a/src/worker/tools/ecs.ts +++ b/src/worker/tools/ecs.ts @@ -23,6 +23,7 @@ export function assembleECS(step: BuildStep): BuildStepResult { putWorkFile(destpath, outtext); var listings: CodeListingMap = {}; listings[destpath] = {lines:[], text:outtext} // TODO + var debuginfo = compiler.em.getDebugTree(); } catch (e) { if (e instanceof ECSError) { compiler.addError(e.message, e.$loc); @@ -33,12 +34,13 @@ export function assembleECS(step: BuildStep): BuildStepResult { throw e; } } + return { + nexttool: "ca65", + path: destpath, + args: [destpath], + files: [destpath].concat(step.files), + listings, + debuginfo + }; } - return { - nexttool: "ca65", - path: destpath, - args: [destpath], - files: [destpath].concat(step.files), - listings - }; } diff --git a/src/worker/workermain.ts b/src/worker/workermain.ts index 04ee1955..ea4d77fe 100644 --- a/src/worker/workermain.ts +++ b/src/worker/workermain.ts @@ -424,6 +424,7 @@ export interface BuildStep extends WorkerBuildStep { code? prefix? maxts? + debuginfo? }; /// @@ -511,6 +512,11 @@ class Builder { } if (step.result) { (step.result as any).params = step.params; // TODO: type check + if (step.debuginfo) { + let r = step.result as any; // TODO + if (!r.debuginfo) r.debuginfo = {}; + Object.assign(r.debuginfo, step.debuginfo); + } // errors? return them if ('errors' in step.result && step.result.errors.length) { applyDefaultErrorPath(step.result.errors, step.path); @@ -522,6 +528,7 @@ class Builder { } // combine files with a link tool? if ('linktool' in step.result) { + // add to existing link step if (linkstep) { linkstep.files = linkstep.files.concat(step.result.files); linkstep.args = linkstep.args.concat(step.result.args); @@ -533,6 +540,7 @@ class Builder { args:step.result.args }; } + linkstep.debuginfo = step.debuginfo; // TODO: multiple debuginfos } // process with another tool? if ('nexttool' in step.result) {