mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
Dwarf: implement and test decls
This commit is contained in:
parent
778519bb0d
commit
f34b198251
@ -64,7 +64,7 @@ stage3-debug/bin/zig build \
|
|||||||
|
|
||||||
stage3-debug/bin/zig build test docs \
|
stage3-debug/bin/zig build test docs \
|
||||||
--maxrss 21000000000 \
|
--maxrss 21000000000 \
|
||||||
-Dlldb=$HOME/deps/lldb-zig/Debug-befcd57a8/bin/lldb \
|
-Dlldb=$HOME/deps/lldb-zig/Debug-4a44163df/bin/lldb \
|
||||||
-fqemu \
|
-fqemu \
|
||||||
-fwasmtime \
|
-fwasmtime \
|
||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
|
|||||||
@ -64,7 +64,7 @@ stage3-release/bin/zig build \
|
|||||||
|
|
||||||
stage3-release/bin/zig build test docs \
|
stage3-release/bin/zig build test docs \
|
||||||
--maxrss 21000000000 \
|
--maxrss 21000000000 \
|
||||||
-Dlldb=$HOME/deps/lldb-zig/Release-befcd57a8/bin/lldb \
|
-Dlldb=$HOME/deps/lldb-zig/Release-4a44163df/bin/lldb \
|
||||||
-fqemu \
|
-fqemu \
|
||||||
-fwasmtime \
|
-fwasmtime \
|
||||||
-Dstatic-llvm \
|
-Dstatic-llvm \
|
||||||
|
|||||||
@ -2509,6 +2509,19 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
|
||||||
|
const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
|
||||||
|
break :parent .{
|
||||||
|
parent_namespace_ptr.owner_type,
|
||||||
|
if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
||||||
|
DW.ACCESS.public
|
||||||
|
else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
||||||
|
DW.ACCESS.private
|
||||||
|
else
|
||||||
|
unreachable,
|
||||||
|
};
|
||||||
|
} else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
|
||||||
|
|
||||||
const tree = try file.getTree(dwarf.gpa);
|
const tree = try file.getTree(dwarf.gpa);
|
||||||
const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]);
|
const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]);
|
||||||
assert(loc.line == zcu.navSrcLine(nav_index));
|
assert(loc.line == zcu.navSrcLine(nav_index));
|
||||||
@ -2534,87 +2547,27 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
|
|
||||||
const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index);
|
const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index);
|
||||||
errdefer _ = dwarf.navs.pop();
|
errdefer _ = dwarf.navs.pop();
|
||||||
switch (ip.indexToKey(nav_val.toIntern())) {
|
|
||||||
.func => |func| {
|
|
||||||
if (nav_gop.found_existing) {
|
|
||||||
const unit_ptr = dwarf.debug_info.section.getUnit(wip_nav.unit);
|
|
||||||
const entry_ptr = unit_ptr.getEntry(nav_gop.value_ptr.*);
|
|
||||||
if (entry_ptr.len >= AbbrevCode.decl_bytes) {
|
|
||||||
var abbrev_code_buf: [AbbrevCode.decl_bytes]u8 = undefined;
|
|
||||||
if (try dwarf.getFile().?.preadAll(
|
|
||||||
&abbrev_code_buf,
|
|
||||||
dwarf.debug_info.section.off(dwarf) + unit_ptr.off + unit_ptr.header_len + entry_ptr.off,
|
|
||||||
) != abbrev_code_buf.len) return error.InputOutput;
|
|
||||||
var abbrev_code_fbs = std.io.fixedBufferStream(&abbrev_code_buf);
|
|
||||||
const abbrev_code: AbbrevCode = @enumFromInt(
|
|
||||||
std.leb.readUleb128(@typeInfo(AbbrevCode).@"enum".tag_type, abbrev_code_fbs.reader()) catch unreachable,
|
|
||||||
);
|
|
||||||
switch (abbrev_code) {
|
|
||||||
else => unreachable,
|
|
||||||
.decl_func, .decl_empty_func => return,
|
|
||||||
.decl_func_generic, .decl_empty_func_generic => {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry_ptr.clear();
|
|
||||||
} else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
|
||||||
wip_nav.entry = nav_gop.value_ptr.*;
|
|
||||||
|
|
||||||
const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
|
const tag: enum { done, decl_alias } = switch (ip.indexToKey(nav_val.toIntern())) {
|
||||||
const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
|
.int_type,
|
||||||
break :parent .{
|
.ptr_type,
|
||||||
parent_namespace_ptr.owner_type,
|
.array_type,
|
||||||
if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
.vector_type,
|
||||||
DW.ACCESS.public
|
.opt_type,
|
||||||
else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
.anyframe_type,
|
||||||
DW.ACCESS.private
|
.error_union_type,
|
||||||
else
|
.simple_type,
|
||||||
unreachable,
|
.anon_struct_type,
|
||||||
};
|
.func_type,
|
||||||
} else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
|
.error_set_type,
|
||||||
|
.inferred_error_set_type,
|
||||||
const func_type = ip.indexToKey(func.ty).func_type;
|
=> .decl_alias,
|
||||||
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
.struct_type => tag: {
|
||||||
try wip_nav.abbrevCode(if (func_type.param_types.len > 0 or func_type.is_var_args)
|
|
||||||
.decl_func_generic
|
|
||||||
else
|
|
||||||
.decl_empty_func_generic);
|
|
||||||
try wip_nav.refType(Type.fromInterned(parent_type));
|
|
||||||
assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
|
|
||||||
try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
|
|
||||||
try uleb128(diw, loc.column + 1);
|
|
||||||
try diw.writeByte(accessibility);
|
|
||||||
try wip_nav.strp(nav.name.toSlice(ip));
|
|
||||||
try wip_nav.refType(Type.fromInterned(func_type.return_type));
|
|
||||||
if (func_type.param_types.len > 0 or func_type.is_var_args) {
|
|
||||||
for (0..func_type.param_types.len) |param_index| {
|
|
||||||
try wip_nav.abbrevCode(.func_type_param);
|
|
||||||
try wip_nav.refType(Type.fromInterned(func_type.param_types.get(ip)[param_index]));
|
|
||||||
}
|
|
||||||
if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);
|
|
||||||
try uleb128(diw, @intFromEnum(AbbrevCode.null));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.struct_type => done: {
|
|
||||||
const loaded_struct = ip.loadStructType(nav_val.toIntern());
|
const loaded_struct = ip.loadStructType(nav_val.toIntern());
|
||||||
|
if (loaded_struct.zir_index == .none) break :tag .decl_alias;
|
||||||
const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
|
|
||||||
const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
|
|
||||||
break :parent .{
|
|
||||||
parent_namespace_ptr.owner_type,
|
|
||||||
if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
|
||||||
DW.ACCESS.public
|
|
||||||
else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
|
||||||
DW.ACCESS.private
|
|
||||||
else
|
|
||||||
unreachable,
|
|
||||||
};
|
|
||||||
} else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
|
|
||||||
|
|
||||||
decl_struct: {
|
|
||||||
if (loaded_struct.zir_index == .none) break :decl_struct;
|
|
||||||
|
|
||||||
const type_inst_info = loaded_struct.zir_index.unwrap().?.resolveFull(ip).?;
|
const type_inst_info = loaded_struct.zir_index.unwrap().?.resolveFull(ip).?;
|
||||||
if (type_inst_info.file != inst_info.file) break :decl_struct;
|
if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
|
||||||
|
|
||||||
const value_inst = value_inst: {
|
const value_inst = value_inst: {
|
||||||
const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
|
const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
|
||||||
@ -2631,7 +2584,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
};
|
};
|
||||||
break :value_inst value_inst;
|
break :value_inst value_inst;
|
||||||
};
|
};
|
||||||
if (type_inst_info.inst != value_inst) break :decl_struct;
|
if (type_inst_info.inst != value_inst) break :tag .decl_alias;
|
||||||
|
|
||||||
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
||||||
if (type_gop.found_existing) {
|
if (type_gop.found_existing) {
|
||||||
@ -2700,45 +2653,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
try uleb128(diw, @intFromEnum(AbbrevCode.null));
|
try uleb128(diw, @intFromEnum(AbbrevCode.null));
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
break :done;
|
break :tag .done;
|
||||||
}
|
|
||||||
|
|
||||||
if (nav_gop.found_existing)
|
|
||||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
|
||||||
else
|
|
||||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
|
||||||
wip_nav.entry = nav_gop.value_ptr.*;
|
|
||||||
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
|
||||||
try wip_nav.abbrevCode(.decl_alias);
|
|
||||||
try wip_nav.refType(Type.fromInterned(parent_type));
|
|
||||||
assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
|
|
||||||
try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
|
|
||||||
try uleb128(diw, loc.column + 1);
|
|
||||||
try diw.writeByte(accessibility);
|
|
||||||
try wip_nav.strp(nav.name.toSlice(ip));
|
|
||||||
try wip_nav.refType(nav_val.toType());
|
|
||||||
},
|
},
|
||||||
.enum_type => done: {
|
.enum_type => tag: {
|
||||||
const loaded_enum = ip.loadEnumType(nav_val.toIntern());
|
const loaded_enum = ip.loadEnumType(nav_val.toIntern());
|
||||||
|
if (loaded_enum.zir_index == .none) break :tag .decl_alias;
|
||||||
const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
|
|
||||||
const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
|
|
||||||
break :parent .{
|
|
||||||
parent_namespace_ptr.owner_type,
|
|
||||||
if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
|
||||||
DW.ACCESS.public
|
|
||||||
else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
|
||||||
DW.ACCESS.private
|
|
||||||
else
|
|
||||||
unreachable,
|
|
||||||
};
|
|
||||||
} else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
|
|
||||||
|
|
||||||
decl_enum: {
|
|
||||||
if (loaded_enum.zir_index == .none) break :decl_enum;
|
|
||||||
|
|
||||||
const type_inst_info = loaded_enum.zir_index.unwrap().?.resolveFull(ip).?;
|
const type_inst_info = loaded_enum.zir_index.unwrap().?.resolveFull(ip).?;
|
||||||
if (type_inst_info.file != inst_info.file) break :decl_enum;
|
if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
|
||||||
|
|
||||||
const value_inst = value_inst: {
|
const value_inst = value_inst: {
|
||||||
const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
|
const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
|
||||||
@ -2755,7 +2677,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
};
|
};
|
||||||
break :value_inst value_inst;
|
break :value_inst value_inst;
|
||||||
};
|
};
|
||||||
if (type_inst_info.inst != value_inst) break :decl_enum;
|
if (type_inst_info.inst != value_inst) break :tag .decl_alias;
|
||||||
|
|
||||||
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
||||||
if (type_gop.found_existing) {
|
if (type_gop.found_existing) {
|
||||||
@ -2787,43 +2709,13 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip));
|
try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip));
|
||||||
}
|
}
|
||||||
if (loaded_enum.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
|
if (loaded_enum.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
|
||||||
break :done;
|
break :tag .done;
|
||||||
}
|
|
||||||
|
|
||||||
if (nav_gop.found_existing)
|
|
||||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
|
||||||
else
|
|
||||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
|
||||||
wip_nav.entry = nav_gop.value_ptr.*;
|
|
||||||
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
|
||||||
try wip_nav.abbrevCode(.decl_alias);
|
|
||||||
try wip_nav.refType(Type.fromInterned(parent_type));
|
|
||||||
assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
|
|
||||||
try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
|
|
||||||
try uleb128(diw, loc.column + 1);
|
|
||||||
try diw.writeByte(accessibility);
|
|
||||||
try wip_nav.strp(nav.name.toSlice(ip));
|
|
||||||
try wip_nav.refType(nav_val.toType());
|
|
||||||
},
|
},
|
||||||
.union_type => done: {
|
.union_type => tag: {
|
||||||
const loaded_union = ip.loadUnionType(nav_val.toIntern());
|
const loaded_union = ip.loadUnionType(nav_val.toIntern());
|
||||||
|
|
||||||
const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
|
|
||||||
const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
|
|
||||||
break :parent .{
|
|
||||||
parent_namespace_ptr.owner_type,
|
|
||||||
if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
|
||||||
DW.ACCESS.public
|
|
||||||
else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
|
||||||
DW.ACCESS.private
|
|
||||||
else
|
|
||||||
unreachable,
|
|
||||||
};
|
|
||||||
} else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
|
|
||||||
|
|
||||||
decl_union: {
|
|
||||||
const type_inst_info = loaded_union.zir_index.resolveFull(ip).?;
|
const type_inst_info = loaded_union.zir_index.resolveFull(ip).?;
|
||||||
if (type_inst_info.file != inst_info.file) break :decl_union;
|
if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
|
||||||
|
|
||||||
const value_inst = value_inst: {
|
const value_inst = value_inst: {
|
||||||
const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
|
const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
|
||||||
@ -2840,7 +2732,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
};
|
};
|
||||||
break :value_inst value_inst;
|
break :value_inst value_inst;
|
||||||
};
|
};
|
||||||
if (type_inst_info.inst != value_inst) break :decl_union;
|
if (type_inst_info.inst != value_inst) break :tag .decl_alias;
|
||||||
|
|
||||||
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
||||||
if (type_gop.found_existing) {
|
if (type_gop.found_existing) {
|
||||||
@ -2908,43 +2800,13 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
field_type.abiAlignment(zcu).toByteUnits().?);
|
field_type.abiAlignment(zcu).toByteUnits().?);
|
||||||
}
|
}
|
||||||
try uleb128(diw, @intFromEnum(AbbrevCode.null));
|
try uleb128(diw, @intFromEnum(AbbrevCode.null));
|
||||||
break :done;
|
break :tag .done;
|
||||||
}
|
|
||||||
|
|
||||||
if (nav_gop.found_existing)
|
|
||||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
|
||||||
else
|
|
||||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
|
||||||
wip_nav.entry = nav_gop.value_ptr.*;
|
|
||||||
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
|
||||||
try wip_nav.abbrevCode(.decl_alias);
|
|
||||||
try wip_nav.refType(Type.fromInterned(parent_type));
|
|
||||||
assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
|
|
||||||
try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
|
|
||||||
try uleb128(diw, loc.column + 1);
|
|
||||||
try diw.writeByte(accessibility);
|
|
||||||
try wip_nav.strp(nav.name.toSlice(ip));
|
|
||||||
try wip_nav.refType(nav_val.toType());
|
|
||||||
},
|
},
|
||||||
.opaque_type => done: {
|
.opaque_type => tag: {
|
||||||
const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern());
|
const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern());
|
||||||
|
|
||||||
const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
|
|
||||||
const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
|
|
||||||
break :parent .{
|
|
||||||
parent_namespace_ptr.owner_type,
|
|
||||||
if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
|
||||||
DW.ACCESS.public
|
|
||||||
else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
|
|
||||||
DW.ACCESS.private
|
|
||||||
else
|
|
||||||
unreachable,
|
|
||||||
};
|
|
||||||
} else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
|
|
||||||
|
|
||||||
decl_opaque: {
|
|
||||||
const type_inst_info = loaded_opaque.zir_index.resolveFull(ip).?;
|
const type_inst_info = loaded_opaque.zir_index.resolveFull(ip).?;
|
||||||
if (type_inst_info.file != inst_info.file) break :decl_opaque;
|
if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
|
||||||
|
|
||||||
const value_inst = value_inst: {
|
const value_inst = value_inst: {
|
||||||
const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
|
const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
|
||||||
@ -2961,7 +2823,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
};
|
};
|
||||||
break :value_inst value_inst;
|
break :value_inst value_inst;
|
||||||
};
|
};
|
||||||
if (type_inst_info.inst != value_inst) break :decl_opaque;
|
if (type_inst_info.inst != value_inst) break :tag .decl_alias;
|
||||||
|
|
||||||
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
||||||
if (type_gop.found_existing) {
|
if (type_gop.found_existing) {
|
||||||
@ -2984,9 +2846,81 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
try diw.writeByte(accessibility);
|
try diw.writeByte(accessibility);
|
||||||
try wip_nav.strp(nav.name.toSlice(ip));
|
try wip_nav.strp(nav.name.toSlice(ip));
|
||||||
try diw.writeByte(@intFromBool(false));
|
try diw.writeByte(@intFromBool(false));
|
||||||
break :done;
|
break :tag .done;
|
||||||
|
},
|
||||||
|
.undef,
|
||||||
|
.simple_value,
|
||||||
|
.variable,
|
||||||
|
.@"extern",
|
||||||
|
.int,
|
||||||
|
.err,
|
||||||
|
.error_union,
|
||||||
|
.enum_literal,
|
||||||
|
.enum_tag,
|
||||||
|
.empty_enum_value,
|
||||||
|
.float,
|
||||||
|
.ptr,
|
||||||
|
.slice,
|
||||||
|
.opt,
|
||||||
|
.aggregate,
|
||||||
|
.un,
|
||||||
|
=> {
|
||||||
|
_ = dwarf.navs.pop();
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
.func => |func| tag: {
|
||||||
|
if (nav_gop.found_existing) {
|
||||||
|
const unit_ptr = dwarf.debug_info.section.getUnit(wip_nav.unit);
|
||||||
|
const entry_ptr = unit_ptr.getEntry(nav_gop.value_ptr.*);
|
||||||
|
if (entry_ptr.len >= AbbrevCode.decl_bytes) {
|
||||||
|
var abbrev_code_buf: [AbbrevCode.decl_bytes]u8 = undefined;
|
||||||
|
if (try dwarf.getFile().?.preadAll(
|
||||||
|
&abbrev_code_buf,
|
||||||
|
dwarf.debug_info.section.off(dwarf) + unit_ptr.off + unit_ptr.header_len + entry_ptr.off,
|
||||||
|
) != abbrev_code_buf.len) return error.InputOutput;
|
||||||
|
var abbrev_code_fbs = std.io.fixedBufferStream(&abbrev_code_buf);
|
||||||
|
const abbrev_code: AbbrevCode = @enumFromInt(
|
||||||
|
std.leb.readUleb128(@typeInfo(AbbrevCode).@"enum".tag_type, abbrev_code_fbs.reader()) catch unreachable,
|
||||||
|
);
|
||||||
|
switch (abbrev_code) {
|
||||||
|
else => unreachable,
|
||||||
|
.decl_func, .decl_empty_func => return,
|
||||||
|
.decl_func_generic, .decl_empty_func_generic => {},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
entry_ptr.clear();
|
||||||
|
} else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||||
|
wip_nav.entry = nav_gop.value_ptr.*;
|
||||||
|
|
||||||
|
const func_type = ip.indexToKey(func.ty).func_type;
|
||||||
|
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
||||||
|
try wip_nav.abbrevCode(if (func_type.param_types.len > 0 or func_type.is_var_args)
|
||||||
|
.decl_func_generic
|
||||||
|
else
|
||||||
|
.decl_empty_func_generic);
|
||||||
|
try wip_nav.refType(Type.fromInterned(parent_type));
|
||||||
|
assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
|
||||||
|
try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
|
||||||
|
try uleb128(diw, loc.column + 1);
|
||||||
|
try diw.writeByte(accessibility);
|
||||||
|
try wip_nav.strp(nav.name.toSlice(ip));
|
||||||
|
try wip_nav.refType(Type.fromInterned(func_type.return_type));
|
||||||
|
if (func_type.param_types.len > 0 or func_type.is_var_args) {
|
||||||
|
for (0..func_type.param_types.len) |param_index| {
|
||||||
|
try wip_nav.abbrevCode(.func_type_param);
|
||||||
|
try wip_nav.refType(Type.fromInterned(func_type.param_types.get(ip)[param_index]));
|
||||||
|
}
|
||||||
|
if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);
|
||||||
|
try uleb128(diw, @intFromEnum(AbbrevCode.null));
|
||||||
|
}
|
||||||
|
break :tag .done;
|
||||||
|
},
|
||||||
|
// memoization, not types
|
||||||
|
.memoized_call => unreachable,
|
||||||
|
};
|
||||||
|
switch (tag) {
|
||||||
|
.done => {},
|
||||||
|
.decl_alias => {
|
||||||
if (nav_gop.found_existing)
|
if (nav_gop.found_existing)
|
||||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
||||||
else
|
else
|
||||||
@ -3002,10 +2936,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
|||||||
try wip_nav.strp(nav.name.toSlice(ip));
|
try wip_nav.strp(nav.name.toSlice(ip));
|
||||||
try wip_nav.refType(nav_val.toType());
|
try wip_nav.refType(nav_val.toType());
|
||||||
},
|
},
|
||||||
else => {
|
|
||||||
_ = dwarf.navs.pop();
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);
|
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);
|
||||||
try wip_nav.flush();
|
try wip_nav.flush();
|
||||||
@ -3734,12 +3664,15 @@ fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(A
|
|||||||
pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {
|
pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {
|
||||||
const zcu = pt.zcu;
|
const zcu = pt.zcu;
|
||||||
const ip = &zcu.intern_pool;
|
const ip = &zcu.intern_pool;
|
||||||
if (dwarf.types.get(.anyerror_type)) |entry| {
|
|
||||||
|
{
|
||||||
|
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, .anyerror_type);
|
||||||
|
if (!type_gop.found_existing) type_gop.value_ptr.* = try dwarf.addCommonEntry(.main);
|
||||||
var wip_nav: WipNav = .{
|
var wip_nav: WipNav = .{
|
||||||
.dwarf = dwarf,
|
.dwarf = dwarf,
|
||||||
.pt = pt,
|
.pt = pt,
|
||||||
.unit = .main,
|
.unit = .main,
|
||||||
.entry = entry,
|
.entry = type_gop.value_ptr.*,
|
||||||
.any_children = false,
|
.any_children = false,
|
||||||
.func = .none,
|
.func = .none,
|
||||||
.func_sym_index = undefined,
|
.func_sym_index = undefined,
|
||||||
|
|||||||
@ -411,10 +411,27 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
|
|||||||
},
|
},
|
||||||
\\breakpoint set --file enums.zig --source-pattern-regexp '_ = enums;'
|
\\breakpoint set --file enums.zig --source-pattern-regexp '_ = enums;'
|
||||||
\\process launch
|
\\process launch
|
||||||
|
\\expression --show-types -- Enums
|
||||||
\\frame variable --show-types enums
|
\\frame variable --show-types enums
|
||||||
\\breakpoint delete --force 1
|
\\breakpoint delete --force 1
|
||||||
,
|
,
|
||||||
&.{
|
&.{
|
||||||
|
\\(lldb) expression --show-types -- Enums
|
||||||
|
\\(type) Enums = struct {
|
||||||
|
\\ (type) Zero = enum {}
|
||||||
|
\\ (type) One = enum {
|
||||||
|
\\ (root.enums.Enums.One) first = .first
|
||||||
|
\\ }
|
||||||
|
\\ (type) Two = enum {
|
||||||
|
\\ (root.enums.Enums.Two) first = .first
|
||||||
|
\\ (root.enums.Enums.Two) second = .second
|
||||||
|
\\ }
|
||||||
|
\\ (type) Three = enum {
|
||||||
|
\\ (root.enums.Enums.Three) first = .first
|
||||||
|
\\ (root.enums.Enums.Three) second = .second
|
||||||
|
\\ (root.enums.Enums.Three) third = .third
|
||||||
|
\\ }
|
||||||
|
\\}
|
||||||
\\(lldb) frame variable --show-types enums
|
\\(lldb) frame variable --show-types enums
|
||||||
\\(root.enums.Enums) enums = {
|
\\(root.enums.Enums) enums = {
|
||||||
\\ (root.enums.Enums.Zero) zero = @enumFromInt(13)
|
\\ (root.enums.Enums.Zero) zero = @enumFromInt(13)
|
||||||
@ -434,12 +451,17 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
|
|||||||
.path = "errors.zig",
|
.path = "errors.zig",
|
||||||
.source =
|
.source =
|
||||||
\\const Errors = struct {
|
\\const Errors = struct {
|
||||||
\\ one: error{One} = error.One,
|
\\ const Zero = error{};
|
||||||
\\ two: error{One,Two} = error.Two,
|
\\ const One = Zero || error{One};
|
||||||
\\ three: error{One,Two,Three} = error.Three,
|
\\ const Two = One || error{Two};
|
||||||
|
\\ const Three = Two || error{Three};
|
||||||
|
\\
|
||||||
|
\\ one: One = error.One,
|
||||||
|
\\ two: Two = error.Two,
|
||||||
|
\\ three: Three = error.Three,
|
||||||
\\ any: anyerror = error.Any,
|
\\ any: anyerror = error.Any,
|
||||||
\\ any_void: anyerror!void = error.NotVoid,
|
\\ any_void: anyerror!void = error.NotVoid,
|
||||||
\\ any_u32: error{One}!u32 = 42,
|
\\ any_u32: One!u32 = 42,
|
||||||
\\};
|
\\};
|
||||||
\\fn testErrors(errors: Errors) void {
|
\\fn testErrors(errors: Errors) void {
|
||||||
\\ _ = errors;
|
\\ _ = errors;
|
||||||
@ -453,10 +475,27 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
|
|||||||
},
|
},
|
||||||
\\breakpoint set --file errors.zig --source-pattern-regexp '_ = errors;'
|
\\breakpoint set --file errors.zig --source-pattern-regexp '_ = errors;'
|
||||||
\\process launch
|
\\process launch
|
||||||
|
\\expression --show-types -- Errors
|
||||||
\\frame variable --show-types errors
|
\\frame variable --show-types errors
|
||||||
\\breakpoint delete --force 1
|
\\breakpoint delete --force 1
|
||||||
,
|
,
|
||||||
&.{
|
&.{
|
||||||
|
\\(lldb) expression --show-types -- Errors
|
||||||
|
\\(type) Errors = struct {
|
||||||
|
\\ (type) Zero = error {}
|
||||||
|
\\ (type) One = error {
|
||||||
|
\\ (error{One}) One = error.One
|
||||||
|
\\ }
|
||||||
|
\\ (type) Two = error {
|
||||||
|
\\ (error{One,Two}) One = error.One
|
||||||
|
\\ (error{One,Two}) Two = error.Two
|
||||||
|
\\ }
|
||||||
|
\\ (type) Three = error {
|
||||||
|
\\ (error{One,Two,Three}) One = error.One
|
||||||
|
\\ (error{One,Two,Three}) Two = error.Two
|
||||||
|
\\ (error{One,Two,Three}) Three = error.Three
|
||||||
|
\\ }
|
||||||
|
\\}
|
||||||
\\(lldb) frame variable --show-types errors
|
\\(lldb) frame variable --show-types errors
|
||||||
\\(root.errors.Errors) errors = {
|
\\(root.errors.Errors) errors = {
|
||||||
\\ (error{One}) one = error.One
|
\\ (error{One}) one = error.One
|
||||||
@ -565,10 +604,30 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
|
|||||||
},
|
},
|
||||||
\\breakpoint set --file unions.zig --source-pattern-regexp '_ = unions;'
|
\\breakpoint set --file unions.zig --source-pattern-regexp '_ = unions;'
|
||||||
\\process launch
|
\\process launch
|
||||||
|
\\expression --show-types -- Unions
|
||||||
\\frame variable --show-types unions
|
\\frame variable --show-types unions
|
||||||
\\breakpoint delete --force 1
|
\\breakpoint delete --force 1
|
||||||
,
|
,
|
||||||
&.{
|
&.{
|
||||||
|
\\(lldb) expression --show-types -- Unions
|
||||||
|
\\(type) Unions = struct {
|
||||||
|
\\ (type) Untagged = union {}
|
||||||
|
\\ (type) SafetyTagged = union(enum) {
|
||||||
|
\\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) void = .void
|
||||||
|
\\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) en = .en
|
||||||
|
\\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) eu = .eu
|
||||||
|
\\ }
|
||||||
|
\\ (type) Enum = enum {
|
||||||
|
\\ (root.unions.Unions.Enum) first = .first
|
||||||
|
\\ (root.unions.Unions.Enum) second = .second
|
||||||
|
\\ (root.unions.Unions.Enum) third = .third
|
||||||
|
\\ }
|
||||||
|
\\ (type) Tagged = union(enum) {
|
||||||
|
\\ (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) void = .void
|
||||||
|
\\ (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) en = .en
|
||||||
|
\\ (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) eu = .eu
|
||||||
|
\\ }
|
||||||
|
\\}
|
||||||
\\(lldb) frame variable --show-types unions
|
\\(lldb) frame variable --show-types unions
|
||||||
\\(root.unions.Unions) unions = {
|
\\(root.unions.Unions) unions = {
|
||||||
\\ (root.unions.Unions.Untagged) untagged = {
|
\\ (root.unions.Unions.Untagged) untagged = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user