Skip to content

Commit

Permalink
Fix xmethods for gdb (#7009)
Browse files Browse the repository at this point in the history
We noticed a few issues in the GDB xmethods scripts. This PR fixes them.
  • Loading branch information
NCKempke committed Oct 10, 2022
1 parent 0385de4 commit e49aa08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sycl/gdb/libsycl.so-gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def get_arg_types(self):


class AccessorMatcher(gdb.xmethod.XMethodMatcher):
"""Entry point for sycl::_V1::accessor"""
"""Entry point for sycl::_V1::(local_)accessor"""

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

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

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

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

class PrivateMemoryMatcher(gdb.xmethod.XMethodMatcher):
"""Entry point for sycl::_V1::private_memory"""
Expand Down
8 changes: 8 additions & 0 deletions sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,10 +1164,15 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor :
// The function references helper methods required by GDB pretty-printers
void GDBMethodsAnchor() {
#ifndef NDEBUG
const auto *this_const = this;
(void)getMemoryRange();
(void)this_const->getMemoryRange();
(void)getOffset();
(void)this_const->getOffset();
(void)getPtr();
(void)this_const->getPtr();
(void)getAccessRange();
(void)this_const->getAccessRange();
#endif
}

Expand Down Expand Up @@ -2439,8 +2444,11 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
// The function references helper methods required by GDB pretty-printers
void GDBMethodsAnchor() {
#ifndef NDEBUG
const auto *this_const = this;
(void)getSize();
(void)this_const->getSize();
(void)getPtr();
(void)this_const->getPtr();
#endif
}

Expand Down

0 comments on commit e49aa08

Please sign in to comment.