Skip to content

Commit

Permalink
Run clang-tidy on src/debugger.
Browse files Browse the repository at this point in the history
  • Loading branch information
sa666666 committed Aug 2, 2024
1 parent 906ad17 commit 925c587
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 62 deletions.
8 changes: 4 additions & 4 deletions src/debugger/BreakpointMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}
Expand All @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down
13 changes: 7 additions & 6 deletions src/debugger/BreakpointMap.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,25 @@ 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;
uInt32 get(uInt16 addr, uInt8 bank) const;

/** 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;
Expand All @@ -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
);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/debugger/CartDebug.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/debugger/CpuDebug.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 2 additions & 2 deletions src/debugger/Debugger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/debugger/Debugger.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
31 changes: 17 additions & 14 deletions src/debugger/DebuggerExpressions.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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()); }
};
Expand All @@ -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()); }
};
Expand All @@ -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; }

Expand All @@ -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()); }

Expand Down Expand Up @@ -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); }

Expand All @@ -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(); }

Expand Down Expand Up @@ -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); }
};
Expand All @@ -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(); }
};
Expand All @@ -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()); }
};
Expand Down Expand Up @@ -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()); }

Expand Down Expand Up @@ -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()); }

Expand All @@ -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()); }

Expand All @@ -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()); }
};
Expand All @@ -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()); }
};
Expand Down
12 changes: 7 additions & 5 deletions src/debugger/DebuggerParser.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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};
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/debugger/DiStella.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/debugger/Expression.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/debugger/RiotDebug.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 3 additions & 1 deletion src/debugger/TIADebug.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/debugger/TimerMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Loading

0 comments on commit 925c587

Please sign in to comment.