17 """$_memeq, $_strlen, $_streq, $_regex"""
23 class _MemEq(gdb.Function):
24 """$_memeq - compare bytes of memory
30 True if len bytes at a and b compare equally.
33 super(_MemEq, self).
__init__(
"_memeq")
37 raise ValueError(
"length must be non-negative")
41 byte_vector = gdb.lookup_type(
"char").vector(length - 1)
42 ptr_byte_vector = byte_vector.pointer()
43 a_ptr = a.reinterpret_cast(ptr_byte_vector)
44 b_ptr = b.reinterpret_cast(ptr_byte_vector)
45 return a_ptr.dereference() == b_ptr.dereference()
49 """$_strlen - compute string length
55 Length of string a, assumed to be a string in the current language.
58 super(_StrLen, self).
__init__(
"_strlen")
65 class _StrEq(gdb.Function):
66 """$_streq - check string equality
72 True if a and b are identical strings in the current language.
74 Example (amd64-linux):
76 cond $bpnum $_streq((char*) $rdi, "foo")
79 super(_StrEq, self).
__init__(
"_streq")
82 return a.string() == b.string()
85 class _RegEx(gdb.Function):
86 """$_regex - check if a string matches a regular expression
89 $_regex(string, regex)
92 True if string str (in the current language) matches the
93 regular expression regex.
96 super(_RegEx, self).
__init__(
"_regex")
100 r = re.compile(regex.string())
101 return bool(r.match(s))
def invoke(self, string, regex)
def invoke(self, a, b, length)
const ULONGEST const LONGEST len