OLD | NEW |
(Empty) | |
| 1 //===- NaClFuzz.h - Fuzz PNaCl bitcode records ------------------*- C++ -*-===// |
| 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 #include "llvm/ADT/STLExtras.h" |
| 13 #include "llvm/Bitcode/NaCl/NaClFuzz.h" |
| 14 #include "llvm/Support/Format.h" |
| 15 |
| 16 #include <array> |
| 17 #include <cmath> |
| 18 #include <cstdlib> |
| 19 #include <map> |
| 20 #include <set> |
| 21 |
| 22 |
| 23 using namespace llvm; |
| 24 using namespace naclfuzz; |
| 25 |
| 26 namespace { |
| 27 |
| 28 // Names for edit actions. |
| 29 const char *ActionNameArray[] = { |
| 30 "Insert", |
| 31 "Mutate", |
| 32 "Remove", |
| 33 "Replace", |
| 34 "Swap" |
| 35 }; |
| 36 |
| 37 } // end of namespace naclfuzz |
| 38 |
| 39 namespace naclfuzz { |
| 40 |
| 41 const char *RecordFuzzer::actionName(EditAction Action) { |
| 42 return Action < array_lengthof(ActionNameArray) |
| 43 ? ActionNameArray[Action] : "???"; |
| 44 } |
| 45 |
| 46 RecordFuzzer::RecordFuzzer(NaClMungedBitcode &Bitcode) |
| 47 : Bitcode(Bitcode) { |
| 48 if (Bitcode.getBaseRecords().empty()) |
| 49 report_fatal_error( |
| 50 "Sorry, the fuzzer doesn't know how to fuzz an empty record list"); |
| 51 } |
| 52 |
| 53 RecordFuzzer::~RecordFuzzer() {} |
| 54 |
| 55 void RecordFuzzer::clear() { |
| 56 Bitcode.removeEdits(); |
| 57 } |
| 58 |
| 59 } // end of namespace naclfuzz |
OLD | NEW |