From c13755494a3b14ac1f49e5305b4b19c2230aa629 Mon Sep 17 00:00:00 2001 From: Evan Teran Date: Mon, 18 Mar 2024 17:14:17 -0400 Subject: [PATCH] more stylistic stuff --- include/GraphEdge.h | 2 +- include/GraphNode.h | 2 +- include/IAnalyzer.h | 10 ++-- include/IDebugEvent.h | 32 +++++----- include/IDebugger.h | 2 +- include/IProcess.h | 2 +- include/Value.h | 20 +++---- plugins/DebuggerCore/unix/Unix.cpp | 4 +- .../unix/freebsd/DebuggerCore.cpp | 2 +- .../unix/freebsd/PlatformEvent.cpp | 2 +- .../unix/freebsd/PlatformProcess.cpp | 2 +- .../unix/linux/PlatformProcess.cpp | 4 +- .../linux/arch/arm-generic/PlatformThread.cpp | 27 ++++++--- .../unix/openbsd/DebuggerCore.cpp | 2 +- .../unix/openbsd/PlatformEvent.cpp | 2 +- .../DebuggerCore/unix/osx/DebuggerCore.cpp | 2 +- .../DebuggerCore/unix/osx/PlatformEvent.cpp | 2 +- src/arch/arm-generic/ArchProcessor.cpp | 12 +++- src/arch/arm-generic/RegisterViewModel.cpp | 8 ++- src/arch/x86-generic/ArchProcessor.cpp | 60 ++++++++++++++----- src/arch/x86-generic/RegisterViewModel.cpp | 26 ++++++-- 21 files changed, 147 insertions(+), 78 deletions(-) diff --git a/include/GraphEdge.h b/include/GraphEdge.h index 510eb21cc..c79bda495 100644 --- a/include/GraphEdge.h +++ b/include/GraphEdge.h @@ -38,7 +38,7 @@ class GraphEdge final : public QGraphicsItemGroup { public: enum { Type = UserType + 3 }; - int type() const override { + [[nodiscard]] int type() const override { // Enable the use of qgraphicsitem_cast with this item. return Type; } diff --git a/include/GraphNode.h b/include/GraphNode.h index d9c952594..680724d8d 100644 --- a/include/GraphNode.h +++ b/include/GraphNode.h @@ -49,7 +49,7 @@ class GraphNode final : public QGraphicsItem { public: enum { Type = UserType + 2 }; - int type() const override { + [[nodiscard]] int type() const override { // Enable the use of qgraphicsitem_cast with this item. return Type; } diff --git a/include/IAnalyzer.h b/include/IAnalyzer.h index 89e7f35ad..05cb4f7e3 100644 --- a/include/IAnalyzer.h +++ b/include/IAnalyzer.h @@ -46,11 +46,11 @@ class IAnalyzer { }; public: - virtual AddressCategory category(edb::address_t address) const = 0; - virtual FunctionMap functions(const std::shared_ptr ®ion) const = 0; - virtual FunctionMap functions() const = 0; - virtual QSet specifiedFunctions() const { return {}; } - virtual Result findContainingFunction(edb::address_t address) const = 0; + [[nodiscard]] virtual AddressCategory category(edb::address_t address) const = 0; + [[nodiscard]] virtual FunctionMap functions(const std::shared_ptr ®ion) const = 0; + [[nodiscard]] virtual FunctionMap functions() const = 0; + [[nodiscard]] virtual QSet specifiedFunctions() const { return {}; } + [[nodiscard]] virtual Result findContainingFunction(edb::address_t address) const = 0; virtual void analyze(const std::shared_ptr ®ion) = 0; virtual void invalidateAnalysis() = 0; virtual void invalidateAnalysis(const std::shared_ptr ®ion) = 0; diff --git a/include/IDebugEvent.h b/include/IDebugEvent.h index 6c44e1154..64c9dab4d 100644 --- a/include/IDebugEvent.h +++ b/include/IDebugEvent.h @@ -38,8 +38,8 @@ class IDebugEvent { struct Message { Message() = default; - Message(const QString &c, const QString &m, const QString &s) - : caption(c), message(m), statusMessage(s) { + Message(QString c, QString m, QString s) + : caption(std::move(c)), message(std::move(m)), statusMessage(std::move(s)) { } QString caption; @@ -51,22 +51,22 @@ class IDebugEvent { virtual ~IDebugEvent() = default; public: - virtual IDebugEvent *clone() const = 0; + [[nodiscard]] virtual IDebugEvent *clone() const = 0; public: - virtual Message errorDescription() const = 0; - virtual REASON reason() const = 0; - virtual TRAP_REASON trapReason() const = 0; - virtual bool exited() const = 0; - virtual bool isError() const = 0; - virtual bool isKill() const = 0; - virtual bool isStop() const = 0; - virtual bool isTrap() const = 0; - virtual bool stopped() const = 0; - virtual bool terminated() const = 0; - virtual edb::pid_t process() const = 0; - virtual edb::tid_t thread() const = 0; - virtual int64_t code() const = 0; + [[nodiscard]] virtual Message errorDescription() const = 0; + [[nodiscard]] virtual REASON reason() const = 0; + [[nodiscard]] virtual TRAP_REASON trapReason() const = 0; + [[nodiscard]] virtual bool exited() const = 0; + [[nodiscard]] virtual bool isError() const = 0; + [[nodiscard]] virtual bool isKill() const = 0; + [[nodiscard]] virtual bool isStop() const = 0; + [[nodiscard]] virtual bool isTrap() const = 0; + [[nodiscard]] virtual bool stopped() const = 0; + [[nodiscard]] virtual bool terminated() const = 0; + [[nodiscard]] virtual edb::pid_t process() const = 0; + [[nodiscard]] virtual edb::tid_t thread() const = 0; + [[nodiscard]] virtual int64_t code() const = 0; }; #endif diff --git a/include/IDebugger.h b/include/IDebugger.h index 3b9021958..f0a20bf13 100644 --- a/include/IDebugger.h +++ b/include/IDebugger.h @@ -84,7 +84,7 @@ class IDebugger { public: // basic process management - [[nodiscard]] virtual std::shared_ptr waitDebugEvent(std::chrono::milliseconds msecs) = 0; + [[nodiscard]] virtual std::shared_ptr waitDebugEvent(std::chrono::milliseconds msecs) = 0; virtual Status attach(edb::pid_t pid) = 0; virtual Status detach() = 0; virtual Status open(const QString &path, const QString &cwd, const QList &args, const QString &input, const QString &output) = 0; diff --git a/include/IProcess.h b/include/IProcess.h index 5e825b10c..d3a3737f9 100644 --- a/include/IProcess.h +++ b/include/IProcess.h @@ -67,7 +67,7 @@ class IProcess { [[nodiscard]] virtual std::shared_ptr currentThread() const = 0; [[nodiscard]] virtual std::size_t readBytes(edb::address_t address, void *buf, size_t len) const = 0; [[nodiscard]] virtual std::size_t readPages(edb::address_t address, void *buf, size_t count) const = 0; - [[nodiscard]] virtual QMap patches() const = 0; + [[nodiscard]] virtual QMap patches() const = 0; virtual Status pause() = 0; virtual Status resume(edb::EventStatus status) = 0; virtual Status step(edb::EventStatus status) = 0; diff --git a/include/Value.h b/include/Value.h index e64941b49..c93d03039 100644 --- a/include/Value.h +++ b/include/Value.h @@ -660,17 +660,17 @@ template > // operators for value_type, value_type template -[[nodiscard]]bool operator==(const value_type &lhs, const value_type &rhs) { +[[nodiscard]] bool operator==(const value_type &lhs, const value_type &rhs) { return lhs.value_ == rhs.value_; } template -[[nodiscard]]bool operator!=(const value_type &lhs, const value_type &rhs) { +[[nodiscard]] bool operator!=(const value_type &lhs, const value_type &rhs) { return lhs.value_ != rhs.value_; } template -[[nodiscard]]auto operator+(const value_type &lhs, const value_type &rhs) -> value_type> { +[[nodiscard]] auto operator+(const value_type &lhs, const value_type &rhs) -> value_type> { using U = value_type>; @@ -680,7 +680,7 @@ template } template -[[nodiscard]]auto operator-(const value_type &lhs, const value_type &rhs) -> value_type> { +[[nodiscard]] auto operator-(const value_type &lhs, const value_type &rhs) -> value_type> { using U = value_type>; @@ -690,7 +690,7 @@ template } template -[[nodiscard]]auto operator*(const value_type &lhs, const value_type &rhs) -> value_type> { +[[nodiscard]] auto operator*(const value_type &lhs, const value_type &rhs) -> value_type> { using U = value_type>; @@ -700,7 +700,7 @@ template } template -[[nodiscard]]auto operator/(const value_type &lhs, const value_type &rhs) -> value_type> { +[[nodiscard]] auto operator/(const value_type &lhs, const value_type &rhs) -> value_type> { using U = value_type>; @@ -710,7 +710,7 @@ template } template -[[nodiscard]]auto operator%(const value_type &lhs, const value_type &rhs) -> value_type> { +[[nodiscard]] auto operator%(const value_type &lhs, const value_type &rhs) -> value_type> { using U = value_type>; @@ -720,7 +720,7 @@ template } template -[[nodiscard]]auto operator&(const value_type &lhs, const value_type &rhs) -> value_type> { +[[nodiscard]] auto operator&(const value_type &lhs, const value_type &rhs) -> value_type> { using U = value_type>; @@ -730,7 +730,7 @@ template } template -[[nodiscard]]auto operator|(const value_type &lhs, const value_type &rhs) -> value_type> { +[[nodiscard]] auto operator|(const value_type &lhs, const value_type &rhs) -> value_type> { using U = value_type>; @@ -740,7 +740,7 @@ template } template -[[nodiscard]]auto operator^(const value_type &lhs, const value_type &rhs) -> value_type> { +[[nodiscard]] auto operator^(const value_type &lhs, const value_type &rhs) -> value_type> { using U = value_type>; diff --git a/plugins/DebuggerCore/unix/Unix.cpp b/plugins/DebuggerCore/unix/Unix.cpp index 73758cb59..5c5498f3a 100644 --- a/plugins/DebuggerCore/unix/Unix.cpp +++ b/plugins/DebuggerCore/unix/Unix.cpp @@ -1,7 +1,7 @@ #include "Unix.h" -#include #include +#include #include namespace DebuggerCorePlugin { @@ -209,7 +209,7 @@ Status Unix::execute_process(const QString &path, const QString &cwd, const QLis p = argv_pointers; while (*p) { - delete[] *p++; + delete[] * p++; } delete[] argv_pointers; } diff --git a/plugins/DebuggerCore/unix/freebsd/DebuggerCore.cpp b/plugins/DebuggerCore/unix/freebsd/DebuggerCore.cpp index 05a457f45..bd68f2cd8 100644 --- a/plugins/DebuggerCore/unix/freebsd/DebuggerCore.cpp +++ b/plugins/DebuggerCore/unix/freebsd/DebuggerCore.cpp @@ -29,11 +29,11 @@ along with this program. If not, see . #include #include +#include #include #include #include #include -#include #include #include #include diff --git a/plugins/DebuggerCore/unix/freebsd/PlatformEvent.cpp b/plugins/DebuggerCore/unix/freebsd/PlatformEvent.cpp index 1db7d5e92..c48695146 100644 --- a/plugins/DebuggerCore/unix/freebsd/PlatformEvent.cpp +++ b/plugins/DebuggerCore/unix/freebsd/PlatformEvent.cpp @@ -18,11 +18,11 @@ along with this program. If not, see . #include "PlatformEvent.h" #include "edb.h" +#include // for the SIG* definitions #include #include #include #include -#include // for the SIG* definitions #include #include #include diff --git a/plugins/DebuggerCore/unix/freebsd/PlatformProcess.cpp b/plugins/DebuggerCore/unix/freebsd/PlatformProcess.cpp index 3c3c8427c..d9748906e 100644 --- a/plugins/DebuggerCore/unix/freebsd/PlatformProcess.cpp +++ b/plugins/DebuggerCore/unix/freebsd/PlatformProcess.cpp @@ -17,11 +17,11 @@ along with this program. If not, see . */ #include "PlatformProcess.h" +#include #include #include #include #include -#include #include #include #include diff --git a/plugins/DebuggerCore/unix/linux/PlatformProcess.cpp b/plugins/DebuggerCore/unix/linux/PlatformProcess.cpp index 8440a5a9b..6fa50ef1b 100644 --- a/plugins/DebuggerCore/unix/linux/PlatformProcess.cpp +++ b/plugins/DebuggerCore/unix/linux/PlatformProcess.cpp @@ -417,7 +417,9 @@ std::size_t PlatformProcess::writeBytes(edb::address_t address, const void *buf, for (std::size_t byteIndex = 0; byteIndex < len; ++byteIndex) { bool ok = false; ptraceWriteByte(address + byteIndex, *(reinterpret_cast(buf) + byteIndex), &ok); - if (!ok) return written; + if (!ok) { + return written; + } ++written; } } diff --git a/plugins/DebuggerCore/unix/linux/arch/arm-generic/PlatformThread.cpp b/plugins/DebuggerCore/unix/linux/arch/arm-generic/PlatformThread.cpp index a0d475c88..7af163506 100644 --- a/plugins/DebuggerCore/unix/linux/arch/arm-generic/PlatformThread.cpp +++ b/plugins/DebuggerCore/unix/linux/arch/arm-generic/PlatformThread.cpp @@ -198,7 +198,9 @@ Status PlatformThread::doStep(const edb::tid_t tid, const long status) { State state; getState(&state); - if (state.empty()) return Status(tr("failed to get thread state.")); + if (state.empty()) { + return Status(tr("failed to get thread state.")); + } const auto pc = state.instructionPointer(); const auto flags = state.flags(); enum { @@ -235,17 +237,24 @@ Status PlatformThread::doStep(const edb::tid_t tid, const long status) { switch (op) { case ARM_INS_LDR: { const auto destOperand = insn.operand(0); - if (!is_register(destOperand) || destOperand->reg != ARM_REG_PC) + if (!is_register(destOperand) || destOperand->reg != ARM_REG_PC) { return Status(tr("instruction %1 with non-PC destination isn't supported yet.").arg(insn.mnemonic().c_str())); + } + const auto srcOperand = insn.operand(1); - if (!is_expression(srcOperand)) + if (!is_expression(srcOperand)) { return Status(tr("unexpected type of second operand of LDR instruction.")); + } + const auto effAddrR = edb::v1::arch_processor().getEffectiveAddress(insn, srcOperand, state); - if (!effAddrR) return Status(effAddrR.error()); + if (!effAddrR) { + return Status(effAddrR.error()); + } const auto effAddr = effAddrR.value(); - if (process_->readBytes(effAddr, &addrAfterInsn, AddressSize) != AddressSize) + if (process_->readBytes(effAddr, &addrAfterInsn, AddressSize) != AddressSize) { return Status(tr("failed to read memory referred to by LDR operand (address %1).").arg(effAddr.toPointerString())); + } // FIXME: for ARMv5 or below (without "T" in the name) bits [1:0] are simply ignored, without any mode change if (addrAfterInsn & 1) @@ -273,7 +282,9 @@ Status PlatformThread::doStep(const edb::tid_t tid, const long status) { assert(operand->access == CS_AC_WRITE); #endif const auto sp = state.gpRegister(PlatformState::GPR::SP); - if (!sp) return Status(tr("failed to get value of SP register")); + if (!sp) { + return Status(tr("failed to get value of SP register")); + } if (process_->readBytes(sp.valueAsAddress() + AddressSize * i, &addrAfterInsn, AddressSize) != AddressSize) return Status(tr("failed to read thread stack")); break; @@ -305,7 +316,9 @@ Status PlatformThread::doStep(const edb::tid_t tid, const long status) { return Status(tr("unpredictable instruction")); // This may happen only with BX or BLX: B and BL require an immediate operand const auto result = edb::v1::arch_processor().getEffectiveAddress(insn, operand, state); - if (!result) return Status(result.error()); + if (!result) { + return Status(result.error()); + } addrAfterInsn = result.value(); if (addrAfterInsn & 1) targetMode = IDebugger::CpuMode::Thumb; diff --git a/plugins/DebuggerCore/unix/openbsd/DebuggerCore.cpp b/plugins/DebuggerCore/unix/openbsd/DebuggerCore.cpp index 235f34b8a..0472dcb2a 100644 --- a/plugins/DebuggerCore/unix/openbsd/DebuggerCore.cpp +++ b/plugins/DebuggerCore/unix/openbsd/DebuggerCore.cpp @@ -29,11 +29,11 @@ along with this program. If not, see . #include #include +#include #include #include #include #include -#include #include #include #include diff --git a/plugins/DebuggerCore/unix/openbsd/PlatformEvent.cpp b/plugins/DebuggerCore/unix/openbsd/PlatformEvent.cpp index d0a9057b5..08159c005 100644 --- a/plugins/DebuggerCore/unix/openbsd/PlatformEvent.cpp +++ b/plugins/DebuggerCore/unix/openbsd/PlatformEvent.cpp @@ -18,11 +18,11 @@ along with this program. If not, see . #include "PlatformEvent.h" #include "edb.h" +#include // for the SIG* definitions #include #include #include #include -#include // for the SIG* definitions #include #include #include diff --git a/plugins/DebuggerCore/unix/osx/DebuggerCore.cpp b/plugins/DebuggerCore/unix/osx/DebuggerCore.cpp index d78705638..b33a528bf 100644 --- a/plugins/DebuggerCore/unix/osx/DebuggerCore.cpp +++ b/plugins/DebuggerCore/unix/osx/DebuggerCore.cpp @@ -25,13 +25,13 @@ along with this program. If not, see . #include +#include #include #include #include #include #include #include -#include #include #include #include diff --git a/plugins/DebuggerCore/unix/osx/PlatformEvent.cpp b/plugins/DebuggerCore/unix/osx/PlatformEvent.cpp index 5e9df20e3..ea2414a19 100644 --- a/plugins/DebuggerCore/unix/osx/PlatformEvent.cpp +++ b/plugins/DebuggerCore/unix/osx/PlatformEvent.cpp @@ -18,9 +18,9 @@ along with this program. If not, see . #include "PlatformEvent.h" #include "edb.h" +#include // for the SIG* definitions #include #include -#include // for the SIG* definitions #include #include #include diff --git a/src/arch/arm-generic/ArchProcessor.cpp b/src/arch/arm-generic/ArchProcessor.cpp index 678ef2260..4bf22fbde 100644 --- a/src/arch/arm-generic/ArchProcessor.cpp +++ b/src/arch/arm-generic/ArchProcessor.cpp @@ -180,9 +180,13 @@ Result ArchProcessor::getEffectiveAddress(const edb::In if (is_register(operand)) { bool ok; const auto regIndex = capstoneRegToGPRIndex(operand->reg, ok); - if (!ok) return make_unexpected(QObject::tr("bad operand register for instruction %1: %2.").arg(insn.mnemonic().c_str()).arg(operand->reg)); + if (!ok) { + return make_unexpected(QObject::tr("bad operand register for instruction %1: %2.").arg(insn.mnemonic().c_str()).arg(operand->reg)); + } const auto reg = state.gpRegister(regIndex); - if (!reg) return make_unexpected(QObject::tr("failed to get register r%1.").arg(regIndex)); + if (!reg) { + return make_unexpected(QObject::tr("failed to get register r%1.").arg(regIndex)); + } auto value = reg.valueAsAddress(); return adjustR15Value(insn, regIndex, value); } else if (is_expression(operand)) { @@ -226,7 +230,9 @@ edb::address_t ArchProcessor::getEffectiveAddress(const edb::Instruction &inst, ok = false; const auto result = getEffectiveAddress(inst, op, state); - if (!result) return 0; + if (!result) { + return 0; + } return result.value(); } diff --git a/src/arch/arm-generic/RegisterViewModel.cpp b/src/arch/arm-generic/RegisterViewModel.cpp index d6a32da46..c8a54dfe4 100644 --- a/src/arch/arm-generic/RegisterViewModel.cpp +++ b/src/arch/arm-generic/RegisterViewModel.cpp @@ -148,7 +148,9 @@ RegisterViewModel::RegisterViewModel(int cpuSuppFlags, QObject *parent) } void invalidate(RegisterViewModelBase::Category *cat, int row, const char *nameToCheck) { - if (!cat) return; + if (!cat) { + return; + } Q_ASSERT(row < cat->childCount()); const auto reg = cat->getRegister(row); Q_ASSERT(!nameToCheck || reg->name() == nameToCheck); @@ -189,7 +191,9 @@ void RegisterViewModel::showAll() { } void RegisterViewModel::setCpuMode(CpuMode newMode) { - if (mode == newMode) return; + if (mode == newMode) { + return; + } beginResetModel(); mode = newMode; diff --git a/src/arch/x86-generic/ArchProcessor.cpp b/src/arch/x86-generic/ArchProcessor.cpp index 6f3d1843e..2f8788e5c 100644 --- a/src/arch/x86-generic/ArchProcessor.cpp +++ b/src/arch/x86-generic/ArchProcessor.cpp @@ -263,7 +263,9 @@ QString format_char(int pointer_level, edb::address_t arg, QChar type) { //------------------------------------------------------------------------------ QString format_argument(const QString &type, const Register &arg) { - if (!arg) return QObject::tr("(failed to get value)"); + if (!arg) { + return QObject::tr("(failed to get value)"); + } int pointer_level = 0; for (QChar ch : type) { @@ -449,10 +451,21 @@ bool is_jcc_taken(const edb::reg_t efl, edb::Instruction::ConditionCode cond) { //------------------------------------------------------------------------------ bool is_jcc_taken(const State &state, edb::Instruction::ConditionCode cond) { - if (cond == edb::Instruction::CC_UNCONDITIONAL) return true; - if (cond == edb::Instruction::CC_RCXZ) return state.gpRegister(rCX).value() == 0; - if (cond == edb::Instruction::CC_ECXZ) return state.gpRegister(rCX).value() == 0; - if (cond == edb::Instruction::CC_CXZ) return state.gpRegister(rCX).value() == 0; + if (cond == edb::Instruction::CC_UNCONDITIONAL) { + return true; + } + + if (cond == edb::Instruction::CC_RCXZ) { + return state.gpRegister(rCX).value() == 0; + } + + if (cond == edb::Instruction::CC_ECXZ) { + return state.gpRegister(rCX).value() == 0; + } + + if (cond == edb::Instruction::CC_CXZ) { + return state.gpRegister(rCX).value() == 0; + } return is_jcc_taken(state.flags(), cond); } @@ -534,7 +547,9 @@ void analyze_call(const State &state, const edb::Instruction &inst, QStringList bool ok; const edb::address_t effective_address = edb::v1::arch_processor().getEffectiveAddress(inst, operand, state, ok); - if (!ok) return; + if (!ok) { + return; + } const auto temp_operand = QString::fromStdString(edb::v1::formatter().toString(operand)); if (is_immediate(operand)) { @@ -656,7 +671,7 @@ void analyze_operands(const State &state, const edb::Instruction &inst, QStringL #if 0 bool ok; const edb::address_t effective_address = edb::v1::arch_processor().getEffectiveAddress(inst, operand, state, ok); - if (!ok) return; + if (!ok) { return; } ret << QString("%1 = %2").arg(temp_operand).arg(edb::v1::format_pointer(effective_address)); #endif } else if (is_register(operand)) { @@ -1029,10 +1044,18 @@ QString FPUComparExplain(uint16_t statusWord) { const bool C0 = statusWord & (1 << 8); const bool C2 = statusWord & (1 << 10); const bool C3 = statusWord & (1 << 14); - if (C3 == 0 && C2 == 0 && C0 == 0) return "GT"; - if (C3 == 0 && C2 == 0 && C0 == 1) return "LT"; - if (C3 == 1 && C2 == 0 && C0 == 0) return "EQ"; - if (C3 == 1 && C2 == 1 && C0 == 1) return QObject::tr("Unordered", "result of FPU comparison instruction"); + if (C3 == 0 && C2 == 0 && C0 == 0) { + return "GT"; + } + if (C3 == 0 && C2 == 0 && C0 == 1) { + return "LT"; + } + if (C3 == 1 && C2 == 0 && C0 == 0) { + return "EQ"; + } + if (C3 == 1 && C2 == 1 && C0 == 1) { + return QObject::tr("Unordered", "result of FPU comparison instruction"); + } return ""; } @@ -1299,12 +1322,16 @@ Result ArchProcessor::getEffectiveAddress(const edb::In } }(); - if (!segBase) return make_unexpected(QObject::tr("failed to obtain segment base")); // no way to reliably compute address + if (!segBase) { + return make_unexpected(QObject::tr("failed to obtain segment base")); + } // no way to reliably compute address ret += segBase.valueAsAddress(); } } else if (is_immediate(op)) { const Register csBase = state["cs_base"]; - if (!csBase) return make_unexpected(QObject::tr("failed to obtain CS segment base")); // no way to reliably compute address + if (!csBase) { + return make_unexpected(QObject::tr("failed to obtain CS segment base")); + } // no way to reliably compute address ret = op->imm + csBase.valueAsAddress(); } } @@ -1317,7 +1344,9 @@ edb::address_t ArchProcessor::getEffectiveAddress(const edb::Instruction &inst, ok = false; const auto result = getEffectiveAddress(inst, op, state); - if (!result) return 0; + if (!result) { + return 0; + } ok = true; return result.value(); } @@ -1465,8 +1494,9 @@ QStringList ArchProcessor::updateInstructionInfo(edb::address_t address) { // FIXME: actually only ERESTARTNOINTR guarantees reexecution. But it seems the other ERESTART* signals // won't go into user space, so whatever the state of signal handlers, the tracee should never appear // to see these signals. So I guess it's OK to assume that tha syscall _will_ be restarted by the kernel. - if (interrupted && err != EINTR) + if (interrupted && err != EINTR) { ret << QString("Syscall will be restarted on next step/run"); + } #else Q_UNUSED(rax) #endif diff --git a/src/arch/x86-generic/RegisterViewModel.cpp b/src/arch/x86-generic/RegisterViewModel.cpp index d1dcaef4c..ae7830fbf 100644 --- a/src/arch/x86-generic/RegisterViewModel.cpp +++ b/src/arch/x86-generic/RegisterViewModel.cpp @@ -358,8 +358,14 @@ QVariant RegisterViewModel::data(const QModelIndex &index, int role) const { } if (name.startsWith("XMM") || name.startsWith("YMM")) { - if (mode == CpuMode::IA32) return 4; - if (mode == CpuMode::AMD64) return 5; + if (mode == CpuMode::IA32) { + return 4; + } + + if (mode == CpuMode::AMD64) { + return 5; + } + return {}; } } @@ -562,12 +568,16 @@ void RegisterViewModel::updateDR(std::size_t i, edb::value64 value, const QStrin void RegisterViewModel::updateMMXReg(std::size_t i, edb::value64 value, const QString &comment) { Q_ASSERT(i < MMX_REG_COUNT); - if (!mmxRegs->childCount()) return; + if (!mmxRegs->childCount()) { + return; + } updateRegister(mmxRegs, static_cast(i), value, comment); } void RegisterViewModel::invalidateMMXReg(std::size_t i) { Q_ASSERT(i < MMX_REG_COUNT); - if (!mmxRegs->childCount()) return; + if (!mmxRegs->childCount()) { + return; + } invalidate(mmxRegs, i); } @@ -600,7 +610,9 @@ void RegisterViewModel::updateSSEReg(std::size_t i, edb::value128 value, const Q unsigned sseRegMax; std::tie(sseCat, avxCat, sseRegMax) = getSSEparams(); Q_ASSERT(i < sseRegMax); - if (!sseCat->childCount()) return; + if (!sseCat->childCount()) { + return; + } updateRegister(sseCat, static_cast(i), value, comment); // To avoid showing stale data in case this is called when AVX state is supported if (avxCat->childCount()) { @@ -740,7 +752,9 @@ void RegisterViewModel::showGenericCategories() { } void RegisterViewModel::setCpuMode(CpuMode newMode) { - if (mode == newMode) return; + if (mode == newMode) { + return; + } beginResetModel(); mode = newMode;