Add docs for `#[collapse_debuginfo]` attribute

This commit is contained in:
Vadim Petrochenkov 2024-02-13 16:26:42 +03:00
parent 8227666de1
commit 0bf5d4e44c
1 changed files with 23 additions and 0 deletions

View File

@ -139,3 +139,26 @@ When the crate's debug executable is passed into GDB[^rust-gdb], `print bob` wil
[Natvis documentation]: https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects
[pretty printing documentation]: https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html
[_MetaListNameValueStr_]: ../attributes.md#meta-item-attribute-syntax
## The `collapse_debuginfo` attribute
This attribute controls whether code locations from this macro definition are collapsed into a
single location associated with the macro's call site, when generating debuginfo for code calling
this macro.
The attribute uses the [_MetaListIdents_] syntax to specify its inputs, and can only be applied to
macro definitions.
Accepted options:
- `#[collapse_debuginfo(yes)]` - code locations in debuginfo are collapsed.
- `#[collapse_debuginfo(no)]` - code locations in debuginfo are not collapsed.
- `#[collapse_debuginfo(external)]` - code locations in debuginfo are collapsed only if the macro
comes from a different crate.
The `external` behavior is the default for macros that don't have this attribute, unless they are
built-in macros. For built-in macros the default is `yes`.
Both the default collapsing behavior and `#[collapse_debuginfo]` attributes can be overridden from
command line using the `-C collapse-macro-debuginfo` option.
[_MetaListIdents_]: ../attributes.md#meta-item-attribute-syntax