Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]add AbstractValue #1423

Merged
merged 7 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
first commit of Abstract Value and its related changes
  • Loading branch information
bjjwwang committed Apr 2, 2024
commit a765d6c35e9a76432b15f0339e7df6f18ff6c993
470 changes: 408 additions & 62 deletions svf/include/AE/Core/AbstractValue.h

Large diffs are not rendered by default.

56 changes: 31 additions & 25 deletions svf/include/AE/Core/AddressValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,44 +33,43 @@
#define AddressMask 0x7f000000
#define FlippedAddressMask (AddressMask^0xffffffff)
// the address of the black hole, getVirtualMemAddress(2);
#define BlackHoleAddr 0x7f000000 + 2;
#define BlackHoleAddr 0x7f000000 + 2

#include "AE/Core/AbstractValue.h"
#include "Util/GeneralType.h"
#include <sstream>

namespace SVF
{
class AddressValue : public AbstractValue
class AddressValue
{
public:
typedef Set<u32_t> AddrSet;
private:
AddrSet _addrs;
public:
/// Default constructor
AddressValue() : AbstractValue(AddressK) {}
AddressValue() {}

/// Constructor
AddressValue(const Set<u32_t> &addrs) : AbstractValue(AddressK), _addrs(addrs) {}
AddressValue(const Set<u32_t> &addrs) : _addrs(addrs) {}

AddressValue(u32_t addr) : AbstractValue(AddressK), _addrs({addr}) {}
AddressValue(u32_t addr) : _addrs({addr}) {}

/// Default destructor
~AddressValue() = default;

/// Copy constructor
AddressValue(const AddressValue &other) : AbstractValue(AddressK), _addrs(other._addrs) {}
AddressValue(const AddressValue &other) : _addrs(other._addrs) {}

/// Move constructor
AddressValue(AddressValue &&other) noexcept: AbstractValue(AddressK), _addrs(std::move(other._addrs)) {}
AddressValue(AddressValue &&other) noexcept: _addrs(std::move(other._addrs)) {}

/// Copy operator=
AddressValue &operator=(const AddressValue &other)
{
if (!this->equals(other))
{
_addrs = other._addrs;
AbstractValue::operator=(other);
}
return *this;
}
Expand All @@ -81,7 +80,6 @@ class AddressValue : public AbstractValue
if (this != &other)
{
_addrs = std::move(other._addrs);
AbstractValue::operator=(std::move(other));
}
return *this;
}
Expand All @@ -91,17 +89,6 @@ class AddressValue : public AbstractValue
return _addrs == rhs._addrs;
}

bool operator==(const AddressValue &rhs) const
{
return _addrs == rhs._addrs;
}

/// Operator !=
bool operator!=(const AddressValue &rhs) const
{
return _addrs != rhs._addrs;
}

AddrSet::const_iterator begin() const
{
return _addrs.cbegin();
Expand Down Expand Up @@ -181,26 +168,45 @@ class AddressValue : public AbstractValue
return !v.empty();
}

inline bool isTop() const override
inline bool isTop() const
{
return *this == BlackHoleAddr;
return *this->begin() == BlackHoleAddr;
}

inline bool isBottom() const override
inline bool isBottom() const
{
return empty();
}

inline void setTop()
{
*this = BlackHoleAddr;
*this = AddressValue(BlackHoleAddr);
}

inline void setBottom()
{
_addrs.clear();
}

const std::string toString() const
{
std::string str;
std::stringstream rawStr(str);
if (this->isBottom())
{
rawStr << "⊥";
}
else
{
rawStr << "[";
for (auto it = _addrs.begin(), eit = _addrs.end(); it!= eit; ++it) {
rawStr << *it << ", ";
}
rawStr << "]";
}
return rawStr.str();
}

/// The physical address starts with 0x7f...... + idx
static inline u32_t getVirtualMemAddress(u32_t idx)
{
Expand Down
2 changes: 1 addition & 1 deletion svf/include/AE/Core/ExeState.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class ExeState
auto it = rhs.find(item.first);
if (it == rhs.end())
return false;
if (item.second != it->second)
if (item.second.equals(it->second))
{
return false;
}
Expand Down
Loading