Skip to content

Commit

Permalink
a bunch more annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
eteran committed Mar 18, 2024
1 parent ee0da7d commit 9c097ca
Show file tree
Hide file tree
Showing 19 changed files with 260 additions and 249 deletions.
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ words:
- konsole
- Mercês
- METATYPE
- Midlight
- Mohd
- nasm
- Nicoleau
Expand Down
2 changes: 1 addition & 1 deletion include/Expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct ExpressionError {
: error_(type) {
}

const char *what() const noexcept {
[[nodiscard]] const char *what() const noexcept {
switch (error_) {
case Syntax:
return "Syntax Error";
Expand Down
56 changes: 28 additions & 28 deletions include/IState.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,50 @@ class IState {
virtual ~IState() = default;

public:
virtual std::unique_ptr<IState> clone() const = 0;
[[nodiscard]] virtual std::unique_ptr<IState> clone() const = 0;

public:
virtual QString flagsToString() const = 0;
virtual QString flagsToString(edb::reg_t flags) const = 0;
virtual Register value(const QString &reg) const = 0;
virtual Register instructionPointerRegister() const = 0;
virtual Register flagsRegister() const = 0;
virtual edb::address_t framePointer() const = 0;
virtual edb::address_t instructionPointer() const = 0;
virtual edb::address_t stackPointer() const = 0;
virtual edb::reg_t debugRegister(size_t n) const = 0;
virtual edb::reg_t flags() const = 0;
virtual void adjustStack(int bytes) = 0;
virtual void clear() = 0;
virtual bool empty() const = 0;
virtual void setDebugRegister(size_t n, edb::reg_t value) = 0;
virtual void setFlags(edb::reg_t flags) = 0;
virtual void setInstructionPointer(edb::address_t value) = 0;
virtual void setRegister(const QString &name, edb::reg_t value) = 0;
virtual void setRegister(const Register &reg) = 0;
[[nodiscard]] virtual bool empty() const = 0;
[[nodiscard]] virtual edb::address_t framePointer() const = 0;
[[nodiscard]] virtual edb::address_t instructionPointer() const = 0;
[[nodiscard]] virtual edb::address_t stackPointer() const = 0;
[[nodiscard]] virtual edb::reg_t debugRegister(size_t n) const = 0;
[[nodiscard]] virtual edb::reg_t flags() const = 0;
[[nodiscard]] virtual QString flagsToString() const = 0;
[[nodiscard]] virtual QString flagsToString(edb::reg_t flags) const = 0;
[[nodiscard]] virtual Register flagsRegister() const = 0;
[[nodiscard]] virtual Register instructionPointerRegister() const = 0;
[[nodiscard]] virtual Register value(const QString &reg) const = 0;
virtual void adjustStack(int bytes) = 0;
virtual void clear() = 0;
virtual void setDebugRegister(size_t n, edb::reg_t value) = 0;
virtual void setFlags(edb::reg_t flags) = 0;
virtual void setInstructionPointer(edb::address_t value) = 0;
virtual void setRegister(const QString &name, edb::reg_t value) = 0;
virtual void setRegister(const Register &reg) = 0;

public:
// GP
virtual Register gpRegister(size_t n) const = 0;
[[nodiscard]] virtual Register gpRegister(size_t n) const = 0;

public:
// This is a more generic means to request architecture
// specific registers. The type should be the result of
// edb::string_hash, for example:
// edb::string_hash("mmx"), string_hash("xmm"), and string_hash("ymm")
// This will allow this interface to be much more platform independent
virtual Register archRegister(uint64_t type, size_t n) const = 0;
[[nodiscard]] virtual Register archRegister(uint64_t type, size_t n) const = 0;

#if defined(EDB_X86) || defined(EDB_X86_64)
public:
// FPU
virtual int fpuStackPointer() const = 0;
virtual bool fpuRegisterIsEmpty(std::size_t n) const = 0;
virtual edb::value80 fpuRegister(size_t n) const = 0;
virtual QString fpuRegisterTagString(std::size_t n) const = 0;
virtual edb::value16 fpuControlWord() const = 0;
virtual edb::value16 fpuStatusWord() const = 0;
virtual edb::value16 fpuTagWord() const = 0;
[[nodiscard]] virtual int fpuStackPointer() const = 0;
[[nodiscard]] virtual bool fpuRegisterIsEmpty(std::size_t n) const = 0;
[[nodiscard]] virtual edb::value80 fpuRegister(size_t n) const = 0;
[[nodiscard]] virtual QString fpuRegisterTagString(std::size_t n) const = 0;
[[nodiscard]] virtual edb::value16 fpuControlWord() const = 0;
[[nodiscard]] virtual edb::value16 fpuStatusWord() const = 0;
[[nodiscard]] virtual edb::value16 fpuTagWord() const = 0;
#endif
};

Expand Down
12 changes: 6 additions & 6 deletions include/MemoryRegions.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class EDB_EXPORT MemoryRegions final : public QAbstractItemModel {
Q_OBJECT

public:
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
[[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
[[nodiscard]] QModelIndex parent(const QModelIndex &index) const override;
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
[[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
[[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;

public:
MemoryRegions();
Expand Down
10 changes: 5 additions & 5 deletions include/Register.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,25 @@ class EDB_EXPORT Register {
[[nodiscard]] bool operator!=(const Register &rhs) const;

public:
bool valid() const { return type_ != TYPE_INVALID; }
explicit operator bool() const { return valid(); }
[[nodiscard]] bool valid() const { return type_ != TYPE_INVALID; }
[[nodiscard]] explicit operator bool() const { return valid(); }

[[nodiscard]] Type type() const { return type_; }
[[nodiscard]] QString name() const { return name_; }
[[nodiscard]] std::size_t bitSize() const { return bitSize_; }
[[nodiscard]] const char *rawData() const { return reinterpret_cast<const char *>(&value_); }

template <class T>
T value() const { return T(value_); }
[[nodiscard]] T value() const { return T(value_); }

// Return the value, zero-extended to address_t to be usable in address calculations
[[nodiscard]] edb::address_t valueAsAddress() const;

uint64_t valueAsInteger() const {
[[nodiscard]] uint64_t valueAsInteger() const {
return valueAsAddress().toUint();
}

int64_t valueAsSignedInteger() const {
[[nodiscard]] int64_t valueAsSignedInteger() const {
uint64_t result = valueAsInteger();
// If MSB is set, sign extend the result
if (result & (1ll << (bitSize_ - 1))) {
Expand Down
6 changes: 3 additions & 3 deletions include/RegisterRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class RegisterRef {
const void *data() const { return ptr_; }

public:
bool operator==(const RegisterRef &rhs) const { return size_ == rhs.size_ && std::memcmp(ptr_, rhs.ptr_, size_) == 0; }
bool operator!=(const RegisterRef &rhs) const { return size_ != rhs.size_ || std::memcmp(ptr_, rhs.ptr_, size_) != 0; }
[[nodiscard]] bool operator==(const RegisterRef &rhs) const { return size_ == rhs.size_ && std::memcmp(ptr_, rhs.ptr_, size_) == 0; }
[[nodiscard]] bool operator!=(const RegisterRef &rhs) const { return size_ != rhs.size_ || std::memcmp(ptr_, rhs.ptr_, size_) != 0; }

public:
bool valid() const { return ptr_ != nullptr; }
[[nodiscard]] bool valid() const { return ptr_ != nullptr; }

public:
// The name of this register.
Expand Down
Loading

0 comments on commit 9c097ca

Please sign in to comment.