Skip to content

Commit d4a388d

Browse files
committed
fix(tools): alloc adjusts
1 parent 9d631cd commit d4a388d

3 files changed

Lines changed: 30 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ jobs:
6161
run: zig build sdk-build --summary all
6262

6363
- name: Build NES examples and generate Mesen label files
64-
run: zig build nes-hello1 nes-hello2 nes-hello3 nes-zig-logo nes-fade nes-sprites nes-random nes-pads nes-color-cycle nes-fullbg nes-mappers nes-cnrom-hello nes-unrom-hello nes-unrom-512-hello nes-mmc1-hello nes-mmc3-hello nes-gtrom-hello nes-action53-hello fds-hello gen-labels --summary all
64+
run: zig build nes-hello1 nes-hello2 nes-hello3 nes-zig-logo nes-fade nes-sprites nes-random nes-pads nes-color-cycle nes-fullbg nes-mappers nes-bat-ball nes-megablast nes-gg-demo nes-cnrom-hello nes-cnrom-sprites nes-unrom-hello nes-unrom-512-hello nes-unrom-color-cycle nes-mmc1-hello nes-mmc1-sprites nes-mmc3-hello nes-mmc3-pads nes-gtrom-hello nes-gtrom-color-cycle nes-action53-hello fds-hello gen-labels --summary all
6565

6666
- name: Build Commodore examples (C64, VIC-20, CX16, GEOS)
6767
run: zig build c64-hello c64-fibonacci c64-plasma vic20-hello cx16-hello cx16-k-console-test geos-hello --summary all
6868

69-
- name: Build Atari examples (Lynx, 2600, 8-bit)
70-
run: zig build lynx-hello atari2600-colorbar atari2600-3e-colorbar atari8dos-hello atari8-cart-hello --summary all
69+
- name: Build Atari examples (Lynx, 2600, 8-bit, 5200)
70+
run: zig build lynx-hello atari2600-colorbar atari2600-3e-colorbar atari8dos-hello atari8-cart-hello atari8-megacart-hello atari8-xegs-hello atari5200-cart-hello --summary all
7171

7272
- name: Build PC Engine, MEGA65, Neo6502 examples
7373
run: zig build pce-color-cycle pce-color-cycle-banked mega65-hello mega65-plasma mega65-viciv neo6502-graphics --summary all
@@ -84,15 +84,20 @@ jobs:
8484
ls -la zig-out/bin/
8585
for f in \
8686
hello1.nes hello2.nes hello3.nes zig-logo.nes fade.nes sprites.nes random.nes pads.nes color-cycle.nes \
87-
fullbg.nes mappers.nes cnrom-hello.nes unrom-hello.nes unrom-512-hello.nes mmc1-hello.nes mmc3-hello.nes gtrom-hello.nes \
87+
fullbg.nes mappers.nes bat-ball.nes megablast.nes gg-demo.nes \
88+
cnrom-hello.nes cnrom-sprites.nes \
89+
unrom-hello.nes unrom-512-hello.nes unrom-color-cycle.nes \
90+
mmc1-hello.nes mmc1-sprites.nes \
91+
mmc3-hello.nes mmc3-pads.nes \
92+
gtrom-hello.nes gtrom-color-cycle.nes \
8893
action53-hello.nes fds-hello.fds \
8994
c64-hello.prg fibonacci.prg plasma.prg \
9095
vic20-hello.prg \
9196
cx16-hello.prg cx16-k-console-test.prg \
9297
geos-hello.cvt \
9398
lynx-hello.bll \
9499
colorbar.a26 colorbar-3e.a26 \
95-
atari8dos-hello.xex atari8-cart-hello.rom \
100+
atari8dos-hello.xex atari8-cart-hello.rom atari8-megacart-hello.rom atari8-xegs-hello.rom atari5200-cart-hello.rom \
96101
pce-color-cycle.pce pce-color-cycle-banked.pce \
97102
mega65-hello.prg viciv.prg \
98103
graphics.neo \
@@ -146,11 +151,15 @@ jobs:
146151
}
147152
# NES
148153
for f in hello1.nes hello2.nes hello3.nes zig-logo.nes fade.nes sprites.nes random.nes \
149-
pads.nes color-cycle.nes fullbg.nes mappers.nes cnrom-hello.nes unrom-hello.nes unrom-512-hello.nes mmc1-hello.nes mmc3-hello.nes; do
154+
pads.nes color-cycle.nes fullbg.nes mappers.nes bat-ball.nes megablast.nes gg-demo.nes \
155+
cnrom-hello.nes cnrom-sprites.nes \
156+
unrom-hello.nes unrom-512-hello.nes unrom-color-cycle.nes \
157+
mmc1-hello.nes mmc1-sprites.nes \
158+
mmc3-hello.nes mmc3-pads.nes; do
150159
smoke "$f"
151160
done
152-
# Note: gtrom-hello.nes (mapper 111) is NOT tested here — apt mednafen lacks GTROM support.
153-
# GTROM is covered by the emutest job (Mesen-X libretro core).
161+
# Note: gtrom-hello.nes / gtrom-color-cycle.nes (mapper 111) are NOT tested here —
162+
# apt mednafen lacks GTROM support. Both are covered by the emutest job (Mesen-X libretro core).
154163
# PC Engine
155164
for f in pce-color-cycle.pce pce-color-cycle-banked.pce; do
156165
smoke "$f"
@@ -245,8 +254,12 @@ jobs:
245254
echo "OK: $f (rc=$rc)"
246255
}
247256
for f in hello1.nes hello2.nes hello3.nes zig-logo.nes fade.nes sprites.nes random.nes \
248-
pads.nes color-cycle.nes fullbg.nes mappers.nes cnrom-hello.nes unrom-hello.nes unrom-512-hello.nes mmc1-hello.nes mmc3-hello.nes \
249-
gtrom-hello.nes; do
257+
pads.nes color-cycle.nes fullbg.nes mappers.nes bat-ball.nes megablast.nes gg-demo.nes \
258+
cnrom-hello.nes cnrom-sprites.nes \
259+
unrom-hello.nes unrom-512-hello.nes unrom-color-cycle.nes \
260+
mmc1-hello.nes mmc1-sprites.nes \
261+
mmc3-hello.nes mmc3-pads.nes \
262+
gtrom-hello.nes gtrom-color-cycle.nes; do
250263
run_emutest "$f" mesen_libretro.so
251264
done
252265
for f in colorbar.a26 colorbar-3e.a26; do

