summary refs log tree commit diff
path: root/src/test/debuginfo
AgeCommit message (Collapse)AuthorLines
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-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
2022-01-28Auto merge of #93006 - michaelwoerister:fix-unsized-ptr-debuginfo, ↵bors-36/+62
r=davidtwco,oli-obk Fix debuginfo for pointers/references to unsized types This PR makes the compiler emit fat pointer debuginfo in all cases. Before, we sometimes got thin-pointer debuginfo, making it impossible to fully interpret the pointed to memory in debuggers. The code is actually cleaner now, especially around generation of trait object pointer debuginfo. Fixes https://github.com/rust-lang/rust/issues/92718 ~~Blocked on https://github.com/rust-lang/rust/pull/92729.~~
2022-01-27[debuginfo] Fix and unify handling of fat pointers in debuginfo: Fix some ↵Michael Woerister-32/+31
debuginfo tests for old GDB versions and 32-bit targets.
2022-01-24Fix vec-slices debuginfo test for GDB.Michael Woerister-11/+10
2022-01-24[debuginfo] Fix and unify handling of fat pointers in debuginfo.Michael Woerister-6/+34
2022-01-24Revert "Do not hash leading zero bytes of i64 numbers in Sip128 hasher"Jakub Beránek-2/+2
2022-01-04Do not hash zero bytes of i64 and u32 in Sip128 hasherJakub Beránek-2/+2
2021-11-28tests: Ignore `test/debuginfo/rc_arc.rs` on windows-gnuVadim Petrochenkov-1/+1
The tests checks some pretty-printer output, but pretty-printers are not embedded on windows-gnu
2021-10-11Fix function-names test for GDB 10.1Michael Woerister-15/+16
2021-09-26Remove box syntax from most places in src/test outside of the issues direst31-100/+83
2021-09-22Rollup merge of #89127 - wesleywiser:reenable_mutex_debuginfo_test, r=ehussthe8472-7/+5
Re-enable the `src/test/debuginfo/mutex.rs` test on Windows This test required a newer version of cdb than was previously enabled in CI thus leading to some bitrot in the test since the time it was originally created. With the update to the `windows-latest` image last week, we're now running this test in CI and thus uncovered the regression. I've updated the test and it now passes. r? `@ehuss`
2021-09-22Auto merge of #88629 - wesleywiser:fix_debuginfo_for_scalarpair_params, ↵bors-0/+101
r=oli-obk Fix debuginfo for parameters passed via the ScalarPair abi on Windows Mark all of these as locals so the debugger does not try to interpret them as being a pointer to the value. This extends the approach used in #81898. Fixes #88625
2021-09-20Re-enable the `src/test/debuginfo/mutex.rs` test on WindowsWesley Wiser-7/+5
This test required a newer version of cdb than was previously enabled in CI thus leading to some bitrot in the test since the time it was originally created. With the update to the `windows-latest` image last week, we're now running this test in CI and thus uncovered the regression. I've updated the test and it now passes.
2021-09-20Auto merge of #88842 - wesleywiser:fix_dbg_tests_windows_sdk, r=michaelwoeristerbors-89/+58
Fix debuginfo tests for the latest version of the Windows SDK. Re-enable the tests that were disabled to fix CI. Changes: - Cdb now correctly visualizes enums. - Cdb doesn't render emoji characters in `OSStr` anymore. - Cdb doesn't always render `str` correctly (#88840)
2021-09-15Disable debuginfo test on Windows that fails in new cdb version.Eric Huss-0/+2
2021-09-13Fix debuginfo for ScalarPair abi parametersWesley Wiser-9/+10
Mark all of these as locals so the debugger does not try to interpret them as being a pointer to the value. This extends the approach used in PR #81898.
2021-09-13Add test to show issue with ScalarPair parametersWesley Wiser-0/+100
2021-09-10Fix debuginfo tests for the latest version of the Windows SDK.Wesley Wiser-77/+58
- Cdb now correctly visualizes enums. - Cdb doesn't render emoji characters in `OSStr` anymore. - Cdb doesn't always render `str` correctly (#88840)
2021-09-10Revert "Temporarily ignore some debuginfo tests on windows."Wesley Wiser-12/+0
This reverts commit 8059bc1069b88a51ec2dfc2483854b9a854b1994.
2021-09-10Temporarily ignore some debuginfo tests on windows.Mara Bos-0/+12
2021-08-30`feature(const_param_types)` -> `feature(adt_const_params)`lcnr-1/+1
2021-08-30`feature(const_generics)` -> `feature(const_param_types)`lcnr-2/+2
2021-08-27Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearthbors-0/+383
Rollup of 11 pull requests Successful merges: - #87832 (Fix debugger stepping behavior with `match` expressions) - #88123 (Make spans for tuple patterns in E0023 more precise) - #88215 (Reland #83738: "rustdoc: Don't load all extern crates unconditionally") - #88216 (Don't stabilize creation of TryReserveError instances) - #88270 (Handle type ascription type ops in NLL HRTB diagnostics) - #88289 (Fixes for LLVM change 0f45c16f2caa7c035e5c3edd40af9e0d51ad6ba7) - #88320 (type_implements_trait consider obligation failure on overflow) - #88332 (Add argument types tait tests) - #88340 (Add `c_size_t` and `c_ssize_t` to `std::os::raw`.) - #88346 (Revert "Add type of a let tait test impl trait straight in let") - #88348 (Add field types tait tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-08-26Add test for stepping though `match` expressionsWesley Wiser-0/+383
2021-08-24tests: support -Zsymbol-mangling-version=v0 being the default.Eduard-Mihai Burtescu-2/+2
2021-08-16Fix a debuginfo testCameron Steffen-1/+3