return sorted list of breakpoints

This commit is contained in:
Thomas Jentzsch 2019-08-26 10:11:41 +02:00
parent d35aaa3252
commit 5dbb5b8957
3 changed files with 24 additions and 22 deletions

View File

@ -15,6 +15,7 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include <map>
#include "BreakpointMap.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -82,8 +83,9 @@ bool BreakpointMap::check(const uInt16 addr, const uInt8 bank) const
BreakpointMap::BreakpointList BreakpointMap::getBreakpoints() const
{
BreakpointList map;
std::map<Breakpoint, uInt32> ordered(myMap.begin(), myMap.end());
for(auto item : myMap)
for(auto item : ordered)
map.push_back(item.first);
return map;

View File

@ -44,13 +44,18 @@ public:
Breakpoint()
: addr(0), bank(0) { }
Breakpoint(const Breakpoint& bp)
: addr(bp.addr), bank(bp.bank) { }
: addr(bp.addr & ADDRESS_MASK), bank(bp.bank) { }
explicit Breakpoint(uInt16 c_addr, uInt8 c_bank)
: addr(c_addr), bank(c_bank) { }
: addr(c_addr & ADDRESS_MASK), bank(c_bank) { }
bool operator==(const Breakpoint& other) const
{
return ((addr & ADDRESS_MASK) == (other.addr & ADDRESS_MASK) && bank == other.bank);
return (addr == other.addr && bank == other.bank);
}
bool operator<(const Breakpoint& other) const
{
return bank < other.bank ||
(bank == other.bank && addr < other.addr);
}
};
using BreakpointList = std::vector<Breakpoint>;
@ -76,6 +81,7 @@ public:
bool check(const Breakpoint& breakpoint) const;
bool check(const uInt16 addr, const uInt8 bank) const;
/** Returns a sorted list of breakpoints */
BreakpointList getBreakpoints() const;
/** clear all breakpoints */
@ -86,7 +92,7 @@ private:
struct BreakpointHash {
size_t operator()(const Breakpoint& bp) const {
return std::hash<uInt64>()(
uInt64(bp.addr & ADDRESS_MASK) * 13 + uInt64(bp.bank)
uInt64(bp.addr) * 13 + uInt64(bp.bank)
);
}
};

View File

@ -1445,25 +1445,19 @@ void DebuggerParser::executeListbreaks()
int count = 0;
uInt32 bankCount = debugger.cartDebug().bankCount();
for(uInt32 bank = 0; bank < bankCount; ++bank)
for(const auto& bp : debugger.breakPoints().getBreakpoints())
{
for(uInt32 addr = 0; addr <= 0x1fff; ++addr)
if(bankCount == 1)
{
if(debugger.breakPoints().check(addr, bank))
{
if(bankCount == 1)
{
buf << debugger.cartDebug().getLabel(addr, true, 4) << " ";
if(!(++count % 8)) buf << endl;
}
else
{
if(count % 6)
buf << ", ";
buf << debugger.cartDebug().getLabel(addr, true, 4) << " #" << int(bank);
if(!(++count % 6)) buf << endl;
}
}
buf << debugger.cartDebug().getLabel(bp.addr, true, 4) << " ";
if(!(++count % 8)) buf << endl;
}
else
{
if(count % 6)
buf << ", ";
buf << debugger.cartDebug().getLabel(bp.addr, true, 4) << " #" << int(bp.bank);
if(!(++count % 6)) buf << endl;
}
}
if(count)