fuzz_with_unicorn: Move instruction generator vector into GenRandomInst
Keeps scope localized and prevents potential static initialization issues.
This commit is contained in:
parent
4491746eae
commit
f96e83c486
1 changed files with 16 additions and 16 deletions
|
@ -31,31 +31,31 @@ static Vector RandomVector() {
|
||||||
return {RandInt<u64>(0, ~u64(0)), RandInt<u64>(0, ~u64(0))};
|
return {RandInt<u64>(0, ~u64(0)), RandInt<u64>(0, ~u64(0))};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<InstructionGenerator> instruction_generators = []{
|
static u32 GenRandomInst(u64 pc, bool is_last_inst) {
|
||||||
const std::vector<std::tuple<const char*, const char*>> list {
|
static const std::vector<InstructionGenerator> instruction_generators = []{
|
||||||
|
const std::vector<std::tuple<const char*, const char*>> list {
|
||||||
#define INST(fn, name, bitstring) {#fn, bitstring},
|
#define INST(fn, name, bitstring) {#fn, bitstring},
|
||||||
#include "frontend/A64/decoder/a64.inc"
|
#include "frontend/A64/decoder/a64.inc"
|
||||||
#undef INST
|
#undef INST
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<InstructionGenerator> result;
|
std::vector<InstructionGenerator> result;
|
||||||
|
|
||||||
for (const auto& [fn, bitstring] : list) {
|
for (const auto& [fn, bitstring] : list) {
|
||||||
if (std::strcmp(fn, "UnallocatedEncoding") == 0) {
|
if (std::strcmp(fn, "UnallocatedEncoding") == 0) {
|
||||||
InstructionGenerator::AddInvalidInstruction(bitstring);
|
InstructionGenerator::AddInvalidInstruction(bitstring);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
result.emplace_back(InstructionGenerator{bitstring});
|
||||||
}
|
}
|
||||||
result.emplace_back(InstructionGenerator{bitstring});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Manually added exceptions:
|
// Manually added exceptions:
|
||||||
// FMOV_float_imm for half-precision floats (QEMU doesn't have half-precision support yet).
|
// FMOV_float_imm for half-precision floats (QEMU doesn't have half-precision support yet).
|
||||||
InstructionGenerator::AddInvalidInstruction("00011110111iiiiiiii10000000ddddd");
|
InstructionGenerator::AddInvalidInstruction("00011110111iiiiiiii10000000ddddd");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
static u32 GenRandomInst(u64 pc, bool is_last_inst) {
|
|
||||||
const A64::LocationDescriptor location{pc, {}};
|
const A64::LocationDescriptor location{pc, {}};
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
|
|
Loading…
Reference in a new issue