Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ jobs:
- name: Build Printer
run: zig build
working-directory: tools/printer
- name: Test Printer
run: zig build test
working-directory: tools/printer

build-sorcerer:
name: Build Sorcerer
Expand Down
97 changes: 0 additions & 97 deletions tools/printer/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,101 +41,4 @@ pub fn build(b: *std.Build) void {
}),
});
b.installArtifact(example_exe);

const test_common_mod = b.createModule(.{
.root_source_file = b.path("tests/common.zig"),
.imports = &.{
.{ .name = "printer", .module = printer_mod },
},
});

const generate_test_data_exe = b.addExecutable(.{
.name = "generate_results",
.root_module = b.createModule(.{
.root_source_file = b.path("tests/generate_test_data.zig"),
.imports = &.{
.{ .name = "common", .module = test_common_mod },
.{ .name = "printer", .module = printer_mod },
},
.target = target,
.optimize = optimize,
}),
});

const test_runner_exe = b.addExecutable(.{
.name = "test",
.root_module = b.createModule(.{
.root_source_file = b.path("tests/test.zig"),
.imports = &.{
.{ .name = "common", .module = test_common_mod },
.{ .name = "printer", .module = printer_mod },
},
.target = target,
.optimize = optimize,
}),
});

const test_dwarf32_exe = b.addExecutable(.{
.name = "test_program.dwarf32",
.root_module = b.createModule(.{
.root_source_file = b.path("tests/test_program.zig"),
.optimize = .Debug,
.target = b.resolveTargetQuery(.{
.os_tag = .linux,
.cpu_arch = .x86_64,
.abi = .gnu,
.ofmt = .elf,
}),
.dwarf_format = .@"32",
.strip = false,
}),
});

const test_dwarf64_exe = b.addExecutable(.{
.name = "test_program.dwarf64",
.root_module = b.createModule(.{
.root_source_file = b.path("tests/test_program.zig"),
.optimize = .Debug,
.target = b.resolveTargetQuery(.{
.os_tag = .linux,
.cpu_arch = .x86_64,
.abi = .gnu,
.ofmt = .elf,
}),
.dwarf_format = .@"64",
}),
});

const generate_test_data_step = b.step("generate-test-data", "regenerate test data");
const test_step = b.step("test", "test printer");

inline for (&.{ test_dwarf32_exe, test_dwarf64_exe }) |exe| {
register_test(
b,
generate_test_data_step,
generate_test_data_exe,
test_step,
test_runner_exe,
exe,
);
}
}

pub fn register_test(
b: *std.Build,
generate_test_data_step: *std.Build.Step,
generate_test_data_exe: *std.Build.Step.Compile,
test_step: *std.Build.Step,
test_runner_exe: *std.Build.Step.Compile,
test_exe: *std.Build.Step.Compile,
) void {
const generate_test_data_run = b.addRunArtifact(generate_test_data_exe);
generate_test_data_run.addFileArg(test_exe.getEmittedBin());
generate_test_data_run.addFileArg(b.path(b.fmt("tests/{s}.zon", .{test_exe.name})));
generate_test_data_step.dependOn(&generate_test_data_run.step);

const test_runner_run = b.addRunArtifact(test_runner_exe);
test_runner_run.addFileArg(test_exe.getEmittedBin());
test_runner_run.addFileArg(b.path(b.fmt("tests/{s}.zon", .{test_exe.name})));
test_step.dependOn(&test_runner_run.step);
}
3 changes: 0 additions & 3 deletions tools/printer/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@
.url = "git+https://github.com/ZigEmbeddedGroup/serial#25b58d0ea62f7bfc33e6c147c1c02193a50c65fb",
.hash = "serial-0.0.1-PoeRzD66AACCQUHzsIssi6bOcEtnQFPebT6WLvno0I_p",
},
// used to compile the test program
// .microzig = .{ .path = "../..", .lazy = true },
},
.paths = .{
"build.zig",
"build.zig.zon",
"README.md",
"src",
"examples",
"tests",
},
}
30 changes: 14 additions & 16 deletions tools/printer/examples/rp2xxx_runner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const std = @import("std");
const printer = @import("printer");
const serial = @import("serial");

var elf_file_reader_buf: [1024]u8 = undefined;
var in_stream_buf: [1024]u8 = undefined;
var out_stream_buf: [1024]u8 = undefined;

Expand All @@ -17,15 +16,12 @@ pub fn main(init: std.process.Init) !void {
const serial_device_path = args[2];
const baud_rate = try std.fmt.parseInt(u32, args[3], 10);

const elf_file = try std.Io.Dir.cwd().openFile(io, elf_path, .{});
defer elf_file.close(io);
var elf_file_reader = elf_file.reader(io, &elf_file_reader_buf);

var elf: printer.Elf = try .init(gpa, &elf_file_reader);
defer elf.deinit(gpa);

var debug_info: printer.DebugInfo = try .init(gpa, elf);
var coverage: std.debug.Coverage = .init;
// arch is ignored for elf files, .thumb is just a placeholder
var debug_info: std.debug.Info = try .load(gpa, io, .initCwd(elf_path), &coverage, .elf, .thumb);
defer debug_info.deinit(gpa);
// NOTE: this is safe because we specify the elf object format when loading the debug_info
const elf_file = &debug_info.impl.elf;

const serial_device = try std.Io.Dir.cwd().openFile(io, serial_device_path, .{});
defer serial_device.close(io);
Expand Down Expand Up @@ -54,11 +50,13 @@ pub fn main(init: std.process.Init) !void {
.mode = try std.Io.Terminal.Mode.detect(io, stdout, no_color, clicolor_force),
};

try printer.annotate(
io,
&reader.interface,
&terminal,
elf,
&debug_info,
);
while (true) {
try printer.annotate(
gpa,
io,
&reader.interface,
&terminal,
elf_file,
);
}
}
Loading
Loading