Class PathPattern
- All Implemented Interfaces:
PathFilter
-
Nested Class Summary
Nested classes/interfaces inherited from interface ghidra.trace.model.target.path.PathFilter
PathFilter.Align -
Field Summary
Fields inherited from interface ghidra.trace.model.target.path.PathFilter
NONE -
Constructor Summary
ConstructorsConstructorDescriptionPathPattern(KeyPath pattern) TODO: This can get more sophisticated if needed, but for now, I don't think we even need regular expressions. -
Method Summary
Modifier and TypeMethodDescriptionbooleanancestorCouldMatchRight(KeyPath path, boolean strict) Check if the given path could have a matching ancestor, right to leftbooleanancestorMatches(KeyPath path, boolean strict) Check if the given path has an ancestor that matchesapplyKeys(PathFilter.Align align, List<String> keys) Substitute wildcards from left to right for the given list of keysasPath()Return the pattern as a key path of patternsintCount the number of wildcard keys in this patternbooleangetNextIndices(KeyPath path) Assuming a successor of path could match, get the patterns for the next possible indexgetNextKeys(KeyPath path) Get the patterns for the next possible keygetNextNames(KeyPath path) Get the patterns for the next possible nameGet the patterns of this predicategetPrevKeys(KeyPath path) Get the patterns for the previous possible key (right-to-left matching)If this predicate is known to match only one path, i.e., no wildcards, get that pathIf this predicate consists of a single pattern, get that patterninthashCode()booleanisNone()Test if any patterns are contained herestatic booleanisWildcard(String pat) booleanCheck if the entire path passesprotected booleanmatchesBackTo(KeyPath path, int length) protected booleanmatchesUpTo(KeyPath path, int length) If the given path matches, extract keys where matched by wildcardsor(PathFilter that) removeRight(int count) Remove count elements from the rightstatic StringsanitizeKey(String key) Sanitize the given key.booleansuccessorCouldMatch(KeyPath path, boolean strict) Check if the given path could have a matching successorConvert this pattern to a string.,toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.trace.model.target.path.PathFilter
applyIntKeys, applyIntKeys, applyIntKeys, applyKeys, applyKeys
-
Constructor Details
-
PathPattern
TODO: This can get more sophisticated if needed, but for now, I don't think we even need regular expressions. Either we care about a path element, or we don't.This takes a keypath as a means of matching paths. The blank key serves as a wildcard accepting all keys in that position, e.g., the following matches all elements within
Processes:PathFilter.parse("Processes[]");- Parameters:
pattern- a list of path elements
-
-
Method Details
-
toString
-
toPatternString
Convert this pattern to a string.,This is the inverse of
PathFilter.parse(String).- Returns:
- the string
-
equals
-
hashCode
public int hashCode() -
or
- Specified by:
orin interfacePathFilter
-
isWildcard
-
matchesUpTo
-
matchesBackTo
-
matches
Description copied from interface:PathFilterCheck if the entire path passes- Specified by:
matchesin interfacePathFilter- Parameters:
path- the path to check- Returns:
- true if it matches, false otherwise
-
successorCouldMatch
Description copied from interface:PathFilterCheck if the given path could have a matching successorThis essentially checks if the given path is a viable prefix to the matcher.
- Specified by:
successorCouldMatchin interfacePathFilter- Parameters:
path- the path (prefix) to checkstrict- true to exclude the case wherePathFilter.matches(KeyPath)would return true- Returns:
- true if a successor could match, false otherwise
-
ancestorMatches
Description copied from interface:PathFilterCheck if the given path has an ancestor that matches- Specified by:
ancestorMatchesin interfacePathFilter- Parameters:
path- the path to checkstrict- true to exclude the case wherePathFilter.matches(KeyPath)would return true- Returns:
- true if an ancestor matches, false otherwise
-
ancestorCouldMatchRight
Description copied from interface:PathFilterCheck if the given path could have a matching ancestor, right to leftThis essentially checks if the given path is a viable postfix to the matcher.
- Specified by:
ancestorCouldMatchRightin interfacePathFilter- Parameters:
path- the path (postfix) to checkstrict- true to exclude the case wherePathFilter.matches(KeyPath)would return true- Returns:
- true if an ancestor could match, false otherwise
-
getSingletonPath
Description copied from interface:PathFilterIf this predicate is known to match only one path, i.e., no wildcards, get that path- Specified by:
getSingletonPathin interfacePathFilter- Returns:
- the singleton path, or
null
-
asPath
Return the pattern as a key path of patterns- Returns:
- the list of key patterns
-
countWildcards
public int countWildcards()Count the number of wildcard keys in this pattern- Returns:
- the count
-
getSingletonPattern
Description copied from interface:PathFilterIf this predicate consists of a single pattern, get that pattern- Specified by:
getSingletonPatternin interfacePathFilter- Returns:
- the singleton pattern, or
null
-
getPatterns
Description copied from interface:PathFilterGet the patterns of this predicate- Specified by:
getPatternsin interfacePathFilter- Returns:
- the patterns
-
getNextKeys
Description copied from interface:PathFilterGet the patterns for the next possible keyIf a successor of the given path cannot match this pattern, the empty set is returned.
- Specified by:
getNextKeysin interfacePathFilter- Parameters:
path- the ancestor path- Returns:
- a set of patterns where indices are enclosed in brackets
[]
-
getNextNames
Description copied from interface:PathFilterGet the patterns for the next possible nameIf a successor of the given path cannot match this pattern, the empty set is returned. If the pattern could accept a name next, get all patterns describing those names
- Specified by:
getNextNamesin interfacePathFilter- Parameters:
path- the ancestor path- Returns:
- a set of patterns
-
getNextIndices
Description copied from interface:PathFilterAssuming a successor of path could match, get the patterns for the next possible indexIf a successor of the given path cannot match this pattern, the empty set is returned. If the pattern could accept an index next, get all patterns describing those indices
- Specified by:
getNextIndicesin interfacePathFilter- Parameters:
path- the ancestor path- Returns:
- a set of patterns, without brackets
[]
-
getPrevKeys
Description copied from interface:PathFilterGet the patterns for the previous possible key (right-to-left matching)If an ancestor of the given path cannot match this pattern, the empty set is returned.
- Specified by:
getPrevKeysin interfacePathFilter- Parameters:
path- the successor path- Returns:
- a set of patterns where indices are enclosed in brackets
[]
-
isNone
public boolean isNone()Description copied from interface:PathFilterTest if any patterns are contained hereNote that the presence of a pattern does not guarantee the presence of a matching object. However, the absence of any pattern does guarantee no object can match.
- Specified by:
isNonein interfacePathFilter- Returns:
- true if equivalent to
PathFilter.NONE
-
sanitizeKey
Sanitize the given key.Because brackets
[]indicate an index in a path, they cannot themselves be used in an index. The first closing bracket seen is taken to end the index. We could support escaping, e.g., by "\[," but that seems a bit onerous for what little it affords. We also should not endeavor to support things like "Memory[something[with][brackets]]," because we'd still have an issue if the user's brackets are not balanced. Instead, we'll just replace the square brackets with curley braces, unless/until that turns out to be a Bad Idea.- Parameters:
key- the key to sanitize- Returns:
- the sanitized key
-
applyKeys
Description copied from interface:PathFilterSubstitute wildcards from left to right for the given list of keysTakes each pattern and substitutes its wildcards for the given indices, according to the given alignment. This object is unmodified, and the result is returned.
If there are fewer wildcards in a pattern than given, only the first keys are taken. If there are fewer keys than wildcards in a pattern, then the remaining wildcards are left in the resulting pattern. In this manner, the left-most wildcards are substituted for the left-most indices, or the right-most wildcards are substituted for the right-most indices, depending on the alignment.
- Specified by:
applyKeysin interfacePathFilter- Parameters:
align- the end to alignkeys- the keys to substitute- Returns:
- the pattern or matcher with the applied substitutions
-
matchKeys
If the given path matches, extract keys where matched by wildcardsThis is essentially the inverse of
PathFilter.applyKeys(String...), but can only be asked of one pattern. The keys are returned from left to right, in the order matched by the pattern. Only those keys matched by a wildcard are included in the result. Indices are extracted with the brackets[]removed.- Parameters:
path- the path to matchmatchLength- true if the path must have the same number of keys as this pattern, or false if the path is allowed to have more keys than this pattern- Returns:
- the list of matched keys or
nullif not matched
-
removeRight
Description copied from interface:PathFilterRemove count elements from the right- Specified by:
removeRightin interfacePathFilter- Parameters:
count- the number of elements to remove- Returns:
- the resulting filter
-