diff --git a/sycl/gdb/libsycl.so-gdb.py b/sycl/gdb/libsycl.so-gdb.py index 99163f26f795a..91ef325387976 100644 --- a/sycl/gdb/libsycl.so-gdb.py +++ b/sycl/gdb/libsycl.so-gdb.py @@ -171,7 +171,7 @@ def dimensions(self): def access_mode(self): return self.type().access_mode() - def subscript_int(self, subscript): + def subscript_sizet(self, subscript): return self.data()[subscript] def subscript_id(self, subscript): @@ -185,25 +185,6 @@ def subscript_id(self, subscript): def subscript_item(self, subscript): return self.subscript_id(SYCLItem(subscript).index()) - def __getitem__(self, subscript): - code = subscript.type.unqualified().code - if code == gdb.TYPE_CODE_INT: - return self.subscript_int(subscript) - elif ( - code == gdb.TYPE_CODE_STRUCT - and subscript.type.name.startswith("sycl::_V1::item<") - and subscript.type.name.endswith(">") - ): - return self.subscript_item(subscript) - elif ( - code == gdb.TYPE_CODE_STRUCT - and subscript.type.name.startswith("sycl::_V1::id<") - and subscript.type.name.endswith(">") - ): - return self.subscript_id(subscript) - else: - raise AttributeError("Unsupported sycl::accessor subscript type.") - def impl(self): return self.gdb_value()["impl"] @@ -511,7 +492,9 @@ def __init__(self, name): self.name = name def matches(self, type): - return type.name == self.name or type.name.startswith(self.name + "<") + return type.name != None and ( + type.name == self.name or type.name.startswith(self.name + "<") + ) def instantiate(self): return SYCLTypePrinter.Recognizer(self) @@ -682,7 +665,7 @@ def gdb_type(self): @staticmethod def data_vector_type(base_type, dimensions, ranges_array): vector_type = base_type - for index in range(dimensions): + for index in reversed(range(dimensions)): upperbound = ranges_array[index] inclusive_upperbound = upperbound - 1 vector_type = vector_type.vector(inclusive_upperbound) @@ -1202,8 +1185,8 @@ def get_arg_types(self): def size_type(self): return SYCLType.size_type() - def __call__(self, accessor_ptr, subscript): - return SYCLAccessor(accessor_ptr.dereference())[subscript] + def __call__(self, ptr, subscript): + return SYCLAccessor(ptr.dereference()).subscript_sizet(subscript) class SYCLAccessorSubscriptID(SYCLAccessorSubscript): @@ -1217,8 +1200,8 @@ def id_type(self): dimensions = SYCLAccessorType(self.class_type()).dimensions() return gdb.lookup_type(f"sycl::_V1::id<{dimensions}>") - def __call__(self, accessor_ptr, subscript): - return SYCLAccessor(accessor_ptr.dereference())[subscript] + def __call__(self, ptr, subscript): + return SYCLAccessor(ptr.dereference()).subscript_id(subscript) class SYCLAccessorSubscriptItem(SYCLAccessorSubscript): @@ -1240,8 +1223,8 @@ def item_type(self): except: return None - def __call__(self, accessor_ptr, subscript): - return SYCLAccessor(accessor_ptr.dereference())[subscript] + def __call__(self, ptr, subscript): + return SYCLAccessor(ptr.dereference()).subscript_item(subscript) class SYCLAccessorSubscriptItemOffset(SYCLAccessorSubscriptItem):