mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2026-10-25 00:02:16 +00:00
cc65: parse symbolsizes from --dbgfile, memory map tweaks
This commit is contained in:
1 parent
83f15d8627
commit
8161ae1fa3
10 files changed
+203
-13
No files matched your search
@@ -415,6 +415,7 @@ describe('Platform Replay', () => {
|
||||
platform.nextFrame();
|
||||
booted = platform.readAddress(0x0600) == 0x42;
|
||||
}
|
||||
platform.pause();
|
||||
assert.ok(booted, "ATR boot code did not run");
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import assert from "assert";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import { before, describe, it } from "mocha";
|
||||
import { after, before, describe, it } from "mocha";
|
||||
import { store, fixParamsWithDefines, applyAsmProjectParams, parseBuildDirectives, applyBuildDirectives } from "../../src/worker/builder";
|
||||
import { defineArgs, linkSymbolArgs, extraArgsFor, getPlatformToolConfig, TOOL_META } from "../../src/common/toolmeta";
|
||||
import { compileSourceFile, preload } from "../../src/tools/testlib";
|
||||
@@ -372,8 +373,9 @@ describe("applyAsmProjectParams (backwards compatibility)", function () {
|
||||
|
||||
describe("build directive wiring (integration)", function () {
|
||||
this.timeout(120000);
|
||||
const tmpdir = "/tmp/pi-agent/buildparams";
|
||||
before(function () { fs.mkdirSync(tmpdir, { recursive: true }); });
|
||||
let tmpdir: string;
|
||||
before(function () { tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), "buildparams-")); });
|
||||
after(function () { fs.rmSync(tmpdir, { recursive: true, force: true }); });
|
||||
|
||||
function writeSource(name: string, code: string): string {
|
||||
const p = path.join(tmpdir, name);
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import assert from "assert";
|
||||
import { describe, it } from "mocha";
|
||||
import { parseCC65DbgSizes } from "../../src/worker/tools/cc65dbg";
|
||||
|
||||
const DBG = [
|
||||
'version\tmajor=2,minor=0',
|
||||
'seg\tid=0,name="CODE",start=0x008500,size=0x0100,addrsize=absolute,type=ro',
|
||||
'seg\tid=2,name="BSS",start=0x00032A,size=0x0136,addrsize=absolute,type=rw',
|
||||
'seg\tid=3,name="DATA",start=0x000300,size=0x0010,addrsize=absolute,type=rw',
|
||||
'seg\tid=8,name="CHARS",start=0x000000,size=0x2000,addrsize=absolute,type=rw',
|
||||
'span\tid=20,seg=8,start=0,size=4096',
|
||||
'span\tid=0,seg=2,start=0,size=32',
|
||||
'span\tid=1,seg=2,start=32,size=48',
|
||||
'span\tid=2,seg=2,start=80,size=1',
|
||||
'span\tid=3,seg=3,start=0,size=4',
|
||||
'span\tid=4,seg=3,start=4,size=4',
|
||||
'span\tid=5,seg=3,start=8,size=2',
|
||||
'span\tid=9,seg=2,start=0,size=300', // scope span: ignored
|
||||
'line\tid=0,file=0,line=10,span=0',
|
||||
'line\tid=1,file=0,line=12,span=1',
|
||||
'line\tid=2,file=0,line=14,span=2',
|
||||
'line\tid=3,file=0,line=20,span=3+4',
|
||||
'line\tid=4,file=0,line=21,span=5',
|
||||
'line\tid=20,file=1,line=1,span=20',
|
||||
'scope\tid=0,name="",mod=0,size=300,span=9',
|
||||
'sym\tid=0,name="_formation",addrsize=absolute,scope=0,def=0,val=0x32A,seg=2,type=lab',
|
||||
'sym\tid=1,name="_attackers",addrsize=absolute,scope=0,def=1,val=0x34A,seg=2,type=lab',
|
||||
'sym\tid=2,name="_last",addrsize=absolute,scope=0,def=2,val=0x37A,seg=2,type=lab',
|
||||
'sym\tid=3,name="_table",addrsize=absolute,scope=0,def=3,val=0x300,seg=3,type=lab',
|
||||
'sym\tid=4,name="_next",addrsize=absolute,scope=0,def=4,val=0x308,seg=3,type=lab',
|
||||
'sym\tid=5,name="_main",addrsize=absolute,size=41,scope=0,def=5,val=0x8500,seg=0,type=lab',
|
||||
'sym\tid=6,name="L0002",addrsize=absolute,size=2,scope=1,def=6,val=0x8510,seg=0,type=lab',
|
||||
'sym\tid=7,name="L0002",addrsize=absolute,size=3,scope=2,def=7,val=0x8520,seg=0,type=lab',
|
||||
'sym\tid=8,name="_nobytes",addrsize=absolute,scope=0,def=8,val=0x8600,seg=0,type=lab',
|
||||
'sym\tid=10,name="_chr_tiles",addrsize=absolute,scope=0,def=20,val=0x0,seg=8,type=lab',
|
||||
'sym\tid=9,name="FOO",addrsize=zeropage,scope=0,def=9,val=0x10,type=equ',
|
||||
].join('\n');
|
||||
|
||||
describe('cc65 debug file', function () {
|
||||
const { sizes, ignored } = parseCC65DbgSizes(DBG, ['HEADER', 'CHARS']);
|
||||
|
||||
it('sizes labels from the line spans that follow them', function () {
|
||||
assert.equal(sizes._formation, 32);
|
||||
assert.equal(sizes._attackers, 48);
|
||||
assert.equal(sizes._last, 1);
|
||||
});
|
||||
|
||||
it('sums multiple spans up to the next label', function () {
|
||||
assert.equal(sizes._table, 8);
|
||||
assert.equal(sizes._next, 2);
|
||||
});
|
||||
|
||||
it('uses sizes recorded by ca65', function () {
|
||||
assert.equal(sizes._main, 41);
|
||||
});
|
||||
|
||||
it('omits duplicates, equates and labels without spans', function () {
|
||||
assert.ok(!('L0002' in sizes));
|
||||
assert.ok(!('FOO' in sizes));
|
||||
assert.ok(!('_nobytes' in sizes));
|
||||
});
|
||||
|
||||
it('reports labels in ignored segments instead of sizing them', function () {
|
||||
assert.deepEqual(ignored, ['_chr_tiles']);
|
||||
assert.ok(!('_chr_tiles' in sizes));
|
||||
assert.equal(parseCC65DbgSizes(DBG).sizes._chr_tiles, 4096);
|
||||
});
|
||||
});
|
||||
@@ -70,7 +70,7 @@ describe('Memory map layout', function () {
|
||||
_small: 0x300, _buffer: 0x302, _last: 0x380,
|
||||
__BSS_RUN__: 0x300, _code: 0x8000, _zp: 0x10,
|
||||
};
|
||||
const vars = findLargeVariables(symbols, native.concat(linker));
|
||||
const vars = findLargeVariables(symbols, native.concat(linker), {minVarSize:16});
|
||||
assert.deepEqual(vars.map(v => [v.name, v.start, v.end]), [
|
||||
['_last', 0x380, 0x400],
|
||||
['_buffer', 0x302, 0x380],
|
||||
@@ -79,14 +79,14 @@ describe('Memory map layout', function () {
|
||||
});
|
||||
|
||||
it('skips the last symbol of a native-only RAM segment', function () {
|
||||
const vars = findLargeVariables({ _a: 0x100, _b: 0x200 }, native);
|
||||
const vars = findLargeVariables({ _a: 0x100, _b: 0x200 }, native, {minVarSize:16});
|
||||
assert.deepEqual(vars.map(v => v.name), ['_a']);
|
||||
});
|
||||
|
||||
it('uses reported symbol sizes over gap estimates', function () {
|
||||
const symbols = { _a: 0x300, _b: 0x340, ZeroStart: 0x380, _c: 0x380 };
|
||||
const sizes = { _a: 20, _b: 8, ZeroStart: 0, _c: 0x40 };
|
||||
const vars = findLargeVariables(symbols, native.concat(linker), {}, sizes);
|
||||
const vars = findLargeVariables(symbols, native.concat(linker), {minVarSize:16}, sizes);
|
||||
assert.deepEqual(vars.map(v => [v.name, v.start, v.end, !!v.approx]), [
|
||||
['_c', 0x380, 0x3c0, false],
|
||||
['_a', 0x300, 0x314, false],
|
||||
|
||||
Reference in new issue
Block a user