summaryrefslogtreecommitdiff
path: root/lib/fuzzer/dataflow/DataFlow.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2018-06-06 01:23:29 +0000
committerKostya Serebryany <kcc@google.com>2018-06-06 01:23:29 +0000
commit9c4a366945d9fe7ed89e679c045f01bb311158ce (patch)
treeff1f3a69b540445b5cb900312f2144c102d2a8ae /lib/fuzzer/dataflow/DataFlow.cpp
parent7f47a0bea177db24ecfc75b9daf3874e39a869df (diff)
downloadcompiler-rt-9c4a366945d9fe7ed89e679c045f01bb311158ce.tar.gz
[libFuzzer] initial implementation of -data_flow_trace. It parses the data flow trace and prints the summary, but doesn't use the information in any other way yet
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@334058 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/fuzzer/dataflow/DataFlow.cpp')
-rw-r--r--lib/fuzzer/dataflow/DataFlow.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/fuzzer/dataflow/DataFlow.cpp b/lib/fuzzer/dataflow/DataFlow.cpp
index 99863074d..a79c796ac 100644
--- a/lib/fuzzer/dataflow/DataFlow.cpp
+++ b/lib/fuzzer/dataflow/DataFlow.cpp
@@ -69,6 +69,7 @@ static const uintptr_t *FuncsBeg;
static __thread size_t CurrentFunc;
static dfsan_label *FuncLabels; // Array of NumFuncs elements.
static char *PrintableStringForLabel; // InputLen + 2 bytes.
+static bool LabelSeen[1 << 8 * sizeof(dfsan_label)];
// Prints all instrumented functions.
static int PrintFunctions() {
@@ -89,7 +90,11 @@ static int PrintFunctions() {
return 0;
}
-static void SetBytesForLabel(dfsan_label L, char *Bytes) {
+extern "C"
+void SetBytesForLabel(dfsan_label L, char *Bytes) {
+ if (LabelSeen[L])
+ return;
+ LabelSeen[L] = true;
assert(L);
if (L <= InputLen + 1) {
Bytes[L - 1] = '1';
@@ -103,6 +108,7 @@ static void SetBytesForLabel(dfsan_label L, char *Bytes) {
static char *GetPrintableStringForLabel(dfsan_label L) {
memset(PrintableStringForLabel, '0', InputLen + 1);
PrintableStringForLabel[InputLen + 1] = 0;
+ memset(LabelSeen, 0, sizeof(LabelSeen));
SetBytesForLabel(L, PrintableStringForLabel);
return PrintableStringForLabel;
}