From 81997094e6e38da15a8939c7a8ab8aae2e00e09a Mon Sep 17 00:00:00 2001 From: The 8472 Date: Mon, 11 Dec 2023 01:08:30 +0100 Subject: [PATCH] update debug providers to match new RawVec capacity field --- src/etc/gdb_providers.py | 6 +++++- src/etc/lldb_providers.py | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/etc/gdb_providers.py b/src/etc/gdb_providers.py index e851aa62634..7d7277d2408 100644 --- a/src/etc/gdb_providers.py +++ b/src/etc/gdb_providers.py @@ -154,7 +154,11 @@ class StdVecDequeProvider(printer_base): self._valobj = valobj self._head = int(valobj["head"]) self._size = int(valobj["len"]) - self._cap = int(valobj["buf"]["cap"]) + # BACKCOMPAT: rust 1.75 + cap = valobj["buf"]["cap"] + if cap.type.code != gdb.TYPE_CODE_INT: + cap = cap[ZERO_FIELD] + self._cap = int(cap) self._data_ptr = unwrap_unique_or_non_null(valobj["buf"]["ptr"]) def to_string(self): diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 4c86b214646..cfb3f0a4eae 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -267,7 +267,8 @@ class StdVecSyntheticProvider: """Pretty-printer for alloc::vec::Vec struct Vec { buf: RawVec, len: usize } - struct RawVec { ptr: Unique, cap: usize, ... } + rust 1.75: struct RawVec { ptr: Unique, cap: usize, ... } + rust 1.76: struct RawVec { ptr: Unique, cap: Cap(usize), ... } rust 1.31.1: struct Unique { pointer: NonZero<*const T>, ... } rust 1.33.0: struct Unique { pointer: *const T, ... } rust 1.62.0: struct Unique { pointer: NonNull, ... } @@ -390,7 +391,10 @@ class StdVecDequeSyntheticProvider: self.head = self.valobj.GetChildMemberWithName("head").GetValueAsUnsigned() self.size = self.valobj.GetChildMemberWithName("len").GetValueAsUnsigned() self.buf = self.valobj.GetChildMemberWithName("buf") - self.cap = self.buf.GetChildMemberWithName("cap").GetValueAsUnsigned() + cap = self.buf.GetChildMemberWithName("cap") + if cap.GetType().num_fields == 1: + cap = cap.GetChildAtIndex(0) + self.cap = cap.GetValueAsUnsigned() self.data_ptr = unwrap_unique_or_non_null(self.buf.GetChildMemberWithName("ptr"))