def __init__(self, where, events):
     if not isinstance(events, list):
         events = [events]
     events = list(events)
     self.where = where
     self.events = events
     self.matcher = LocationMatcher(where)
class DeleteEvent(Mutator):
    def __init__(self, events):
        if not isinstance(events, list):
            events = [events]
        self.events = list(events)
        self.matcher = LocationMatcher(map(lambda e: Location(e, 'before'), self.events))

    def __str__(self):
        return "d-%d:%s" % (self.events[0].proc.pid,
                ','.join(map(lambda e: str(e.index), self.events)))

    def process_events(self, events):
        syscall_depth = 0
        res_depth = 0
        for e in events:
            match = self.matcher.match(e)
            if match is not None or syscall_depth > 0 or res_depth > 0:
                if e.is_a(scribe.EventSyscallExtra):
                    syscall_depth += 1
                elif e.is_a(scribe.EventResourceLockExtra):
                    res_depth += 1
                elif e.is_a(scribe.EventSyscallEnd):
                    syscall_depth -= 1
                elif e.is_a(scribe.EventResourceUnlock):
                    res_depth -= 1
            else:
                yield e
Exemplo n.º 3
0
 def __init__(self, where, events):
     if not isinstance(events, list):
         events = [events]
     events = list(events)
     self.where = where
     self.events = events
     self.matcher = LocationMatcher(where)
Exemplo n.º 4
0
class Bookmark(Mutator):
    def __init__(self, bmarks):
        self.num_procs = len(bmarks)
        self.matcher = LocationMatcher(bmarks)

    def start(self, env):
        self.bookmark_id = env.get('next_bookmark_id', 0)
        env['next_bookmark_id'] = self.bookmark_id + 1

    def process_events(self, events):
        for event in events:
            match = self.matcher.match(event)
            if match is not None:
                bmark_event = scribe.EventBookmark()
                if match == 'before':
                    bmark_event.type = scribe.SCRIBE_BOOKMARK_PRE_SYSCALL
                else:
                    bmark_event.type = scribe.SCRIBE_BOOKMARK_POST_SYSCALL
                bmark_event.id = self.bookmark_id
                bmark_event.npr = self.num_procs
                yield Event(bmark_event, event.proc)

            if not (event.is_a(scribe.EventBookmark) and
                    self.bookmark_id == 0):
                yield event
Exemplo n.º 5
0
class TruncateQueue(Mutator):
    def __init__(self, where):
        self.matcher = LocationMatcher(where)
        self.num_procs = -1
        self.last_anchors = None

    def start(self, env):
        graph = env.get('graph')
        if graph is not None:
            self.num_procs = len(graph.processes)
            self.last_anchors = set(map(lambda (p): p.last_anchor,
                                        graph.processes.values()))

    def process_events(self, events):
        truncate_procs = set()
        stop_processing = [False]

        def truncate_queue(proc):
            truncate_procs.add(proc)
            if len(truncate_procs) == self.num_procs:
                stop_processing[0] = True

        for event in events:
            if self.matcher.match(event) is not None:
                truncate_queue(event.proc)

            if event.proc not in truncate_procs:
                yield event

            if self.last_anchors is not None and event in self.last_anchors:
                truncate_queue(event.proc)

            if stop_processing[0]:
                break
Exemplo n.º 6
0
class SetFlags(Mutator):
    def __init__(self, where, flags, duration, extra=None):
        self.where = where
        self.flags = flags
        self.duration = duration
        self.extra = extra
        self.matcher = LocationMatcher(where)

    def __str__(self):
        return "i-%d:%d" % (self.where.obj.proc.pid, self.where.obj.index)

    def process_events(self, events):
        for event in events:
            match = self.matcher.match(event)
            if match is not None:
                ignore_event = scribe.EventSetFlags(self.flags, self.duration, self.extra)
                yield Event(ignore_event, event.proc)
            yield event
Exemplo n.º 7
0
class SetFlags(Mutator):
    def __init__(self, where, flags, duration, extra=None):
        self.where = where
        self.flags = flags
        self.duration = duration
        self.extra = extra
        self.matcher = LocationMatcher(where)

    def __str__(self):
        return "i-%d:%d" % (self.where.obj.proc.pid, self.where.obj.index)

    def process_events(self, events):
        for event in events:
            match = self.matcher.match(event)
            if match is not None:
                ignore_event = scribe.EventSetFlags(self.flags, self.duration,
                                                    self.extra)
                yield Event(ignore_event, event.proc)
            yield event
Exemplo n.º 8
0
class InsertEvent(Mutator):
    def __init__(self, where, events):
        if not isinstance(events, list):
            events = [events]
        events = list(events)
        self.where = where
        self.events = events
        self.matcher = LocationMatcher(where)

    def __str__(self):
        return "I-%d:%d" % (self.where.obj.proc.pid, self.where.obj.index)

    def process_events(self, events):
        for event in events:
            match = self.matcher.match(event)
            if match is not None:
                for e in self.events:
                    yield e
            yield event
class InsertEvent(Mutator):
    def __init__(self, where, events):
        if not isinstance(events, list):
            events = [events]
        events = list(events)
        self.where = where
        self.events = events
        self.matcher = LocationMatcher(where)

    def __str__(self):
        return "I-%d:%d" % (self.where.obj.proc.pid, self.where.obj.index)

    def process_events(self, events):
        for event in events:
            match = self.matcher.match(event)
            if match is not None:
                for e in self.events:
                    yield e
            yield event
Exemplo n.º 10
0
 def __init__(self, events):
     if not isinstance(events, list):
         events = [events]
     self.events = list(events)
     self.matcher = LocationMatcher(map(lambda e: Location(e, 'before'), self.events))
Exemplo n.º 11
0
 def __init__(self, where, flags, duration, extra=None):
     self.where = where
     self.flags = flags
     self.duration = duration
     self.extra = extra
     self.matcher = LocationMatcher(where)
Exemplo n.º 12
0
 def __init__(self, where, flags, duration, extra=None):
     self.where = where
     self.flags = flags
     self.duration = duration
     self.extra = extra
     self.matcher = LocationMatcher(where)
Exemplo n.º 13
0
 def __init__(self, bmarks):
     self.num_procs = len(bmarks)
     self.matcher = LocationMatcher(bmarks)
Exemplo n.º 14
0
 def __init__(self, where):
     self.matcher = LocationMatcher(where)
     self.num_procs = -1
     self.last_anchors = None