summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerInterface.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-09-04 00:12:11 +0000
committerKostya Serebryany <kcc@google.com>2015-09-04 00:12:11 +0000
commit7d211662188c6ee6aa8a073ff55773e3978c28c5 (patch)
treee7aa3fd0153b42f71a3bfd6050f0b9e7ba148d18 /llvm/lib/Fuzzer/FuzzerInterface.h
parent4a7be2397684f3c9d7d897392b96e68d4c086e76 (diff)
downloadbcm5719-llvm-7d211662188c6ee6aa8a073ff55773e3978c28c5.tar.gz
bcm5719-llvm-7d211662188c6ee6aa8a073ff55773e3978c28c5.zip
[libFuzzer] actually make the dictionaries work (+docs)
llvm-svn: 246825
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerInterface.h')
-rw-r--r--llvm/lib/Fuzzer/FuzzerInterface.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerInterface.h b/llvm/lib/Fuzzer/FuzzerInterface.h
index d3843a47d1c..8798b650383 100644
--- a/llvm/lib/Fuzzer/FuzzerInterface.h
+++ b/llvm/lib/Fuzzer/FuzzerInterface.h
@@ -64,7 +64,8 @@ class FuzzerRandomLibc : public FuzzerRandomBase {
class MutationDispatcher {
public:
- MutationDispatcher(FuzzerRandomBase &Rand) : Rand(Rand) {}
+ MutationDispatcher(FuzzerRandomBase &Rand);
+ ~MutationDispatcher();
/// Mutates data by shuffling bytes.
size_t Mutate_ShuffleBytes(uint8_t *Data, size_t Size, size_t MaxSize);
/// Mutates data by erasing a byte.
@@ -76,6 +77,10 @@ class MutationDispatcher {
/// Mutates data by chanding one bit.
size_t Mutate_ChangeBit(uint8_t *Data, size_t Size, size_t MaxSize);
+ /// Mutates data by adding a word from the dictionary.
+ size_t Mutate_AddWordFromDictionary(uint8_t *Data, size_t Size,
+ size_t MaxSize);
+
/// Applies one of the above mutations.
/// Returns the new size of data which could be up to MaxSize.
size_t Mutate(uint8_t *Data, size_t Size, size_t MaxSize);
@@ -84,8 +89,12 @@ class MutationDispatcher {
size_t CrossOver(const uint8_t *Data1, size_t Size1, const uint8_t *Data2,
size_t Size2, uint8_t *Out, size_t MaxOutSize);
+ void AddWordToDictionary(const uint8_t *Word, size_t Size);
+
private:
FuzzerRandomBase &Rand;
+ struct Impl;
+ Impl *MDImpl;
};
// For backward compatibility only, deprecated.
@@ -140,6 +149,8 @@ class UserSuppliedFuzzer {
FuzzerRandomBase &GetRand() { return *Rand; }
+ MutationDispatcher &GetMD() { return MD; }
+
private:
bool OwnRand = false;
FuzzerRandomBase *Rand;
OpenPOWER on IntegriCloud