Prepare emulation bisection

This commit is contained in:
momo5502
2025-01-25 20:59:10 +01:00
parent 130367619b
commit 45d7c542c3
2 changed files with 82 additions and 4 deletions

View File

@@ -486,19 +486,37 @@ namespace utils
this->break_offset_ = break_offset;
}
void print_diff(const buffer_serializer& other) const
std::optional<size_t> get_diff(const buffer_serializer& other) const
{
auto& b1 = this->get_buffer();
auto& b2 = other.get_buffer();
for (size_t i = 0; i < b1.size() && i < b2.size(); ++i)
const auto s1 = b1.size();
const auto s2 = b2.size();
for (size_t i = 0; i < s1 && i < s2; ++i)
{
if (b1.at(i) != b2.at(i))
{
printf("Diff at %zd\n", i);
break;
return i;
}
}
if (s1 != s2)
{
return std::min(s1, s2);
}
return std::nullopt;
}
void print_diff(const buffer_serializer& other) const
{
const auto diff = this->get_diff(other);
if (diff)
{
printf("Diff at %zd\n", *diff);
}
}
private: