Skip to content

Commit

Permalink
a bunch more clang-tidy related cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eteran committed Mar 18, 2024
1 parent 5ddf237 commit 5d5d6f8
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 133 deletions.
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ words:
- stepover
- tbyte
- Teran
- TSTP
- xmmword
- yasm
- ymmword
Expand Down
10 changes: 5 additions & 5 deletions include/IBinary.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class EDB_EXPORT IBinary {
virtual ~IBinary() = default;

public:
virtual bool native() const = 0;
virtual edb::address_t entryPoint() = 0;
virtual size_t headerSize() const = 0;
virtual const void *header() const = 0;
virtual std::vector<Header> headers() const = 0;
[[nodiscard]] virtual bool native() const = 0;
[[nodiscard]] virtual edb::address_t entryPoint() = 0;
[[nodiscard]] virtual size_t headerSize() const = 0;
[[nodiscard]] virtual const void *header() const = 0;
[[nodiscard]] virtual std::vector<Header> headers() const = 0;

public:
using create_func_ptr_t = std::unique_ptr<IBinary> (*)(const std::shared_ptr<IRegion> &);
Expand Down
60 changes: 30 additions & 30 deletions include/IProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,41 @@ class IProcess {

public:
// legal to call when not attached
virtual QDateTime startTime() const = 0;
virtual QList<QByteArray> arguments() const = 0;
virtual QString currentWorkingDirectory() const = 0;
virtual QString executable() const = 0;
virtual QString standardInput() const = 0;
virtual QString standardOutput() const = 0;
virtual edb::pid_t pid() const = 0;
virtual std::shared_ptr<IProcess> parent() const = 0;
virtual edb::address_t codeAddress() const = 0;
virtual edb::address_t dataAddress() const = 0;
virtual edb::address_t entryPoint() const = 0;
virtual QList<std::shared_ptr<IRegion>> regions() const = 0;
virtual edb::uid_t uid() const = 0;
virtual QString user() const = 0;
virtual QString name() const = 0;
virtual QList<Module> loadedModules() const = 0;
[[nodiscard]] virtual QDateTime startTime() const = 0;
[[nodiscard]] virtual QList<QByteArray> arguments() const = 0;
[[nodiscard]] virtual QString currentWorkingDirectory() const = 0;
[[nodiscard]] virtual QString executable() const = 0;
[[nodiscard]] virtual QString standardInput() const = 0;
[[nodiscard]] virtual QString standardOutput() const = 0;
[[nodiscard]] virtual edb::pid_t pid() const = 0;
[[nodiscard]] virtual std::shared_ptr<IProcess> parent() const = 0;
[[nodiscard]] virtual edb::address_t codeAddress() const = 0;
[[nodiscard]] virtual edb::address_t dataAddress() const = 0;
[[nodiscard]] virtual edb::address_t entryPoint() const = 0;
[[nodiscard]] virtual QList<std::shared_ptr<IRegion>> regions() const = 0;
[[nodiscard]] virtual edb::uid_t uid() const = 0;
[[nodiscard]] virtual QString user() const = 0;
[[nodiscard]] virtual QString name() const = 0;
[[nodiscard]] virtual QList<Module> loadedModules() const = 0;

public:
virtual edb::address_t debugPointer() const { return 0; }
virtual edb::address_t calculateMain() const { return 0; }
[[nodiscard]] virtual edb::address_t debugPointer() const { return 0; }
[[nodiscard]] virtual edb::address_t calculateMain() const { return 0; }

public:
// only legal to call when attached
virtual QList<std::shared_ptr<IThread>> threads() const = 0;
virtual std::shared_ptr<IThread> currentThread() const = 0;
virtual void setCurrentThread(IThread &thread) = 0;
virtual std::size_t writeBytes(edb::address_t address, const void *buf, size_t len) = 0;
virtual std::size_t patchBytes(edb::address_t address, const void *buf, size_t len) = 0;
virtual std::size_t readBytes(edb::address_t address, void *buf, size_t len) const = 0;
virtual std::size_t readPages(edb::address_t address, void *buf, size_t count) const = 0;
virtual Status pause() = 0;
virtual Status resume(edb::EventStatus status) = 0;
virtual Status step(edb::EventStatus status) = 0;
virtual bool isPaused() const = 0;
virtual QMap<edb::address_t, Patch> patches() const = 0;
[[nodiscard]] virtual bool isPaused() const = 0;
[[nodiscard]] virtual QList<std::shared_ptr<IThread>> threads() const = 0;
[[nodiscard]] virtual std::shared_ptr<IThread> 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;
virtual QMap<edb::address_t, Patch> patches() const = 0;
virtual Status pause() = 0;
virtual Status resume(edb::EventStatus status) = 0;
virtual Status step(edb::EventStatus status) = 0;
virtual std::size_t patchBytes(edb::address_t address, const void *buf, size_t len) = 0;
virtual std::size_t writeBytes(edb::address_t address, const void *buf, size_t len) = 0;
virtual void setCurrentThread(IThread &thread) = 0;
};

#endif
26 changes: 13 additions & 13 deletions include/IRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,34 @@ class IRegion {
virtual ~IRegion() = default;

public:
virtual IRegion *clone() const = 0;
[[nodiscard]] virtual IRegion *clone() const = 0;

public:
virtual bool accessible() const = 0;
virtual bool readable() const = 0;
virtual bool writable() const = 0;
virtual bool executable() const = 0;
virtual size_t size() const = 0;
[[nodiscard]] virtual bool accessible() const = 0;
[[nodiscard]] virtual bool readable() const = 0;
[[nodiscard]] virtual bool writable() const = 0;
[[nodiscard]] virtual bool executable() const = 0;
[[nodiscard]] virtual size_t size() const = 0;

public:
virtual void setPermissions(bool read, bool write, bool execute) = 0;
virtual void setStart(edb::address_t address) = 0;
virtual void setEnd(edb::address_t address) = 0;

public:
virtual edb::address_t start() const = 0;
virtual edb::address_t end() const = 0; // NOTE: is the address of one past the last byte of the region
virtual edb::address_t base() const = 0;
virtual QString name() const = 0;
virtual permissions_t permissions() const = 0;
[[nodiscard]] virtual edb::address_t start() const = 0;
[[nodiscard]] virtual edb::address_t end() const = 0; // NOTE: is the address of one past the last byte of the region
[[nodiscard]] virtual edb::address_t base() const = 0;
[[nodiscard]] virtual QString name() const = 0;
[[nodiscard]] virtual permissions_t permissions() const = 0;

public:
bool contains(edb::address_t address) const {
[[nodiscard]] bool contains(edb::address_t address) const {
return address >= start() && address < end();
}

template <class Pointer>
bool equals(const Pointer &other) const {
[[nodiscard]] bool equals(const Pointer &other) const {

if (!other) {
return false;
Expand Down
24 changes: 12 additions & 12 deletions include/ISymbolManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ class ISymbolManager {
virtual ~ISymbolManager() = default;

public:
virtual const std::vector<std::shared_ptr<Symbol>> symbols() const = 0;
virtual const std::shared_ptr<Symbol> find(const QString &name) const = 0;
virtual const std::shared_ptr<Symbol> find(edb::address_t address) const = 0;
virtual const std::shared_ptr<Symbol> findNearSymbol(edb::address_t address) const = 0;
virtual void addSymbol(const std::shared_ptr<Symbol> &symbol) = 0;
virtual void clear() = 0;
virtual void loadSymbolFile(const QString &filename, edb::address_t base) = 0;
virtual void setSymbolGenerator(ISymbolGenerator *generator) = 0;
virtual void setLabel(edb::address_t address, const QString &label) = 0;
virtual QString findAddressName(edb::address_t address, bool prefixed = true) = 0;
virtual QHash<edb::address_t, QString> labels() const = 0;
virtual QStringList files() const = 0;
[[nodiscard]] virtual const std::shared_ptr<Symbol> find(const QString &name) const = 0;
[[nodiscard]] virtual const std::shared_ptr<Symbol> find(edb::address_t address) const = 0;
[[nodiscard]] virtual const std::shared_ptr<Symbol> findNearSymbol(edb::address_t address) const = 0;
[[nodiscard]] virtual const std::vector<std::shared_ptr<Symbol>> symbols() const = 0;
[[nodiscard]] virtual QHash<edb::address_t, QString> labels() const = 0;
[[nodiscard]] virtual QStringList files() const = 0;
virtual QString findAddressName(edb::address_t address, bool prefixed = true) = 0;
virtual void addSymbol(const std::shared_ptr<Symbol> &symbol) = 0;
virtual void clear() = 0;
virtual void loadSymbolFile(const QString &filename, edb::address_t base) = 0;
virtual void setLabel(edb::address_t address, const QString &label) = 0;
virtual void setSymbolGenerator(ISymbolGenerator *generator) = 0;
};

#endif
12 changes: 6 additions & 6 deletions include/IThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class IThread {
virtual ~IThread() = default;

public:
virtual edb::tid_t tid() const = 0;
virtual QString name() const = 0;
virtual int priority() const = 0;
virtual edb::address_t instructionPointer() const = 0;
virtual QString runState() const = 0;
[[nodiscard]] virtual edb::tid_t tid() const = 0;
[[nodiscard]] virtual QString name() const = 0;
[[nodiscard]] virtual int priority() const = 0;
[[nodiscard]] virtual edb::address_t instructionPointer() const = 0;
[[nodiscard]] virtual QString runState() const = 0;

public:
virtual void getState(State *state) = 0;
Expand All @@ -47,7 +47,7 @@ class IThread {
virtual Status resume(edb::EventStatus status) = 0;

public:
virtual bool isPaused() const = 0;
[[nodiscard]] virtual bool isPaused() const = 0;
};

#endif
48 changes: 24 additions & 24 deletions src/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,11 @@ Debugger::Debugger(QWidget *parent)
setRIPAction_ = createAction(tr("&Set %1 to this Instruction").arg("RIP"), QKeySequence(tr("Ctrl+*")), &Debugger::mnuCPUSetEIP);
gotoRIPAction_ = createAction(tr("&Goto %1").arg("RIP"), QKeySequence(tr("*")), &Debugger::mnuCPUJumpToEIP);
#elif defined(EDB_X86)
setRIPAction_ = createAction(tr("&Set %1 to this Instruction").arg("EIP"), QKeySequence(tr("Ctrl+*")), &Debugger::mnuCPUSetEIP);
gotoRIPAction_ = createAction(tr("&Goto %1").arg("EIP"), QKeySequence(tr("*")), &Debugger::mnuCPUJumpToEIP);
setRIPAction_ = createAction(tr("&Set %1 to this Instruction").arg("EIP"), QKeySequence(tr("Ctrl+*")), &Debugger::mnuCPUSetEIP);
gotoRIPAction_ = createAction(tr("&Goto %1").arg("EIP"), QKeySequence(tr("*")), &Debugger::mnuCPUJumpToEIP);
#elif defined(EDB_ARM32) || defined(EDB_ARM64)
setRIPAction_ = createAction(tr("&Set %1 to this Instruction").arg("PC"), QKeySequence(tr("Ctrl+*")), &Debugger::mnuCPUSetEIP);
gotoRIPAction_ = createAction(tr("&Goto %1").arg("PC"), QKeySequence(tr("*")), &Debugger::mnuCPUJumpToEIP);
setRIPAction_ = createAction(tr("&Set %1 to this Instruction").arg("PC"), QKeySequence(tr("Ctrl+*")), &Debugger::mnuCPUSetEIP);
gotoRIPAction_ = createAction(tr("&Goto %1").arg("PC"), QKeySequence(tr("*")), &Debugger::mnuCPUJumpToEIP);
#else
#error "This doesn't initialize actions and will lead to crash"
#endif
Expand Down Expand Up @@ -527,7 +527,7 @@ QAction *Debugger::createAction(const QString &text, const QKeySequence &keySequ
}

//------------------------------------------------------------------------------
// Name: update_menu_state
// Name: updateMenuState
// Desc:
//------------------------------------------------------------------------------
void Debugger::updateMenuState(GuiState state) {
Expand Down Expand Up @@ -590,7 +590,7 @@ void Debugger::updateMenuState(GuiState state) {
}

//------------------------------------------------------------------------------
// Name: create_tty
// Name: createTty
// Desc: creates a TTY object for our command line I/O
//------------------------------------------------------------------------------
QString Debugger::createTty() {
Expand Down Expand Up @@ -715,7 +715,7 @@ QString Debugger::createTty() {
}

//------------------------------------------------------------------------------
// Name: tty_proc_finished
// Name: ttyProcFinished
// Desc: cleans up the data associated with a TTY when the terminal dies
//------------------------------------------------------------------------------
void Debugger::ttyProcFinished(int exit_code, QProcess::ExitStatus exit_status) {
Expand All @@ -726,31 +726,31 @@ void Debugger::ttyProcFinished(int exit_code, QProcess::ExitStatus exit_status)
}

//------------------------------------------------------------------------------
// Name: current_tab
// Name: currentTab
// Desc:
//------------------------------------------------------------------------------
int Debugger::currentTab() const {
return tabWidget_->currentIndex();
}

//------------------------------------------------------------------------------
// Name: current_data_view_info
// Name: currentDataViewInfo
// Desc:
//------------------------------------------------------------------------------
std::shared_ptr<DataViewInfo> Debugger::currentDataViewInfo() const {
return dataRegions_[currentTab()];
}

//------------------------------------------------------------------------------
// Name: set_debugger_caption
// Name: setDebuggerCaption
// Desc: sets the caption part to also show the application name and pid
//------------------------------------------------------------------------------
void Debugger::setDebuggerCaption(const QString &appname) {
setWindowTitle(tr("edb - %1 [%2]").arg(appname).arg(edb::v1::debugger_core->process()->pid()));
}

//------------------------------------------------------------------------------
// Name: delete_data_tab
// Name: deleteDataTab
// Desc:
//------------------------------------------------------------------------------
void Debugger::deleteDataTab() {
Expand All @@ -769,7 +769,7 @@ void Debugger::deleteDataTab() {
}

//------------------------------------------------------------------------------
// Name: create_data_tab
// Name: createDataTab
// Desc:
//------------------------------------------------------------------------------
void Debugger::createDataTab() {
Expand Down Expand Up @@ -896,21 +896,21 @@ void Debugger::finishPluginSetup() {
}

//------------------------------------------------------------------------------
// Name: get_goto_expression
// Name: getGotoExpression
// Desc:
//------------------------------------------------------------------------------
Result<edb::address_t, QString> Debugger::getGotoExpression() {

std::optional<edb::address_t> address = edb::v2::get_expression_from_user(tr("Goto Expression"), tr("Expression:"));
if (address) {
return *address;
} else {
return make_unexpected(tr("No Address"));
}

return make_unexpected(tr("No Address"));
}

//------------------------------------------------------------------------------
// Name: get_follow_register
// Name: getFollowRegister
// Desc:
//------------------------------------------------------------------------------
Result<edb::reg_t, QString> Debugger::getFollowRegister() const {
Expand All @@ -924,7 +924,7 @@ Result<edb::reg_t, QString> Debugger::getFollowRegister() const {
}

//------------------------------------------------------------------------------
// Name: goto_triggered
// Name: gotoTriggered
// Desc:
//------------------------------------------------------------------------------
void Debugger::gotoTriggered() {
Expand All @@ -941,7 +941,7 @@ void Debugger::gotoTriggered() {
}

//------------------------------------------------------------------------------
// Name: setup_ui
// Name: setupUi
// Desc: creates the UI
//------------------------------------------------------------------------------
void Debugger::setupUi() {
Expand Down Expand Up @@ -1192,7 +1192,7 @@ void Debugger::showEvent(QShowEvent *) {
QScreen *screen = QGuiApplication::primaryScreen();
QRect sg = screen->geometry();
#else
QRect sg = desktop.screenGeometry();
QRect sg = desktop.screenGeometry();
#endif
int x = (sg.width() - this->width()) / 2;
int y = (sg.height() - this->height()) / 2;
Expand Down Expand Up @@ -2884,7 +2884,7 @@ void Debugger::on_action_Pause_triggered() {
}

//------------------------------------------------------------------------------
// Name: cleanup_debugger
// Name: cleanupDebugger
// Desc:
//------------------------------------------------------------------------------
void Debugger::cleanupDebugger() {
Expand Down Expand Up @@ -2914,7 +2914,7 @@ void Debugger::cleanupDebugger() {
}

//------------------------------------------------------------------------------
// Name: session_filename
// Name: sessionFilename
// Desc:
//------------------------------------------------------------------------------
QString Debugger::sessionFilename() const {
Expand Down Expand Up @@ -2950,7 +2950,7 @@ QString Debugger::sessionFilename() const {
}

//------------------------------------------------------------------------------
// Name: detach_from_process
// Name: detachFromProcess
// Desc:
//------------------------------------------------------------------------------
void Debugger::detachFromProcess(DetachAction kill) {
Expand All @@ -2977,7 +2977,7 @@ void Debugger::detachFromProcess(DetachAction kill) {
}

//------------------------------------------------------------------------------
// Name: set_initial_debugger_state
// Name: setInitialDebuggerState
// Desc: resets all of the basic data to sane defaults
//------------------------------------------------------------------------------
void Debugger::setInitialDebuggerState() {
Expand All @@ -2988,7 +2988,7 @@ void Debugger::setInitialDebuggerState() {
edb::v1::symbol_manager().clear();
edb::v1::memory_regions().sync();

Q_ASSERT(dataRegions_.size() > 0);
Q_ASSERT(!dataRegions_.empty());

dataRegions_.first()->region = edb::v1::primary_data_region();

Expand Down
Loading

0 comments on commit 5d5d6f8

Please sign in to comment.