Skip to content

Commit

Permalink
Fix gdb pretty printers for libSupport
Browse files Browse the repository at this point in the history
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, 8753917.
  • Loading branch information
dwblaikie committed Jun 19, 2024
1 parent 3c8f3b9 commit 1c9a81b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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.
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions llvm/utils/gdb-scripts/prettyprinters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 1c9a81b

Please sign in to comment.