about summary refs log tree commit diff
path: root/docs
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2020-04-18 15:57:08 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2020-04-18 15:57:08 +0200
commit5b4a8091d5dfeebcd2925eecc7e887bc83f5a689 (patch)
tree35523cc0600dbe93101c6e6fd914d1e3bebc4535 /docs
parenteab4c9063ec63bf484347cbd6b21117d336db4a5 (diff)
downloadrust-5b4a8091d5dfeebcd2925eecc7e887bc83f5a689.tar.gz
rust-5b4a8091d5dfeebcd2925eecc7e887bc83f5a689.zip
Add some documentation about the debuginfo support of cg_clif
Diffstat (limited to 'docs')
-rw-r--r--docs/dwarf.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/dwarf.md b/docs/dwarf.md
new file mode 100644
index 00000000000..ac400bb8d07
--- /dev/null
+++ b/docs/dwarf.md
@@ -0,0 +1,21 @@
+# Line number information
+
+Line number information maps between machine code instructions and the source level location.
+
+## Encoding
+
+The line number information is stored in the `.debug_line` section for ELF and `__debug_line`
+section of the `__DWARF` segment for Mach-O object files. The line number information contains a
+header followed by the line program. The line program is a program for a virtual machine with
+instructions like set line number for the current machine code instruction and advance the current
+machine code instruction.
+
+## Tips
+
+You need to set either `DW_AT_low_pc` and `DW_AT_high_pc` **or** `DW_AT_ranges` of a
+`DW_TAG_compilation_unit` to the range of addresses in the compilation unit. After that you need
+to set `DW_AT_stmt_list` to the `.debug_line` section offset of the line program. Otherwise a
+debugger won't find the line number information. On macOS the debuginfo relocations **must** be
+section relative and not symbol relative.
+See [#303 (comment)](https://github.com/bjorn3/rustc_codegen_cranelift/issues/303#issuecomment-457825535)
+for more information.