about summary refs log tree commit diff
path: root/src/test/debuginfo
AgeCommit message (Collapse)AuthorLines
2022-09-13Auto merge of #99556 - davidtwco:collapse-debuginfo, r=wesleywiserbors-0/+243
ssa: implement `#[collapse_debuginfo]` cc #39153 rust-lang/compiler-team#386 Debuginfo line information for macro invocations are collapsed by default - line information are replaced by the line of the outermost expansion site. Using `-Zdebug-macros` disables this behaviour. When the `collapse_debuginfo` feature is enabled, the default behaviour is reversed so that debuginfo is not collapsed by default. In addition, the `#[collapse_debuginfo]` attribute is available and can be applied to macro definitions which will then have their line information collapsed. r? rust-lang/wg-debugging
2022-09-07Change name of "dataful" variant to "untagged"Michael Benfield-3/+3
This is in anticipation of a new enum layout, in which the niche optimization may be applied even when multiple variants have data.
2022-09-07ssa: implement `#[collapse_debuginfo]`David Wood-0/+243
Debuginfo line information for macro invocations are collapsed by default - line information are replaced by the line of the outermost expansion site. Using `-Zdebug-macros` disables this behaviour. When the `collapse_debuginfo` feature is enabled, the default behaviour is reversed so that debuginfo is not collapsed by default. In addition, the `#[collapse_debuginfo]` attribute is available and can be applied to macro definitions which will then have their line information collapsed. Signed-off-by: David Wood <david.wood@huawei.com>
2022-08-28Rollup merge of #98301 - ortem:pretty-printers-nonzero, r=wesleywiserMatthias Krüger-1/+86
Add GDB/LLDB pretty-printers for NonZero types Add GDB/LLDB pretty-printers for `NonZero` types. These pretty-printers were originally implemented for IntelliJ Rust by ```@Kobzol``` in https://github.com/intellij-rust/intellij-rust/pull/5270. Part of #29392.
2022-08-24Add GDB/LLDB pretty-printers for NonZero typesArtem Mukhin-1/+86
2022-08-15[debuginfo] Fix msvc-pretty-enums debuginfo test for i686.Michael Woerister-2/+2
2022-08-12[debuginfo] Update src/test/debuginfo/mutex.rs for new cpp-like enum ↵Michael Woerister-5/+7
debuginfo encoding.
2022-08-12[debuginfo] Add more test cases cpp-like enum debuginfo.Michael Woerister-4/+39
2022-08-12Support wrapping 128-bit tag ranges for cpp-like enum debuginfo.Michael Woerister-0/+32
2022-08-12Use enum2<_> instead of enum<_> for Cpp-like debuginfo enum type names.Michael Woerister-63/+62
And add more comments about niche tag enum encoding.
2022-08-12debuginfo: Change C++-like encoding for enums.Michael Woerister-50/+119
The updated encoding should be able to handle niche layouts where more than one variant has fields.
2022-08-04Add min-gdb-versionRyan Levick-0/+1
2022-08-04Update FIXME commentRyan Levick-1/+1
Co-authored-by: Wesley Wiser <wwiser@gmail.com>
2022-08-04Add comment about issue caused with multiple staticsRyan Levick-0/+2
2022-08-04Fix linux testsRyan Levick-7/+7
2022-08-04Turn CDB test back on and all clarifying testRyan Levick-6/+18
2022-08-04Turn off cdb test for now, link to issueRyan Levick-6/+5
2022-08-04Add a test for issue #33172Ryan Levick-0/+26
2022-07-20Use revision support to remove near identical debuginfo test.Luqman Aden-81/+6
2022-07-18Fix debuginfo tests.Nicholas Nethercote-2/+2
This is needed for my Ubuntu 22.04 box due to a slight change in gdb output. The fix is similar to the fix in #95063.
2022-07-16Auto merge of #95685 - oxidecomputer:restore-static-dwarf, r=pnkfelixbors-7/+85
Revert "Work around invalid DWARF bugs for fat LTO" Since September, the toolchain has not been generating reliable DWARF information for static variables when LTO is on. This has affected projects in the embedded space where the use of LTO is typical. In our case, it has kept us from bumping past the 2021-09-22 nightly toolchain lest our debugger break. This has been a pretty dramatic regression for people using debuggers and static variables. See #90357 for more info and a repro case. This commit is a mechanical revert of d5de680e20def848751cb3c11e1182408112b1d3 from PR #89041, which caused the issue. (Note on that PR that the commit's author has requested it be reverted.) I have locally verified that this fixes #90357 by restoring the functionality of both the repro case I posted on that bug, and debugger behavior on real programs. There do not appear to be test cases for this in the toolchain; if I've missed them, point me at 'em and I'll update them.
2022-07-15Set minimum GDB version needed for basic-types-globals* tests.Luqman Aden-0/+2
2022-06-25Auto merge of #96820 - r-raymond:master, r=cuviperbors-5/+2
Make RwLockReadGuard covariant Hi, first time contributor here, if anything is not as expected, please let me know. `RwLockReadGoard`'s type constructor is invariant. Since it behaves like a smart pointer to an immutable reference, there is no reason that it should not be covariant. Take e.g. ``` fn test_read_guard_covariance() { fn do_stuff<'a>(_: RwLockReadGuard<'_, &'a i32>, _: &'a i32) {} let j: i32 = 5; let lock = RwLock::new(&j); { let i = 6; do_stuff(lock.read().unwrap(), &i); } drop(lock); } ``` where the compiler complains that &i doesn't live long enough. If `RwLockReadGuard` is covariant, then the above code is accepted because the lifetime can be shorter than `'a`. In order for `RwLockReadGuard` to be covariant, it can't contain a full reference to the `RwLock`, which can never be covariant (because it exposes a mutable reference to the underlying data structure). By reducing the data structure to the required pieces of `RwLock`, the rest falls in place. If there is a better way to do a test that tests successful compilation, please let me know. Fixes #80392
2022-06-22Fix debug info testRobin Raymond-5/+2
2022-06-20Auto merge of #97931 - xldenis:fix-if-let-source-scopes, r=nagisabors-0/+100
Fix `SourceScope` for `if let` bindings. Fixes #97799. I'm not sure how to test this properly, is there any way to observe the difference in behavior apart from `ui` tests? I'm worried that they would be overlooked in the case of a regression.
2022-06-15The type of the slice length field is architecture dependentWesley Wiser-4/+4
2022-06-15Add debuginfo test for if let lexical scopesWesley Wiser-0/+100
2022-06-15debuginfo: Fix NatVis for Rc and Arc with unsized pointees.Michael Woerister-40/+104
2022-06-14account for endianness in debuginfo for const argsb-naber-2/+2
2022-06-04Auto merge of #97191 - wesleywiser:main_thread_name, r=ChrisDentonbors-0/+51
Call the OS function to set the main thread's name on program init Normally, `Thread::spawn` takes care of setting the thread's name, if one was provided, but since the main thread wasn't created by calling `Thread::spawn`, we need to call that function in `std::rt::init`. This is mainly useful for system tools like debuggers and profilers which might show the thread name to a user. Prior to these changes, gdb and WinDbg would show all thread names except the main thread's name to a user. I've validated that this patch resolves the issue for both debuggers.
2022-06-04Update src/test/debuginfo/thread-names.rsWesley Wiser-0/+11
Co-authored-by: Chris Denton <ChrisDenton@users.noreply.github.com>
2022-05-27Call the OS function to set the main thread's name on program initWesley Wiser-0/+40
Normally, `Thread::spawn` takes care of setting the thread's name, if one was provided, but since the main thread wasn't created by calling `Thread::spawn`, we need to call that function in `std::rt::init`. This is mainly useful for system tools like debuggers and profilers which might show the thread name to a user. Prior to these changes, gdb and WinDbg would show all thread names except the main thread's name to a user. I've validated that this patch resolves the issue for both debuggers.
2022-05-24Add support for embedding pretty printers via the `#[debugger_visualizer]` ↵ridwanabdillahi-73/+221
attribute. Add tests for embedding pretty printers and update documentation. Ensure all error checking for `#[debugger_visualizer]` is done up front and not when the `debugger_visualizer` query is run. Clean up potential ODR violations when embedding pretty printers into the `__rustc_debug_gdb_scripts_section__` section. Respond to PR comments and update documentation.
2022-05-03Add support for a new attribute `#[debugger_visualizer]` to support ↵ridwanabdillahi-0/+82
embedding debugger visualizers into a generated PDB. Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries. Merge the queries for debugger visualizers into a single query. Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`. Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate. Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature. Respond to PR comments and minor cleanups.
2022-04-28std: update debuginfo check to match type definitionjoboet-1/+1
2022-04-22debuginfo: Emit ZST struct debuginfo for unit type when CPP-like debuginfo ↵Michael Woerister-0/+71
is enabled (instead of custom basic type).
2022-04-05Improve debuginfo test coverage for simple statics.Cliff L. Biffle-7/+83
- Re-enabled basic-types-globals which has been disabled since 2018 - Updated its now-rotted assertions about GDB's output to pass - Rewrote header comment describing some previous state of GDB behavior that didn't match either the checked-in assertions _or_ the current behavior, and so I assume has just been wrong for some time. - Copy-pasta'd the test into a version that uses LTO to check for regression on #90357, because I don't see a way to matrix the same test into several build configurations.
2022-03-24debuginfo: Fix debuginfo for Box<T> where T is unsized.Michael Woerister-4/+15
Before this fix, the debuginfo for the fields was generated from the struct defintion of Box<T>, but (at least at the moment) the compiler pretends that Box<T> is just a (fat) pointer, so the fields need to be `pointer` and `vtable` instead of `__0: Unique<T>` and `__1: Allocator`. This is meant as a temporary mitigation until we can make sure that simply treating Box as a regular struct in debuginfo does not cause too much breakage in the ecosystem.
2022-03-17Fix debuginfo tests with GDB 11.2Tom Tromey-8/+25
GDB 11.2 added support for DW_ATE_UTF, which caused some test failures. This fixes these tests by changing the format that is used, and adds a new test to verify that characters are emitted as something that GDB can print in a char-like way. Fixes #94458
2022-03-15Rollup merge of #94810 - michaelwoerister:fix-trait-pointer-debuginfo-names, ↵Matthias Krüger-0/+16
r=wesleywiser debuginfo: Fix bug in type name generation for dyn types with associated types but no other generic arguments. For types like `&dyn Future<Output=bool>` the compiler currently emits invalid types names in debuginfo. This PR fixes this. Before: ```txt // DWARF &dyn core::future::future::Future, Output=bool> // CodeView ref$<dyn$<core::future::future::Future,assoc$<Output,bool> > > > ``` After: ```txt // DWARF &dyn core::future::future::Future<Output=bool> // CodeView ref$<dyn$<core::future::future::Future<assoc$<Output,bool> > > > ``` These syntactically incorrect type names can cause downstream tools (e.g. debugger extensions) crash when trying to parse them. r? `@wesleywiser`
2022-03-15debuginfo: Refactor debuginfo generation for types -- Make generator-objects ↵Michael Woerister-8/+9
test case architecture independent.
2022-03-14debuginfo: change cpp-like naming for generator environments so that NatVis ↵Michael Woerister-0/+31
works for them
2022-03-14debuginfo: Refactor debuginfo generation for typesMichael Woerister-19/+20
This commit - changes names to use di_node instead of metadata - uniformly names all functions that build new debuginfo nodes build_xyz_di_node - renames CrateDebugContext to CodegenUnitDebugContext (which is more accurate) - moves TypeMap and functions that work directly work with it to a new type_map module - moves and reimplements enum related builder functions to a new enums module - splits enum debuginfo building for the native and cpp-like cases, since they are mostly separate - uses SmallVec instead of Vec in many places - removes the old infrastructure for dealing with recursion cycles (create_and_register_recursive_type_forward_declaration(), RecursiveTypeDescription, set_members_of_composite_type(), MemberDescription, MemberDescriptionFactory, prepare_xyz_metadata(), etc) - adds type_map::build_type_with_children() as a replacement for dealing with recursion cycles - adds many (doc-)comments explaining what's going on - changes cpp-like naming for C-Style enums so they don't get a enum$<...> name (because the NatVis visualizer does not apply to them) - fixes detection of what is a C-style enum because some enums where classified as C-style even though they have fields - changes the position of discriminant debuginfo node so it is consistently nested inside the top-level union instead of, sometimes, next to it
2022-03-10debuginfo: Fix bug in type name generation for dyn types with associated ↵Michael Woerister-0/+16
types but no other generic arguments.
2022-02-23Change `char` type in debuginfo to DW_ATE_UTFArlo Siemsen-5/+4
Rust previously encoded the `char` type as DW_ATE_unsigned_char. The more appropriate encoding is DW_ATE_UTF. Clang uses this same debug encoding for char32_t. This fixes the display of `char` types in Windows debuggers as well as LLDB.
2022-02-16debuginfo: Support fat pointers to unsized tuples.Michael Woerister-0/+23
2022-02-03Auto merge of #93432 - Kobzol:stable-hash-isize-hash-compression, r=the8472bors-2/+2
Compress amount of hashed bytes for `isize` values in StableHasher This is another attempt to land https://github.com/rust-lang/rust/pull/92103, this time hopefully with a correct implementation w.r.t. stable hashing guarantees. The previous PR was [reverted](https://github.com/rust-lang/rust/pull/93014) because it could produce the [same hash](https://github.com/rust-lang/rust/pull/92103#issuecomment-1014625442) for different values even in quite simple situations. I have since added a basic [test](https://github.com/rust-lang/rust/pull/93193) that should guard against that situation, I also added a new test in this PR, specialised for this optimization. ## Why this optimization helps Since the original PR, I have tried to analyze why this optimization even helps (and why it especially helps for `clap`). I found that the vast majority of stable-hashing `i64` actually comes from hashing `isize` (which is converted to `i64` in the stable hasher). I only found a single place where is this datatype used directly in the compiler, and this place has also been showing up in traces that I used to find out when is `isize` being hashed. This place is `rustc_span::FileName::DocTest`, however, I suppose that isizes also come from other places, but they might not be so easy to find (there were some other entries in the trace). `clap` hashes about 8.5 million `isize`s, and all of them fit into a single byte, which is why this optimization has helped it [quite a lot](https://github.com/rust-lang/rust/pull/92103#issuecomment-1005711861). Now, I'm not sure if special casing `isize` is the correct solution here, maybe something could be done with that `isize` inside `DocTest` or in other places, but that's for another discussion I suppose. In this PR, instead of hardcoding a special case inside `SipHasher128`, I instead put it into `StableHasher`, and only used it for `isize` (I tested that for `i64` it doesn't help, or at least not for `clap` and other few benchmarks that I was testing). ## New approach Since the most common case is a single byte, I added a fast path for hashing `isize` values which positive value fits within a single byte, and a cold path for the rest of the values. To avoid the previous correctness problem, we need to make sure that each unique `isize` value will produce a unique hash stream to the hasher. By hash stream I mean a sequence of bytes that will be hashed (a different sequence should produce a different hash, but that is of course not guaranteed). We have to distinguish different values that produce the same bit pattern when we combine them. For example, if we just simply skipped the leading zero bytes for values that fit within a single byte, `(0xFF, 0xFFFFFFFFFFFFFFFF)` and `(0xFFFFFFFFFFFFFFFF, 0xFF)` would send the same hash stream to the hasher, which must not happen. To avoid this situation, values `[0, 0xFE]` are hashed as a single byte. When we hash a larger (treating `isize` as `u64`) value, we first hash an additional byte `0xFF`. Since `0xFF` cannot occur when we apply the single byte optimization, we guarantee that the hash streams will be unique when hashing two values `(a, b)` and `(b, a)` if `a != b`: 1) When both `a` and `b` are within `[0, 0xFE]`, their hash streams will be different. 2) When neither `a` and `b` are within `[0, 0xFE]`, their hash streams will be different. 3) When `a` is within `[0, 0xFE]` and `b` isn't, when we hash `(a, b)`, the hash stream will definitely not begin with `0xFF`. When we hash `(b, a)`, the hash stream will definitely begin with `0xFF`. Therefore the hash streams will be different. r? `@the8472`
2022-02-02Auto merge of #93154 - ↵bors-50/+59
michaelwoerister:fix-generic-closure-and-generator-debuginfo, r=wesleywiser debuginfo: Make sure that type names for closure and generator environments are unique in debuginfo. Before this change, closure/generator environments coming from different instantiations of the same generic function were all assigned the same name even though they were distinct types with potentially different data layout. Now we append the generic arguments of the originating function to the type name. This commit also emits `{closure_env#0}` as the name of these types in order to disambiguate them from the accompanying closure function (which keeps being called `{closure#0}`). Previously both were assigned the same name. NOTE: Changing debuginfo names like this can break pretty printers and other debugger plugins. I think it's OK in this particular case because the names we are changing were ambiguous anyway. In general though it would be great to have a process for doing changes like these.
2022-02-01debuginfo: Make sure that type names for closure and generator environments ↵Michael Woerister-50/+59
are unique in debuginfo. Before this change, closure/generator environments coming from different instantiations of the same generic function were all assigned the same name even though they were distinct types with potentially different data layout. Now we append the generic arguments of the originating function to the type name. This commit also emits '{closure_env#0}' as the name of these types in order to disambiguate them from the accompanying closure function '{closure#0}'. Previously both were assigned the same name.
2022-01-30Compress amount of hashed bytes for `isize` values in StableHasherJakub Beránek-2/+2