tools/bininfo.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ fn dwarfLangStr(lang: u32) []const u8 {
151151

152152
fn dumpDebugInfo(
153153
out: anytype,
154+
gpa: std.mem.Allocator,
154155
debug_info: []const u8,
155156
debug_abbrev: []const u8,
156157
debug_str: []const u8,
157158
debug_ranges: []const u8,
158159
) void {
159-
const gpa = std.heap.page_allocator;
160160
const Dw = std.debug.Dwarf;
161161
const Id = Dw.Section.Id;
162162

@@ -276,7 +276,7 @@ fn dumpDebugLine(out: anytype, debug_line: []const u8) void {
276276

277277
// ── ELF inspector ─────────────────────────────────────────────────────────────
278278

279-
fn checkElf(out: anytype, path: []const u8, data: []const u8, opts: Opts) bool {
279+
fn checkElf(out: anytype, gpa: std.mem.Allocator, path: []const u8, data: []const u8, opts: Opts) bool {
280280
if (data.len < 52) {
281281
out.print("{s}: [ELF] ERROR: header truncated ({d} B)\n", .{ path, data.len }) catch {};
282282
return false;
@@ -583,7 +583,7 @@ fn checkElf(out: anytype, path: []const u8, data: []const u8, opts: Opts) bool {
583583
data[rng_off..][0..rng_sz]
584584
else
585585
&[_]u8{};
586-
dumpDebugInfo(out, data[di_off..][0..di_sz], data[ab_off..][0..ab_sz], str_data, rng_data);
586+
dumpDebugInfo(out, gpa, data[di_off..][0..di_sz], data[ab_off..][0..ab_sz], str_data, rng_data);
587587
}
588588

589589
// Parse .debug_line file tables.
@@ -1224,10 +1224,10 @@ fn disasm6502(out: anytype, data: []const u8, load_addr: u16) void {
12241224

12251225
// ── dispatch ──────────────────────────────────────────────────────────────────
12261226

1227-
fn checkFile(out: anytype, path: []const u8, data: []const u8, opts: Opts) bool {
1227+
fn checkFile(out: anytype, gpa: std.mem.Allocator, path: []const u8, data: []const u8, opts: Opts) bool {
12281228
// Detect by magic first.
12291229
if (data.len >= 4 and std.mem.eql(u8, data[0..4], "\x7FELF"))
1230-
return checkElf(out, path, data, opts);
1230+
return checkElf(out, gpa, path, data, opts);
12311231
if (data.len >= 4 and std.mem.eql(u8, data[0..4], "NES\x1a"))
12321232
return checkNes(out, path, data);
12331233
if (data.len >= 4 and std.mem.eql(u8, data[0..4], "FDS\x1a"))
@@ -1395,7 +1395,7 @@ pub fn main(init: std.process.Init) !void {
13951395
};
13961396
defer alloc.free(data);
13971397

1398-
if (!checkFile(stdout, arg, data, opts)) all_ok = false;
1398+
if (!checkFile(stdout, alloc, arg, data, opts)) all_ok = false;
13991399

14001400
if (opts.xxd) {
14011401
stdout.print(" -- xxd " ++ "-" ** 47 ++ "\n", .{}) catch {};

tools/elf2mlb.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub fn main(init: std.process.Init) !void {
113113
const sym_count = symtab_size / @sizeOf(elf.Elf32_Sym);
114114

115115
// Build MLb content in an in-memory buffer.
116-
var mlb_buf: std.ArrayList(u8) = .empty;
116+
var mlb_buf: std.ArrayListUnmanaged(u8) = .empty;
117117
defer mlb_buf.deinit(alloc);
118118

119119
var count: usize = 0;

0 commit comments

Comments
 (0)