Skip to content

Commit 5b4a809

Browse files
committed
Add some documentation about the debuginfo support of cg_clif
1 parent eab4c90 commit 5b4a809

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/dwarf.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Line number information
2+
3+
Line number information maps between machine code instructions and the source level location.
4+
5+
## Encoding
6+
7+
The line number information is stored in the `.debug_line` section for ELF and `__debug_line`
8+
section of the `__DWARF` segment for Mach-O object files. The line number information contains a
9+
header followed by the line program. The line program is a program for a virtual machine with
10+
instructions like set line number for the current machine code instruction and advance the current
11+
machine code instruction.
12+
13+
## Tips
14+
15+
You need to set either `DW_AT_low_pc` and `DW_AT_high_pc` **or** `DW_AT_ranges` of a
16+
`DW_TAG_compilation_unit` to the range of addresses in the compilation unit. After that you need
17+
to set `DW_AT_stmt_list` to the `.debug_line` section offset of the line program. Otherwise a
18+
debugger won't find the line number information. On macOS the debuginfo relocations **must** be
19+
section relative and not symbol relative.
20+
See [#303 (comment)](https://github.com/bjorn3/rustc_codegen_cranelift/issues/303#issuecomment-457825535)
21+
for more information.

0 commit comments

Comments
 (0)