OLD | NEW |
(Empty) | |
| 1 //===- NaClFuzz.cpp - Fuzz PNaCl bitcode records --------------------------===// |
| 2 // |
| 3 // The LLVM Compiler Infrastructure |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 // |
| 10 // This file implements a basic fuzzer for a list of PNaCl bitcode records. |
| 11 // |
| 12 //===----------------------------------------------------------------------===// |
| 13 |
| 14 #include "llvm/ADT/STLExtras.h" |
| 15 #include "llvm/Bitcode/NaCl/NaClFuzz.h" |
| 16 |
| 17 using namespace llvm; |
| 18 |
| 19 namespace { |
| 20 |
| 21 // Names for edit actions. |
| 22 const char *ActionNameArray[] = { |
| 23 "Insert", |
| 24 "Mutate", |
| 25 "Remove", |
| 26 "Replace", |
| 27 "Swap" |
| 28 }; |
| 29 |
| 30 } // end of anonymous namespace |
| 31 |
| 32 namespace naclfuzz { |
| 33 |
| 34 const char *RecordFuzzer::actionName(EditAction Action) { |
| 35 return Action < array_lengthof(ActionNameArray) |
| 36 ? ActionNameArray[Action] : "???"; |
| 37 } |
| 38 |
| 39 RecordFuzzer::RecordFuzzer(NaClMungedBitcode &Bitcode, |
| 40 RandomNumberGenerator &Generator) |
| 41 : Bitcode(Bitcode), Generator(Generator) { |
| 42 if (Bitcode.getBaseRecords().empty()) |
| 43 report_fatal_error( |
| 44 "Sorry, the fuzzer doesn't know how to fuzz an empty record list"); |
| 45 } |
| 46 |
| 47 RecordFuzzer::~RecordFuzzer() {} |
| 48 |
| 49 void RecordFuzzer::clear() { |
| 50 Bitcode.removeEdits(); |
| 51 } |
| 52 |
| 53 } // end of namespace naclfuzz |
OLD | NEW |