class StackFrameSymptom(Symptom): def __init__(self, obj): ''' Private constructor, called by L{Symptom.fromJSONObject}. Do not use directly. ''' Symptom.__init__(self, obj) self.functionName = StringMatch( JSONHelper.getNumberOrStringChecked(obj, "functionName", True)) self.frameNumber = JSONHelper.getNumberOrStringChecked( obj, "frameNumber") if self.frameNumber is not None: self.frameNumber = NumberMatch(self.frameNumber) else: # Default to 0 self.frameNumber = NumberMatch(0) def matches(self, crashInfo): ''' Check if the symptom matches the given crash information @type crashInfo: CrashInfo @param crashInfo: The crash information to check against @rtype: bool @return: True if the symptom matches, False otherwise ''' for idx in range(len(crashInfo.backtrace)): # Not the most efficient way for very long stacks with a small match area if self.frameNumber.matches(idx): if self.functionName.matches(crashInfo.backtrace[idx]): return True return False
class StackFrameSymptom(Symptom): def __init__(self, obj): ''' Private constructor, called by L{Symptom.fromJSONObject}. Do not use directly. ''' Symptom.__init__(self, obj) self.functionName = StringMatch(JSONHelper.getNumberOrStringChecked(obj, "functionName", True)) self.frameNumber = JSONHelper.getNumberOrStringChecked(obj, "frameNumber") if self.frameNumber != None: self.frameNumber = NumberMatch(self.frameNumber) else: # Default to 0 self.frameNumber = NumberMatch(0) def matches(self, crashInfo): ''' Check if the symptom matches the given crash information @type crashInfo: CrashInfo @param crashInfo: The crash information to check against @rtype: bool @return: True if the symptom matches, False otherwise ''' for idx in range(len(crashInfo.backtrace)): # Not the most efficient way for very long stacks with a small match area if self.frameNumber.matches(idx): if self.functionName.matches(crashInfo.backtrace[idx]): return True return False
class StackSizeSymptom(Symptom): def __init__(self, obj): ''' Private constructor, called by L{Symptom.fromJSONObject}. Do not use directly. ''' Symptom.__init__(self, obj) self.stackSize = NumberMatch(JSONHelper.getNumberOrStringChecked(obj, "size", True)) def matches(self, crashInfo): ''' Check if the symptom matches the given crash information @type crashInfo: CrashInfo @param crashInfo: The crash information to check against @rtype: bool @return: True if the symptom matches, False otherwise ''' return self.stackSize.matches(len(crashInfo.backtrace))
class CrashAddressSymptom(Symptom): def __init__(self, obj): ''' Private constructor, called by L{Symptom.fromJSONObject}. Do not use directly. ''' Symptom.__init__(self, obj) self.address = NumberMatch(JSONHelper.getNumberOrStringChecked(obj, "address", True)) def matches(self, crashInfo): ''' Check if the symptom matches the given crash information @type crashInfo: CrashInfo @param crashInfo: The crash information to check against @rtype: bool @return: True if the symptom matches, False otherwise ''' # In case the crash address is not available, # the NumberMatch class will return false to not match. return self.address.matches(crashInfo.crashAddress)