Struct InstructionFilter
pub struct InstructionFilter {
pub data: ArrayVec<ByteFilter, 16>,
}
Expand description
A filter that can match groups of instructions.
Fields§
§data: ArrayVec<ByteFilter, 16>
The filters for each byte in the instruction.
Implementations§
§impl InstructionFilter
impl InstructionFilter
pub fn new<I: IntoIterator<Item = ByteFilter>>(data: I) -> InstructionFilter
pub fn new<I: IntoIterator<Item = ByteFilter>>(data: I) -> InstructionFilter
Creates a new InstructionFilter
from the provided iterator.
The iterator should not yield more than 15 elements.
pub fn parse(s: &str) -> InstructionFilter
pub fn parse(s: &str) -> InstructionFilter
Parses an instruction filter from a string.
pub fn intersect(&self, other: &InstructionFilter) -> InstructionFilter
pub fn intersect(&self, other: &InstructionFilter) -> InstructionFilter
Computes the intersection of the InstructionFilter
s.
pub fn matches(&self, instr: &Instruction) -> bool
pub fn matches(&self, instr: &Instruction) -> bool
Returns true if the filter matches instr
.
pub fn matches_smaller_instr_partially(&self, instr: &Instruction) -> bool
pub fn matches_smaller_instr_partially(&self, instr: &Instruction) -> bool
Returns true if the filter matches all bytes in instr
, even if not all instructions that start with instr
are matched by this filter.
For example: the filter 03AB
partially matches the instruction 03
.
However, it does not match all instructions starting with 03
.
For example, 0300
.
pub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the byte length of the instructions matched by the InstructionFilter
.
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the InstructionFilter
is empty.
pub fn bit_len(&self) -> usize
pub fn bit_len(&self) -> usize
Returns the bitlength of the instructions matched by the InstructionFilter
.
pub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Returns the byte length of the instructions matched by the InstructionFilter
.
pub fn nth_bit_from_left(&self, index: usize) -> FilterBit
pub fn nth_bit_from_left(&self, index: usize) -> FilterBit
Returns the bit at position index
, counting from the left.
pub fn nth_bit_from_right(&self, index: usize) -> FilterBit
pub fn nth_bit_from_right(&self, index: usize) -> FilterBit
Returns the bit at position index
, counting from the right.
pub fn value_as_u128(&self) -> u128
pub fn value_as_u128(&self) -> u128
Returns the values of the ByteFilter
s concatenated into an u128
.
pub fn mask_as_u128(&self) -> u128
pub fn mask_as_u128(&self) -> u128
Returns the masks of the ByteFilter
s concatenated into an u128
.
pub fn covers(&self, other: &InstructionFilter) -> bool
pub fn covers(&self, other: &InstructionFilter) -> bool
Returns true if the filter matches all instructions matched by other
.
pub fn overlaps(&self, other: &InstructionFilter) -> bool
pub fn overlaps(&self, other: &InstructionFilter) -> bool
Returns true if there is at least one instruction which both filters match.
pub fn try_merge(&self, other: &InstructionFilter) -> Option<InstructionFilter>
pub fn try_merge(&self, other: &InstructionFilter) -> Option<InstructionFilter>
Tries to merge the filters into a filter that matches all instructions matched by either self or other
.
pub fn try_exclude(
&self,
other: &InstructionFilter,
) -> Option<InstructionFilter>
pub fn try_exclude( &self, other: &InstructionFilter, ) -> Option<InstructionFilter>
Tries to compute self - other
.
pub fn smallest_matching_instruction(&self) -> Instruction
pub fn smallest_matching_instruction(&self) -> Instruction
Returns the smallest matching instruction. In other words, the instruction with all wildcard bits set to 0.
pub fn largest_matching_instruction(&self) -> Instruction
pub fn largest_matching_instruction(&self) -> Instruction
Returns the largest matching instruction. In other words, the instruction with all wildcard bits set to 1.
pub fn next_matching_instruction(
&self,
instr: &Instruction,
) -> Option<Instruction>
pub fn next_matching_instruction( &self, instr: &Instruction, ) -> Option<Instruction>
When instr does not match the filter, returns the first instruction after instr
that matches the filter.
When instr does match the filter, returns instr
.
pub fn num_wildcard_bits(&self) -> usize
pub fn num_wildcard_bits(&self) -> usize
Returns the number of wildcard bits in the InstructionFilter
.
pub fn set_nth_bit_from_right(&mut self, index: usize, bit: FilterBit)
pub fn set_nth_bit_from_right(&mut self, index: usize, bit: FilterBit)
Sets the bit at position index
, counting from the right, to bit
.
pub fn set_nth_bit_from_left(&mut self, index: usize, bit: FilterBit)
pub fn set_nth_bit_from_left(&mut self, index: usize, bit: FilterBit)
Sets the bit at position index
, counting from the left, to bit
.
pub fn find_uncovered_instr(
&self,
covering_filters: Vec<InstructionFilter>,
) -> Option<Instruction>
pub fn find_uncovered_instr( &self, covering_filters: Vec<InstructionFilter>, ) -> Option<Instruction>
Returns an crate::instr::Instruction
that matches this filter, but none of the filters in covering_filters
.
Trait Implementations§
§impl Clone for InstructionFilter
impl Clone for InstructionFilter
§impl Debug for InstructionFilter
impl Debug for InstructionFilter
§impl<'de> Deserialize<'de> for InstructionFilter
impl<'de> Deserialize<'de> for InstructionFilter
§fn deserialize<D>(deserializer: D) -> Result<InstructionFilter, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<InstructionFilter, D::Error>where
D: Deserializer<'de>,
§impl From<&Instruction> for InstructionFilter
impl From<&Instruction> for InstructionFilter
§fn from(instr: &Instruction) -> Self
fn from(instr: &Instruction) -> Self
§impl From<&str> for InstructionFilter
impl From<&str> for InstructionFilter
§impl From<Instruction> for InstructionFilter
impl From<Instruction> for InstructionFilter
§fn from(instr: Instruction) -> Self
fn from(instr: Instruction) -> Self
§impl FromStr for InstructionFilter
impl FromStr for InstructionFilter
§impl Hash for InstructionFilter
impl Hash for InstructionFilter
§impl Ord for InstructionFilter
impl Ord for InstructionFilter
§fn cmp(&self, other: &InstructionFilter) -> Ordering
fn cmp(&self, other: &InstructionFilter) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialEq for InstructionFilter
impl PartialEq for InstructionFilter
§impl PartialOrd for InstructionFilter
impl PartialOrd for InstructionFilter
§impl Serialize for InstructionFilter
impl Serialize for InstructionFilter
impl Eq for InstructionFilter
impl StructuralPartialEq for InstructionFilter
Auto Trait Implementations§
impl Freeze for InstructionFilter
impl RefUnwindSafe for InstructionFilter
impl Send for InstructionFilter
impl Sync for InstructionFilter
impl Unpin for InstructionFilter
impl UnwindSafe for InstructionFilter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more