summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
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
commit53df4f447db0408d00bdcbee3105e013bdd19c3a (patch)
tree0ccccacae81b902088f16cf704345fa53b3b252b
parente52c9cc290a710c11fef4a08c715e46d04db9f07 (diff)
Use std::forward_list for breakpoint and registerpoint lists (nw)
-rw-r--r--src/emu/debug/debugcmd.cpp24
-rw-r--r--src/emu/debug/debugcpu.cpp118
-rw-r--r--src/emu/debug/debugcpu.h13
-rw-r--r--src/emu/debug/dvbpoints.cpp8
-rw-r--r--src/emu/debug/dvbpoints.h2
-rw-r--r--src/emu/debug/dvdisasm.cpp4
-rw-r--r--src/emu/emu.h1
-rw-r--r--src/frontend/mame/luaengine.cpp14
-rw-r--r--src/osd/modules/debugger/debuggdbstub.cpp10
-rw-r--r--src/osd/modules/debugger/osx/debugconsole.mm11
-rw-r--r--src/osd/modules/debugger/osx/debugwindowhandler.h2
-rw-r--r--src/osd/modules/debugger/osx/debugwindowhandler.mm8
-rw-r--r--src/osd/modules/debugger/osx/disassemblyviewer.mm9
-rw-r--r--src/osd/modules/debugger/qt/dasmwindow.cpp25
-rw-r--r--src/osd/modules/debugger/qt/mainwindow.cpp28
-rw-r--r--src/osd/modules/debugger/win/disasmbasewininfo.cpp27
16 files changed, 122 insertions, 182 deletions
diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp
index 9ef8b5bcbb3..c61afae5126 100644
--- a/src/emu/debug/debugcmd.cpp
+++ b/src/emu/debug/debugcmd.cpp
@@ -1400,18 +1400,18 @@ void debugger_commands::execute_bplist(int ref, const std::vector<std::string> &
/* loop over all CPUs */
for (device_t &device : device_iterator(m_machine.root_device()))
- if (device.debug()->breakpoint_first() != nullptr)
+ if (!device.debug()->breakpoint_list().empty())
{
m_console.printf("Device '%s' breakpoints:\n", device.tag());
/* loop over the breakpoints */
- for (device_debug::breakpoint *bp = device.debug()->breakpoint_first(); bp != nullptr; bp = bp->next())
+ for (const device_debug::breakpoint &bp : device.debug()->breakpoint_list())
{
- buffer = string_format("%c%4X @ %0*X", bp->enabled() ? ' ' : 'D', bp->index(), device.debug()->logaddrchars(), bp->address());
- if (std::string(bp->condition()).compare("1") != 0)
- buffer.append(string_format(" if %s", bp->condition()));
- if (std::string(bp->action()).compare("") != 0)
- buffer.append(string_format(" do %s", bp->action()));
+ buffer = string_format("%c%4X @ %0*X", bp.enabled() ? ' ' : 'D', bp.index(), device.debug()->logaddrchars(), bp.address());
+ if (std::string(bp.condition()).compare("1") != 0)
+ buffer.append(string_format(" if %s", bp.condition()));
+ if (std::string(bp.action()).compare("") != 0)
+ buffer.append(string_format(" do %s", bp.action()));
m_console.printf("%s\n", buffer.c_str());
printed++;
}
@@ -1700,16 +1700,16 @@ void debugger_commands::execute_rplist(int ref, const std::vector<std::string> &
/* loop over all CPUs */
for (device_t &device : device_iterator(m_machine.root_device()))
- if (device.debug()->registerpoint_first() != nullptr)
+ if (!device.debug()->registerpoint_list().empty())
{
m_console.printf("Device '%s' registerpoints:\n", device.tag());
/* loop over the breakpoints */
- for (device_debug::registerpoint *rp = device.debug()->registerpoint_first(); rp != nullptr; rp = rp->next())
+ for (const device_debug::registerpoint &rp : device.debug()->registerpoint_list())
{
- buffer = string_format("%c%4X if %s", rp->enabled() ? ' ' : 'D', rp->index(), rp->condition());
- if (rp->action() != nullptr)
- buffer.append(string_format(" do %s", rp->action()));
+ buffer = string_format("%c%4X if %s", rp.enabled() ? ' ' : 'D', rp.index(), rp.condition());
+ if (rp.action() != nullptr)
+ buffer.append(string_format(" do %s", rp.action()));
m_console.printf("%s\n", buffer.c_str());
printed++;
}
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 : "")
diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h
index 0feeee51386..26653eb2baa 100644
--- a/src/emu/debug/debugcpu.h
+++ b/src/emu/debug/debugcpu.h
@@ -57,7 +57,6 @@ public:
// getters
const device_debug *debugInterface() const { return m_debugInterface; }
- breakpoint *next() const { return m_next; }
int index() const { return m_index; }
bool enabled() const { return m_enabled; }
offs_t address() const { return m_address; }
@@ -71,7 +70,6 @@ public:
// internals
bool hit(offs_t pc);
const device_debug * m_debugInterface; // the interface we were created from
- breakpoint * m_next; // next in the list
int m_index; // user reported index
bool m_enabled; // enabled?
offs_t m_address; // execution address
@@ -147,7 +145,6 @@ public:
registerpoint(symbol_table &symbols, int index, const char *condition, const char *action = nullptr);
// getters
- registerpoint *next() const { return m_next; }
int index() const { return m_index; }
bool enabled() const { return m_enabled; }
const char *condition() const { return m_condition.original_string(); }
@@ -157,7 +154,6 @@ public:
// internals
bool hit();
- registerpoint * m_next; // next in the list
int m_index; // user reported index
bool m_enabled; // enabled?
parsed_expression m_condition; // condition
@@ -217,7 +213,8 @@ public:
}
// breakpoints
- breakpoint *breakpoint_first() const { return m_bplist; }
+ const std::forward_list<breakpoint> &breakpoint_list() const { return m_bplist; }
+ const breakpoint *breakpoint_find(offs_t address) const;
int breakpoint_set(offs_t address, const char *condition = nullptr, const char *action = nullptr);
bool breakpoint_clear(int index);
void breakpoint_clear_all();
@@ -237,7 +234,7 @@ public:
watchpoint *triggered_watchpoint(void) { watchpoint *ret = m_triggered_watchpoint; m_triggered_watchpoint = nullptr; return ret; }
// registerpoints
- registerpoint *registerpoint_first() const { return m_rplist; }
+ const std::forward_list<registerpoint> &registerpoint_list() const { return m_rplist; }
int registerpoint_set(const char *condition, const char *action = nullptr);
bool registerpoint_clear(int index);
void registerpoint_clear_all();
@@ -340,9 +337,9 @@ private:
u32 m_pc_history_index; // current history index
// breakpoints and watchpoints
- breakpoint * m_bplist; // list of breakpoints
+ std::forward_list<breakpoint> m_bplist; // list of breakpoints
std::vector<std::vector<std::unique_ptr<watchpoint>>> m_wplist; // watchpoint lists for each address space
- registerpoint * m_rplist; // list of registerpoints
+ std::forward_list<registerpoint> m_rplist; // list of registerpoints
breakpoint * m_triggered_breakpoint; // latest breakpoint that was triggered
watchpoint * m_triggered_watchpoint; // latest watchpoint that was triggered
diff --git a/src/emu/debug/dvbpoints.cpp b/src/emu/debug/dvbpoints.cpp
index 3b76c7d26fe..d86ce1150cc 100644
--- a/src/emu/debug/dvbpoints.cpp
+++ b/src/emu/debug/dvbpoints.cpp
@@ -167,7 +167,7 @@ void debug_view_breakpoints::view_click(const int button, const debug_view_xy& p
return;
// Enable / disable
- m_buffer[bpIndex]->setEnabled(!m_buffer[bpIndex]->enabled());
+ const_cast<device_debug::breakpoint &>(*m_buffer[bpIndex]).setEnabled(!m_buffer[bpIndex]->enabled());
machine().debug_view().update_all(DVT_DISASSEMBLY);
}
@@ -193,8 +193,8 @@ void debug_view_breakpoints::gather_breakpoints()
{
// Collect
device_debug &debugInterface = *source.device()->debug();
- for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != nullptr; bp = bp->next())
- m_buffer.push_back(bp);
+ for (const device_debug::breakpoint &bp : debugInterface.breakpoint_list())
+ m_buffer.push_back(&bp);
}
// And now for the sort
@@ -268,7 +268,7 @@ void debug_view_breakpoints::view_update()
int bpi = row + m_topleft.y - 1;
if ((bpi < m_buffer.size()) && (bpi >= 0))
{
- device_debug::breakpoint *const bp = m_buffer[bpi];
+ const device_debug::breakpoint *const bp = m_buffer[bpi];
linebuf.clear();
linebuf.rdbuf()->clear();
diff --git a/src/emu/debug/dvbpoints.h b/src/emu/debug/dvbpoints.h
index 2d3ae38fa58..2cba6cd3081 100644
--- a/src/emu/debug/dvbpoints.h
+++ b/src/emu/debug/dvbpoints.h
@@ -49,7 +49,7 @@ private:
// internal state
bool (*m_sortType)(const device_debug::breakpoint *, const device_debug::breakpoint *);
- std::vector<device_debug::breakpoint *> m_buffer;
+ std::vector<const device_debug::breakpoint *> m_buffer;
};
#endif // MAME_EMU_DEBUG_DVBPOINTS_H
diff --git a/src/emu/debug/dvdisasm.cpp b/src/emu/debug/dvdisasm.cpp
index 35550e75c01..667542483a4 100644
--- a/src/emu/debug/dvdisasm.cpp
+++ b/src/emu/debug/dvdisasm.cpp
@@ -353,8 +353,8 @@ void debug_view_disasm::complete_information(const debug_view_disasm_source &sou
dasm.m_is_pc = adr == pc;
dasm.m_is_bp = false;
- for(device_debug::breakpoint *bp = source.device()->debug()->breakpoint_first(); bp != nullptr; bp = bp->next())
- if(adr ==(bp->address() & source.m_space.logaddrmask())) {
+ for(const device_debug::breakpoint &bp : source.device()->debug()->breakpoint_list())
+ if(adr == (bp.address() & source.m_space.logaddrmask())) {
dasm.m_is_bp = true;
break;
}
diff --git a/src/emu/emu.h b/src/emu/emu.h
index 9c9b2c78e4e..35a5d6a3f60 100644
--- a/src/emu/emu.h
+++ b/src/emu/emu.h
@@ -19,6 +19,7 @@
#define __EMU_H__
#include <list>
+#include <forward_list>
#include <vector>
#include <memory>
#include <map>
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index 5412f182304..7b45fd92c59 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -1479,16 +1479,14 @@ void lua_engine::initialize()
"bpclr", &device_debug::breakpoint_clear,
"bplist", [this](device_debug &dev) {
sol::table table = sol().create_table();
- device_debug::breakpoint *list = dev.breakpoint_first();
- while(list)
+ for(const device_debug::breakpoint &bpt : dev.breakpoint_list())
{
sol::table bp = sol().create_table();
- bp["enabled"] = list->enabled();
- bp["address"] = list->address();
- bp["condition"] = list->condition();
- bp["action"] = list->action();
- table[list->index()] = bp;
- list = list->next();
+ bp["enabled"] = bpt.enabled();
+ bp["address"] = bpt.address();
+ bp["condition"] = bpt.condition();
+ bp["action"] = bpt.action();
+ table[bpt.index()] = bp;
}
return table;
},
diff --git a/src/osd/modules/debugger/debuggdbstub.cpp b/src/osd/modules/debugger/debuggdbstub.cpp
index 4028dd3b994..4c7e4e3707e 100644
--- a/src/osd/modules/debugger/debuggdbstub.cpp
+++ b/src/osd/modules/debugger/debuggdbstub.cpp
@@ -977,13 +977,9 @@ debug_gdbstub::cmd_reply debug_gdbstub::handle_s(const char *buf)
//-------------------------------------------------------------------------
static bool remove_breakpoint(device_debug *debug, uint64_t address, int /*kind*/)
{
- device_debug::breakpoint *bp = debug->breakpoint_first();
- while ( bp != nullptr )
- {
- if ( bp->address() == address )
- return debug->breakpoint_clear(bp->index());
- bp = bp->next();
- }
+ const device_debug::breakpoint *bp = debug->breakpoint_find(address);
+ if (bp != nullptr)
+ return debug->breakpoint_clear(bp->index());
return false;
}
diff --git a/src/osd/modules/debugger/osx/debugconsole.mm b/src/osd/modules/debugger/osx/debugconsole.mm
index b6c02c67224..1bd285e8c3b 100644
--- a/src/osd/modules/debugger/osx/debugconsole.mm
+++ b/src/osd/modules/debugger/osx/debugconsole.mm
@@ -237,8 +237,7 @@
if ([dasmView cursorVisible] && (machine->debugger().cpu().get_visible_cpu() == &device))
{
offs_t const address = [dasmView selectedAddress];
- device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address
- forDevice:device];
+ const device_debug::breakpoint *bp = [dasmView source]->device()->debug()->breakpoint_find(address);
// if it doesn't exist, add a new one
NSString *command;
@@ -255,8 +254,7 @@
device_t &device = *[dasmView source]->device();
if ([dasmView cursorVisible] && (machine->debugger().cpu().get_visible_cpu() == &device))
{
- device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:[dasmView selectedAddress]
- forDevice:device];
+ const device_debug::breakpoint *bp = [dasmView source]->device()->debug()->breakpoint_find([dasmView selectedAddress]);
if (bp != nullptr)
{
NSString *command;
@@ -566,11 +564,10 @@
BOOL const haveCursor = [dasmView cursorVisible];
BOOL const isCurrent = (machine->debugger().cpu().get_visible_cpu() == [dasmView source]->device());
- device_debug::breakpoint *breakpoint = nullptr;
+ const device_debug::breakpoint *breakpoint = nullptr;
if (haveCursor)
{
- breakpoint = [[self class] findBreakpointAtAddress:[dasmView selectedAddress]
- forDevice:*[dasmView source]->device()];
+ breakpoint = [dasmView source]->device()->debug()->breakpoint_find([dasmView selectedAddress]);
}
if (action == @selector(debugToggleBreakpoint:))
diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.h b/src/osd/modules/debugger/osx/debugwindowhandler.h
index 4feeff267c9..c48bbb031b2 100644
--- a/src/osd/modules/debugger/osx/debugwindowhandler.h
+++ b/src/osd/modules/debugger/osx/debugwindowhandler.h
@@ -45,8 +45,6 @@ enum
+ (void)addCommonActionItems:(NSMenu *)menu;
+ (NSPopUpButton *)newActionButtonWithFrame:(NSRect)frame;
-+ (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device;
-
- (id)initWithMachine:(running_machine &)m title:(NSString *)t;
- (void)activate;
diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.mm b/src/osd/modules/debugger/osx/debugwindowhandler.mm
index 1f483139452..27d487c86ff 100644
--- a/src/osd/modules/debugger/osx/debugwindowhandler.mm
+++ b/src/osd/modules/debugger/osx/debugwindowhandler.mm
@@ -134,14 +134,6 @@ NSString *const MAMESaveDebuggerConfigurationNotification = @"MAMESaveDebuggerCo
}
-+ (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device {
- device_debug *const cpuinfo = device.debug();
- device_debug::breakpoint *bp = cpuinfo->breakpoint_first();
- while ((bp != nullptr) && (address != bp->address())) bp = bp->next();
- return bp;
-}
-
-
- (id)initWithMachine:(running_machine &)m title:(NSString *)t {
if (!(self = [super init]))
return nil;
diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.mm b/src/osd/modules/debugger/osx/disassemblyviewer.mm
index 5c9c1c8aa23..eb039f4ca17 100644
--- a/src/osd/modules/debugger/osx/disassemblyviewer.mm
+++ b/src/osd/modules/debugger/osx/disassemblyviewer.mm
@@ -176,7 +176,7 @@
{
device_t &device = *[dasmView source]->device();
offs_t const address = [dasmView selectedAddress];
- device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address forDevice:device];
+ const device_debug::breakpoint *bp = device.debug()->breakpoint_find(address);
// if it doesn't exist, add a new one
if (bp == nullptr)
@@ -203,7 +203,7 @@
{
device_t &device = *[dasmView source]->device();
offs_t const address = [dasmView selectedAddress];
- device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address forDevice:device];
+ const device_debug::breakpoint *bp = device.debug()->breakpoint_find(address);
if (bp != nullptr)
{
device.debug()->breakpoint_enable(bp->index(), !bp->enabled());
@@ -252,11 +252,10 @@
BOOL const inContextMenu = ([item menu] == [dasmView menu]);
BOOL const haveCursor = [dasmView cursorVisible];
- device_debug::breakpoint *breakpoint = nullptr;
+ const device_debug::breakpoint *breakpoint = nullptr;
if (haveCursor)
{
- breakpoint = [[self class] findBreakpointAtAddress:[dasmView selectedAddress]
- forDevice:*[dasmView source]->device()];
+ breakpoint = [dasmView source]->device()->debug()->breakpoint_find([dasmView selectedAddress]);
}
if (action == @selector(debugToggleBreakpoint:))
diff --git a/src/osd/modules/debugger/qt/dasmwindow.cpp b/src/osd/modules/debugger/qt/dasmwindow.cpp
index 396f97c78bf..5c575b400b1 100644
--- a/src/osd/modules/debugger/qt/dasmwindow.cpp
+++ b/src/osd/modules/debugger/qt/dasmwindow.cpp
@@ -143,26 +143,17 @@ void DasmWindow::toggleBreakpointAtCursor(bool changedTo)
device_debug *const cpuinfo = device->debug();
// Find an existing breakpoint at this address
- int32_t bpindex = -1;
- for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
- bp != nullptr;
- bp = bp->next())
- {
- if (address == bp->address())
- {
- bpindex = bp->index();
- break;
- }
- }
+ const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address);
// If none exists, add a new one
- if (bpindex == -1)
+ if (bp == nullptr)
{
- bpindex = cpuinfo->breakpoint_set(address, nullptr, nullptr);
+ int32_t bpindex = cpuinfo->breakpoint_set(address, nullptr, nullptr);
m_machine->debugger().console().printf("Breakpoint %X set\n", bpindex);
}
else
{
+ int32_t bpindex = bp->index();
cpuinfo->breakpoint_clear(bpindex);
m_machine->debugger().console().printf("Breakpoint %X cleared\n", bpindex);
}
@@ -183,9 +174,7 @@ void DasmWindow::enableBreakpointAtCursor(bool changedTo)
device_debug *const cpuinfo = device->debug();
// Find an existing breakpoint at this address
- device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
- while ((bp != nullptr) && (bp->address() != address))
- bp = bp->next();
+ const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address);
if (bp != nullptr)
{
@@ -241,9 +230,7 @@ void DasmWindow::dasmViewUpdated()
device_debug *const cpuinfo = device->debug();
// Find an existing breakpoint at this address
- device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
- while ((bp != nullptr) && (bp->address() != address))
- bp = bp->next();
+ const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address);
if (bp != nullptr)
{
diff --git a/src/osd/modules/debugger/qt/mainwindow.cpp b/src/osd/modules/debugger/qt/mainwindow.cpp
index fffe3577e9e..84aad82e363 100644
--- a/src/osd/modules/debugger/qt/mainwindow.cpp
+++ b/src/osd/modules/debugger/qt/mainwindow.cpp
@@ -220,27 +220,17 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
device_debug *const cpuinfo = dasmView->source()->device()->debug();
// Find an existing breakpoint at this address
- int32_t bpindex = -1;
- for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
- bp != nullptr;
- bp = bp->next())
- {
- if (address == bp->address())
- {
- bpindex = bp->index();
- break;
- }
- }
+ const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address);
// If none exists, add a new one
std::string command;
- if (bpindex == -1)
+ if (bp == nullptr)
{
command = string_format("bpset 0x%X", address);
}
else
{
- command = string_format("bpclear 0x%X", bpindex);
+ command = string_format("bpclear 0x%X", bp.index());
}
m_machine->debugger().console().execute_command(command.c_str(), true);
}
@@ -258,14 +248,12 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo)
device_debug *const cpuinfo = dasmView->source()->device()->debug();
// Find an existing breakpoint at this address
- device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
- while ((bp != nullptr) && (bp->address() != address))
- bp = bp->next();
+ const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address);
if (bp != nullptr)
{
- int32_t const bpindex = bp->index();
- std::string command = string_format(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex);
+ int32_t const bpindex = bp.index();
+ std::string command = string_format(bp.enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex);
m_machine->debugger().console().execute_command(command.c_str(), true);
}
}
@@ -418,9 +406,7 @@ void MainWindow::dasmViewUpdated()
device_debug *const cpuinfo = device->debug();
// Find an existing breakpoint at this address
- device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
- while ((bp != nullptr) && (bp->address() != address))
- bp = bp->next();
+ const device_debug::breakpoint *bp = cpuinfo->breakpoint_find(address);
if (bp != nullptr)
{
diff --git a/src/osd/modules/debugger/win/disasmbasewininfo.cpp b/src/osd/modules/debugger/win/disasmbasewininfo.cpp
index ef4c5122ba6..c466e059f23 100644
--- a/src/osd/modules/debugger/win/disasmbasewininfo.cpp
+++ b/src/osd/modules/debugger/win/disasmbasewininfo.cpp
@@ -115,9 +115,7 @@ void disasmbasewin_info::update_menu()
device_debug *const debug = dasmview->source_device()->debug();
// first find an existing breakpoint at this address
- device_debug::breakpoint *bp = debug->breakpoint_first();
- while ((bp != nullptr) && (bp->address() != address))
- bp = bp->next();
+ const device_debug::breakpoint *bp = debug->breakpoint_find(address);
if (bp == nullptr)
{
@@ -166,28 +164,21 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam)
{
offs_t const address = dasmview->selected_address();
device_debug *const debug = dasmview->source_device()->debug();
- int32_t bpindex = -1;
// first find an existing breakpoint at this address
- for (device_debug::breakpoint *bp = debug->breakpoint_first(); bp != nullptr; bp = bp->next())
- {
- if (address == bp->address())
- {
- bpindex = bp->index();
- break;
- }
- }
+ const device_debug::breakpoint *bp = debug->breakpoint_find(address);
// if it doesn't exist, add a new one
if (!is_main_console())
{
- if (bpindex == -1)
+ if (bp == nullptr)
{
- bpindex = debug->breakpoint_set(address, nullptr, nullptr);
+ int32_t bpindex = debug->breakpoint_set(address, nullptr, nullptr);
machine().debugger().console().printf("Breakpoint %X set\n", bpindex);
}
else
{
+ int32_t bpindex = bp->index();
debug->breakpoint_clear(bpindex);
machine().debugger().console().printf("Breakpoint %X cleared\n", bpindex);
}
@@ -197,10 +188,10 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam)
else if (dasmview->source_is_visible_cpu())
{
std::string command;
- if (bpindex == -1)
+ if (bp == nullptr)
command = string_format("bpset 0x%X", address);
else
- command = string_format("bpclear 0x%X", bpindex);
+ command = string_format("bpclear 0x%X", bp->index());
machine().debugger().console().execute_command(command.c_str(), true);
}
}
@@ -213,9 +204,7 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam)
device_debug *const debug = dasmview->source_device()->debug();
// first find an existing breakpoint at this address
- device_debug::breakpoint *bp = debug->breakpoint_first();
- while ((bp != nullptr) && (bp->address() != address))
- bp = bp->next();
+ const device_debug::breakpoint *bp = debug->breakpoint_find(address);
// if it doesn't exist, add a new one
if (bp != nullptr)