Skip to content

Commit e49aa08

Browse files
authored
Fix xmethods for gdb (#7009)
We noticed a few issues in the GDB xmethods scripts. This PR fixes them.
1 parent 0385de4 commit e49aa08

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

sycl/gdb/libsycl.so-gdb.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def get_arg_types(self):
153153

154154

155155
class AccessorMatcher(gdb.xmethod.XMethodMatcher):
156-
"""Entry point for sycl::_V1::accessor"""
156+
"""Entry point for sycl::_V1::(local_)accessor"""
157157

158158
def __init__(self):
159159
gdb.xmethod.XMethodMatcher.__init__(self, "AccessorMatcher")
@@ -162,7 +162,7 @@ def match(self, class_type, method_name):
162162
if method_name != "operator[]":
163163
return None
164164

165-
result = re.match("^sycl::_V1::accessor<.+>$", class_type.tag)
165+
result = re.match("^sycl::_V1::(?:local_)?accessor<.+>$", class_type.tag)
166166
if result is None:
167167
return None
168168

@@ -249,8 +249,9 @@ def __call__(self, obj, *args):
249249
item_base = args[0]["localItem"]["MImpl"]
250250
item_base = self.ItemBase(item_base)
251251
index = item_base.get_linear_id()
252-
return obj["Val"]["_M_t"]["_M_t"]["_M_head_impl"][index]
253252

253+
eval_string = "((" + str(obj.type) + ")" + str(obj) + ")->Val.get()"
254+
return gdb.parse_and_eval(eval_string)[index]
254255

255256
class PrivateMemoryMatcher(gdb.xmethod.XMethodMatcher):
256257
"""Entry point for sycl::_V1::private_memory"""

sycl/include/sycl/accessor.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,10 +1164,15 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
11641164
// The function references helper methods required by GDB pretty-printers
11651165
void GDBMethodsAnchor() {
11661166
#ifndef NDEBUG
1167+
const auto *this_const = this;
11671168
(void)getMemoryRange();
1169+
(void)this_const->getMemoryRange();
11681170
(void)getOffset();
1171+
(void)this_const->getOffset();
11691172
(void)getPtr();
1173+
(void)this_const->getPtr();
11701174
(void)getAccessRange();
1175+
(void)this_const->getAccessRange();
11711176
#endif
11721177
}
11731178

@@ -2439,8 +2444,11 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
24392444
// The function references helper methods required by GDB pretty-printers
24402445
void GDBMethodsAnchor() {
24412446
#ifndef NDEBUG
2447+
const auto *this_const = this;
24422448
(void)getSize();
2449+
(void)this_const->getSize();
24432450
(void)getPtr();
2451+
(void)this_const->getPtr();
24442452
#endif
24452453
}
24462454

0 commit comments

Comments
 (0)