func (s *WorkingSet) Clear(mu uc.Unicorn) *errors.Error { if s.newest == -1 { return nil } for i := s.oldest; i != s.newest; i = (i + 1) % len(s.mapped) { err := mu.MemUnmap(s.mapped[i], pagesize) if err != nil { return wrap(err) } } return nil }
func (s *WorkingSet) StoreInWorkingSet(addr uint64, mu uc.Unicorn) error { if s.newest == -1 { s.mapped[0] = addr s.oldest = 0 s.newest = 0 } s.newest = (s.newest + 1) % len(s.mapped) if s.newest == s.oldest { // unmap old page addr_to_unmap := s.mapped[s.oldest] err := mu.MemUnmap(addr_to_unmap, pagesize) if err != nil { return err } } s.oldest = (s.oldest + 1) % len(s.mapped) s.mapped[s.newest] = addr return nil }
func (s *WorkingSet) StoreInWorkingSet(addr uint64, mu uc.Unicorn) *errors.Error { if log_mem { log.WithFields(log.Fields{"addr": hex(addr)}).Debug("Store In Working Set") } if s.newest == -1 { s.mapped[0] = addr s.oldest = 0 s.newest = 0 } s.newest = (s.newest + 1) % len(s.mapped) if s.newest == s.oldest { // unmap old page addr_to_unmap := s.mapped[s.oldest] if log_mem { log.WithFields(log.Fields{"addr_to_unmap": addr_to_unmap}).Debug("unmap") } err := mu.MemUnmap(addr_to_unmap, pagesize) if err != nil { return wrap(err) } } s.oldest = (s.oldest + 1) % len(s.mapped) s.mapped[s.newest] = addr return nil }