mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-17 20:28:08 +00:00
refactoring debug/be_quiet, fatal on dont_optimize and instrument_file
This commit is contained in:
@ -56,7 +56,6 @@ struct InsTrim : public ModulePass {
|
||||
|
||||
protected:
|
||||
uint32_t function_minimum_size = 1;
|
||||
uint32_t debug = 0;
|
||||
char * skip_nozero = NULL;
|
||||
|
||||
private:
|
||||
@ -102,7 +101,6 @@ struct InsTrim : public ModulePass {
|
||||
|
||||
bool runOnModule(Module &M) override {
|
||||
|
||||
char be_quiet = 0;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
|
||||
if ((isatty(2) && !getenv("AFL_QUIET")) || getenv("AFL_DEBUG") != NULL) {
|
||||
|
@ -639,6 +639,10 @@ int main(int argc, char **argv, char **envp) {
|
||||
|
||||
}
|
||||
|
||||
if ((getenv("AFL_LLVM_INSTRUMENT_FILE") || getenv("AFL_LLVM_WHITELIST")) &&
|
||||
getenv("AFL_DONT_OPTIMIZE"))
|
||||
FATAL("AFL_LLVM_INSTRUMENT_FILE and AFL_DONT_OPTIMIZE cannot be combined");
|
||||
|
||||
if (getenv("AFL_LLVM_INSTRIM") || getenv("INSTRIM") ||
|
||||
getenv("INSTRIM_LIB")) {
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <fstream>
|
||||
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
#define IS_EXTERN extern
|
||||
#include "afl-llvm-common.h"
|
||||
|
||||
using namespace llvm;
|
||||
@ -88,6 +90,7 @@ void initInstrumentList() {
|
||||
char *instrumentListFilename = getenv("AFL_LLVM_INSTRUMENT_FILE");
|
||||
if (!instrumentListFilename)
|
||||
instrumentListFilename = getenv("AFL_LLVM_WHITELIST");
|
||||
|
||||
if (instrumentListFilename) {
|
||||
|
||||
std::string line;
|
||||
@ -105,6 +108,10 @@ void initInstrumentList() {
|
||||
|
||||
}
|
||||
|
||||
if (debug)
|
||||
SAYF(cMGN "[D] " cRST "loaded instrument list with %zu entries\n",
|
||||
myInstrumentList.size());
|
||||
|
||||
}
|
||||
|
||||
bool isInInstrumentList(llvm::Function *F) {
|
||||
@ -145,8 +152,6 @@ bool isInInstrumentList(llvm::Function *F) {
|
||||
|
||||
}
|
||||
|
||||
(void)instLine;
|
||||
|
||||
/* Continue only if we know where we actually are */
|
||||
if (!instFilename.str().empty()) {
|
||||
|
||||
@ -164,6 +169,10 @@ bool isInInstrumentList(llvm::Function *F) {
|
||||
if (fnmatch(("*" + *it).c_str(), instFilename.str().c_str(), 0) ==
|
||||
0) {
|
||||
|
||||
if (debug)
|
||||
SAYF(cMGN "[D] " cRST
|
||||
"Function %s is in the list (%s), instrumenting ... \n",
|
||||
F->getName().str().c_str(), instFilename.str().c_str());
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -219,12 +228,15 @@ bool isInInstrumentList(llvm::Function *F) {
|
||||
|
||||
// we could not find out the location. in this case we say it is not
|
||||
// in the the instrument file list
|
||||
|
||||
if (!be_quiet)
|
||||
WARNF(
|
||||
"No debug information found for function %s, will not be "
|
||||
"instrumented (recompile with -g -O[1-3]).",
|
||||
F->getName().str().c_str());
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
return false;
|
||||
|
||||
}
|
||||
|
@ -38,5 +38,14 @@ void initInstrumentList();
|
||||
bool isInInstrumentList(llvm::Function *F);
|
||||
unsigned long long int calculateCollisions(uint32_t edges);
|
||||
|
||||
#ifndef IS_EXTERN
|
||||
#define IS_EXTERN
|
||||
#endif
|
||||
|
||||
IS_EXTERN int debug;
|
||||
IS_EXTERN int be_quiet;
|
||||
|
||||
#undef IS_EXTERN
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -73,8 +73,8 @@ struct InsTrimLTO : public ModulePass {
|
||||
protected:
|
||||
uint32_t function_minimum_size = 1;
|
||||
char * skip_nozero = NULL;
|
||||
int afl_global_id = 1, debug = 0, autodictionary = 1;
|
||||
uint32_t be_quiet = 0, inst_blocks = 0, inst_funcs = 0;
|
||||
int afl_global_id = 1, autodictionary = 1;
|
||||
uint32_t inst_blocks = 0, inst_funcs = 0;
|
||||
uint64_t map_addr = 0x10000;
|
||||
|
||||
public:
|
||||
|
@ -86,9 +86,9 @@ class AFLLTOPass : public ModulePass {
|
||||
bool runOnModule(Module &M) override;
|
||||
|
||||
protected:
|
||||
int afl_global_id = 1, debug = 0, autodictionary = 1;
|
||||
int afl_global_id = 1, autodictionary = 1;
|
||||
uint32_t function_minimum_size = 1;
|
||||
uint32_t be_quiet = 0, inst_blocks = 0, inst_funcs = 0, total_instr = 0;
|
||||
uint32_t inst_blocks = 0, inst_funcs = 0, total_instr = 0;
|
||||
uint64_t map_addr = 0x10000;
|
||||
char * skip_nozero = NULL;
|
||||
|
||||
@ -207,7 +207,8 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
||||
if (debug)
|
||||
fprintf(stderr,
|
||||
"DEBUG: Function %s is not in a source file that was specified "
|
||||
"in the instrument file list\n", F.getName().str().c_str());
|
||||
"in the instrument file list\n",
|
||||
F.getName().str().c_str());
|
||||
continue;
|
||||
|
||||
}
|
||||
|
@ -104,7 +104,6 @@ class AFLcheckIfInstrument : public ModulePass {
|
||||
|
||||
protected:
|
||||
std::list<std::string> myInstrumentList;
|
||||
int debug = 0;
|
||||
|
||||
};
|
||||
|
||||
@ -116,7 +115,6 @@ bool AFLcheckIfInstrument::runOnModule(Module &M) {
|
||||
|
||||
/* Show a banner */
|
||||
|
||||
char be_quiet = 0;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
|
||||
if ((isatty(2) && !getenv("AFL_QUIET")) || getenv("AFL_DEBUG") != NULL) {
|
||||
@ -209,8 +207,10 @@ bool AFLcheckIfInstrument::runOnModule(Module &M) {
|
||||
} else {
|
||||
|
||||
if (!be_quiet)
|
||||
WARNF("No debug information found for function %s, recompile with -g",
|
||||
F.getName().str().c_str());
|
||||
WARNF(
|
||||
"No debug information found for function %s, recompile with -g "
|
||||
"-O[1-3]",
|
||||
F.getName().str().c_str());
|
||||
continue;
|
||||
|
||||
}
|
||||
|
@ -82,7 +82,6 @@ class AFLCoverage : public ModulePass {
|
||||
|
||||
protected:
|
||||
uint32_t ngram_size = 0;
|
||||
uint32_t debug = 0;
|
||||
uint32_t map_size = MAP_SIZE;
|
||||
uint32_t function_minimum_size = 1;
|
||||
char * ctx_str = NULL, *skip_nozero = NULL;
|
||||
@ -139,7 +138,6 @@ bool AFLCoverage::runOnModule(Module &M) {
|
||||
|
||||
/* Show a banner */
|
||||
|
||||
char be_quiet = 0;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
|
||||
if (getenv("AFL_DEBUG")) debug = 1;
|
||||
|
@ -76,9 +76,6 @@ class CmpLogInstructions : public ModulePass {
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
int be_quiet = 0;
|
||||
|
||||
private:
|
||||
bool hookInstrs(Module &M);
|
||||
|
||||
|
@ -76,9 +76,6 @@ class CmpLogRoutines : public ModulePass {
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
int be_quiet = 0;
|
||||
|
||||
private:
|
||||
bool hookRtns(Module &M);
|
||||
|
||||
|
@ -75,9 +75,6 @@ class CompareTransform : public ModulePass {
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
int be_quiet = 0;
|
||||
|
||||
private:
|
||||
bool transformCmps(Module &M, const bool processStrcmp,
|
||||
const bool processMemcmp, const bool processStrncmp,
|
||||
|
@ -71,9 +71,6 @@ class SplitComparesTransform : public ModulePass {
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
int be_quiet = 0;
|
||||
|
||||
private:
|
||||
int enableFPSplit;
|
||||
|
||||
|
@ -91,9 +91,6 @@ class SplitSwitchesTransform : public ModulePass {
|
||||
|
||||
typedef std::vector<CaseExpr> CaseVector;
|
||||
|
||||
protected:
|
||||
int be_quiet = 0;
|
||||
|
||||
private:
|
||||
bool splitSwitches(Module &M);
|
||||
bool transformCmps(Module &M, const bool processStrcmp,
|
||||
|
Reference in New Issue
Block a user