From 147babf93f3a1f186abb26b535ba24e2f6b6e973 Mon Sep 17 00:00:00 2001 From: Mihails Strasuns Date: Wed, 24 Mar 2021 19:59:27 +0100 Subject: [PATCH] [GDB] Support cl::sycl::item argument in op[] Minor enhancement to handle accessor::operator[] overloads which take id wrapped in cl::sycl::item as an argument. --- sycl/gdb/libsycl.so-gdb.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sycl/gdb/libsycl.so-gdb.py b/sycl/gdb/libsycl.so-gdb.py index dc5b25240a74f..7c57338c5699e 100644 --- a/sycl/gdb/libsycl.so-gdb.py +++ b/sycl/gdb/libsycl.so-gdb.py @@ -29,6 +29,11 @@ def __init__(self, obj, result_type, depth): def index(self, arg): if arg.type.code == gdb.TYPE_CODE_INT: return int(arg) + # unwrap if inside item + try: + arg = arg['MImpl']['MIndex'] + except: + pass # https://github.com/intel/llvm/blob/97272b7ebd569bfa13811913a31e30f926559217/sycl/include/CL/sycl/accessor.hpp#L678-L690 result = 0 for dim in range(self.depth): @@ -126,6 +131,17 @@ def get_arg_types(self): assert self.depth == 1 return gdb.lookup_type('size_t') +class AccessorOpIndexItemTrue(AccessorOpIndex): + """Introduces an extra overload for item wrapper""" + + def get_arg_types(self): + return gdb.lookup_type("cl::sycl::item<%s, true>" % self.depth) + +class AccessorOpIndexItemFalse(AccessorOpIndex): + """Introduces an extra overload for item wrapper""" + + def get_arg_types(self): + return gdb.lookup_type("cl::sycl::item<%s, false>" % self.depth) class AccessorMatcher(gdb.xmethod.XMethodMatcher): """Entry point for cl::sycl::accessor""" @@ -146,6 +162,18 @@ def match(self, class_type, method_name): methods = [ AccessorOpIndex(class_type, result_type, depth) ] + try: + method = AccessorOpIndexItemTrue(class_type, result_type, depth) + method.get_arg_types() + methods.append(method) + except: + pass + try: + method = AccessorOpIndexItemFalse(class_type, result_type, depth) + method.get_arg_types() + methods.append(method) + except: + pass if depth == 1: methods.append(AccessorOpIndex1D(class_type, result_type, depth)) return methods