authorgravatar for heidezomp@protonmail.comheidezomp <heidezomp@protonmail.com> 2020-08-13 17:14:15+02:00
committergravatar for heidezomp@protonmail.comheidezomp <heidezomp@protonmail.com> 2020-08-13 17:14:15+02:00
log16d118a8d9ce48143ef406ff7b3a1f9d62021d98
treeed1ee766942fbdc7ee0d9cd154dfad24f7a483a8
parent2439f67061b007197bdd1b0037ffe4ba7b520024

update std and src-self-hosted for std.log breaking change


5 files changed, 41 insertions(+), 40 deletions(-)

lib/std/heap/general_purpose_allocator.zig+5-4
......@@ -93,6 +93,7 @@
9393//! in a `std.HashMap` using the backing allocator.
9494
9595const std = @import("std");
96const log = std.log.scoped(.std);
9697const math = std.math;
9798const assert = std.debug.assert;
9899const mem = std.mem;
......@@ -288,7 +289,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
288289 if (is_used) {
289290 const slot_index = @intCast(SlotIndex, used_bits_byte * 8 + bit_index);
290291 const stack_trace = bucketStackTrace(bucket, size_class, slot_index, .alloc);
291 std.log.err(.std, "Memory leak detected: {}", .{stack_trace});
292 log.err("Memory leak detected: {}", .{stack_trace});
292293 leaks = true;
293294 }
294295 if (bit_index == math.maxInt(u3))
......@@ -315,7 +316,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
315316 }
316317 }
317318 for (self.large_allocations.items()) |*large_alloc| {
318 std.log.err(.std, "Memory leak detected: {}", .{large_alloc.value.getStackTrace()});
319 log.err("Memory leak detected: {}", .{large_alloc.value.getStackTrace()});
319320 leaks = true;
320321 }
321322 return leaks;
......@@ -450,7 +451,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
450451 .index = 0,
451452 };
452453 std.debug.captureStackTrace(ret_addr, &free_stack_trace);
453 std.log.err(.std, "Allocation size {} bytes does not match free size {}. Allocation: {} Free: {}", .{
454 log.err("Allocation size {} bytes does not match free size {}. Allocation: {} Free: {}", .{
454455 entry.value.bytes.len,
455456 old_mem.len,
456457 entry.value.getStackTrace(),
......@@ -533,7 +534,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
533534 .index = 0,
534535 };
535536 std.debug.captureStackTrace(ret_addr, &second_free_stack_trace);
536 std.log.err(.std, "Double free detected. Allocation: {} First free: {} Second free: {}", .{
537 log.err("Double free detected. Allocation: {} First free: {} Second free: {}", .{
537538 alloc_stack_trace,
538539 free_stack_trace,
539540 second_free_stack_trace,
src-self-hosted/Module.zig+9-9
......@@ -6,7 +6,7 @@ const Value = @import("value.zig").Value;
66const Type = @import("type.zig").Type;
77const TypedValue = @import("TypedValue.zig");
88const assert = std.debug.assert;
9const log = std.log;
9const log = std.log.scoped(.module);
1010const BigIntConst = std.math.big.int.Const;
1111const BigIntMutable = std.math.big.int.Mutable;
1212const Target = std.Target;
......@@ -1055,7 +1055,7 @@ pub fn performAllTheWork(self: *Module) error{OutOfMemory}!void {
10551055 // lifetime annotations in the ZIR.
10561056 var decl_arena = decl.typed_value.most_recent.arena.?.promote(self.gpa);
10571057 defer decl.typed_value.most_recent.arena.?.* = decl_arena.state;
1058 std.log.debug(.module, "analyze liveness of {}\n", .{decl.name});
1058 log.debug("analyze liveness of {}\n", .{decl.name});
10591059 try liveness.analyze(self.gpa, &decl_arena.allocator, payload.func.analysis.success);
10601060 }
10611061
......@@ -1117,7 +1117,7 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void {
11171117 .complete => return,
11181118
11191119 .outdated => blk: {
1120 log.debug(.module, "re-analyzing {}\n", .{decl.name});
1120 log.debug("re-analyzing {}\n", .{decl.name});
11211121
11221122 // The exports this Decl performs will be re-discovered, so we remove them here
11231123 // prior to re-analysis.
......@@ -1563,7 +1563,7 @@ fn analyzeRootSrcFile(self: *Module, root_scope: *Scope.File) !void {
15631563 // Handle explicitly deleted decls from the source code. Not to be confused
15641564 // with when we delete decls because they are no longer referenced.
15651565 for (deleted_decls.items()) |entry| {
1566 log.debug(.module, "noticed '{}' deleted from source\n", .{entry.key.name});
1566 log.debug("noticed '{}' deleted from source\n", .{entry.key.name});
15671567 try self.deleteDecl(entry.key);
15681568 }
15691569}
......@@ -1616,7 +1616,7 @@ fn analyzeRootZIRModule(self: *Module, root_scope: *Scope.ZIRModule) !void {
16161616 // Handle explicitly deleted decls from the source code. Not to be confused
16171617 // with when we delete decls because they are no longer referenced.
16181618 for (deleted_decls.items()) |entry| {
1619 log.debug(.module, "noticed '{}' deleted from source\n", .{entry.key.name});
1619 log.debug("noticed '{}' deleted from source\n", .{entry.key.name});
16201620 try self.deleteDecl(entry.key);
16211621 }
16221622}
......@@ -1628,7 +1628,7 @@ fn deleteDecl(self: *Module, decl: *Decl) !void {
16281628 // not be present in the set, and this does nothing.
16291629 decl.scope.removeDecl(decl);
16301630
1631 log.debug(.module, "deleting decl '{}'\n", .{decl.name});
1631 log.debug("deleting decl '{}'\n", .{decl.name});
16321632 const name_hash = decl.fullyQualifiedNameHash();
16331633 self.decl_table.removeAssertDiscard(name_hash);
16341634 // Remove itself from its dependencies, because we are about to destroy the decl pointer.
......@@ -1715,17 +1715,17 @@ fn analyzeFnBody(self: *Module, decl: *Decl, func: *Fn) !void {
17151715 const fn_zir = func.analysis.queued;
17161716 defer fn_zir.arena.promote(self.gpa).deinit();
17171717 func.analysis = .{ .in_progress = {} };
1718 log.debug(.module, "set {} to in_progress\n", .{decl.name});
1718 log.debug("set {} to in_progress\n", .{decl.name});
17191719
17201720 try zir_sema.analyzeBody(self, &inner_block.base, fn_zir.body);
17211721
17221722 const instructions = try arena.allocator.dupe(*Inst, inner_block.instructions.items);
17231723 func.analysis = .{ .success = .{ .instructions = instructions } };
1724 log.debug(.module, "set {} to success\n", .{decl.name});
1724 log.debug("set {} to success\n", .{decl.name});
17251725}
17261726
17271727fn markOutdatedDecl(self: *Module, decl: *Decl) !void {
1728 log.debug(.module, "mark {} outdated\n", .{decl.name});
1728 log.debug("mark {} outdated\n", .{decl.name});
17291729 try self.work_queue.writeItem(.{ .analyze_decl = decl });
17301730 if (self.failed_decls.remove(decl)) |entry| {
17311731 entry.value.destroy(self.gpa);
src-self-hosted/link.zig+25-25
......@@ -8,7 +8,7 @@ const fs = std.fs;
88const elf = std.elf;
99const codegen = @import("codegen.zig");
1010const c_codegen = @import("codegen/c.zig");
11const log = std.log;
11const log = std.log.scoped(.link);
1212const DW = std.dwarf;
1313const trace = @import("tracy.zig").trace;
1414const leb128 = std.debug.leb;
......@@ -726,7 +726,7 @@ pub const File = struct {
726726 const file_size = self.base.options.program_code_size_hint;
727727 const p_align = 0x1000;
728728 const off = self.findFreeSpace(file_size, p_align);
729 log.debug(.link, "found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
729 log.debug("found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
730730 try self.program_headers.append(self.base.allocator, .{
731731 .p_type = elf.PT_LOAD,
732732 .p_offset = off,
......@@ -747,7 +747,7 @@ pub const File = struct {
747747 // page align.
748748 const p_align = if (self.base.options.target.os.tag == .linux) 0x1000 else @as(u16, ptr_size);
749749 const off = self.findFreeSpace(file_size, p_align);
750 log.debug(.link, "found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
750 log.debug("found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
751751 // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at.
752752 // we'll need to re-use that function anyway, in case the GOT grows and overlaps something
753753 // else in virtual memory.
......@@ -769,7 +769,7 @@ pub const File = struct {
769769 assert(self.shstrtab.items.len == 0);
770770 try self.shstrtab.append(self.base.allocator, 0); // need a 0 at position 0
771771 const off = self.findFreeSpace(self.shstrtab.items.len, 1);
772 log.debug(.link, "found shstrtab free space 0x{x} to 0x{x}\n", .{ off, off + self.shstrtab.items.len });
772 log.debug("found shstrtab free space 0x{x} to 0x{x}\n", .{ off, off + self.shstrtab.items.len });
773773 try self.sections.append(self.base.allocator, .{
774774 .sh_name = try self.makeString(".shstrtab"),
775775 .sh_type = elf.SHT_STRTAB,
......@@ -827,7 +827,7 @@ pub const File = struct {
827827 const each_size: u64 = if (small_ptr) @sizeOf(elf.Elf32_Sym) else @sizeOf(elf.Elf64_Sym);
828828 const file_size = self.base.options.symbol_count_hint * each_size;
829829 const off = self.findFreeSpace(file_size, min_align);
830 log.debug(.link, "found symtab free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
830 log.debug("found symtab free space 0x{x} to 0x{x}\n", .{ off, off + file_size });
831831
832832 try self.sections.append(self.base.allocator, .{
833833 .sh_name = try self.makeString(".symtab"),
......@@ -869,7 +869,7 @@ pub const File = struct {
869869 const file_size_hint = 200;
870870 const p_align = 1;
871871 const off = self.findFreeSpace(file_size_hint, p_align);
872 log.debug(.link, "found .debug_info free space 0x{x} to 0x{x}\n", .{
872 log.debug("found .debug_info free space 0x{x} to 0x{x}\n", .{
873873 off,
874874 off + file_size_hint,
875875 });
......@@ -894,7 +894,7 @@ pub const File = struct {
894894 const file_size_hint = 128;
895895 const p_align = 1;
896896 const off = self.findFreeSpace(file_size_hint, p_align);
897 log.debug(.link, "found .debug_abbrev free space 0x{x} to 0x{x}\n", .{
897 log.debug("found .debug_abbrev free space 0x{x} to 0x{x}\n", .{
898898 off,
899899 off + file_size_hint,
900900 });
......@@ -919,7 +919,7 @@ pub const File = struct {
919919 const file_size_hint = 160;
920920 const p_align = 16;
921921 const off = self.findFreeSpace(file_size_hint, p_align);
922 log.debug(.link, "found .debug_aranges free space 0x{x} to 0x{x}\n", .{
922 log.debug("found .debug_aranges free space 0x{x} to 0x{x}\n", .{
923923 off,
924924 off + file_size_hint,
925925 });
......@@ -944,7 +944,7 @@ pub const File = struct {
944944 const file_size_hint = 250;
945945 const p_align = 1;
946946 const off = self.findFreeSpace(file_size_hint, p_align);
947 log.debug(.link, "found .debug_line free space 0x{x} to 0x{x}\n", .{
947 log.debug("found .debug_line free space 0x{x} to 0x{x}\n", .{
948948 off,
949949 off + file_size_hint,
950950 });
......@@ -1071,7 +1071,7 @@ pub const File = struct {
10711071 debug_abbrev_sect.sh_offset = self.findFreeSpace(needed_size, 1);
10721072 }
10731073 debug_abbrev_sect.sh_size = needed_size;
1074 log.debug(.link, ".debug_abbrev start=0x{x} end=0x{x}\n", .{
1074 log.debug(".debug_abbrev start=0x{x} end=0x{x}\n", .{
10751075 debug_abbrev_sect.sh_offset,
10761076 debug_abbrev_sect.sh_offset + needed_size,
10771077 });
......@@ -1218,7 +1218,7 @@ pub const File = struct {
12181218 debug_aranges_sect.sh_offset = self.findFreeSpace(needed_size, 16);
12191219 }
12201220 debug_aranges_sect.sh_size = needed_size;
1221 log.debug(.link, ".debug_aranges start=0x{x} end=0x{x}\n", .{
1221 log.debug(".debug_aranges start=0x{x} end=0x{x}\n", .{
12221222 debug_aranges_sect.sh_offset,
12231223 debug_aranges_sect.sh_offset + needed_size,
12241224 });
......@@ -1386,7 +1386,7 @@ pub const File = struct {
13861386 shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);
13871387 }
13881388 shstrtab_sect.sh_size = needed_size;
1389 log.debug(.link, "writing shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size });
1389 log.debug("writing shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size });
13901390
13911391 try self.base.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset);
13921392 if (!self.shdr_table_dirty) {
......@@ -1407,7 +1407,7 @@ pub const File = struct {
14071407 debug_strtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);
14081408 }
14091409 debug_strtab_sect.sh_size = needed_size;
1410 log.debug(.link, "debug_strtab start=0x{x} end=0x{x}\n", .{ debug_strtab_sect.sh_offset, debug_strtab_sect.sh_offset + needed_size });
1410 log.debug("debug_strtab start=0x{x} end=0x{x}\n", .{ debug_strtab_sect.sh_offset, debug_strtab_sect.sh_offset + needed_size });
14111411
14121412 try self.base.file.?.pwriteAll(self.debug_strtab.items, debug_strtab_sect.sh_offset);
14131413 if (!self.shdr_table_dirty) {
......@@ -1441,7 +1441,7 @@ pub const File = struct {
14411441
14421442 for (buf) |*shdr, i| {
14431443 shdr.* = sectHeaderTo32(self.sections.items[i]);
1444 std.log.debug(.link, "writing section {}\n", .{shdr.*});
1444 log.debug("writing section {}\n", .{shdr.*});
14451445 if (foreign_endian) {
14461446 bswapAllFields(elf.Elf32_Shdr, shdr);
14471447 }
......@@ -1454,7 +1454,7 @@ pub const File = struct {
14541454
14551455 for (buf) |*shdr, i| {
14561456 shdr.* = self.sections.items[i];
1457 log.debug(.link, "writing section {}\n", .{shdr.*});
1457 log.debug("writing section {}\n", .{shdr.*});
14581458 if (foreign_endian) {
14591459 bswapAllFields(elf.Elf64_Shdr, shdr);
14601460 }
......@@ -1465,10 +1465,10 @@ pub const File = struct {
14651465 self.shdr_table_dirty = false;
14661466 }
14671467 if (self.entry_addr == null and self.base.options.output_mode == .Exe) {
1468 log.debug(.link, "flushing. no_entry_point_found = true\n", .{});
1468 log.debug("flushing. no_entry_point_found = true\n", .{});
14691469 self.error_flags.no_entry_point_found = true;
14701470 } else {
1471 log.debug(.link, "flushing. no_entry_point_found = false\n", .{});
1471 log.debug("flushing. no_entry_point_found = false\n", .{});
14721472 self.error_flags.no_entry_point_found = false;
14731473 try self.writeElfHeader();
14741474 }
......@@ -1797,10 +1797,10 @@ pub const File = struct {
17971797 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);
17981798
17991799 if (self.local_symbol_free_list.popOrNull()) |i| {
1800 log.debug(.link, "reusing symbol index {} for {}\n", .{ i, decl.name });
1800 log.debug("reusing symbol index {} for {}\n", .{ i, decl.name });
18011801 decl.link.elf.local_sym_index = i;
18021802 } else {
1803 log.debug(.link, "allocating symbol index {} for {}\n", .{ self.local_symbols.items.len, decl.name });
1803 log.debug("allocating symbol index {} for {}\n", .{ self.local_symbols.items.len, decl.name });
18041804 decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len);
18051805 _ = self.local_symbols.addOneAssumeCapacity();
18061806 }
......@@ -1993,11 +1993,11 @@ pub const File = struct {
19931993 !mem.isAlignedGeneric(u64, local_sym.st_value, required_alignment);
19941994 if (need_realloc) {
19951995 const vaddr = try self.growTextBlock(&decl.link.elf, code.len, required_alignment);
1996 log.debug(.link, "growing {} from 0x{x} to 0x{x}\n", .{ decl.name, local_sym.st_value, vaddr });
1996 log.debug("growing {} from 0x{x} to 0x{x}\n", .{ decl.name, local_sym.st_value, vaddr });
19971997 if (vaddr != local_sym.st_value) {
19981998 local_sym.st_value = vaddr;
19991999
2000 log.debug(.link, " (writing new offset table entry)\n", .{});
2000 log.debug(" (writing new offset table entry)\n", .{});
20012001 self.offset_table.items[decl.link.elf.offset_table_index] = vaddr;
20022002 try self.writeOffsetTableEntry(decl.link.elf.offset_table_index);
20032003 }
......@@ -2015,7 +2015,7 @@ pub const File = struct {
20152015 const decl_name = mem.spanZ(decl.name);
20162016 const name_str_index = try self.makeString(decl_name);
20172017 const vaddr = try self.allocateTextBlock(&decl.link.elf, code.len, required_alignment);
2018 log.debug(.link, "allocated text block for {} at 0x{x}\n", .{ decl_name, vaddr });
2018 log.debug("allocated text block for {} at 0x{x}\n", .{ decl_name, vaddr });
20192019 errdefer self.freeTextBlock(&decl.link.elf);
20202020
20212021 local_sym.* = .{
......@@ -2125,7 +2125,7 @@ pub const File = struct {
21252125 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {
21262126 const new_offset = self.findFreeSpace(needed_size, 1);
21272127 const existing_size = last_src_fn.off;
2128 log.debug(.link, "moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{
2128 log.debug("moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{
21292129 existing_size,
21302130 debug_line_sect.sh_offset,
21312131 new_offset,
......@@ -2204,7 +2204,7 @@ pub const File = struct {
22042204 try dbg_info_buffer.writer().print("{}\x00", .{ty});
22052205 },
22062206 else => {
2207 log.err(.compiler, "TODO implement .debug_info for type '{}'", .{ty});
2207 std.log.scoped(.compiler).err("TODO implement .debug_info for type '{}'", .{ty});
22082208 try dbg_info_buffer.append(abbrev_pad1);
22092209 },
22102210 }
......@@ -2276,7 +2276,7 @@ pub const File = struct {
22762276 if (needed_size > self.allocatedSize(debug_info_sect.sh_offset)) {
22772277 const new_offset = self.findFreeSpace(needed_size, 1);
22782278 const existing_size = last_decl.dbg_info_off;
2279 log.debug(.link, "moving .debug_info section: {} bytes from 0x{x} to 0x{x}\n", .{
2279 log.debug("moving .debug_info section: {} bytes from 0x{x} to 0x{x}\n", .{
22802280 existing_size,
22812281 debug_info_sect.sh_offset,
22822282 new_offset,
src-self-hosted/liveness.zig+1-1
......@@ -114,5 +114,5 @@ fn analyzeInst(arena: *std.mem.Allocator, table: *std.AutoHashMap(*ir.Inst, void
114114 @panic("Handle liveness analysis for instructions with many parameters");
115115 }
116116
117 std.log.debug(.liveness, "analyze {}: 0b{b}\n", .{ base.tag, base.deaths });
117 std.log.scoped(.liveness).debug("analyze {}: 0b{b}\n", .{ base.tag, base.deaths });
118118}
src-self-hosted/main.zig+1-1
......@@ -560,7 +560,7 @@ fn updateModule(gpa: *Allocator, module: *Module, zir_out_path: ?[]const u8) !vo
560560 });
561561 }
562562 } else {
563 std.log.info(.compiler, "Update completed in {} ms\n", .{update_nanos / std.time.ns_per_ms});
563 std.log.scoped(.compiler).info("Update completed in {} ms\n", .{update_nanos / std.time.ns_per_ms});
564564 }
565565
566566 if (zir_out_path) |zop| {