From e13e1e4c0c3253d25e2571ed7e58b3a02e28e922 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Tue, 12 Aug 2025 17:13:13 +0800 Subject: fix(debuginfo): handle false positives in overflow check --- tests/debuginfo/recursive-struct.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/debuginfo') diff --git a/tests/debuginfo/recursive-struct.rs b/tests/debuginfo/recursive-struct.rs index 5be90992848..427a7100a4f 100644 --- a/tests/debuginfo/recursive-struct.rs +++ b/tests/debuginfo/recursive-struct.rs @@ -62,6 +62,7 @@ use self::Opt::{Empty, Val}; use std::boxed::Box as B; +use std::marker::PhantomData; enum Opt { Empty, @@ -98,6 +99,11 @@ struct LongCycleWithAnonymousTypes { value: usize, } +struct Expanding { + a: PhantomData, + b: *const Expanding<(T, T)>, +} + // This test case makes sure that recursive structs are properly described. The Node structs are // generic so that we can have a new type (that newly needs to be described) for the different // cases. The potential problem with recursive types is that the DI generation algorithm gets @@ -205,6 +211,9 @@ fn main() { value: 30 }))))); + // This type can generate new instances infinitely if not handled properly. + std::hint::black_box(Expanding::<()> { a: PhantomData, b: std::ptr::null() }); + zzz(); // #break } -- cgit 1.4.1-3-g733a5 From 12eb1a0bce83b569f0500f0a78972a1102906264 Mon Sep 17 00:00:00 2001 From: nilptr Date: Sun, 10 Aug 2025 22:16:17 +0800 Subject: feat(lldb debug info): improve enum value formatting in lldb --- src/etc/lldb_providers.py | 35 +++++++++++++++++------------------ tests/debuginfo/borrowed-enum.rs | 6 +++--- 2 files changed, 20 insertions(+), 21 deletions(-) (limited to 'tests/debuginfo') diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 98426e42423..46f483de388 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -1,4 +1,5 @@ from __future__ import annotations +import re import sys from typing import List, TYPE_CHECKING @@ -409,6 +410,14 @@ class MSVCStrSyntheticProvider: else: return "&str" +def _getVariantName(variant) -> str: + """ + Since the enum variant's type name is in the form `TheEnumName::TheVariantName$Variant`, + we can extract `TheVariantName` from it for display purpose. + """ + s = variant.GetType().GetName() + match = re.search(r'::([^:]+)\$Variant$', s) + return match.group(1) if match else "" class ClangEncodedEnumProvider: """Pretty-printer for 'clang-encoded' enums support implemented in LLDB""" @@ -424,37 +433,27 @@ class ClangEncodedEnumProvider: return True def num_children(self) -> int: - if self.is_default: - return 1 - return 2 + return 1 - def get_child_index(self, name: str) -> int: - if name == ClangEncodedEnumProvider.VALUE_MEMBER_NAME: - return 0 - if name == ClangEncodedEnumProvider.DISCRIMINANT_MEMBER_NAME: - return 1 + def get_child_index(self, _name: str) -> int: return -1 def get_child_at_index(self, index: int) -> SBValue: if index == 0: - return self.variant.GetChildMemberWithName( + value = self.variant.GetChildMemberWithName( ClangEncodedEnumProvider.VALUE_MEMBER_NAME ) - if index == 1: - return self.variant.GetChildMemberWithName( - ClangEncodedEnumProvider.DISCRIMINANT_MEMBER_NAME + return value.CreateChildAtOffset( + _getVariantName(self.variant), + 0, + value.GetType() ) + return None def update(self): all_variants = self.valobj.GetChildAtIndex(0) index = self._getCurrentVariantIndex(all_variants) self.variant = all_variants.GetChildAtIndex(index) - self.is_default = ( - self.variant.GetIndexOfChildWithName( - ClangEncodedEnumProvider.DISCRIMINANT_MEMBER_NAME - ) - == -1 - ) def _getCurrentVariantIndex(self, all_variants: SBValue) -> int: default_index = 0 diff --git a/tests/debuginfo/borrowed-enum.rs b/tests/debuginfo/borrowed-enum.rs index 517b439ff15..893dd777bcd 100644 --- a/tests/debuginfo/borrowed-enum.rs +++ b/tests/debuginfo/borrowed-enum.rs @@ -22,11 +22,11 @@ // lldb-command:run // lldb-command:v *the_a_ref -// lldb-check:(borrowed_enum::ABC) *the_a_ref = { value = { x = 0 y = 8970181431921507452 } $discr$ = 0 } +// lldb-check:(borrowed_enum::ABC) *the_a_ref = { TheA = { x = 0 y = 8970181431921507452 } } // lldb-command:v *the_b_ref -// lldb-check:(borrowed_enum::ABC) *the_b_ref = { value = { 0 = 0 1 = 286331153 2 = 286331153 } $discr$ = 1 } +// lldb-check:(borrowed_enum::ABC) *the_b_ref = { TheB = { 0 = 0 1 = 286331153 2 = 286331153 } } // lldb-command:v *univariant_ref -// lldb-check:(borrowed_enum::Univariant) *univariant_ref = { value = { 0 = 4820353753753434 } } +// lldb-check:(borrowed_enum::Univariant) *univariant_ref = { TheOnlyCase = { 0 = 4820353753753434 } } #![allow(unused_variables)] -- cgit 1.4.1-3-g733a5 From d61353ff43a328c9d5116f6dfb5820e852449d11 Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Fri, 22 Aug 2025 15:58:52 +0800 Subject: tests: Ignore basic-stepping.rs on LoongArch --- tests/debuginfo/basic-stepping.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/debuginfo') diff --git a/tests/debuginfo/basic-stepping.rs b/tests/debuginfo/basic-stepping.rs index 6e1344d22a5..e7a70c8b087 100644 --- a/tests/debuginfo/basic-stepping.rs +++ b/tests/debuginfo/basic-stepping.rs @@ -3,6 +3,7 @@ //! Regression test for . //@ ignore-aarch64: Doesn't work yet. +//@ ignore-loongarch64: Doesn't work yet. //@ compile-flags: -g // gdb-command: run -- cgit 1.4.1-3-g733a5