| author | |
| committer | |
| log | 237d9a105d5eec82aefc63da8e844c47d8990eea |
| tree | 24ebeba0e09b069f52871a8869fb8417e2544719 |
| parent | e97157f71c79257ab575598d142f3caa785a2a76 |
So that it's not needed to manually comment and uncomment the debug
code.2 files changed, 11 insertions(+), 5 deletions(-)
build.zig+2| ... | ... | @@ -83,6 +83,7 @@ pub fn build(b: *Builder) !void { |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | const log_scopes = b.option([]const []const u8, "log", "Which log scopes to enable") orelse &[0][]const u8{}; |
| 86 | const zir_dumps = b.option([]const []const u8, "dump-zir", "Which functions to dump ZIR for before codegen") orelse &[0][]const u8{}; | |
| 86 | 87 | |
| 87 | 88 | const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git."); |
| 88 | 89 | const version = if (opt_version_string) |version| version else v: { |
| ... | ... | @@ -103,6 +104,7 @@ pub fn build(b: *Builder) !void { |
| 103 | 104 | exe.addBuildOption([]const u8, "version", version); |
| 104 | 105 | |
| 105 | 106 | exe.addBuildOption([]const []const u8, "log_scopes", log_scopes); |
| 107 | exe.addBuildOption([]const []const u8, "zir_dumps", zir_dumps); | |
| 106 | 108 | exe.addBuildOption(bool, "enable_tracy", tracy != null); |
| 107 | 109 | if (tracy) |tracy_path| { |
| 108 | 110 | const client_cpp = fs.path.join( |
src-self-hosted/link/Elf.zig+9-5| ... | ... | @@ -17,6 +17,7 @@ const Type = @import("../type.zig").Type; |
| 17 | 17 | const link = @import("../link.zig"); |
| 18 | 18 | const File = link.File; |
| 19 | 19 | const Elf = @This(); |
| 20 | const build_options = @import("build_options"); | |
| 20 | 21 | |
| 21 | 22 | const default_entry_addr = 0x8000000; |
| 22 | 23 | |
| ... | ... | @@ -1640,11 +1641,14 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { |
| 1640 | 1641 | else => false, |
| 1641 | 1642 | }; |
| 1642 | 1643 | if (is_fn) { |
| 1643 | { | |
| 1644 | //if (mem.eql(u8, mem.spanZ(decl.name), "add")) { | |
| 1645 | //} | |
| 1646 | std.debug.print("\n{}\n", .{decl.name}); | |
| 1647 | typed_value.val.cast(Value.Payload.Function).?.func.dump(module.*); | |
| 1644 | const zir_dumps = if (std.builtin.is_test) &[0][]const u8{} else build_options.zir_dumps; | |
| 1645 | if (zir_dumps.len != 0) { | |
| 1646 | for (zir_dumps) |fn_name| { | |
| 1647 | if (mem.eql(u8, mem.spanZ(decl.name), fn_name)) { | |
| 1648 | std.debug.print("\n{}\n", .{decl.name}); | |
| 1649 | typed_value.val.cast(Value.Payload.Function).?.func.dump(module.*); | |
| 1650 | } | |
| 1651 | } | |
| 1648 | 1652 | } |
| 1649 | 1653 | |
| 1650 | 1654 | // For functions we need to add a prologue to the debug line program. |