mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[libFuzzer] debug prints in tracing
llvm-svn: 257249
This commit is contained in:
parent
bdc66ac566
commit
b57e7c0541
@ -170,6 +170,25 @@ struct TraceBasedMutation {
|
||||
uint8_t Data[kMaxSize];
|
||||
};
|
||||
|
||||
static void PrintDataByte(uint8_t Byte) {
|
||||
if (Byte == '\\')
|
||||
Printf("\\\\");
|
||||
else if (Byte == '"')
|
||||
Printf("\\\"");
|
||||
else if (Byte >= 32 && Byte < 127)
|
||||
Printf("%c", Byte);
|
||||
else
|
||||
Printf("\\x02x", Byte);
|
||||
}
|
||||
|
||||
static void PrintData(const uint8_t *Data, size_t Size) {
|
||||
Printf("\"");
|
||||
for (size_t i = 0; i < Size; i++) {
|
||||
PrintDataByte(Data[i]);
|
||||
}
|
||||
Printf("\"");
|
||||
}
|
||||
|
||||
const size_t TraceBasedMutation::kMaxSize;
|
||||
|
||||
class TraceState {
|
||||
@ -394,8 +413,14 @@ void TraceState::TraceMemcmpCallback(size_t CmpSize, const uint8_t *Data1,
|
||||
const uint8_t *Data2) {
|
||||
if (!RecordingTraces || !IsMyThread) return;
|
||||
CmpSize = std::min(CmpSize, TraceBasedMutation::kMaxSize);
|
||||
TryToAddDesiredData(Data1, Data2, CmpSize);
|
||||
TryToAddDesiredData(Data2, Data1, CmpSize);
|
||||
int Added2 = TryToAddDesiredData(Data1, Data2, CmpSize);
|
||||
int Added1 = TryToAddDesiredData(Data2, Data1, CmpSize);
|
||||
if ((Added1 || Added2) && Options.Verbosity >= 3) {
|
||||
Printf("MemCmp Added %d%d: ", Added1, Added2);
|
||||
if (Added1) PrintData(Data1, CmpSize);
|
||||
if (Added2) PrintData(Data2, CmpSize);
|
||||
Printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void TraceState::TraceSwitchCallback(uintptr_t PC, size_t ValSizeInBits,
|
||||
|
Loading…
Reference in New Issue
Block a user