summaryrefslogtreecommitdiffstats
path: root/compiler-rt/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
commit1fd005f552595ceb2a10f2deacc6b64a50019afb (patch)
tree224b67c41f607b9c7564e49515ba03cfa5beaf85 /compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp
parentf3914b74c1825f4deece3317542743109dabbf56 (diff)
downloadbcm5719-llvm-1fd005f552595ceb2a10f2deacc6b64a50019afb.tar.gz
bcm5719-llvm-1fd005f552595ceb2a10f2deacc6b64a50019afb.zip
[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
llvm-svn: 334058
Diffstat (limited to 'compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp')
-rw-r--r--compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp b/compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp
index 99863074d72..a79c796ac45 100644
--- a/compiler-rt/lib/fuzzer/dataflow/DataFlow.cpp
+++ b/compiler-rt/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;
}
OpenPOWER on IntegriCloud