diff --git a/sycl/gdb/libsycl.so-gdb.py b/sycl/gdb/libsycl.so-gdb.py index b98e2c80949bf..aaa4f85f8a64e 100644 --- a/sycl/gdb/libsycl.so-gdb.py +++ b/sycl/gdb/libsycl.so-gdb.py @@ -56,6 +56,23 @@ def offset(self, dim): def data(self): return self.payload()['MData'] +class HostAccessorLocal(HostAccessor): + """For Host device memory layout""" + + def index(self, arg): + if arg.type.code == gdb.TYPE_CODE_INT: + return int(arg) + # https://github.com/intel/llvm/blob/97272b7ebd569bfa13811913a31e30f926559217/sycl/include/CL/sycl/accessor.hpp#L1049-L1053 + result = 0; + for dim in range(self.depth): + result = result * \ + self.payload()['MSize']['common_array'][dim] + \ + arg['common_array'][dim]; + return result; + + def data(self): + return self.payload()['MMem'] + class DeviceAccessor(Accessor): """For CPU/GPU memory layout""" @@ -88,7 +105,8 @@ def __call__(self, obj, arg): # try all accessor implementations until one of them works: accessors = [ DeviceAccessor(obj, self.result_type, self.depth), - HostAccessor(obj, self.result_type, self.depth) + HostAccessor(obj, self.result_type, self.depth), + HostAccessorLocal(obj, self.result_type, self.depth) ] for accessor in accessors: try: diff --git a/sycl/test/gdb/accessors.cpp b/sycl/test/gdb/accessors.cpp index e30d597c7e462..34ee280350509 100644 --- a/sycl/test/gdb/accessors.cpp +++ b/sycl/test/gdb/accessors.cpp @@ -19,7 +19,15 @@ typedef cl::sycl::accessor dummy; // CHECK: CXXRecordDecl {{.*}} class AccessorBaseHost definition // CHECK-NOT: CXXRecordDecl {{.*}} definition // CHECK: FieldDecl {{.*}} referenced impl {{.*}}:'std::shared_ptr' + +// LocalAccessorImplHost must have MSize and MMem fields + +// CHECK: CXXRecordDecl {{.*}} class LocalAccessorImplHost definition +// CHECK-NOT: CXXRecordDecl {{.*}} definition +// CHECK: FieldDecl {{.*}} referenced MSize +// CHECK-NOT: CXXRecordDecl {{.*}} definition +// CHECK: FieldDecl {{.*}} referenced MMem + // CHECK: CXXRecordDecl {{.*}} class accessor definition // CHECK-NOT: CXXRecordDecl {{.*}} definition // CHECK: public {{.*}}:'sycl::detail::AccessorBaseHost' -