[llvm] 1c9a81b - Fix gdb pretty printers for libSupport
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 22:53:24 PDT 2024
Author: David Blaikie
Date: 2024-06-19T05:50:08Z
New Revision: 1c9a81b2bd91e8cd9baf742fa66650eefbaf552c
URL: https://github.com/llvm/llvm-project/commit/1c9a81b2bd91e8cd9baf742fa66650eefbaf552c
DIFF: https://github.com/llvm/llvm-project/commit/1c9a81b2bd91e8cd9baf742fa66650eefbaf552c.diff
LOG: Fix gdb pretty printers for libSupport
Remove the testing for std::optional - it was originally for
llvm::Optional, but now that that doesn't exist and we use
std::optional, testing for that pretty printer should live, wherever the
pretty printer lives, not here in LLVM.
And the PointerIntPair pretty printer bit rotted due to changes in
PointerIntPair, 875391728c11339c8a6cd3338bcaa5ec0ffc2496.
Added:
Modified:
cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.cpp
cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.gdb
llvm/utils/gdb-scripts/prettyprinters.py
Removed:
################################################################################
diff --git a/cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.cpp b/cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.cpp
index 8c5c5da83428c..737d9bd38c27c 100644
--- a/cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.cpp
+++ b/cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.cpp
@@ -19,8 +19,6 @@ llvm::DenseMap<int, int> DenseMap = {{4, 5}, {6, 7}};
llvm::StringMap<int> StringMap = {{"foo", 123}, {"bar", 456}};
llvm::Expected<int> ExpectedValue(8);
llvm::Expected<int> ExpectedError(llvm::createStringError(""));
-std::optional<int> OptionalValue(9);
-std::optional<int> OptionalNone(std::nullopt);
llvm::SmallVector<int, 5> SmallVector = {10, 11, 12};
llvm::SmallString<5> SmallString("foo");
llvm::StringRef StringRef = "bar";
@@ -69,7 +67,5 @@ int main() {
dont_strip(MutableArrayRef);
dont_strip(ExpectedValue);
dont_strip(ExpectedError);
- dont_strip(OptionalValue);
- dont_strip(OptionalNone);
return result; // Non-zero return value is OK.
}
diff --git a/cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.gdb b/cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.gdb
index 6222ab84ed8ca..de6738e53bb51 100644
--- a/cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.gdb
+++ b/cross-project-tests/debuginfo-tests/llvm-prettyprinters/gdb/llvm-support.gdb
@@ -22,12 +22,6 @@ p ExpectedValue
# CHECK: llvm::Expected is error
p ExpectedError
-# CHECK: llvm::Optional = {value = 9}
-p OptionalValue
-
-# CHECK: llvm::Optional is not initialized
-p OptionalNone
-
# CHECK: llvm::SmallVector of Size 3, Capacity 5 = {10, 11, 12}
p SmallVector
@@ -37,7 +31,7 @@ p SmallString
# CHECK: "bar"
p StringRef
-# CHECK: "foobarbaz"
+# CHECK: "{{foo|\(missing .*\)}}barbaz"
p Twine
# CHECK: llvm::StringMap with 2 elements = {["foo"] = 123, ["bar"] = 456}
diff --git a/llvm/utils/gdb-scripts/prettyprinters.py b/llvm/utils/gdb-scripts/prettyprinters.py
index 1016467fc0974..c78491529182b 100644
--- a/llvm/utils/gdb-scripts/prettyprinters.py
+++ b/llvm/utils/gdb-scripts/prettyprinters.py
@@ -415,7 +415,12 @@ def get_pointer_int_pair(val):
int_shift = enum_dict[info_name + "::IntShift"]
int_mask = enum_dict[info_name + "::IntMask"]
pair_union = val["Value"]
+ value_type = pair_union.type.template_argument(0)
+ value_type_ptr = value_type.pointer()
+ pair_union = pair_union.address.cast(value_type_ptr).dereference()
+ pair_union = pair_union.cast(gdb.lookup_type("intptr_t"))
pointer = pair_union & ptr_mask
+ pointer = pointer.cast(value_type)
value = (pair_union >> int_shift) & int_mask
return (pointer, value)
More information about the llvm-commits
mailing list