OLD | NEW |
---|---|
(Empty) | |
1 //===- NaClFuzz.h - Fuzz PNaCl bitcode records ------------------*- C++ -*-===// | |
jvoung (off chromium)
2015/06/01 17:26:35
NaClFuzz.cpp
No need to have the -*- C++... stuff
Karl
2015/06/01 22:40:54
Done.
| |
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. | |
jvoung (off chromium)
2015/06/01 17:26:35
//===---------------------------------------------
Karl
2015/06/01 22:40:54
Done.
| |
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 | |
jvoung (off chromium)
2015/06/01 17:26:35
This is anonymous namespace instead of namespace n
Karl
2015/06/01 22:40:54
Done.
| |
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 RandomNumberGenerator &Generator) | |
48 : Bitcode(Bitcode), Generator(Generator) { | |
49 if (Bitcode.getBaseRecords().empty()) | |
50 report_fatal_error( | |
51 "Sorry, the fuzzer doesn't know how to fuzz an empty record list"); | |
52 } | |
53 | |
54 RecordFuzzer::~RecordFuzzer() {} | |
55 | |
56 void RecordFuzzer::clear() { | |
57 Bitcode.removeEdits(); | |
58 } | |
59 | |
60 } // end of namespace naclfuzz | |
OLD | NEW |