Run clang-tidy on `src/debugger`.

This commit is contained in:
Stephen Anthony 2024-08-02 09:47:59 -02:30
parent 906ad17259
commit 925c587255
15 changed files with 69 additions and 62 deletions

View File

@ -19,7 +19,7 @@
#include "BreakpointMap.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BreakpointMap::add(const Breakpoint& breakpoint, const uInt32 flags)
void BreakpointMap::add(const Breakpoint& breakpoint, uInt32 flags)
{
const Breakpoint bp = convertBreakpoint(breakpoint);
@ -28,7 +28,7 @@ void BreakpointMap::add(const Breakpoint& breakpoint, const uInt32 flags)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BreakpointMap::add(const uInt16 addr, const uInt8 bank, const uInt32 flags)
void BreakpointMap::add(uInt16 addr, uInt8 bank, uInt32 flags)
{
add(Breakpoint(addr, bank), flags);
}
@ -47,7 +47,7 @@ void BreakpointMap::erase(const Breakpoint& breakpoint)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BreakpointMap::erase(const uInt16 addr, const uInt8 bank)
void BreakpointMap::erase(uInt16 addr, uInt8 bank)
{
erase(Breakpoint(addr, bank));
}
@ -92,7 +92,7 @@ bool BreakpointMap::check(const Breakpoint& breakpoint) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool BreakpointMap::check(const uInt16 addr, const uInt8 bank) const
bool BreakpointMap::check(uInt16 addr, uInt8 bank) const
{
return check(Breakpoint(addr, bank));
}

View File

@ -63,16 +63,17 @@ class BreakpointMap
using BreakpointList = std::vector<Breakpoint>;
BreakpointMap() = default;
~BreakpointMap() = default;
inline bool isInitialized() const { return myInitialized; }
bool isInitialized() const { return myInitialized; }
/** Add new breakpoint */
void add(const Breakpoint& breakpoint, const uInt32 flags = 0);
void add(const uInt16 addr, const uInt8 bank, const uInt32 flags = 0);
void add(const Breakpoint& breakpoint, uInt32 flags = 0);
void add(uInt16 addr, uInt8 bank, uInt32 flags = 0);
/** Erase breakpoint */
void erase(const Breakpoint& breakpoint);
void erase(const uInt16 addr, const uInt8 bank);
void erase(uInt16 addr, uInt8 bank);
/** Get info for breakpoint */
uInt32 get(const Breakpoint& breakpoint) const;
@ -80,7 +81,7 @@ class BreakpointMap
/** Check if a breakpoint exists */
bool check(const Breakpoint& breakpoint) const;
bool check(const uInt16 addr, const uInt8 bank) const;
bool check(uInt16 addr, uInt8 bank) const;
/** Returns a sorted list of breakpoints */
BreakpointList getBreakpoints() const;
@ -95,7 +96,7 @@ class BreakpointMap
struct BreakpointHash {
size_t operator()(const Breakpoint& bp) const {
return std::hash<uInt64>()(
uInt64(bp.addr) * 13 // only check for address, bank check via == operator
static_cast<uInt64>(bp.addr) * 13 // only check for address, bank check via == operator
);
}
};

View File

@ -65,7 +65,7 @@ class CartDebug : public DebuggerSystem
};
// Determine 'type' of address (ie, what part of the system accessed)
enum class AddrType { TIA, IO, ZPRAM, ROM };
enum class AddrType: uInt8 { TIA, IO, ZPRAM, ROM };
static AddrType addressType(uInt16 addr);
public:
@ -302,7 +302,7 @@ class CartDebug : public DebuggerSystem
std::array<bool, 64> TIAWrite{false};
std::array<bool, 32> IOReadWrite{false};
std::array<bool, 128> ZPRAM{false};
AddrToLabel Label{};
AddrToLabel Label;
bool breakFound{false};
};
ReservedEquates myReserved;

View File

