aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2020-12-30 15:55:27 +0100
committerJakub Konka <kubkon@jakubkonka.com>2020-12-31 10:19:04 +0100
commit364691fa1f5a1c7da024cc58b9b3138425a5e475 (patch)
treeace3c9356e4b6b7d9b38b7137c48d2b59e03f236 /src
parentfa28f7006ddba699048c54a363244dcad49af1e2 (diff)
downloadzig-364691fa1f5a1c7da024cc58b9b3138425a5e475.tar.gz
zig-364691fa1f5a1c7da024cc58b9b3138425a5e475.zip
macho: add decl line and file info to subprogram
Diffstat (limited to 'src')
-rw-r--r--src/link/MachO.zig4
-rw-r--r--src/link/MachO/DebugSymbols.zig67
2 files changed, 31 insertions, 40 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index 9840dccf4a..eaca814627 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -1199,7 +1199,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void {
// .debug_info subprogram
const decl_name_with_null = decl.name[0 .. mem.lenZ(decl.name) + 1];
- try dbg_info_buffer.ensureCapacity(dbg_info_buffer.items.len + 25 + decl_name_with_null.len);
+ try dbg_info_buffer.ensureCapacity(dbg_info_buffer.items.len + 27 + decl_name_with_null.len);
const fn_ret_type = typed_value.ty.fnReturnType();
const fn_ret_has_bits = fn_ret_type.hasCodeGenBits();
@@ -1227,6 +1227,8 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void {
dbg_info_buffer.items.len += 4; // DW.AT_type, DW.FORM_ref4
}
dbg_info_buffer.appendSliceAssumeCapacity(decl_name_with_null); // DW.AT_name, DW.FORM_string
+ mem.writeIntLittle(u32, dbg_info_buffer.addManyAsArrayAssumeCapacity(4), line_off + 1); // DW.AT_decl_line, DW.FORM_data4
+ dbg_info_buffer.appendAssumeCapacity(file_index); // DW.AT_decl_file, DW.FORM_data1
} else {
// TODO implement .debug_info for global variables
}
diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig
index faa7a00139..b809d3a2aa 100644
--- a/src/link/MachO/DebugSymbols.zig
+++ b/src/link/MachO/DebugSymbols.zig
@@ -361,52 +361,41 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt
// we can simply append these bytes.
const abbrev_buf = [_]u8{
abbrev_compile_unit, DW.TAG_compile_unit, DW.CHILDREN_yes, // header
- DW.AT_stmt_list, DW.FORM_sec_offset, DW.AT_low_pc,
- DW.FORM_addr, DW.AT_high_pc, DW.FORM_addr,
- DW.AT_name, DW.FORM_strp, DW.AT_comp_dir,
- DW.FORM_strp, DW.AT_producer, DW.FORM_strp,
- DW.AT_language, DW.FORM_data2, 0,
- 0, // table sentinel
- abbrev_subprogram,
- DW.TAG_subprogram,
- DW.CHILDREN_yes, // header
- DW.AT_low_pc,
- DW.FORM_addr,
- DW.AT_high_pc,
- DW.FORM_data4,
- DW.AT_type,
- DW.FORM_ref4,
- DW.AT_name,
- DW.FORM_string,
+ DW.AT_stmt_list, DW.FORM_sec_offset, // offset
+ DW.AT_low_pc, DW.FORM_addr,
+ DW.AT_high_pc, DW.FORM_addr,
+ DW.AT_name, DW.FORM_strp,
+ DW.AT_comp_dir, DW.FORM_strp,
+ DW.AT_producer, DW.FORM_strp,
+ DW.AT_language, DW.FORM_data2,
+ 0, 0, // table sentinel
+ abbrev_subprogram, DW.TAG_subprogram, DW.CHILDREN_yes, // header
+ DW.AT_low_pc, DW.FORM_addr, // start VM address
+ DW.AT_high_pc, DW.FORM_data4,
+ DW.AT_type, DW.FORM_ref4,
+ DW.AT_name, DW.FORM_string,
+ DW.AT_decl_line, DW.FORM_data4,
+ DW.AT_decl_file, DW.FORM_data1,
0, 0, // table sentinel
abbrev_subprogram_retvoid,
DW.TAG_subprogram, DW.CHILDREN_yes, // header
DW.AT_low_pc, DW.FORM_addr,
DW.AT_high_pc, DW.FORM_data4,
DW.AT_name, DW.FORM_string,
- 0,
- 0, // table sentinel
- abbrev_base_type,
- DW.TAG_base_type,
- DW.CHILDREN_no, // header
- DW.AT_encoding,
- DW.FORM_data1,
- DW.AT_byte_size,
- DW.FORM_data1,
- DW.AT_name,
- DW.FORM_string, 0, 0, // table sentinel
+ DW.AT_decl_line, DW.FORM_data4,
+ DW.AT_decl_file, DW.FORM_data1,
+ 0, 0, // table sentinel
+ abbrev_base_type, DW.TAG_base_type, DW.CHILDREN_no, // header
+ DW.AT_encoding, DW.FORM_data1, DW.AT_byte_size,
+ DW.FORM_data1, DW.AT_name, DW.FORM_string,
+ 0, 0, // table sentinel
abbrev_pad1, DW.TAG_unspecified_type, DW.CHILDREN_no, // header
- 0, 0, // table sentinel
- abbrev_parameter,
- DW.TAG_formal_parameter, DW.CHILDREN_no, // header
- DW.AT_location, DW.FORM_exprloc,
- DW.AT_type, DW.FORM_ref4,
- DW.AT_name, DW.FORM_string,
- 0,
- 0, // table sentinel
- 0,
- 0,
- 0, // section sentinel
+ 0, 0, // table sentinel
+ abbrev_parameter, DW.TAG_formal_parameter, DW.CHILDREN_no, // header
+ DW.AT_location, DW.FORM_exprloc, DW.AT_type,
+ DW.FORM_ref4, DW.AT_name, DW.FORM_string,
+ 0, 0, // table sentinel
+ 0, 0, 0, // section sentinel
};
const needed_size = abbrev_buf.len;