blob: 91a9746e729128d54d78e5918ecd7fb6c0d4d0cc [file] [log] [blame]
Kostya Serebryanyda63c1d2016-02-26 21:33:56 +00001//===- FuzzerTracePC.cpp - PC tracing--------------------------------------===//
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// Trace PCs.
Kostya Serebryanya00b2432016-09-14 02:13:06 +000010// This module implements __sanitizer_cov_trace_pc_guard[_init],
11// the callback required for -fsanitize-coverage=trace-pc-guard instrumentation.
Kostya Serebryanyda63c1d2016-02-26 21:33:56 +000012//
Kostya Serebryanyda63c1d2016-02-26 21:33:56 +000013//===----------------------------------------------------------------------===//
14
Kostya Serebryany1c73f1b2016-10-05 22:56:21 +000015#include "FuzzerCorpus.h"
Kostya Serebryany86586182016-09-21 21:17:23 +000016#include "FuzzerDefs.h"
Kostya Serebryanya5f94fb2016-10-14 20:20:33 +000017#include "FuzzerDictionary.h"
Kostya Serebryany95b1a432016-10-19 00:12:03 +000018#include "FuzzerExtFunctions.h"
Zachary Turner24a148b2016-11-30 19:06:14 +000019#include "FuzzerIO.h"
Kostya Serebryany6f5a8042016-09-21 01:50:50 +000020#include "FuzzerTracePC.h"
Marcos Pividori62c8fc52017-01-22 01:58:26 +000021#include "FuzzerUtil.h"
Kostya Serebryany86586182016-09-21 21:17:23 +000022#include "FuzzerValueBitMap.h"
Zachary Turner24a148b2016-11-30 19:06:14 +000023#include <map>
24#include <set>
25#include <sstream>
Kostya Serebryanyda63c1d2016-02-26 21:33:56 +000026
27namespace fuzzer {
Mike Aizatsky1aa501e2016-05-10 23:43:15 +000028
Kostya Serebryanya00b2432016-09-14 02:13:06 +000029TracePC TPC;
Mike Aizatsky1aa501e2016-05-10 23:43:15 +000030
Kostya Serebryanya9b0dd02016-09-29 17:43:24 +000031void TracePC::HandleTrace(uint32_t *Guard, uintptr_t PC) {
32 uint32_t Idx = *Guard;
Kostya Serebryany8e781a82016-09-18 04:52:23 +000033 if (!Idx) return;
Kostya Serebryany2fabeca2016-10-26 18:52:04 +000034 PCs[Idx % kNumPCs] = PC;
35 Counters[Idx % kNumCounters]++;
Kostya Serebryanyda63c1d2016-02-26 21:33:56 +000036}
Kostya Serebryanya5277d52016-09-15 01:30:18 +000037
Kostya Serebryany275e2602016-10-25 23:52:25 +000038size_t TracePC::GetTotalPCCoverage() {
39 size_t Res = 0;
Kostya Serebryany06b87572016-10-26 00:42:52 +000040 for (size_t i = 1; i < GetNumPCs(); i++)
Kostya Serebryany275e2602016-10-25 23:52:25 +000041 if (PCs[i])
42 Res++;
43 return Res;
44}
45
Kostya Serebryanya9b0dd02016-09-29 17:43:24 +000046void TracePC::HandleInit(uint32_t *Start, uint32_t *Stop) {
Kostya Serebryany3e36ec12016-09-17 05:04:47 +000047 if (Start == Stop || *Start) return;
48 assert(NumModules < sizeof(Modules) / sizeof(Modules[0]));
Kostya Serebryanya9b0dd02016-09-29 17:43:24 +000049 for (uint32_t *P = Start; P < Stop; P++)
Kostya Serebryany8e781a82016-09-18 04:52:23 +000050 *P = ++NumGuards;
Kostya Serebryany3e36ec12016-09-17 05:04:47 +000051 Modules[NumModules].Start = Start;
52 Modules[NumModules].Stop = Stop;
53 NumModules++;
54}
55
56void TracePC::PrintModuleInfo() {
57 Printf("INFO: Loaded %zd modules (%zd guards): ", NumModules, NumGuards);
58 for (size_t i = 0; i < NumModules; i++)
59 Printf("[%p, %p), ", Modules[i].Start, Modules[i].Stop);
60 Printf("\n");
Kostya Serebryanyda63c1d2016-02-26 21:33:56 +000061}
Kostya Serebryanya5277d52016-09-15 01:30:18 +000062
Kostya Serebryany09845172016-09-15 22:16:15 +000063void TracePC::HandleCallerCallee(uintptr_t Caller, uintptr_t Callee) {
64 const uintptr_t kBits = 12;
65 const uintptr_t kMask = (1 << kBits) - 1;
Kostya Serebryany1c73f1b2016-10-05 22:56:21 +000066 uintptr_t Idx = (Caller & kMask) | ((Callee & kMask) << kBits);
67 HandleValueProfile(Idx);
Kostya Serebryany09845172016-09-15 22:16:15 +000068}
69
Kostya Serebryany11a22bc2016-12-30 01:13:07 +000070void TracePC::InitializePrintNewPCs() {
Kostya Serebryany4986e812017-01-03 18:51:28 +000071 if (!DoPrintNewPCs) return;
Kostya Serebryany11a22bc2016-12-30 01:13:07 +000072 assert(!PrintedPCs);
73 PrintedPCs = new std::set<uintptr_t>;
74 for (size_t i = 1; i < GetNumPCs(); i++)
75 if (PCs[i])
76 PrintedPCs->insert(PCs[i]);
77}
78
Kostya Serebryanya5b2e542016-10-26 00:20:51 +000079void TracePC::PrintNewPCs() {
Kostya Serebryany4986e812017-01-03 18:51:28 +000080 if (!DoPrintNewPCs) return;
Kostya Serebryany11a22bc2016-12-30 01:13:07 +000081 assert(PrintedPCs);
82 for (size_t i = 1; i < GetNumPCs(); i++)
83 if (PCs[i] && PrintedPCs->insert(PCs[i]).second)
84 PrintPC("\tNEW_PC: %p %F %L\n", "\tNEW_PC: %p\n", PCs[i]);
Kostya Serebryanya5b2e542016-10-26 00:20:51 +000085}
86
Kostya Serebryanyb706b482016-09-18 21:47:08 +000087void TracePC::PrintCoverage() {
Kostya Serebryany1394ce22016-12-10 01:19:35 +000088 if (!EF->__sanitizer_symbolize_pc ||
89 !EF->__sanitizer_get_module_and_offset_for_pc) {
90 Printf("INFO: __sanitizer_symbolize_pc or "
91 "__sanitizer_get_module_and_offset_for_pc is not available,"
Kostya Serebryany95b1a432016-10-19 00:12:03 +000092 " not printing coverage\n");
93 return;
94 }
95 std::map<std::string, std::vector<uintptr_t>> CoveredPCsPerModule;
96 std::map<std::string, uintptr_t> ModuleOffsets;
Kostya Serebryany1cba0a92016-11-30 21:53:32 +000097 std::set<std::string> CoveredDirs, CoveredFiles, CoveredFunctions,
98 CoveredLines;
Kostya Serebryanyb706b482016-09-18 21:47:08 +000099 Printf("COVERAGE:\n");
Kostya Serebryany06b87572016-10-26 00:42:52 +0000100 for (size_t i = 1; i < GetNumPCs(); i++) {
Kostya Serebryany95b1a432016-10-19 00:12:03 +0000101 if (!PCs[i]) continue;
102 std::string FileStr = DescribePC("%s", PCs[i]);
103 if (!IsInterestingCoverageFile(FileStr)) continue;
104 std::string FixedPCStr = DescribePC("%p", PCs[i]);
105 std::string FunctionStr = DescribePC("%F", PCs[i]);
106 std::string LineStr = DescribePC("%l", PCs[i]);
Kostya Serebryany1394ce22016-12-10 01:19:35 +0000107 char ModulePathRaw[4096] = ""; // What's PATH_MAX in portable C++?
108 void *OffsetRaw = nullptr;
109 if (!EF->__sanitizer_get_module_and_offset_for_pc(
110 reinterpret_cast<void *>(PCs[i]), ModulePathRaw,
111 sizeof(ModulePathRaw), &OffsetRaw))
112 continue;
113 std::string Module = ModulePathRaw;
Kostya Serebryany95b1a432016-10-19 00:12:03 +0000114 uintptr_t FixedPC = std::stol(FixedPCStr, 0, 16);
Kostya Serebryany1394ce22016-12-10 01:19:35 +0000115 uintptr_t PcOffset = reinterpret_cast<uintptr_t>(OffsetRaw);
Kostya Serebryany95b1a432016-10-19 00:12:03 +0000116 ModuleOffsets[Module] = FixedPC - PcOffset;
117 CoveredPCsPerModule[Module].push_back(PcOffset);
118 CoveredFunctions.insert(FunctionStr);
119 CoveredFiles.insert(FileStr);
Kostya Serebryany1cba0a92016-11-30 21:53:32 +0000120 CoveredDirs.insert(DirName(FileStr));
Kostya Serebryany95b1a432016-10-19 00:12:03 +0000121 if (!CoveredLines.insert(FileStr + ":" + LineStr).second)
122 continue;
123 Printf("COVERED: %s %s:%s\n", FunctionStr.c_str(),
124 FileStr.c_str(), LineStr.c_str());
125 }
126
Kostya Serebryany1cba0a92016-11-30 21:53:32 +0000127 std::string CoveredDirsStr;
128 for (auto &Dir : CoveredDirs) {
129 if (!CoveredDirsStr.empty())
130 CoveredDirsStr += ",";
131 CoveredDirsStr += Dir;
132 }
133 Printf("COVERED_DIRS: %s\n", CoveredDirsStr.c_str());
134
Kostya Serebryany95b1a432016-10-19 00:12:03 +0000135 for (auto &M : CoveredPCsPerModule) {
136 std::set<std::string> UncoveredFiles, UncoveredFunctions;
137 std::map<std::string, std::set<int> > UncoveredLines; // Func+File => lines
138 auto &ModuleName = M.first;
139 auto &CoveredOffsets = M.second;
140 uintptr_t ModuleOffset = ModuleOffsets[ModuleName];
141 std::sort(CoveredOffsets.begin(), CoveredOffsets.end());
142 Printf("MODULE_WITH_COVERAGE: %s\n", ModuleName.c_str());
143 // sancov does not yet fully support DSOs.
144 // std::string Cmd = "sancov -print-coverage-pcs " + ModuleName;
Marcos Pividori62c8fc52017-01-22 01:58:26 +0000145 std::string Cmd = DisassembleCmd(ModuleName) + " | " +
146 SearchRegexCmd("call.*__sanitizer_cov_trace_pc_guard");
Kostya Serebryany95b1a432016-10-19 00:12:03 +0000147 std::string SanCovOutput;
148 if (!ExecuteCommandAndReadOutput(Cmd, &SanCovOutput)) {
149 Printf("INFO: Command failed: %s\n", Cmd.c_str());
150 continue;
151 }
152 std::istringstream ISS(SanCovOutput);
153 std::string S;
154 while (std::getline(ISS, S, '\n')) {
Marcos Pividori62c8fc52017-01-22 01:58:26 +0000155 size_t PcOffsetEnd = S.find(':');
156 if (PcOffsetEnd == std::string::npos)
157 continue;
158 S.resize(PcOffsetEnd);
Kostya Serebryany95b1a432016-10-19 00:12:03 +0000159 uintptr_t PcOffset = std::stol(S, 0, 16);
160 if (!std::binary_search(CoveredOffsets.begin(), CoveredOffsets.end(),
161 PcOffset)) {
162 uintptr_t PC = ModuleOffset + PcOffset;
163 auto FileStr = DescribePC("%s", PC);
164 if (!IsInterestingCoverageFile(FileStr)) continue;
165 if (CoveredFiles.count(FileStr) == 0) {
166 UncoveredFiles.insert(FileStr);
167 continue;
168 }
169 auto FunctionStr = DescribePC("%F", PC);
170 if (CoveredFunctions.count(FunctionStr) == 0) {
171 UncoveredFunctions.insert(FunctionStr);
172 continue;
173 }
174 std::string LineStr = DescribePC("%l", PC);
175 uintptr_t Line = std::stoi(LineStr);
176 std::string FileLineStr = FileStr + ":" + LineStr;
177 if (CoveredLines.count(FileLineStr) == 0)
178 UncoveredLines[FunctionStr + " " + FileStr].insert(Line);
179 }
180 }
181 for (auto &FileLine: UncoveredLines)
182 for (int Line : FileLine.second)
183 Printf("UNCOVERED_LINE: %s:%d\n", FileLine.first.c_str(), Line);
184 for (auto &Func : UncoveredFunctions)
185 Printf("UNCOVERED_FUNC: %s\n", Func.c_str());
186 for (auto &File : UncoveredFiles)
187 Printf("UNCOVERED_FILE: %s\n", File.c_str());
Kostya Serebryanyb706b482016-09-18 21:47:08 +0000188 }
189}
190
Mike Aizatsky9b415be2016-12-19 22:18:08 +0000191void TracePC::DumpCoverage() {
Kostya Serebryanyeee8b4a2017-01-20 23:35:29 +0000192 if (EF->__sanitizer_dump_coverage)
193 EF->__sanitizer_dump_coverage(PCs, GetNumPCs());
Mike Aizatsky9b415be2016-12-19 22:18:08 +0000194}
195
Kostya Serebryany379359c2016-10-05 01:09:40 +0000196// Value profile.
197// We keep track of various values that affect control flow.
198// These values are inserted into a bit-set-based hash map.
199// Every new bit in the map is treated as a new coverage.
200//
201// For memcmp/strcmp/etc the interesting value is the length of the common
202// prefix of the parameters.
203// For cmp instructions the interesting value is a XOR of the parameters.
204// The interesting value is mixed up with the PC and is then added to the map.
205
Kostya Serebryany3a4e2dd2016-12-16 22:45:25 +0000206ATTRIBUTE_NO_SANITIZE_MEMORY
Kostya Serebryany379359c2016-10-05 01:09:40 +0000207void TracePC::AddValueForMemcmp(void *caller_pc, const void *s1, const void *s2,
Kostya Serebryany1d8c2ce2017-01-17 23:09:05 +0000208 size_t n, bool StopAtZero) {
Kostya Serebryany379359c2016-10-05 01:09:40 +0000209 if (!n) return;
Kostya Serebryany1d8c2ce2017-01-17 23:09:05 +0000210 size_t Len = std::min(n, Word::GetMaxSize());
Kostya Serebryany379359c2016-10-05 01:09:40 +0000211 const uint8_t *A1 = reinterpret_cast<const uint8_t *>(s1);
212 const uint8_t *A2 = reinterpret_cast<const uint8_t *>(s2);
Kostya Serebryany1d8c2ce2017-01-17 23:09:05 +0000213 uint8_t B1[Word::kMaxSize];
214 uint8_t B2[Word::kMaxSize];
215 // Copy the data into locals in this non-msan-instrumented function
216 // to avoid msan complaining further.
Kostya Serebryany6bdd8fc2017-01-23 22:11:04 +0000217 size_t Hash = 0; // Compute some simple hash of both strings.
Kostya Serebryany1d8c2ce2017-01-17 23:09:05 +0000218 for (size_t i = 0; i < Len; i++) {
219 B1[i] = A1[i];
220 B2[i] = A2[i];
Kostya Serebryany6bdd8fc2017-01-23 22:11:04 +0000221 size_t T = B1[i];
222 Hash ^= (T << 8) | B2[i];
Kostya Serebryany1d8c2ce2017-01-17 23:09:05 +0000223 }
Kostya Serebryany379359c2016-10-05 01:09:40 +0000224 size_t I = 0;
225 for (; I < Len; I++)
Kostya Serebryany1d8c2ce2017-01-17 23:09:05 +0000226 if (B1[I] != B2[I] || (StopAtZero && B1[I] == 0))
Kostya Serebryany379359c2016-10-05 01:09:40 +0000227 break;
228 size_t PC = reinterpret_cast<size_t>(caller_pc);
Kostya Serebryany1d8c2ce2017-01-17 23:09:05 +0000229 size_t Idx = (PC & 4095) | (I << 12);
230 TPC.HandleValueProfile(Idx);
Kostya Serebryany6bdd8fc2017-01-23 22:11:04 +0000231 TORCW.Insert(Idx ^ Hash, Word(B1, Len), Word(B2, Len));
Kostya Serebryany379359c2016-10-05 01:09:40 +0000232}
233
Kostya Serebryany17d176e12016-10-13 16:19:09 +0000234template <class T>
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000235ATTRIBUTE_TARGET_POPCNT ALWAYS_INLINE
236void TracePC::HandleCmp(uintptr_t PC, T Arg1, T Arg2) {
Kostya Serebryanya5f94fb2016-10-14 20:20:33 +0000237 uint64_t ArgXor = Arg1 ^ Arg2;
238 uint64_t ArgDistance = __builtin_popcountl(ArgXor) + 1; // [1,65]
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000239 uintptr_t Idx = ((PC & 4095) + 1) * ArgDistance;
Kostya Serebryany94c427c2016-10-27 00:36:38 +0000240 if (sizeof(T) == 4)
241 TORC4.Insert(ArgXor, Arg1, Arg2);
242 else if (sizeof(T) == 8)
243 TORC8.Insert(ArgXor, Arg1, Arg2);
Kostya Serebryany17d176e12016-10-13 16:19:09 +0000244 HandleValueProfile(Idx);
Kostya Serebryany379359c2016-10-05 01:09:40 +0000245}
246
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000247inline ALWAYS_INLINE uintptr_t GetPreviousInstructionPc(void* pc) {
248 // TODO: this implementation is x86 only.
249 // see sanitizer_common GetPreviousInstructionPc for full implementation.
250 return reinterpret_cast<uintptr_t>(pc) - 1;
251}
252
Kostya Serebryanyda63c1d2016-02-26 21:33:56 +0000253} // namespace fuzzer
254
Dan Liew59144072016-06-06 20:27:09 +0000255extern "C" {
Marcos Pividori6137f982017-01-22 01:27:38 +0000256ATTRIBUTE_INTERFACE
Kostya Serebryanya9b0dd02016-09-29 17:43:24 +0000257void __sanitizer_cov_trace_pc_guard(uint32_t *Guard) {
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000258 uintptr_t PC = fuzzer::GetPreviousInstructionPc(__builtin_return_address(0));
Kostya Serebryanya5277d52016-09-15 01:30:18 +0000259 fuzzer::TPC.HandleTrace(Guard, PC);
Kostya Serebryanyda63c1d2016-02-26 21:33:56 +0000260}
Dan Liew59144072016-06-06 20:27:09 +0000261
Marcos Pividori6137f982017-01-22 01:27:38 +0000262ATTRIBUTE_INTERFACE
Kostya Serebryanya9b0dd02016-09-29 17:43:24 +0000263void __sanitizer_cov_trace_pc_guard_init(uint32_t *Start, uint32_t *Stop) {
Kostya Serebryanya5277d52016-09-15 01:30:18 +0000264 fuzzer::TPC.HandleInit(Start, Stop);
Dan Liew59144072016-06-06 20:27:09 +0000265}
Kostya Serebryany09845172016-09-15 22:16:15 +0000266
Marcos Pividori6137f982017-01-22 01:27:38 +0000267ATTRIBUTE_INTERFACE
Kostya Serebryany09845172016-09-15 22:16:15 +0000268void __sanitizer_cov_trace_pc_indir(uintptr_t Callee) {
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000269 uintptr_t PC = fuzzer::GetPreviousInstructionPc(__builtin_return_address(0));
Kostya Serebryany09845172016-09-15 22:16:15 +0000270 fuzzer::TPC.HandleCallerCallee(PC, Callee);
271}
Kostya Serebryany379359c2016-10-05 01:09:40 +0000272
Marcos Pividori6137f982017-01-22 01:27:38 +0000273ATTRIBUTE_INTERFACE
Kostya Serebryany17d176e12016-10-13 16:19:09 +0000274void __sanitizer_cov_trace_cmp8(uint64_t Arg1, uint64_t Arg2) {
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000275 uintptr_t PC = fuzzer::GetPreviousInstructionPc(__builtin_return_address(0));
276 fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);
Kostya Serebryany379359c2016-10-05 01:09:40 +0000277}
Marcos Pividori6137f982017-01-22 01:27:38 +0000278
279ATTRIBUTE_INTERFACE
Kostya Serebryany17d176e12016-10-13 16:19:09 +0000280void __sanitizer_cov_trace_cmp4(uint32_t Arg1, uint32_t Arg2) {
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000281 uintptr_t PC = fuzzer::GetPreviousInstructionPc(__builtin_return_address(0));
282 fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);
Kostya Serebryany379359c2016-10-05 01:09:40 +0000283}
Marcos Pividori6137f982017-01-22 01:27:38 +0000284
285ATTRIBUTE_INTERFACE
Kostya Serebryany17d176e12016-10-13 16:19:09 +0000286void __sanitizer_cov_trace_cmp2(uint16_t Arg1, uint16_t Arg2) {
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000287 uintptr_t PC = fuzzer::GetPreviousInstructionPc(__builtin_return_address(0));
288 fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);
Kostya Serebryany379359c2016-10-05 01:09:40 +0000289}
Marcos Pividori6137f982017-01-22 01:27:38 +0000290
291ATTRIBUTE_INTERFACE
Kostya Serebryany17d176e12016-10-13 16:19:09 +0000292void __sanitizer_cov_trace_cmp1(uint8_t Arg1, uint8_t Arg2) {
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000293 uintptr_t PC = fuzzer::GetPreviousInstructionPc(__builtin_return_address(0));
294 fuzzer::TPC.HandleCmp(PC, Arg1, Arg2);
Kostya Serebryany379359c2016-10-05 01:09:40 +0000295}
296
Marcos Pividori6137f982017-01-22 01:27:38 +0000297ATTRIBUTE_INTERFACE
Kostya Serebryany379359c2016-10-05 01:09:40 +0000298void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t *Cases) {
Kostya Serebryanyd19919a2016-10-11 01:14:41 +0000299 uint64_t N = Cases[0];
Kostya Serebryanyd7238042016-12-29 02:50:35 +0000300 uint64_t ValSizeInBits = Cases[1];
Kostya Serebryanyd19919a2016-10-11 01:14:41 +0000301 uint64_t *Vals = Cases + 2;
Kostya Serebryanyd7238042016-12-29 02:50:35 +0000302 // Skip the most common and the most boring case.
303 if (Vals[N - 1] < 256 && Val < 256)
304 return;
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000305 uintptr_t PC = fuzzer::GetPreviousInstructionPc(__builtin_return_address(0));
Kostya Serebryanyd7238042016-12-29 02:50:35 +0000306 size_t i;
307 uint64_t Token = 0;
308 for (i = 0; i < N; i++) {
309 Token = Val ^ Vals[i];
310 if (Val < Vals[i])
311 break;
312 }
313
314 if (ValSizeInBits == 16)
315 fuzzer::TPC.HandleCmp(PC + i, static_cast<uint16_t>(Token), (uint16_t)(0));
316 else if (ValSizeInBits == 32)
317 fuzzer::TPC.HandleCmp(PC + i, static_cast<uint32_t>(Token), (uint32_t)(0));
Kostya Serebryany00e638e2016-12-17 02:03:34 +0000318 else
Kostya Serebryanyd7238042016-12-29 02:50:35 +0000319 fuzzer::TPC.HandleCmp(PC + i, Token, (uint64_t)(0));
Kostya Serebryany379359c2016-10-05 01:09:40 +0000320}
321
Marcos Pividori6137f982017-01-22 01:27:38 +0000322ATTRIBUTE_INTERFACE
Kostya Serebryany379359c2016-10-05 01:09:40 +0000323void __sanitizer_cov_trace_div4(uint32_t Val) {
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000324 uintptr_t PC = fuzzer::GetPreviousInstructionPc(__builtin_return_address(0));
325 fuzzer::TPC.HandleCmp(PC, Val, (uint32_t)0);
Kostya Serebryany379359c2016-10-05 01:09:40 +0000326}
Marcos Pividori6137f982017-01-22 01:27:38 +0000327
328ATTRIBUTE_INTERFACE
Kostya Serebryany379359c2016-10-05 01:09:40 +0000329void __sanitizer_cov_trace_div8(uint64_t Val) {
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000330 uintptr_t PC = fuzzer::GetPreviousInstructionPc(__builtin_return_address(0));
331 fuzzer::TPC.HandleCmp(PC, Val, (uint64_t)0);
Kostya Serebryany379359c2016-10-05 01:09:40 +0000332}
Marcos Pividori6137f982017-01-22 01:27:38 +0000333
334ATTRIBUTE_INTERFACE
Kostya Serebryany379359c2016-10-05 01:09:40 +0000335void __sanitizer_cov_trace_gep(uintptr_t Idx) {
Mike Aizatsky0e37f8e2017-01-17 23:11:32 +0000336 uintptr_t PC = fuzzer::GetPreviousInstructionPc(__builtin_return_address(0));
337 fuzzer::TPC.HandleCmp(PC, Idx, (uintptr_t)0);
Kostya Serebryany379359c2016-10-05 01:09:40 +0000338}
Kostya Serebryany379359c2016-10-05 01:09:40 +0000339} // extern "C"