@ -39,6 +39,7 @@ class CpuDebug : public DebuggerSystem
{
public:
CpuDebug(Debugger& dbg, Console& console);
~CpuDebug() override = default;
const DebuggerState& getState() override;
const DebuggerState& getOldState() override { return myOldState; }

View File

@ -681,13 +681,13 @@ uInt16 Debugger::windStates(uInt16 numStates, bool unwind, string& message)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Debugger::rewindStates(const uInt16 numStates, string& message)
uInt16 Debugger::rewindStates(uInt16 numStates, string& message)
{
return windStates(numStates, false, message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Debugger::unwindStates(const uInt16 numStates, string& message)
uInt16 Debugger::unwindStates(uInt16 numStates, string& message)
{
return windStates(numStates, true, message);
}

View File

@ -312,8 +312,8 @@ class Debugger : public DialogContainer
int trace();
void nextScanline(int lines);
void nextFrame(int frames);
uInt16 rewindStates(const uInt16 numStates, string& message);
uInt16 unwindStates(const uInt16 numStates, string& message);
uInt16 rewindStates(uInt16 numStates, string& message);
uInt16 unwindStates(uInt16 numStates, string& message);
void clearAllBreakPoints() const;

View File

@ -46,7 +46,7 @@ class BinAndExpression : public Expression
class BinNotExpression : public Expression
{
public:
BinNotExpression(Expression* left) : Expression(left) { }
explicit BinNotExpression(Expression* left) : Expression(left) { }
Int32 evaluate() const override
{ return ~(myLHS->evaluate()); }
};
@ -73,7 +73,7 @@ class BinXorExpression : public Expression
class ByteDerefExpression : public Expression
{
public:
ByteDerefExpression(Expression* left): Expression(left) { }
explicit ByteDerefExpression(Expression* left): Expression(left) { }
Int32 evaluate() const override
{ return Debugger::debugger().peek(myLHS->evaluate()); }
};
@ -91,7 +91,7 @@ class ByteDerefOffsetExpression : public Expression
class ConstExpression : public Expression
{
public:
ConstExpression(const int value) : Expression(), myValue{value} { }
explicit ConstExpression(int value) : myValue{value} { }
Int32 evaluate() const override
{ return myValue; }
@ -103,7 +103,7 @@ class ConstExpression : public Expression
class CpuMethodExpression : public Expression
{
public:
CpuMethodExpression(CpuMethod method) : Expression(), myMethod{std::mem_fn(method)} { }
explicit CpuMethodExpression(CpuMethod method) : myMethod{std::mem_fn(method)} { }
Int32 evaluate() const override
{ return myMethod(Debugger::debugger().cpuDebug()); }
@ -134,7 +134,7 @@ class EqualsExpression : public Expression
class EquateExpression : public Expression
{
public:
EquateExpression(string_view label) : Expression(), myLabel{label} { }
explicit EquateExpression(string_view label) : myLabel{label} { }
Int32 evaluate() const override
{ return Debugger::debugger().cartDebug().getAddress(myLabel); }
@ -146,7 +146,7 @@ class EquateExpression : public Expression
class FunctionExpression : public Expression
{
public:
FunctionExpression(string_view label) : Expression(), myLabel{label} { }
explicit FunctionExpression(string_view label) : myLabel{label} { }
Int32 evaluate() const override
{ return Debugger::debugger().getFunction(myLabel).evaluate(); }
@ -176,7 +176,7 @@ class GreaterExpression : public Expression
class HiByteExpression : public Expression
{
public:
HiByteExpression(Expression* left) : Expression(left) { }
explicit HiByteExpression(Expression* left) : Expression(left) { }
Int32 evaluate() const override
{ return 0xff & (myLHS->evaluate() >> 8); }
};
@ -203,7 +203,7 @@ class LessExpression : public Expression
class LoByteExpression : public Expression
{
public:
LoByteExpression(Expression* left) : Expression(left) { }
explicit LoByteExpression(Expression* left) : Expression(left) { }
Int32 evaluate() const override
{ return 0xff & myLHS->evaluate(); }
};
@ -221,7 +221,7 @@ class LogAndExpression : public Expression
class LogNotExpression : public Expression
{
public:
LogNotExpression(Expression* left) : Expression(left) { }
explicit LogNotExpression(Expression* left) : Expression(left) { }
Int32 evaluate() const override
{ return !(myLHS->evaluate()); }
};
@ -285,7 +285,8 @@ class PlusExpression : public Expression
class CartMethodExpression : public Expression
{
public:
CartMethodExpression(CartMethod method) : Expression(), myMethod{std::mem_fn(method)} { }
explicit CartMethodExpression(CartMethod method) :
myMethod{std::mem_fn(method)} { }
Int32 evaluate() const override
{ return myMethod(Debugger::debugger().cartDebug()); }
@ -315,7 +316,8 @@ class ShiftRightExpression : public Expression
class RiotMethodExpression : public Expression
{
public:
RiotMethodExpression(RiotMethod method) : Expression(), myMethod{std::mem_fn(method)} { }
explicit RiotMethodExpression(RiotMethod method) :
myMethod{std::mem_fn(method)} { }
Int32 evaluate() const override
{ return myMethod(Debugger::debugger().riotDebug()); }
@ -327,7 +329,8 @@ class RiotMethodExpression : public Expression
class TiaMethodExpression : public Expression
{
public:
TiaMethodExpression(TiaMethod method) : Expression(), myMethod{std::mem_fn(method)} { }
explicit TiaMethodExpression(TiaMethod method) :
myMethod{std::mem_fn(method)} { }
Int32 evaluate() const override
{ return myMethod(Debugger::debugger().tiaDebug()); }
@ -339,7 +342,7 @@ class TiaMethodExpression : public Expression
class UnaryMinusExpression : public Expression
{
public:
UnaryMinusExpression(Expression* left) : Expression(left) { }
explicit UnaryMinusExpression(Expression* left) : Expression(left) { }
Int32 evaluate() const override
{ return -(myLHS->evaluate()); }
};
@ -348,7 +351,7 @@ class UnaryMinusExpression : public Expression
class WordDerefExpression : public Expression
{
public:
WordDerefExpression(Expression* left) : Expression(left) { }
explicit WordDerefExpression(Expression* left) : Expression(left) { }
Int32 evaluate() const override
{ return Debugger::debugger().dpeekAsInt(myLHS->evaluate()); }
};

View File

@ -28,11 +28,13 @@ struct Command;
#include "bspf.hxx"
#include "Device.hxx"
#include "FrameBufferConstants.hxx"
class DebuggerParser
{
public:
DebuggerParser(Debugger& debugger, Settings& settings);
~DebuggerParser() = default;
/** Run the given command, and return the result */
string run(string_view command);
@ -50,11 +52,11 @@ class DebuggerParser
/** String representation of all watches currently defined */
string showWatches();
static inline string red(string_view msg = "")
static string red(string_view msg = "")
{
return char(kDbgColorRed & 0xff) + string{msg};
return static_cast<char>(kDbgColorRed & 0xff) + string{msg};
}
static inline string inverse(string_view msg = "")
static string inverse(string_view msg = "")
{
// ASCII DEL char, decimal 127
return "\177" + string{msg};
@ -71,14 +73,14 @@ class DebuggerParser
private:
// Constants for argument processing
enum class ParseState {
enum class ParseState: uInt8 {
IN_COMMAND,
IN_SPACE,
IN_BRACE,
IN_ARG
};
enum class Parameters {
enum class Parameters: uInt8 {
ARG_WORD, // single 16-bit value
ARG_DWORD, // single 32-bit value
ARG_MULTI_WORD, // multiple 16-bit values (must occur last)

View File

@ -71,12 +71,13 @@ class DiStella
CartDebug::AddrTypeArray& labels,
CartDebug::AddrTypeArray& directives,
CartDebug::ReservedEquates& reserved);
~DiStella() = default;
private:
/**
Enumeration of the addressing type (RAM, ROM, RIOT, TIA...)
Enumeration of the addressing type (RAM, ROM, RIOT, TIA...)
*/
enum class AddressType : int
enum class AddressType: uInt8
{
INVALID,
ROM,
@ -86,7 +87,6 @@ class DiStella
ZP_RAM
};
private:
// Indicate that a new line of disassembly has been completed
// In the original Distella code, this indicated a new line to be printed
@ -112,12 +112,12 @@ class DiStella
void outputBytes(Device::AccessType type);
// Convenience methods to generate appropriate labels
inline void labelA12High(stringstream& buf, uInt8 op, uInt16 addr, AddressType labfound)
void labelA12High(stringstream& buf, uInt8 op, uInt16 addr, AddressType labfound)
{
if(!myDbg.getLabel(buf, addr, true))
buf << "L" << Common::Base::HEX4 << addr;
}
inline void labelA12Low(stringstream& buf, uInt8 op, uInt16 addr, AddressType labfound)
void labelA12Low(stringstream& buf, uInt8 op, uInt16 addr, AddressType labfound)
{
myDbg.getLabel(buf, addr, ourLookup[op].rw_mode == RWMode::READ, 2);
if (labfound == AddressType::TIA)

View File

@ -31,7 +31,7 @@
class Expression
{
public:
Expression(Expression* lhs = nullptr, Expression* rhs = nullptr)
explicit Expression(Expression* lhs = nullptr, Expression* rhs = nullptr)
: myLHS{lhs}, myRHS{rhs} { }
virtual ~Expression() = default;

View File

@ -52,6 +52,7 @@ class RiotDebug : public DebuggerSystem
{
public:
RiotDebug(Debugger& dbg, Console& console);
~RiotDebug() override = default;
const DebuggerState& getState() override;
const DebuggerState& getOldState() override { return myOldState; }

View File

@ -48,13 +48,15 @@ class TiaState : public DebuggerState
BoolArray vsb;
// Indices for various IntArray above
enum { P0, P1, M0, M1, BL };
enum: uInt8 { P0, P1, M0, M1, BL };
};
class TIADebug : public DebuggerSystem
{
public:
TIADebug(Debugger& dbg, Console& console);
~TIADebug() override = default;
TIA& tia() const { return myTIA; }
const DebuggerState& getState() override;

View File

@ -158,7 +158,7 @@ void TimerMap::reset()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TimerMap::update(uInt16 addr, uInt8 bank, const uInt64 cycles)
void TimerMap::update(uInt16 addr, uInt8 bank, uInt64 cycles)
{
if((addr & ADDRESS_MASK) != addr)
{

View File

@ -42,12 +42,10 @@ class TimerMap
uInt16 addr{0};
uInt8 bank{ANY_BANK};
TimerPoint() = default;
explicit constexpr TimerPoint(uInt16 c_addr, uInt8 c_bank)
: addr{c_addr}, bank{c_bank} {}
TimerPoint()
: addr{0}, bank(ANY_BANK) {}
bool operator<(const TimerPoint& other) const
{
if(bank == ANY_BANK || other.bank == ANY_BANK)
@ -60,8 +58,8 @@ class TimerMap
public:
struct Timer
{
TimerPoint from{};
TimerPoint to{};
TimerPoint from;
TimerPoint to;
bool mirrors{false};
bool anyBank{false};
bool isPartial{false};
@ -79,10 +77,9 @@ class TimerMap
Timer(uInt16 fromAddr, uInt16 toAddr, uInt8 fromBank, uInt8 toBank,
bool c_mirrors = false, bool c_anyBank = false)
{
Timer(TimerPoint(fromAddr, fromBank), TimerPoint(fromAddr, fromBank),
c_mirrors, c_anyBank);
}
: Timer(TimerPoint{fromAddr, fromBank}, TimerPoint{fromAddr, fromBank},
c_mirrors, c_anyBank)
{}
explicit Timer(const TimerPoint& tp, bool c_mirrors = false,
bool c_anyBank = false)
@ -90,9 +87,8 @@ class TimerMap
Timer(uInt16 addr, uInt8 bank, bool c_mirrors = false,
bool c_anyBank = false)
{
Timer(TimerPoint(addr, bank), c_mirrors, c_anyBank);
}
: Timer(TimerPoint{addr, bank}, c_mirrors, c_anyBank)
{}
void setTo(const TimerPoint& tp, bool c_mirrors = false,
bool c_anyBank = false)
@ -136,8 +132,9 @@ class TimerMap
}; // Timer
explicit TimerMap() = default;
~TimerMap() = default;
inline bool isInitialized() const { return myList.size(); }
bool isInitialized() const { return !myList.empty(); }
/** Add new timer */
uInt32 add(uInt16 fromAddr, uInt16 toAddr,
@ -147,7 +144,7 @@ class TimerMap
bool mirrors, bool anyBank);
/** Erase timer */
bool erase(const uInt32 idx);
bool erase(uInt32 idx);
/** Clear all timers */
void clear();
@ -160,8 +157,7 @@ class TimerMap
uInt32 size() const { return static_cast<uInt32>(myList.size()); }
/** Update timer */
void update(uInt16 addr, uInt8 bank,
const uInt64 cycles);
void update(uInt16 addr, uInt8 bank, uInt64 cycles);
private:
static void toKey(TimerPoint& tp, bool mirrors, bool anyBank);

View File

@ -24,9 +24,10 @@ class TrapArray
{
public:
TrapArray() = default;
~TrapArray() = default;
inline bool isSet(const uInt16 address) const { return myCount[address]; }
inline bool isClear(const uInt16 address) const { return myCount[address] == 0; }
bool isSet(const uInt16 address) const { return myCount[address]; }
bool isClear(const uInt16 address) const { return myCount[address] == 0; }
void add(const uInt16 address) { myCount[address]++; }
void remove(const uInt16 address) { myCount[address]--; }
@ -39,7 +40,7 @@ class TrapArray
}
void clearAll() { myInitialized = false; myCount.fill(0); }
inline bool isInitialized() const { return myInitialized; }
bool isInitialized() const { return myInitialized; }
private:
// The actual counts