17"""$_memeq, $_strlen, $_streq, $_regex"""
24 """$_memeq - compare bytes of memory.
26 Usage: $_memeq (A, B, LEN)
29 True if LEN bytes at A
and B compare equally.
"""
32 super(_MemEq, self).
__init__(
"_memeq")
36 raise ValueError(
"length must be non-negative")
40 byte_vector = gdb.lookup_type(
"char").vector(length - 1)
41 ptr_byte_vector = byte_vector.pointer()
42 a_ptr = a.reinterpret_cast(ptr_byte_vector)
43 b_ptr = b.reinterpret_cast(ptr_byte_vector)
44 return a_ptr.dereference() == b_ptr.dereference()
48 """$_strlen - compute string length.
53 Length of string A, assumed to be a string in the current language.
"""
56 super(_StrLen, self).
__init__(
"_strlen")
64 """$_streq - check string equality.
69 True if A
and B are identical strings
in the current language.
71 Example (amd64-linux):
73 cond $bpnum $_streq((char*) $rdi,
"foo")
"""
76 super(_StrEq, self).
__init__(
"_streq")
79 return a.string() == b.string()
83 """$_regex - check if a string matches a regular expression.
85 Usage: $_regex (STRING, REGEX)
88 True if string STRING (
in the current language) matches the
89 regular expression REGEX.
"""
92 super(_RegEx, self).
__init__(
"_regex")
96 r = re.compile(regex.string())
97 return bool(r.match(s))
invoke(self, a, b, length)
invoke(self, string, regex)