Revert "[llvm][formatters] Add LLDB data-formatter for llvm::PointerIntPair" (#174673)
Reverts llvm/llvm-project#173261 Some bots were failing with: ``` Step 6 (build-unified-tree) failure: build (failure) ... 2.874 [7103/10/382] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/CallingConvEmitter.cpp.o 2.875 [7102/10/383] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeEmitterGen.cpp.o 2.895 [7101/10/384] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenMapTable.cpp.o 2.896 [7100/10/385] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/CompressInstEmitter.cpp.o 2.898 [7099/10/386] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/CTagsEmitter.cpp.o 2.901 [7098/10/387] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelEmitter.cpp.o 2.905 [7097/10/388] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcherEmitter.cpp.o 2.918 [7096/10/389] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcherGen.cpp.o 2.920 [7095/10/390] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/DecoderTree.cpp.o 2.932 [7094/10/391] Building CXX object projects/cross-project-tests/CMakeFiles/check-lldb-llvm-support-pointer-int-pair.dir/debuginfo-tests/llvm-prettyprinters/lldb/pointer-int-pair.cpp.o FAILED: projects/cross-project-tests/CMakeFiles/check-lldb-llvm-support-pointer-int-pair.dir/debuginfo-tests/llvm-prettyprinters/lldb/pointer-int-pair.cpp.o /opt/ccache/bin/g++ -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbot/buildbot-root/abi-test/build/projects/cross-project-tests -I/home/buildbot/buildbot-root/abi-test/llvm/cross-project-tests -I/home/buildbot/buildbot-root/abi-test/build/include -I/home/buildbot/buildbot-root/abi-test/llvm/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-array-bounds -Wno-stringop-overread -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -UNDEBUG -g -O0 -std=c++17 -MD -MT projects/cross-project-tests/CMakeFiles/check-lldb-llvm-support-pointer-int-pair.dir/debuginfo-tests/llvm-prettyprinters/lldb/pointer-int-pair.cpp.o -MF projects/cross-project-tests/CMakeFiles/check-lldb-llvm-support-pointer-int-pair.dir/debuginfo-tests/llvm-prettyprinters/lldb/pointer-int-pair.cpp.o.d -o projects/cross-project-tests/CMakeFiles/check-lldb-llvm-support-pointer-int-pair.dir/debuginfo-tests/llvm-prettyprinters/lldb/pointer-int-pair.cpp.o -c /home/buildbot/buildbot-root/abi-test/llvm/cross-project-tests/debuginfo-tests/llvm-prettyprinters/lldb/pointer-int-pair.cpp /home/buildbot/buildbot-root/abi-test/llvm/cross-project-tests/debuginfo-tests/llvm-prettyprinters/lldb/pointer-int-pair.cpp: In function ‘int main()’: /home/buildbot/buildbot-root/abi-test/llvm/cross-project-tests/debuginfo-tests/llvm-prettyprinters/lldb/pointer-int-pair.cpp:25:3: error: ‘__builtin_debugtrap’ was not declared in this scope; did you mean ‘__builtin_trap’? 25 | __builtin_debugtrap(); | ^~~~~~~~~~~~~~~~~~~ | __builtin_trap 2.932 [7094/9/392] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcherOpt.cpp.o 2.933 [7094/8/393] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/DecoderTableEmitter.cpp.o 2.936 [7094/7/394] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/DecoderEmitter.cpp.o 2.937 [7094/6/395] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/DFAEmitter.cpp.o 2.944 [7094/5/396] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/DFAPacketizerEmitter.cpp.o 3.340 [7094/4/397] Building PPCGenTargetFeatures.inc... 3.450 [7094/3/398] Building ARMTargetParserDef.inc... 3.780 [7094/2/399] Building AArch64TargetParserDef.inc... 5.093 [7094/1/400] Building RISCVTargetParserDef.inc... ninja: build stopped: subcommand failed. ```
This commit is contained in:
parent
3bdda61f8c
commit
a4cc033408
@ -18,12 +18,6 @@ add_executable(check-lldb-llvm-support-arrayref
|
||||
target_link_libraries(check-lldb-llvm-support-arrayref PRIVATE LLVMSupport)
|
||||
target_compile_options(check-lldb-llvm-support-arrayref PRIVATE -g -O0)
|
||||
|
||||
add_executable(check-lldb-llvm-support-pointer-int-pair
|
||||
debuginfo-tests/llvm-prettyprinters/lldb/pointer-int-pair.cpp
|
||||
)
|
||||
target_link_libraries(check-lldb-llvm-support-pointer-int-pair PRIVATE LLVMSupport)
|
||||
target_compile_options(check-lldb-llvm-support-pointer-int-pair PRIVATE -g -O0)
|
||||
|
||||
set(CROSS_PROJECT_TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(CROSS_PROJECT_TESTS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@ -31,7 +25,6 @@ set(CROSS_PROJECT_TEST_DEPS
|
||||
FileCheck
|
||||
check-gdb-llvm-support
|
||||
check-lldb-llvm-support-arrayref
|
||||
check-lldb-llvm-support-pointer-int-pair
|
||||
count
|
||||
llvm-ar
|
||||
llvm-config
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
|
||||
int main() {
|
||||
float a = 5;
|
||||
llvm::PointerIntPair<float *, 1, bool> float_pair(&a, true);
|
||||
llvm::PointerIntPair<void *, 1, bool> void_pair(&a, false);
|
||||
llvm::PointerIntPair<llvm::PointerIntPair<void *, 1, bool>, 1, bool> nested(
|
||||
void_pair, true);
|
||||
|
||||
struct S {
|
||||
int i;
|
||||
};
|
||||
S s;
|
||||
|
||||
enum class E : unsigned {
|
||||
Case1,
|
||||
Case2,
|
||||
Case3,
|
||||
Case4,
|
||||
};
|
||||
llvm::PointerIntPair<S *, 2, E> enum_pair(&s, E::Case2);
|
||||
|
||||
S s2;
|
||||
|
||||
__builtin_debugtrap();
|
||||
|
||||
enum_pair.setPointerAndInt(&s2, E::Case3);
|
||||
|
||||
__builtin_debugtrap();
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
# RUN: split-file %s %t
|
||||
# RUN: lldb -x \
|
||||
# RUN: -o 'command script import %llvm_src_root/utils/lldbDataFormatters.py' \
|
||||
# RUN: -s %t/commands.input %llvm_tools_dir/check-lldb-llvm-support-pointer-int-pair \
|
||||
# RUN: -o quit \
|
||||
# RUN: | FileCheck %t/checks
|
||||
|
||||
#--- commands.input
|
||||
run
|
||||
|
||||
p &a
|
||||
v -T float_pair
|
||||
v -T nested
|
||||
p &s
|
||||
v -T enum_pair
|
||||
|
||||
continue
|
||||
|
||||
p &s2
|
||||
p enum_pair
|
||||
p enum_pair.Pointer
|
||||
p enum_pair.Int
|
||||
|
||||
#--- checks
|
||||
# CHECK: (lldb) p &a
|
||||
# CHECK-NEXT: (float *) [[PTR_A:0x[0-9a-zA-Z]+]]
|
||||
|
||||
# CHECK: (lldb) v -T float_pair
|
||||
# CHECK-NEXT: (llvm::PointerIntPair<float *, 1, bool>) float_pair = {
|
||||
# CHECK-NEXT: (float *) Pointer = [[PTR_A]]
|
||||
# CHECK-NEXT: (bool) Int = true
|
||||
# CHECK-NEXT: }
|
||||
|
||||
# CHECK: (lldb) v -T nested
|
||||
# CHECK-NEXT: (llvm::PointerIntPair<llvm::PointerIntPair<void *, 1, bool>, 1, bool>) nested = {
|
||||
# CHECK-NEXT: (llvm::PointerIntPair<void *, 1, bool>) Pointer = {
|
||||
# CHECK-NEXT: (void *) Pointer = [[PTR_A]]
|
||||
# CHECK-NEXT: (bool) Int = false
|
||||
# CHECK-NEXT: }
|
||||
# CHECK-NEXT: Int = true
|
||||
# CHECK-NEXT: }
|
||||
|
||||
# CHECK: (lldb) p &s
|
||||
# CHECK-NEXT: (S *) [[PTR_S:0x[0-9a-zA-Z]+]]
|
||||
|
||||
# CHECK: (lldb) v -T enum_pair
|
||||
# CHECK-NEXT: (llvm::PointerIntPair<S *, 2, E>) enum_pair = {
|
||||
# CHECK-NEXT: (S *) Pointer = [[PTR_S]]
|
||||
# CHECK-NEXT: (E) Int = Case2
|
||||
# CHECK-NEXT: }
|
||||
|
||||
# CHECK: (lldb) continue
|
||||
|
||||
# CHECK: (lldb) p &s2
|
||||
# CHECK-NEXT: (S *) [[PTR_S2:0x[0-9a-zA-Z]+]]
|
||||
|
||||
# CHECK: (lldb) p enum_pair
|
||||
# CHECK-NEXT: (llvm::PointerIntPair<S *, 2, E>) {
|
||||
# CHECK-NEXT: Pointer = [[PTR_S2]]
|
||||
# CHECK-NEXT: Int = Case3
|
||||
# CHECK-NEXT: }
|
||||
|
||||
# CHECK: (lldb) p enum_pair.Pointer
|
||||
# CHECK-NEXT: (S *) [[PTR_S2]]
|
||||
|
||||
# CHECK: (lldb) p enum_pair.Int
|
||||
# CHECK-NEXT: (E) Case3
|
||||
@ -57,11 +57,21 @@ def __lldb_init_module(debugger, internal_dict):
|
||||
f"-F {__name__}.ConstStringSummaryProvider "
|
||||
"lldb_private::ConstString"
|
||||
)
|
||||
debugger.HandleCommand(
|
||||
"type synthetic add -w llvm "
|
||||
f"-l {__name__}.PointerIntPairSynthProvider "
|
||||
'-x "^llvm::PointerIntPair<.+>$"'
|
||||
)
|
||||
|
||||
# The synthetic providers for PointerIntPair and PointerUnion are disabled
|
||||
# because of a few issues. One example is template arguments that are
|
||||
# non-pointer types that instead specialize PointerLikeTypeTraits.
|
||||
# debugger.HandleCommand(
|
||||
# "type synthetic add -w llvm "
|
||||
# f"-l {__name__}.PointerIntPairSynthProvider "
|
||||
# '-x "^llvm::PointerIntPair<.+>$"'
|
||||
# )
|
||||
# debugger.HandleCommand(
|
||||
# "type synthetic add -w llvm "
|
||||
# f"-l {__name__}.PointerUnionSynthProvider "
|
||||
# '-x "^llvm::PointerUnion<.+>$"'
|
||||
# )
|
||||
|
||||
debugger.HandleCommand(
|
||||
"type summary add -w llvm "
|
||||
f"-e -F {__name__}.DenseMapSummary "
|
||||
@ -207,6 +217,13 @@ def ConstStringSummaryProvider(valobj, internal_dict):
|
||||
return ""
|
||||
|
||||
|
||||
def get_expression_path(val):
|
||||
stream = lldb.SBStream()
|
||||
if not val.GetExpressionPath(stream):
|
||||
return None
|
||||
return stream.GetData()
|
||||
|
||||
|
||||
class PointerIntPairSynthProvider:
|
||||
def __init__(self, valobj, internal_dict):
|
||||
self.valobj = valobj
|
||||
@ -222,101 +239,81 @@ class PointerIntPairSynthProvider:
|
||||
return 1
|
||||
return None
|
||||
|
||||
def _get_raw_value(self):
|
||||
data: SBData = self.value.GetData()
|
||||
error = lldb.SBError()
|
||||
raw_bytes = data.ReadRawData(error, 0, self.ptr_size)
|
||||
if error.Fail():
|
||||
return None
|
||||
|
||||
return raw_bytes
|
||||
|
||||
def _get_pointer(self, pointer_bit_mask: int, pointer_ty: SBType):
|
||||
raw_bytes = self._get_raw_value()
|
||||
if raw_bytes is None:
|
||||
return
|
||||
|
||||
unmasked_pointer = int.from_bytes(raw_bytes, self.byteorder)
|
||||
pointer_value = unmasked_pointer & pointer_bit_mask
|
||||
|
||||
data = lldb.SBData()
|
||||
data.SetDataFromUInt64Array([pointer_value])
|
||||
return self.valobj.CreateValueFromData("Pointer", data, pointer_ty)
|
||||
|
||||
def _get_int(self, int_shift: int, int_mask: int, int_ty: SBType):
|
||||
raw_bytes = self._get_raw_value()
|
||||
if raw_bytes is None:
|
||||
return
|
||||
|
||||
unmasked_pointer = int.from_bytes(raw_bytes, self.byteorder)
|
||||
int_value = (unmasked_pointer >> int_shift) & int_mask
|
||||
|
||||
data = lldb.SBData()
|
||||
data.SetDataFromUInt64Array([int_value])
|
||||
return self.valobj.CreateValueFromData("Int", data, int_ty)
|
||||
|
||||
def get_child_at_index(self, index):
|
||||
expr_path = get_expression_path(self.valobj)
|
||||
if index == 0:
|
||||
return self.pointer_valobj
|
||||
return self.valobj.CreateValueFromExpression(
|
||||
"Pointer", f"({self.pointer_ty.name}){expr_path}.getPointer()"
|
||||
)
|
||||
if index == 1:
|
||||
return self.int_valobj
|
||||
return self.valobj.CreateValueFromExpression(
|
||||
"Int", f"({self.int_ty.name}){expr_path}.getInt()"
|
||||
)
|
||||
return None
|
||||
|
||||
def update(self):
|
||||
self.byteorder = (
|
||||
"big"
|
||||
if self.valobj.target.GetByteOrder() == lldb.eByteOrderBig
|
||||
else "little"
|
||||
self.pointer_ty = self.valobj.GetType().GetTemplateArgumentType(0)
|
||||
self.int_ty = self.valobj.GetType().GetTemplateArgumentType(2)
|
||||
|
||||
|
||||
def parse_template_parameters(typename):
|
||||
"""
|
||||
LLDB doesn't support template parameter packs, so let's parse them manually.
|
||||
"""
|
||||
result = []
|
||||
start = typename.find("<")
|
||||
end = typename.rfind(">")
|
||||
if start < 1 or end < 2 or end - start < 2:
|
||||
return result
|
||||
|
||||
nesting_level = 0
|
||||
current_parameter_start = start + 1
|
||||
|
||||
for i in range(start + 1, end + 1):
|
||||
c = typename[i]
|
||||
if c == "<":
|
||||
nesting_level += 1
|
||||
elif c == ">":
|
||||
nesting_level -= 1
|
||||
elif c == "," and nesting_level == 0:
|
||||
result.append(typename[current_parameter_start:i].strip())
|
||||
current_parameter_start = i + 1
|
||||
|
||||
result.append(typename[current_parameter_start:i].strip())
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class PointerUnionSynthProvider:
|
||||
def __init__(self, valobj, internal_dict):
|
||||
self.valobj = valobj
|
||||
self.update()
|
||||
|
||||
def num_children(self):
|
||||
return 1
|
||||
|
||||
def get_child_index(self, name):
|
||||
if name == "Ptr":
|
||||
return 0
|
||||
return None
|
||||
|
||||
def get_child_at_index(self, index):
|
||||
if index != 0:
|
||||
return None
|
||||
ptr_type_name = self.template_args[self.active_type_tag]
|
||||
return self.valobj.CreateValueFromExpression(
|
||||
"Ptr", f"({ptr_type_name}){self.val_expr_path}.getPointer()"
|
||||
)
|
||||
self.ptr_size = self.valobj.target.GetAddressByteSize()
|
||||
self.value: SBValue = self.valobj.GetChildMemberWithName("Value")
|
||||
if not self.value:
|
||||
return
|
||||
|
||||
valobj_type = self.valobj.GetType()
|
||||
|
||||
pointer_ty: SBType = valobj_type.GetTemplateArgumentType(0)
|
||||
if not pointer_ty:
|
||||
return
|
||||
|
||||
int_ty: SBType = valobj_type.GetTemplateArgumentType(2)
|
||||
if not int_ty:
|
||||
return
|
||||
|
||||
pointer_info = valobj_type.GetTemplateArgumentType(4)
|
||||
if not pointer_info:
|
||||
return
|
||||
|
||||
mask_and_shift_constants = pointer_info.FindDirectNestedType(
|
||||
"MaskAndShiftConstants"
|
||||
).GetEnumMembers()
|
||||
|
||||
# FIXME: SBAPI should provide a way to retrieve an enum member
|
||||
# by name.
|
||||
pointer_bit_mask: SBTypeEnumMember = (
|
||||
mask_and_shift_constants.GetTypeEnumMemberAtIndex(0)
|
||||
)
|
||||
if pointer_bit_mask.name != "PointerBitMask":
|
||||
return
|
||||
|
||||
int_shift: SBTypeEnumMember = mask_and_shift_constants.GetTypeEnumMemberAtIndex(
|
||||
1
|
||||
)
|
||||
if int_shift.name != "IntShift":
|
||||
return
|
||||
|
||||
int_mask: SBTypeEnumMember = mask_and_shift_constants.GetTypeEnumMemberAtIndex(
|
||||
2
|
||||
)
|
||||
if int_mask.name != "IntMask":
|
||||
return
|
||||
|
||||
self.pointer_valobj = self._get_pointer(
|
||||
pointer_bit_mask.GetValueAsUnsigned(), pointer_ty
|
||||
)
|
||||
self.int_valobj = self._get_int(
|
||||
int_shift.GetValueAsUnsigned(), int_mask.GetValueAsUnsigned(), int_ty
|
||||
def update(self):
|
||||
self.pointer_int_pair = self.valobj.GetChildMemberWithName("Val")
|
||||
self.val_expr_path = get_expression_path(
|
||||
self.valobj.GetChildMemberWithName("Val")
|
||||
)
|
||||
self.active_type_tag = self.valobj.CreateValueFromExpression(
|
||||
"", f"(int){self.val_expr_path}.getInt()"
|
||||
).GetValueAsSigned()
|
||||
self.template_args = parse_template_parameters(self.valobj.GetType().name)
|
||||
|
||||
|
||||
def DenseMapSummary(valobj: lldb.SBValue, _) -> str:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user