From 0bf5d4e44c5f55092dfabb0f7b7f1a03352a4fe8 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 13 Feb 2024 16:26:42 +0300 Subject: [PATCH] Add docs for `#[collapse_debuginfo]` attribute --- src/attributes/debugger.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/attributes/debugger.md b/src/attributes/debugger.md index 6ea80221e..468a1b2cf 100644 --- a/src/attributes/debugger.md +++ b/src/attributes/debugger.md @@ -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