mutator.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef TOOLS_IPC_FUZZER_MUTATE_MUTATOR_H_
  5. #define TOOLS_IPC_FUZZER_MUTATE_MUTATOR_H_
  6. #include <stddef.h>
  7. #include <stdint.h>
  8. #include <string>
  9. #include "tools/ipc_fuzzer/fuzzer/fuzzer.h"
  10. namespace ipc_fuzzer {
  11. class Mutator : public Fuzzer {
  12. public:
  13. explicit Mutator(unsigned int frequency) : frequency_(frequency) {}
  14. virtual ~Mutator() {}
  15. void FuzzBool(bool* value) override;
  16. void FuzzInt(int* value) override;
  17. void FuzzLong(long* value) override;
  18. void FuzzSize(size_t* value) override;
  19. void FuzzUChar(unsigned char* value) override;
  20. void FuzzWChar(wchar_t* value) override;
  21. void FuzzUInt16(uint16_t* value) override;
  22. void FuzzUInt32(uint32_t* value) override;
  23. void FuzzInt64(int64_t* value) override;
  24. void FuzzUInt64(uint64_t* value) override;
  25. void FuzzFloat(float* value) override;
  26. void FuzzDouble(double* value) override;
  27. void FuzzString(std::string* value) override;
  28. void FuzzString16(base::string16* value) override;
  29. void FuzzData(char* data, int length) override;
  30. void FuzzBytes(void* data, int data_len) override;
  31. bool ShouldGenerate() override;
  32. private:
  33. // TODO(mbarbella): Use double frequencies.
  34. unsigned int frequency_;
  35. };
  36. } // namespace ipc_fuzzer
  37. #endif // TOOLS_IPC_FUZZER_MUTATE_MUTATOR_H_