def handle_data_content(self):
        new_syscall = None
        if self.syscall is not None:
            new_syscall = scribe.EventSyscallExtra(nr=self.syscall.nr,
                                                   ret=0,
                                                   args=self.syscall.args)

            self.mutations = [
                None,
                Event(
                    scribe.EventDataExtra(data_type=scribe.SCRIBE_DATA_INPUT
                                          | scribe.SCRIBE_DATA_STRING,
                                          data=self.diverge_event.
                                          data[:self.diverge_event.size]),
                    self.proc),
                Event(scribe.EventSyscallEnd(), self.proc)
            ]
            add_state = self.get_add_state()

            self.add_event(self.syscall,
                           scribe.EventSetFlags(
                               0, scribe.SCRIBE_UNTIL_NEXT_SYSCALL,
                               new_syscall.encode()),
                           fly_state=add_state)
            # not replacing inline data events, it's messed up with resource
            # and all.
            #self.replace_event(self.culprit, scribe.EventData(data=self.diverge_event.data[:self.diverge_event.size]))

        start = self.syscall or self.culprit
        end = new_syscall or self.culprit
        self.delete_event(self.take_until_match(start, end))
        self.status = "diverge data content"
예제 #2
0
 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
    def add_event(self, event, add_event, add_location=None, fly_state=None):
        if not self.is_allowed_event('+'):
            return

        if not add_location:
            add_location = Location(event, 'before')

        add_events = [Event(add_event, event.proc)]
        if self.diverge_event.fatal or fly_state == ExecutionStates.TODO or \
                self.execution.depth_otf > self.explorer.max_otf:
            add_events.append(
                Event(scribe.EventNop(scribe.EventSyscallEnd().encode()),
                      event.proc))
            self.explorer.add_execution(
                self.execution,
                Execution(self.execution,
                          mutator.InsertEvent(add_location, add_events),
                          mutation_index=event.index + len(add_events),
                          fly_offset_delta=0,
                          mutation_pid=self.diverge_event.pid))
        else:
            if fly_state is None:
                fly_state = ExecutionStates.RUNNING
            add_events.extend([
                Event(scribe.EventNop(e.encode()), event.proc)
                for e in self.mutations[1:]
            ])
            self.explorer.add_execution(
                self.execution,
                Execution(self.execution,
                          mutator.InsertEvent(add_location, add_events),
                          state=fly_state,
                          running_session=self.execution.running_session,
                          mutation_index=event.index,
                          fly_offset_delta=len(add_events),
                          mutation_pid=self.diverge_event.pid))
예제 #4
0
    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
    def handle_default(self):
        new_syscall = None
        if self.syscall is not None:
            new_syscall = scribe.EventSyscallExtra(nr=self.syscall.nr,
                                                   ret=0,
                                                   args=self.syscall.args)
            self.mutations = [None, Event(scribe.EventSyscallEnd(), self.proc)]
            self.add_event(
                self.syscall,
                scribe.EventSetFlags(0, scribe.SCRIBE_UNTIL_NEXT_SYSCALL,
                                     new_syscall.encode()))

        start = self.syscall or self.culprit
        end = new_syscall or self.culprit
        self.delete_event(self.take_until_match(start, end))
        self.status = "unhandled case: %s" % self.diverge_event.__class__
    def extract_culprit(self):
        num = self.diverge_event.num_ev_consumed - 1
        if not self.diverge_event.fatal:
            if isinstance(self.diverge_event, scribe.EventDivergeSyscall):
                num += 1
            if isinstance(self.diverge_event, scribe.EventDivergeMemOwned):
                num += 1
        if isinstance(self.diverge_event, scribe.EventDivergeDataContent):
            num += 1

        self.pid = self.diverge_event.pid
        self.execution.update_progress(self.pid, num)
        self.execution.state = ExecutionStates.FAILED
        self.proc = self.execution.running_session.processes[self.pid]
        self.culprit = self.proc.events[num]
        self.mutations = map(lambda e: Event(e, self.proc), self.mutations)

        assert self.culprit.index == num

        try:
            self.syscall = self.culprit.syscall
        except AttributeError:
            self.syscall = None
    def replace_event(self, original, new):
        if not self.is_allowed_event('r'):
            return

        new = Event(new, self.proc)
        if self.diverge_event.fatal or self.execution.depth_otf > self.explorer.max_otf:
            print("Replacing: (%s) with (%s)" % (str(original), str(new)))
            self.explorer.add_execution(
                self.execution,
                Execution(self.execution,
                          mutator.Replace({original: new}),
                          mutation_index=original.index,
                          fly_offset_delta=0,
                          mutation_pid=self.pid))
        else:
            self.explorer.add_execution(
                self.execution,
                Execution(self.execution,
                          mutator.Replace({original: new}),
                          state=ExecutionStates.RUNNING,
                          running_session=self.execution.running_session,
                          mutation_index=original.index,
                          fly_offset_delta=0,
                          mutation_pid=self.pid))
예제 #8
0
 def __init__(self, session, flags):
     SetFlags.__init__(self,
                       Location(Event(Start(), session.init_proc), 'after'),
                       flags, scribe.SCRIBE_PERMANANT)
예제 #9
0
 def __init__(self, session):
     SetFlags.__init__(
         self, Location(Event(Start(), session.init_proc), 'after'),
         scribe.SCRIBE_PS_ENABLE_ALL & ~scribe.SCRIBE_PS_ENABLE_STRICT_RPY,
         scribe.SCRIBE_PERMANANT)