From ed55daa1e452f08e3ae16d8fc33788821b881717 Mon Sep 17 00:00:00 2001 From: JayanAXHF Date: Thu, 19 Feb 2026 18:37:33 +0530 Subject: [PATCH 1/7] feat: add a nightly feature for Backtrace Frame access --- library/std/src/backtrace.rs | 40 +++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index 99724e29e02b2..002b1575c8bfb 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -159,7 +159,10 @@ enum RawFrame { Fake, } -struct BacktraceSymbol { +/// A single symbol associated with a backtrace frame, which may include a +/// function name, filename, line number, and column number. +#[unstable(feature = "backtrace_internals_accessors", issue = "122899")] +pub struct BacktraceSymbol { name: Option>, filename: Option, lineno: Option, @@ -207,6 +210,41 @@ impl fmt::Debug for BacktraceFrame { } } +///NOTE: This is never intended to become stable. It doesn't have an ACP +/// Its meant to help us port the tests mentioned in issue #122899 +#[unstable(feature = "backtrace_internals_accessors", issue = "122899")] +impl BacktraceFrame { + /// Returns the instruction pointer associated with this frame. + pub fn ip(&self) -> *mut c_void { + self.frame.ip() + } + + /// Returns the symbols associated with this frame, if any. + pub fn symbols(&self) -> &[BacktraceSymbol] { + &self.symbols + } + + /// Returns the base address of the module this frame belongs to, if available. + pub fn module_base_address(&self) -> Option<*mut c_void> { + match &self.frame { + RawFrame::Actual(frame) => frame.module_base_address(), + #[cfg(test)] + RawFrame::Fake => None, + } + } +} + +///NOTE: This is never intended to become stable. It doesn't have an ACP +/// Its meant to help us port the tests mentioned in issue #122899 +impl BacktraceSymbol { + /// Returns the name of this symbol, if available. + #[unstable(feature = "backtrace_internals_accessors", issue = "122899")] + pub fn name(&self) -> Option<&[u8]> { + self.name.as_deref() + } +} + +#[unstable(feature = "backtrace_internals_accessors", issue = "122899")] impl fmt::Debug for BacktraceSymbol { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { // FIXME: improve formatting: https://github.com/rust-lang/rust/issues/65280 From e255ee5240c15363006ae347af44e4989b22e147 Mon Sep 17 00:00:00 2001 From: JayanAXHF Date: Thu, 19 Feb 2026 12:59:48 +0530 Subject: [PATCH 2/7] test: port `no_debuginfo` to the testsuite --- .../all_frames_have_module_base_address.rs | 20 +++++++++++ .../no_debuginfo/all_frames_have_symbols.rs | 33 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/ui/no_debuginfo/all_frames_have_module_base_address.rs create mode 100644 tests/ui/no_debuginfo/all_frames_have_symbols.rs diff --git a/tests/ui/no_debuginfo/all_frames_have_module_base_address.rs b/tests/ui/no_debuginfo/all_frames_have_module_base_address.rs new file mode 100644 index 0000000000000..35e66023a5b63 --- /dev/null +++ b/tests/ui/no_debuginfo/all_frames_have_module_base_address.rs @@ -0,0 +1,20 @@ +//@ compile-flags: -Cstrip=none -Cdebuginfo=none +//@ run-pass +#![feature(backtrace_frames)] +#![feature(backtrace_internals_accessors)] +use std::backtrace; + +fn main() { + let mut missing_base_addresses = 0; + let btrace = backtrace::Backtrace::force_capture(); + let frames = btrace.frames(); + for frame in frames { + if frame.module_base_address().is_none() { + missing_base_addresses += 1; + } + } + + if cfg!(windows) { + assert_eq!(missing_base_addresses, 0); + } +} diff --git a/tests/ui/no_debuginfo/all_frames_have_symbols.rs b/tests/ui/no_debuginfo/all_frames_have_symbols.rs new file mode 100644 index 0000000000000..f8ff003be4073 --- /dev/null +++ b/tests/ui/no_debuginfo/all_frames_have_symbols.rs @@ -0,0 +1,33 @@ +//@ compile-flags: -Cstrip=none -Cdebuginfo=none +//@ run-pass +#![feature(backtrace_frames)] +#![feature(backtrace_internals_accessors)] +use std::backtrace; +fn main() { + let mut missing_symbols = 0; + let mut has_symbols = 0; + let btrace = backtrace::Backtrace::force_capture(); + let frames = btrace.frames(); + for frame in frames { + let mut any = false; + for sym in frame.symbols() { + if sym.name().is_some() { + any = true; + break; + } + } + if any { + has_symbols += 1; + } else if !frame.ip().is_null() { + missing_symbols += 1; + } + } + + // FIXME(#346) currently on MinGW we can't symbolize kernel32.dll and other + // system libraries, which means we miss the last few symbols. + if cfg!(windows) && cfg!(target_env = "gnu") { + assert!(missing_symbols < has_symbols && has_symbols > 4); + } else { + assert_eq!(missing_symbols, 0); + } +} From a7b81529303c10044d397df97d4829616db00ddc Mon Sep 17 00:00:00 2001 From: JayanAXHF Date: Fri, 20 Feb 2026 00:11:11 +0530 Subject: [PATCH 3/7] chore: update `tests/ui/README.md` --- library/backtrace | 2 +- src/doc/book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/tools/cargo | 2 +- tests/ui/README.md | 18 +++++++++++------- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/library/backtrace b/library/backtrace index 28ec93b503bf0..b65ab935fb2e0 160000 --- a/library/backtrace +++ b/library/backtrace @@ -1 +1 @@ -Subproject commit 28ec93b503bf0410745bc3d571bf3dc1caac3019 +Subproject commit b65ab935fb2e0d59dba8966ffca09c9cc5a5f57c diff --git a/src/doc/book b/src/doc/book index 05d114287b7d6..39aeceaa3aeab 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 05d114287b7d6f6c9253d5242540f00fbd6172ab +Subproject commit 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe diff --git a/src/doc/nomicon b/src/doc/nomicon index b8f254a991b8b..050c002a360fa 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit b8f254a991b8b7e8f704527f0d4f343a4697dfa9 +Subproject commit 050c002a360fa45b701ea34feed7a860dc8a41bf diff --git a/src/doc/reference b/src/doc/reference index addd0602c819b..28b5a54419985 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit addd0602c819b6526b9cc97653b0fadca395528c +Subproject commit 28b5a54419985f03db5294de5eede71b6665b594 diff --git a/src/tools/cargo b/src/tools/cargo index ce69df6f72a3b..85eff7c80277b 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit ce69df6f72a3b6a2b5c722ba68ddef255344b31c +Subproject commit 85eff7c80277b57f78b11e28d14154ab12fcf643 diff --git a/tests/ui/README.md b/tests/ui/README.md index 16cdde08431c0..b88fdf145af19 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -1,12 +1,12 @@ # UI Test Suite Categories -This is a high-level summary of the organization of the UI test suite (`tests/ui/`). It is not intended to be *prescriptive*, but instead provide a quick survey of existing groupings. +This is a high-level summary of the organization of the UI test suite (`tests/ui/`). It is not intended to be _prescriptive_, but instead provide a quick survey of existing groupings. For now, only immediate subdirectories under `tests/ui/` are described, but these subdirectories can themselves include a `SUMMARY.md` to further describe their own organization and intent, should that be helpful. ## `tests/ui/abi` -These tests deal with *Application Binary Interfaces* (ABI), mostly relating to function name mangling (and the `#[no_mangle]` attribute), calling conventions, or compiler flags which affect ABI. +These tests deal with _Application Binary Interfaces_ (ABI), mostly relating to function name mangling (and the `#[no_mangle]` attribute), calling conventions, or compiler flags which affect ABI. Tests for unsupported ABIs can be made cross-platform by using the `extern "rust-invalid"` ABI, which is considered unsupported on every platform. @@ -198,13 +198,13 @@ See [Conditional compilation | Reference](https://doc.rust-lang.org/reference/co ## `tests/ui/check-cfg/`: Configuration Checks -Tests for the `--check-cfg` compiler mechanism for checking cfg configurations, for `#[cfg(..)]` and `cfg!(..)`. +Tests for the `--check-cfg` compiler mechanism for checking cfg configurations, for `#[cfg(..)]` and `cfg!(..)`. See [Checking conditional configurations | The rustc book](https://doc.rust-lang.org/rustc/check-cfg.html). ## `tests/ui/closure-expected-type/`: Closure type inference -Tests targeted at how we deduce the types of closure arguments. This process is a result of some heuristics which take into account the *expected type* we have alongside the *actual types* that we get from inputs. +Tests targeted at how we deduce the types of closure arguments. This process is a result of some heuristics which take into account the _expected type_ we have alongside the _actual types_ that we get from inputs. **FIXME**: Appears to have significant overlap with `tests/ui/closure_context` and `tests/ui/functions-closures/closure-expected-type`. Needs further investigation. @@ -272,7 +272,7 @@ This directory is actually for the standard library [`std::process::Command`](ht Some traits' implementation must be compared with their definition, checking for problems such as the implementation having stricter requirements (such as needing to implement `Copy`). -This subdirectory is *not* intended comparison traits (`PartialEq`, `Eq`, `PartialOrd`, `Ord`). +This subdirectory is _not_ intended comparison traits (`PartialEq`, `Eq`, `PartialOrd`, `Ord`). ## `tests/ui/compile-flags/` @@ -885,7 +885,7 @@ Tests on [AST lowering](https://rustc-dev-guide.rust-lang.org/ast-lowering.html) ## `tests/ui/lto/` -Exercise *Link-Time Optimization* (LTO), involving the flags `-C lto` or `-Z thinlto`. +Exercise _Link-Time Optimization_ (LTO), involving the flags `-C lto` or `-Z thinlto`. ## `tests/ui/lub-glb/`: LUB/GLB algorithm update @@ -973,6 +973,10 @@ See [RFC 3550 New Range](https://github.com/rust-lang/rfcs/blob/master/text/3550 Tests for Non-lexical lifetimes. See [RFC 2094 NLL](https://rust-lang.github.io/rfcs/2094-nll.html). +## `tests/ui/no_debuginfo`: without_debuginfo test ported from backtrace-rs + +Tests for behavior when debug information is not available, ported from `backtrace-rs`'s `without_debuginfo` crate's test. + ## `tests/ui/no_std/` Tests for where the standard library is disabled through `#![no_std]`. @@ -1368,7 +1372,7 @@ Generic collection of tests for suggestions, when no more specific directories a ## `tests/ui/svh/`: Strict Version Hash -Tests on the *Strict Version Hash* (SVH, also known as the "crate hash"). +Tests on the _Strict Version Hash_ (SVH, also known as the "crate hash"). See [Strict Version Hash](https://rustc-dev-guide.rust-lang.org/backend/libs-and-metadata.html#strict-version-hash). From 2ee2332cd4adcaf45406c6b8dcb6b44a4f37bd3a Mon Sep 17 00:00:00 2001 From: JayanAXHF Date: Fri, 20 Feb 2026 00:36:21 +0530 Subject: [PATCH 4/7] fixup! chore: update `tests/ui/README.md` --- library/backtrace | 2 +- src/doc/book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/tools/cargo | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/backtrace b/library/backtrace index b65ab935fb2e0..28ec93b503bf0 160000 --- a/library/backtrace +++ b/library/backtrace @@ -1 +1 @@ -Subproject commit b65ab935fb2e0d59dba8966ffca09c9cc5a5f57c +Subproject commit 28ec93b503bf0410745bc3d571bf3dc1caac3019 diff --git a/src/doc/book b/src/doc/book index 39aeceaa3aeab..05d114287b7d6 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe +Subproject commit 05d114287b7d6f6c9253d5242540f00fbd6172ab diff --git a/src/doc/nomicon b/src/doc/nomicon index 050c002a360fa..b8f254a991b8b 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit 050c002a360fa45b701ea34feed7a860dc8a41bf +Subproject commit b8f254a991b8b7e8f704527f0d4f343a4697dfa9 diff --git a/src/doc/reference b/src/doc/reference index 28b5a54419985..addd0602c819b 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 28b5a54419985f03db5294de5eede71b6665b594 +Subproject commit addd0602c819b6526b9cc97653b0fadca395528c diff --git a/src/tools/cargo b/src/tools/cargo index 85eff7c80277b..ce69df6f72a3b 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 85eff7c80277b57f78b11e28d14154ab12fcf643 +Subproject commit ce69df6f72a3b6a2b5c722ba68ddef255344b31c From f245f105bd4332cbf328ecabb4c6ff15ed7d3412 Mon Sep 17 00:00:00 2001 From: JayanAXHF Date: Fri, 20 Feb 2026 15:17:37 +0530 Subject: [PATCH 5/7] test: add debug info for the test to find the missing symbols --- tests/ui/no_debuginfo/all_frames_have_symbols.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/ui/no_debuginfo/all_frames_have_symbols.rs b/tests/ui/no_debuginfo/all_frames_have_symbols.rs index f8ff003be4073..ed4268693094f 100644 --- a/tests/ui/no_debuginfo/all_frames_have_symbols.rs +++ b/tests/ui/no_debuginfo/all_frames_have_symbols.rs @@ -8,7 +8,8 @@ fn main() { let mut has_symbols = 0; let btrace = backtrace::Backtrace::force_capture(); let frames = btrace.frames(); - for frame in frames { + let mut missing_symbol_indices = Vec::new(); + for (i, frame) in frames.iter().enumerate() { let mut any = false; for sym in frame.symbols() { if sym.name().is_some() { @@ -20,6 +21,7 @@ fn main() { has_symbols += 1; } else if !frame.ip().is_null() { missing_symbols += 1; + missing_symbol_indices.push(i); } } @@ -28,6 +30,10 @@ fn main() { if cfg!(windows) && cfg!(target_env = "gnu") { assert!(missing_symbols < has_symbols && has_symbols > 4); } else { + for i in missing_symbol_indices { + eprintln!("missing symbol for frame {i}: {:#?}", frames[i]); + } + eprintln!("Full erroneous backtrace: {:#?}", btrace); assert_eq!(missing_symbols, 0); } } From a2e9dadde1a6c86cc013e241504316cfd71cb1d4 Mon Sep 17 00:00:00 2001 From: JayanAXHF Date: Fri, 20 Feb 2026 16:49:04 +0530 Subject: [PATCH 6/7] fixup chore: revert formatting changes --- tests/ui/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/ui/README.md b/tests/ui/README.md index b88fdf145af19..6e4d707392a00 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -1,12 +1,12 @@ # UI Test Suite Categories -This is a high-level summary of the organization of the UI test suite (`tests/ui/`). It is not intended to be _prescriptive_, but instead provide a quick survey of existing groupings. +This is a high-level summary of the organization of the UI test suite (`tests/ui/`). It is not intended to be *prescriptive*, but instead provide a quick survey of existing groupings. For now, only immediate subdirectories under `tests/ui/` are described, but these subdirectories can themselves include a `SUMMARY.md` to further describe their own organization and intent, should that be helpful. ## `tests/ui/abi` -These tests deal with _Application Binary Interfaces_ (ABI), mostly relating to function name mangling (and the `#[no_mangle]` attribute), calling conventions, or compiler flags which affect ABI. +These tests deal with *Application Binary Interfaces* (ABI), mostly relating to function name mangling (and the `#[no_mangle]` attribute), calling conventions, or compiler flags which affect ABI. Tests for unsupported ABIs can be made cross-platform by using the `extern "rust-invalid"` ABI, which is considered unsupported on every platform. @@ -198,13 +198,13 @@ See [Conditional compilation | Reference](https://doc.rust-lang.org/reference/co ## `tests/ui/check-cfg/`: Configuration Checks -Tests for the `--check-cfg` compiler mechanism for checking cfg configurations, for `#[cfg(..)]` and `cfg!(..)`. +Tests for the `--check-cfg` compiler mechanism for checking cfg configurations, for `#[cfg(..)]` and `cfg!(..)`. See [Checking conditional configurations | The rustc book](https://doc.rust-lang.org/rustc/check-cfg.html). ## `tests/ui/closure-expected-type/`: Closure type inference -Tests targeted at how we deduce the types of closure arguments. This process is a result of some heuristics which take into account the _expected type_ we have alongside the _actual types_ that we get from inputs. +Tests targeted at how we deduce the types of closure arguments. This process is a result of some heuristics which take into account the *expected type* we have alongside the *actual types* that we get from inputs. **FIXME**: Appears to have significant overlap with `tests/ui/closure_context` and `tests/ui/functions-closures/closure-expected-type`. Needs further investigation. @@ -272,7 +272,7 @@ This directory is actually for the standard library [`std::process::Command`](ht Some traits' implementation must be compared with their definition, checking for problems such as the implementation having stricter requirements (such as needing to implement `Copy`). -This subdirectory is _not_ intended comparison traits (`PartialEq`, `Eq`, `PartialOrd`, `Ord`). +This subdirectory is *not* intended comparison traits (`PartialEq`, `Eq`, `PartialOrd`, `Ord`). ## `tests/ui/compile-flags/` @@ -885,7 +885,7 @@ Tests on [AST lowering](https://rustc-dev-guide.rust-lang.org/ast-lowering.html) ## `tests/ui/lto/` -Exercise _Link-Time Optimization_ (LTO), involving the flags `-C lto` or `-Z thinlto`. +Exercise *Link-Time Optimization* (LTO), involving the flags `-C lto` or `-Z thinlto`. ## `tests/ui/lub-glb/`: LUB/GLB algorithm update @@ -1372,7 +1372,7 @@ Generic collection of tests for suggestions, when no more specific directories a ## `tests/ui/svh/`: Strict Version Hash -Tests on the _Strict Version Hash_ (SVH, also known as the "crate hash"). +Tests on the *Strict Version Hash* (SVH, also known as the "crate hash"). See [Strict Version Hash](https://rustc-dev-guide.rust-lang.org/backend/libs-and-metadata.html#strict-version-hash). From a54b64265554614d6c5d7b0cb93d16309960e98d Mon Sep 17 00:00:00 2001 From: Jayan Sunil Date: Tue, 24 Feb 2026 09:27:24 +0000 Subject: [PATCH 7/7] fix: add exception for aarch64-unknown-linux-gnu --- tests/ui/no_debuginfo/all_frames_have_symbols.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/ui/no_debuginfo/all_frames_have_symbols.rs b/tests/ui/no_debuginfo/all_frames_have_symbols.rs index ed4268693094f..a2001c98162b2 100644 --- a/tests/ui/no_debuginfo/all_frames_have_symbols.rs +++ b/tests/ui/no_debuginfo/all_frames_have_symbols.rs @@ -29,6 +29,11 @@ fn main() { // system libraries, which means we miss the last few symbols. if cfg!(windows) && cfg!(target_env = "gnu") { assert!(missing_symbols < has_symbols && has_symbols > 4); + } else if cfg!(all(target_os = "linux", target_env = "gnu")) { + //NOTE: The reason we allow one missing symbol is because the frame for the + // `__libc_start_main` fn doesn't have a symbol. See the discussion in + // #152860 for more details. + assert!(missing_symbols < has_symbols && missing_symbols <= 1) } else { for i in missing_symbol_indices { eprintln!("missing symbol for frame {i}: {:#?}", frames[i]);