diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2019-09-10 15:11:00 -0400 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2019-09-10 15:11:02 -0400 |
commit | 53df4f447db0408d00bdcbee3105e013bdd19c3a (patch) | |
tree | 0ccccacae81b902088f16cf704345fa53b3b252b /src/emu/debug/debugcpu.cpp | |
parent | e52c9cc290a710c11fef4a08c715e46d04db9f07 (diff) |
Use std::forward_list for breakpoint and registerpoint lists (nw)
Diffstat (limited to 'src/emu/debug/debugcpu.cpp')
-rw-r--r-- | src/emu/debug/debugcpu.cpp | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index e49c5bfdb61..01e0a91647b 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -1297,8 +1297,8 @@ device_debug::device_debug(device_t &device) , m_total_cycles(0) , m_last_total_cycles(0) , m_pc_history_index(0) - , m_bplist(nullptr) - , m_rplist(nullptr) + , m_bplist() + , m_rplist() , m_triggered_breakpoint(nullptr) , m_triggered_watchpoint(nullptr) , m_trace(nullptr) @@ -1922,23 +1922,33 @@ void device_debug::halt_on_next_instruction_impl(util::format_argument_pack<std: } //------------------------------------------------- +// breakpoint_find - return a breakpoint at the +// given address, or nullptr if none exists there +//------------------------------------------------- + +const device_debug::breakpoint *device_debug::breakpoint_find(offs_t address) const +{ + for (const breakpoint &bp : m_bplist) + if (bp.address() == address) + return &bp; + + return nullptr; +} + +//------------------------------------------------- // breakpoint_set - set a new breakpoint, // returning its index //------------------------------------------------- int device_debug::breakpoint_set(offs_t address, const char *condition, const char *action) { - // allocate a new one + // allocate a new one and hook it into our list u32 id = m_device.machine().debugger().cpu().get_breakpoint_index(); - breakpoint *bp = auto_alloc(m_device.machine(), breakpoint(this, m_symtable, id, address, condition, action)); - - // hook it into our list - bp->m_next = m_bplist; - m_bplist = bp; + m_bplist.emplace_front(this, m_symtable, id, address, condition, action); // update the flags and return the index breakpoint_update_flags(); - return bp->m_index; + return m_bplist.front().m_index; } @@ -1950,12 +1960,10 @@ int device_debug::breakpoint_set(offs_t address, const char *condition, const ch bool device_debug::breakpoint_clear(int index) { // scan the list to see if we own this breakpoint - for (breakpoint **bp = &m_bplist; *bp != nullptr; bp = &(*bp)->m_next) - if ((*bp)->m_index == index) + for (auto bbp = m_bplist.before_begin(); std::next(bbp) != m_bplist.end(); ++bbp) + if (std::next(bbp)->m_index == index) { - breakpoint *deleteme = *bp; - *bp = deleteme->m_next; - auto_free(m_device.machine(), deleteme); + m_bplist.erase_after(bbp); breakpoint_update_flags(); return true; } @@ -1971,9 +1979,9 @@ bool device_debug::breakpoint_clear(int index) void device_debug::breakpoint_clear_all() { - // clear the head until we run out - while (m_bplist != nullptr) - breakpoint_clear(m_bplist->index()); + // clear the list + m_bplist.clear(); + breakpoint_update_flags(); } @@ -1985,10 +1993,10 @@ void device_debug::breakpoint_clear_all() bool device_debug::breakpoint_enable(int index, bool enable) { // scan the list to see if we own this breakpoint - for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->next()) - if (bp->m_index == index) + for (breakpoint &bp : m_bplist) + if (bp.m_index == index) { - bp->m_enabled = enable; + bp.m_enabled = enable; breakpoint_update_flags(); return true; } @@ -2006,8 +2014,8 @@ bool device_debug::breakpoint_enable(int index, bool enable) void device_debug::breakpoint_enable_all(bool enable) { // apply the enable to all breakpoints we own - for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->next()) - breakpoint_enable(bp->index(), enable); + for (breakpoint &bp : m_bplist) + breakpoint_enable(bp.index(), enable); } @@ -2107,15 +2115,11 @@ int device_debug::registerpoint_set(const char *condition, const char *action) { // allocate a new one u32 id = m_device.machine().debugger().cpu().get_registerpoint_index(); - registerpoint *rp = auto_alloc(m_device.machine(), registerpoint(m_symtable, id, condition, action)); - - // hook it into our list - rp->m_next = m_rplist; - m_rplist = rp; + m_rplist.emplace_front(m_symtable, id, condition, action); // update the flags and return the index breakpoint_update_flags(); - return rp->m_index; + return m_rplist.front().m_index; } @@ -2127,12 +2131,10 @@ int device_debug::registerpoint_set(const char *condition, const char *action) bool device_debug::registerpoint_clear(int index) { // scan the list to see if we own this registerpoint - for (registerpoint **rp = &m_rplist; *rp != nullptr; rp = &(*rp)->m_next) - if ((*rp)->m_index == index) + for (auto brp = m_rplist.before_begin(); std::next(brp) != m_rplist.end(); ++brp) + if (std::next(brp)->m_index == index) { - registerpoint *deleteme = *rp; - *rp = deleteme->m_next; - auto_free(m_device.machine(), deleteme); + m_rplist.erase_after(brp); breakpoint_update_flags(); return true; } @@ -2148,9 +2150,9 @@ bool device_debug::registerpoint_clear(int index) void device_debug::registerpoint_clear_all() { - // clear the head until we run out - while (m_rplist != nullptr) - registerpoint_clear(m_rplist->index()); + // clear the list + m_rplist.clear(); + breakpoint_update_flags(); } @@ -2162,10 +2164,10 @@ void device_debug::registerpoint_clear_all() bool device_debug::registerpoint_enable(int index, bool enable) { // scan the list to see if we own this conditionpoint - for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->next()) - if (rp->m_index == index) + for (registerpoint &rp : m_rplist) + if (rp.m_index == index) { - rp->m_enabled = enable; + rp.m_enabled = enable; breakpoint_update_flags(); return true; } @@ -2183,8 +2185,8 @@ bool device_debug::registerpoint_enable(int index, bool enable) void device_debug::registerpoint_enable_all(bool enable) { // apply the enable to all registerpoints we own - for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->next()) - registerpoint_enable(rp->index(), enable); + for (registerpoint &rp : m_rplist) + registerpoint_enable(rp.index(), enable); } @@ -2506,8 +2508,8 @@ void device_debug::breakpoint_update_flags() { // see if there are any enabled breakpoints m_flags &= ~DEBUG_FLAG_LIVE_BP; - for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->m_next) - if (bp->m_enabled) + for (breakpoint &bp : m_bplist) + if (bp.m_enabled) { m_flags |= DEBUG_FLAG_LIVE_BP; break; @@ -2516,9 +2518,9 @@ void device_debug::breakpoint_update_flags() if ( ! ( m_flags & DEBUG_FLAG_LIVE_BP ) ) { // see if there are any enabled registerpoints - for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->m_next) + for (registerpoint &rp : m_rplist) { - if (rp->m_enabled) + if (rp.m_enabled) { m_flags |= DEBUG_FLAG_LIVE_BP; } @@ -2541,43 +2543,43 @@ void device_debug::breakpoint_check(offs_t pc) debugger_cpu& debugcpu = m_device.machine().debugger().cpu(); // see if we match - for (breakpoint *bp = m_bplist; bp != nullptr; bp = bp->m_next) - if (bp->hit(pc)) + for (breakpoint &bp : m_bplist) + if (bp.hit(pc)) { // halt in the debugger by default debugcpu.set_execution_stopped(); // if we hit, evaluate the action - if (!bp->m_action.empty()) - m_device.machine().debugger().console().execute_command(bp->m_action, false); + if (!bp.m_action.empty()) + m_device.machine().debugger().console().execute_command(bp.m_action, false); // print a notification, unless the action made us go again if (debugcpu.is_stopped()) { - m_device.machine().debugger().console().printf("Stopped at breakpoint %X\n", bp->m_index); - m_triggered_breakpoint = bp; + m_device.machine().debugger().console().printf("Stopped at breakpoint %X\n", bp.m_index); + m_triggered_breakpoint = &bp; } break; } // see if we have any matching registerpoints - for (registerpoint *rp = m_rplist; rp != nullptr; rp = rp->m_next) + for (registerpoint &rp : m_rplist) { - if (rp->hit()) + if (rp.hit()) { // halt in the debugger by default debugcpu.set_execution_stopped(); // if we hit, evaluate the action - if (!rp->m_action.empty()) + if (!rp.m_action.empty()) { - m_device.machine().debugger().console().execute_command(rp->m_action, false); + m_device.machine().debugger().console().execute_command(rp.m_action, false); } // print a notification, unless the action made us go again if (debugcpu.is_stopped()) { - m_device.machine().debugger().console().printf("Stopped at registerpoint %X\n", rp->m_index); + m_device.machine().debugger().console().printf("Stopped at registerpoint %X\n", rp.m_index); } break; } @@ -2723,7 +2725,6 @@ device_debug::breakpoint::breakpoint(device_debug* debugInterface, const char *condition, const char *action) : m_debugInterface(debugInterface), - m_next(nullptr), m_index(index), m_enabled(true), m_address(address), @@ -3091,8 +3092,7 @@ void device_debug::watchpoint::triggered(read_or_write type, offs_t address, u64 //------------------------------------------------- device_debug::registerpoint::registerpoint(symbol_table &symbols, int index, const char *condition, const char *action) - : m_next(nullptr), - m_index(index), + : m_index(index), m_enabled(true), m_condition(&symbols, (condition != nullptr) ? condition : "1"), m_action((action != nullptr) ? action : "") |