debugging. This default can be overridden by setting the `strip` rustc flag to either `debuginfo`
or `symbols`.
Rust has support for embedding Natvis files for crates outside of the standard libraries by
using the `#[debugger_visualizer]` attribute.
For more details on how to embed debugger visualizers,
please refer to the section on the [`debugger_visualizer` attribute].
## DWARF and `rustc`
[DWARF] is the standard way compilers generate debugging information that debuggers read.
It is _the_ debugging format on macOS and Linux.
It is a multi-language and extensible format,
and is mostly good enough for Rust's purposes.
Hence, the current implementation reuses DWARF's concepts.
This is true even if some of the concepts in DWARF do not align with Rust semantically because,
generally, there can be some kind of mapping between the two.
We have some DWARF extensions that the Rust compiler emits and the debuggers understand that
are _not_ in the DWARF standard.
* Rust compiler will emit DWARF for a virtual table, and this `vtable` object will have a
`DW_AT_containing_type` that points to the real type. This lets debuggers dissect a trait object
pointer to correctly find the payload. E.g., here's such a DIE, from a test case in the gdb
repository:
```asm
<1><1a9>: Abbrev Number: 3 (DW_TAG_structure_type)
<1aa> DW_AT_containing_type: <0x1b4>
<1ae> DW_AT_name : (indirect string, offset: 0x23d): vtable
<1b2> DW_AT_byte_size : 0
<1b3> DW_AT_alignment : 8
```
* The other extension is that the Rust compiler can emit a tagless discriminated union.
See [DWARF feature request] for this item.
### Current limitations of DWARF
* Traits - require a bigger change than normal to DWARF, on how to represent Traits in DWARF.
* DWARF provides no way to differentiate between Structs and Tuples. Rust compiler emits
fields with `__0` and debuggers look for a sequence of such names to overcome this limitation.
For example, in this case the debugger would look at a field via `x.__0` instead of `x.0`.
This is resolved via the Rust parser in the debugger so now you can do `x.0`.
DWARF relies on debuggers to know some information about platform ABI.
Rust does not do that all the time.
## Developer notes
This section is from the talk about certain aspects of development.
## What is missing
### Code signing for LLDB debug server on macOS
According to Wikipedia, [System Integrity Protection] is
> System Integrity Protection (SIP, sometimes referred to as rootless) is a security feature
> of Apple's macOS operating system introduced in OS X El Capitan. It comprises a number of
> mechanisms that are enforced by the kernel. A centerpiece is the protection of system-owned
> files and directories against modifications by processes without a specific "entitlement",
> even when executed by the root user or a user with root privileges (sudo).
It prevents processes using `ptrace` syscall. If a process wants to use `ptrace` it has to be
code signed. The certificate that signs it has to be trusted on your machine.
See [Apple developer documentation for System Integrity Protection].
We may need to sign up with Apple and get the keys to do this signing. Tom has looked into if
Mozilla cannot do this because it is at the maximum number of
keys it is allowed to sign. Tom does not know if Mozilla could get more keys.
Alternatively, Tom suggests that maybe a Rust legal entity is needed to get the keys via Apple.
This problem is not technical in nature. If we had such a key we could sign GDB as well and
ship that.
### DWARF and Traits
Rust traits are not emitted into DWARF at all. The impact of this is calling a method `x.method()`
does not work as is. The reason being that method is implemented by a trait, as opposed
to a type. That information is not present so finding trait methods is missing.
DWARF has a notion of interface types (possibly added for Java). Tom's idea was to use this
interface type as traits.