WIP: experiment with variable hashing

This commit is contained in:
Duncan Ogilvie 2021-08-31 13:25:11 +02:00
parent aa0a478b53
commit 2607e92f54
3 changed files with 34 additions and 3 deletions

View file

@ -244,6 +244,14 @@ namespace vtil
//
routine* owner = nullptr;
static uint64_t unique_block_id()
{
static uint64_t id = 0;
return id++;
}
uint64_t block_id = unique_block_id();
// Virtual instruction pointer to the first instruction this block originated
// from. ::front().vip will not do the job here in case of any skipped or
// optimized out instructions.

View file

@ -223,7 +223,7 @@ namespace vtil::symbolic
// Declare reduction.
//
REDUCE_TO( at.block, at.entry, descriptor, is_branch_dependant );
REDUCE_TO( at.block->block_id, at.entry, descriptor, is_branch_dependant );
// Packs all the variables in the expression where it'd be optimal.
//

View file

@ -1,8 +1,9 @@
#include "doctest.h"
#include <vtil/vtil>
#include <vtil/arch>
#include <vtil/symex>
DOCTEST_TEST_CASE("dummy")
/*DOCTEST_TEST_CASE("dummy")
{
auto block = vtil::basic_block::begin(0);
block->vemits("cpuid");
@ -48,4 +49,26 @@ DOCTEST_TEST_CASE("Simplification")
vtil::logger::log(":: After:\n");
vtil::debug::dump(block->owner);
CHECK(1 == 1);
}
}*/
DOCTEST_TEST_CASE("Expression hash")
{
// $sp#0x13df89?+0x90
using namespace vtil::symbolic;
using namespace vtil::math;
using namespace vtil::logger;
auto block = vtil::basic_block::begin(0x13df89);
block->nop();
auto var = variable(block->begin(), vtil::REG_SP);
log("var hash: %s\n", var.hash());
auto v = var.to_expression();
log("v hash: %s\n", v.hash());
//expression(unique_identifier())
auto c = expression(0x90);
log("c hash: %s\n", c.hash());
auto kurwa = expression::make(v, operator_id::add, c);
log("%s (Hash: %s)\n", kurwa.to_string(), kurwa.hash());
kurwa.update(false);
log("%s (Hash: %s)\n", kurwa.to_string(), kurwa.hash());
}