Files
revng-revng/include/revng/Support/MetaAddress/IntervalContainers.h
Kacper Kołodziej 46e9ea0e10 HexDump implementation
HexDumpPipe dumps content of binary file in the similar way as hexdump
tool with addition of PTML markup for instructions addresses.

Continuous parts of binary code are wrapped with <span
data-location-definition=""></span> where data-location-definition
attribute contains Entry/BasicBlock/Instruction addresses in generic
form. <span> tags can be nested if byte(s) belong to many instructions
in code.

At the end of the line every <span> is closed and opened on the next
line again if it still applies to the next byte.

MetaAddress are converted to IntervalMetaAddress (which implements own,
optional-less operator-) and stored in boost::icl::intruval_map. This
map is used to get addresses of instructions to which each byte belongs.
2023-07-31 11:29:41 +02:00

64 lines
1.3 KiB
C++

#pragma once
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include <cstdint>
#include "boost/icl/interval_map.hpp"
#include "revng/Support/MetaAddress.h"
struct IntervalMetaAddress : MetaAddress {
IntervalMetaAddress() = default;
IntervalMetaAddress(MetaAddress &Address) : MetaAddress(Address) {}
uint64_t operator-(const IntervalMetaAddress &Other) const {
std::optional<uint64_t> Diff = MetaAddress(*this) - MetaAddress(Other);
revng_assert(Diff.has_value());
return *Diff;
}
IntervalMetaAddress &operator++() {
MetaAddress::operator+=(1u);
return *this;
}
IntervalMetaAddress &operator--() {
MetaAddress::operator-=(1u);
return *this;
}
};
namespace boost::icl {
template<>
struct is_discrete<IntervalMetaAddress> {
using type = is_discrete;
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
struct identity_element<IntervalMetaAddress> {
static IntervalMetaAddress value() { return IntervalMetaAddress{}; }
};
template<>
struct has_difference<IntervalMetaAddress> {
using type = has_difference;
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
struct difference_type_of<IntervalMetaAddress> {
using type = uint64_t;
};
template<>
struct size_type_of<IntervalMetaAddress> {
using type = uint64_t;
};
} // namespace boost::icl