Skip to content

Commit 4b5ee53

Browse files
[GDB] Support cl::sycl::item argument in op[] (#3407)
Minor enhancement to handle accessor::operator[] overloads which take id wrapped in cl::sycl::item as an argument.
1 parent 9a734f6 commit 4b5ee53

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

sycl/gdb/libsycl.so-gdb.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ def __init__(self, obj, result_type, depth):
2929
def index(self, arg):
3030
if arg.type.code == gdb.TYPE_CODE_INT:
3131
return int(arg)
32+
# unwrap if inside item
33+
try:
34+
arg = arg['MImpl']['MIndex']
35+
except:
36+
pass
3237
# https://github.com/intel/llvm/blob/97272b7ebd569bfa13811913a31e30f926559217/sycl/include/CL/sycl/accessor.hpp#L678-L690
3338
result = 0
3439
for dim in range(self.depth):
@@ -126,6 +131,17 @@ def get_arg_types(self):
126131
assert self.depth == 1
127132
return gdb.lookup_type('size_t')
128133

134+
class AccessorOpIndexItemTrue(AccessorOpIndex):
135+
"""Introduces an extra overload for item wrapper"""
136+
137+
def get_arg_types(self):
138+
return gdb.lookup_type("cl::sycl::item<%s, true>" % self.depth)
139+
140+
class AccessorOpIndexItemFalse(AccessorOpIndex):
141+
"""Introduces an extra overload for item wrapper"""
142+
143+
def get_arg_types(self):
144+
return gdb.lookup_type("cl::sycl::item<%s, false>" % self.depth)
129145

130146
class AccessorMatcher(gdb.xmethod.XMethodMatcher):
131147
"""Entry point for cl::sycl::accessor"""
@@ -146,6 +162,18 @@ def match(self, class_type, method_name):
146162
methods = [
147163
AccessorOpIndex(class_type, result_type, depth)
148164
]
165+
try:
166+
method = AccessorOpIndexItemTrue(class_type, result_type, depth)
167+
method.get_arg_types()
168+
methods.append(method)
169+
except:
170+
pass
171+
try:
172+
method = AccessorOpIndexItemFalse(class_type, result_type, depth)
173+
method.get_arg_types()
174+
methods.append(method)
175+
except:
176+
pass
149177
if depth == 1:
150178
methods.append(AccessorOpIndex1D(class_type, result_type, depth))
151179
return methods

0 commit comments

Comments
 (0)