summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/devices/bus/isa/s3virge.cpp2
-rw-r--r--src/devices/cpu/alph8201/alph8201.cpp4
-rw-r--r--src/devices/cpu/arm/arm.cpp4
-rw-r--r--src/devices/cpu/avr8/avr8.cpp4
-rw-r--r--src/devices/cpu/dsp32/dsp32ops.hxx4
-rw-r--r--src/devices/cpu/mips/mips3.cpp2
-rw-r--r--src/devices/cpu/psx/psx.cpp2
-rw-r--r--src/devices/cpu/sh4/sh4.cpp4
-rw-r--r--src/devices/cpu/tms32031/32031ops.hxx2
-rw-r--r--src/devices/cpu/tms32031/tms32031.cpp2
-rw-r--r--src/devices/cpu/tms34010/34010ops.hxx2
-rw-r--r--src/devices/cpu/z8000/8000dasm.cpp39
-rw-r--r--src/devices/cpu/z8000/z8000.cpp48
-rw-r--r--src/devices/cpu/z8000/z8000.h3
-rw-r--r--src/devices/machine/aakart.cpp2
-rw-r--r--src/devices/machine/atahle.cpp2
-rw-r--r--src/devices/sound/l7a1045_l6028_dsp_a.cpp2
-rw-r--r--src/devices/video/pc_vga.cpp2
-rw-r--r--src/emu/debug/debugcmd.cpp1466
-rw-r--r--src/emu/debug/debugcmd.h160
-rw-r--r--src/emu/debug/debugcon.cpp238
-rw-r--r--src/emu/debug/debugcon.h100
-rw-r--r--src/emu/debug/debugcpu.cpp1219
-rw-r--r--src/emu/debug/debugcpu.h195
-rw-r--r--src/emu/debug/debugvw.cpp13
-rw-r--r--src/emu/debug/dvdisasm.cpp18
-rw-r--r--src/emu/debug/dvmemory.cpp17
-rw-r--r--src/emu/debug/dvtext.cpp7
-rw-r--r--src/emu/debug/express.cpp16
-rw-r--r--src/emu/debug/express.h14
-rw-r--r--src/emu/debugger.cpp110
-rw-r--r--src/emu/debugger.h127
-rw-r--r--src/emu/machine.cpp17
-rw-r--r--src/emu/machine.h12
-rw-r--r--src/emu/video.cpp2
-rw-r--r--src/frontend/mame/cheat.cpp4
-rw-r--r--src/frontend/mame/cheat.h8
-rw-r--r--src/frontend/mame/ui/slider.cpp20
-rw-r--r--src/mame/drivers/atvtrack.cpp2
-rw-r--r--src/mame/drivers/chihiro.cpp90
-rw-r--r--src/mame/drivers/icatel.cpp4
-rw-r--r--src/mame/drivers/naomi.cpp2
-rw-r--r--src/mame/drivers/nokia_3310.cpp2
-rw-r--r--src/mame/drivers/palm.cpp1
-rw-r--r--src/mame/drivers/pasopia7.cpp12
-rw-r--r--src/mame/drivers/pc8801.cpp2
-rw-r--r--src/mame/drivers/raiden2.cpp2
-rw-r--r--src/mame/drivers/segas24.cpp4
-rw-r--r--src/mame/drivers/xbox.cpp1
-rw-r--r--src/mame/includes/dgn_beta.h4
-rw-r--r--src/mame/includes/mbc55x.h4
-rw-r--r--src/mame/includes/rmnimbus.h4
-rw-r--r--src/mame/includes/xbox.h16
-rw-r--r--src/mame/machine/3do.cpp2
-rw-r--r--src/mame/machine/dc.cpp4
-rw-r--r--src/mame/machine/dccons.cpp7
-rw-r--r--src/mame/machine/dgn_beta.cpp32
-rw-r--r--src/mame/machine/fddebug.cpp148
-rw-r--r--src/mame/machine/fddebug.h1
-rw-r--r--src/mame/machine/mbc55x.cpp23
-rw-r--r--src/mame/machine/midwayic.cpp2
-rw-r--r--src/mame/machine/rmnimbus.cpp20
-rw-r--r--src/mame/machine/tx1.cpp4
-rw-r--r--src/mame/machine/xbox.cpp380
-rw-r--r--src/mame/video/mbc55x.cpp17
-rw-r--r--src/mame/video/namcos2.cpp8
-rw-r--r--src/mame/video/powervr2.cpp4
-rw-r--r--src/mame/video/rmnimbus.cpp22
-rw-r--r--src/osd/modules/debugger/debugimgui.cpp44
-rw-r--r--src/osd/modules/debugger/debugwin.cpp5
-rw-r--r--src/osd/modules/debugger/none.cpp3
-rw-r--r--src/osd/modules/debugger/osx/debugconsole.mm21
-rw-r--r--src/osd/modules/debugger/osx/debugview.mm3
-rw-r--r--src/osd/modules/debugger/osx/debugwindowhandler.mm21
-rw-r--r--src/osd/modules/debugger/osx/disassemblyviewer.mm13
-rw-r--r--src/osd/modules/debugger/osx/memoryviewer.mm3
-rw-r--r--src/osd/modules/debugger/osx/registersview.mm3
-rw-r--r--src/osd/modules/debugger/qt/dasmwindow.cpp6
-rw-r--r--src/osd/modules/debugger/qt/mainwindow.cpp28
-rw-r--r--src/osd/modules/debugger/qt/memorywindow.cpp4
-rw-r--r--src/osd/modules/debugger/qt/windowqt.cpp20
-rw-r--r--src/osd/modules/debugger/win/consolewininfo.cpp7
-rw-r--r--src/osd/modules/debugger/win/debugviewinfo.cpp4
-rw-r--r--src/osd/modules/debugger/win/debugwininfo.cpp19
-rw-r--r--src/osd/modules/debugger/win/disasmbasewininfo.cpp12
-rw-r--r--src/osd/sdl/osdsdl.h1
-rw-r--r--src/osd/sdl/sdlmain.cpp32
-rw-r--r--src/osd/windows/winmain.cpp10
-rw-r--r--src/osd/windows/winmain.h1
89 files changed, 2517 insertions, 2460 deletions
diff --git a/src/devices/bus/isa/s3virge.cpp b/src/devices/bus/isa/s3virge.cpp
index 965e47e50f0..979860a233e 100644
--- a/src/devices/bus/isa/s3virge.cpp
+++ b/src/devices/bus/isa/s3virge.cpp
@@ -244,7 +244,7 @@ UINT8 s3virge_vga_device::s3_crtc_reg_read(UINT8 index)
break;
default:
res = vga.crtc.data[index];
- //debugger_break(machine);
+ //machine.debugger().debug_break();
//printf("%02x\n",index);
break;
}
diff --git a/src/devices/cpu/alph8201/alph8201.cpp b/src/devices/cpu/alph8201/alph8201.cpp
index dec4a650ab8..7013dedf809 100644
--- a/src/devices/cpu/alph8201/alph8201.cpp
+++ b/src/devices/cpu/alph8201/alph8201.cpp
@@ -274,7 +274,7 @@ void alpha8201_cpu_device::M_UNDEFINED()
osd_printf_debug("alpha8201: PC = %03x, Unimplemented opcode = %02x\n", m_pc.w.l-1, M_RDMEM(m_pc.w.l-1));
#endif
#if BREAK_ON_UNKNOWN_OPCODE
- debugger_break(machine());
+ machine().debugger().debug_break();
#endif
}
@@ -287,7 +287,7 @@ void alpha8201_cpu_device::M_UNDEFINED2()
osd_printf_debug("alpha8201: PC = %03x, Unimplemented opcode = %02x,%02x\n", m_pc.w.l-2, op,imm);
#endif
#if BREAK_ON_UNKNOWN_OPCODE
- debugger_break(machine());
+ machine().debugger().debug_break();
#endif
}
diff --git a/src/devices/cpu/arm/arm.cpp b/src/devices/cpu/arm/arm.cpp
index f9505fda6d8..01ce6ba96b9 100644
--- a/src/devices/cpu/arm/arm.cpp
+++ b/src/devices/cpu/arm/arm.cpp
@@ -1390,7 +1390,7 @@ void arm_cpu_device::HandleCoProVL86C020( UINT32 insn )
0x00<<0 <- Revision number, 0
*/
SetRegister(rn, 0x41560300);
- //debugger_break(machine());
+ //machine().debugger().debug_break();
}
else
SetRegister(rn, m_coproRegister[crn]);
@@ -1407,7 +1407,7 @@ void arm_cpu_device::HandleCoProVL86C020( UINT32 insn )
else
{
printf("%08x: Unimplemented VL86C020 copro instruction %08x %d %d\n", R15 & 0x3ffffff, insn,rn,crn);
- debugger_break(machine());
+ machine().debugger().debug_break();
}
}
diff --git a/src/devices/cpu/avr8/avr8.cpp b/src/devices/cpu/avr8/avr8.cpp
index 420c5ba86fa..8826ed6b91e 100644
--- a/src/devices/cpu/avr8/avr8.cpp
+++ b/src/devices/cpu/avr8/avr8.cpp
@@ -706,7 +706,7 @@ void avr8_device::set_lock_bits(const UINT8 byte)
void avr8_device::unimplemented_opcode(UINT32 op)
{
-// debugger_break(machine());
+// machine().debugger().debug_break();
fatalerror("AVR8: unknown opcode (%08x) at %08x\n", op, m_shifted_pc);
}
@@ -2915,7 +2915,7 @@ READ8_MEMBER( avr8_device::regs_r )
default:
printf("[%08X] AVR8: Unknown Register Read: 0x%03X\n", m_shifted_pc, offset);
-// debugger_break(machine());
+// machine().debugger().debug_break();
return 0;
}
}
diff --git a/src/devices/cpu/dsp32/dsp32ops.hxx b/src/devices/cpu/dsp32/dsp32ops.hxx
index 09844f6ee4f..768d1704102 100644
--- a/src/devices/cpu/dsp32/dsp32ops.hxx
+++ b/src/devices/cpu/dsp32/dsp32ops.hxx
@@ -358,7 +358,7 @@ inline void dsp32c_device::dau_set_val_flags(int aidx, double res)
else if (absres > 3.40282e38)
{
m_VUflags = VFLAGBIT;
-// debugger_break(Machine);
+// machine().debugger().debug_break();
// fprintf(stderr, "Result = %g\n", absres);
res = (res < 0) ? -3.40282e38 : 3.40282e38;
}
@@ -403,7 +403,7 @@ inline UINT32 dsp32c_device::double_to_dsp(double val)
return 0x00000000;
else if (exponent > 255)
{
-// debugger_break(Machine);
+// machine().debugger().debug_break();
// fprintf(stderr, "Exponent = %d\n", exponent);
return ((INT32)id.i[BYTE_XOR_BE(0)] >= 0) ? 0x7fffffff : 0x800000ff;
}
diff --git a/src/devices/cpu/mips/mips3.cpp b/src/devices/cpu/mips/mips3.cpp
index 7ae1fd1f337..f2b3252620e 100644
--- a/src/devices/cpu/mips/mips3.cpp
+++ b/src/devices/cpu/mips/mips3.cpp
@@ -224,7 +224,7 @@ void mips3_device::generate_exception(int exception, int backup)
if (exception != 0)
{
fprintf(stderr, "Exception: PC=%08X, PPC=%08X\n", m_core->pc, m_ppc);
- debugger_break(machine());
+ machine().debugger().debug_break();
}
*/
diff --git a/src/devices/cpu/psx/psx.cpp b/src/devices/cpu/psx/psx.cpp
index 2c4db7ecbc6..6c31ac94a84 100644
--- a/src/devices/cpu/psx/psx.cpp
+++ b/src/devices/cpu/psx/psx.cpp
@@ -297,7 +297,7 @@ WRITE32_MEMBER( psxcpu_device::biu_w )
void psxcpu_device::stop()
{
- debugger_break( machine() );
+ machine().debugger().debug_break();
debugger_instruction_hook( this, m_pc );
}
diff --git a/src/devices/cpu/sh4/sh4.cpp b/src/devices/cpu/sh4/sh4.cpp
index 047e7405537..2b906e3600a 100644
--- a/src/devices/cpu/sh4/sh4.cpp
+++ b/src/devices/cpu/sh4/sh4.cpp
@@ -3028,7 +3028,7 @@ inline void sh34_base_device::op1111_0xf13(const UINT16 opcode)
FRCHG();
break;
default:
- debugger_break(machine());
+ machine().debugger().debug_break();
break;
}
} else {
@@ -3041,7 +3041,7 @@ inline void sh34_base_device::op1111_0xf13(const UINT16 opcode)
void sh34_base_device::dbreak(const UINT16 opcode)
{
- debugger_break(machine());
+ machine().debugger().debug_break();
}
diff --git a/src/devices/cpu/tms32031/32031ops.hxx b/src/devices/cpu/tms32031/32031ops.hxx
index eda4955ee34..49af48fbe04 100644
--- a/src/devices/cpu/tms32031/32031ops.hxx
+++ b/src/devices/cpu/tms32031/32031ops.hxx
@@ -74,7 +74,7 @@ void tms3203x_device::illegal(UINT32 op)
if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
{
logerror("Illegal op @ %06X: %08X (tbl=%03X)\n", m_pc - 1, op, op >> 21);
- debugger_break(machine());
+ machine().debugger().debug_break();
}
}
diff --git a/src/devices/cpu/tms32031/tms32031.cpp b/src/devices/cpu/tms32031/tms32031.cpp
index ce6651d4fba..a9ca572d963 100644
--- a/src/devices/cpu/tms32031/tms32031.cpp
+++ b/src/devices/cpu/tms32031/tms32031.cpp
@@ -814,7 +814,7 @@ void tms3203x_device::execute_run()
{
// watch for out-of-range stack pointers
if (IREG(TMR_SP) & 0xff000000)
- debugger_break(machine());
+ machine().debugger().debug_break();
if ((IREG(TMR_ST) & RMFLAG) && m_pc == IREG(TMR_RE) + 1)
{
if ((INT32)--IREG(TMR_RC) >= 0)
diff --git a/src/devices/cpu/tms34010/34010ops.hxx b/src/devices/cpu/tms34010/34010ops.hxx
index 6674d7a1faa..29f31a0066d 100644
--- a/src/devices/cpu/tms34010/34010ops.hxx
+++ b/src/devices/cpu/tms34010/34010ops.hxx
@@ -99,7 +99,7 @@ void tms340x0_device::unimpl(UINT16 op)
if (m_pc == 0 || s_opcode_table[m_direct->read_word(TOBYTE(m_pc)) >> 4] == &tms34010_device::unimpl)
{
set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
- debugger_break(machine());
+ machine().debugger().debug_break();
}
}
diff --git a/src/devices/cpu/z8000/8000dasm.cpp b/src/devices/cpu/z8000/8000dasm.cpp
index c8eaa7ad9b9..5118af4b433 100644
--- a/src/devices/cpu/z8000/8000dasm.cpp
+++ b/src/devices/cpu/z8000/8000dasm.cpp
@@ -48,45 +48,6 @@ static const char *const ints[4] = {
int z8k_segm; /* Current disassembler mode: 0 - non-segmented, 1 - segmented */
int z8k_segm_mode = Z8K_SEGM_MODE_AUTO; /* User disassembler mode setting: segmented, non-segmented, auto */
-void z8k_disass_mode(running_machine &machine, int ref, int params, const char *param[])
-{
- size_t len;
- if (params == 1)
- {
- len = strlen(param[0]);
- if (!core_strnicmp(param[0], "segmented", len) || !core_stricmp(param[0], "z8001")) {
- z8k_segm = true;
- z8k_segm_mode = Z8K_SEGM_MODE_SEG;
- debug_console_printf(machine, "Disassembler mode set to Z8001/segmented\n");
- }
- else if (!core_strnicmp(param[0], "non-segmented", len) || !core_stricmp(param[0], "z8002")) {
- z8k_segm = false;
- z8k_segm_mode = Z8K_SEGM_MODE_NONSEG;
- debug_console_printf(machine, "Disassembler mode set to Z8002/non-segmented\n");
- }
- else if (!core_strnicmp(param[0], "automatic", len)) {
- z8k_segm_mode = Z8K_SEGM_MODE_AUTO;
- debug_console_printf(machine, "Disassembler mode set to automatic\n");
- }
- else
- goto usage;
- }
- else if (params > 1) {
- usage:
- debug_console_printf(machine, "Usage: z8k_disass_mode <mode>\n");
- debug_console_printf(machine, " set disassembler mode\n");
- debug_console_printf(machine, " mode: \"segmented\" or \"z8001\" - Z8001 mode\n");
- debug_console_printf(machine, " \"non-segmented\" or \"z8002\" - Z8002 mode\n");
- debug_console_printf(machine, " \"automatic\" - automatic mode\n");
- }
- else {
- debug_console_printf(machine, "Current disassembler mode: ");
- if (z8k_segm_mode == Z8K_SEGM_MODE_AUTO)
- debug_console_printf(machine, "automatic, currently ");
- debug_console_printf(machine, "%s\n", z8k_segm ? "Z8001/segmented" : "Z8002/non-segmented");
- }
-}
-
CPU_DISASSEMBLE( z8000 )
{
int new_pc = pc, i, j, tmp;
diff --git a/src/devices/cpu/z8000/z8000.cpp b/src/devices/cpu/z8000/z8000.cpp
index 910402cf1b3..bdfbc436275 100644
--- a/src/devices/cpu/z8000/z8000.cpp
+++ b/src/devices/cpu/z8000/z8000.cpp
@@ -25,7 +25,6 @@
extern int z8k_segm;
extern int z8k_segm_mode;
-extern void z8k_disass_mode(running_machine &machine, int ref, int params, const char *param[]);
#include "z8000cpu.h"
@@ -642,7 +641,49 @@ void z8002_device::state_string_export(const device_state_entry &entry, std::str
m_fcw & 0x0001 ? '?':'.');
break;
}
+}
+void z8001_device::z8k_disass_mode(int ref, int params, const char *param[])
+{
+ size_t len;
+ if (params == 1)
+ {
+ len = strlen(param[0]);
+ if (!core_strnicmp(param[0], "segmented", len) || !core_stricmp(param[0], "z8001")) {
+ z8k_segm = true;
+ z8k_segm_mode = Z8K_SEGM_MODE_SEG;
+ machine().debugger().console().printf("Disassembler mode set to Z8001/segmented\n");
+ }
+ else if (!core_strnicmp(param[0], "non-segmented", len) || !core_stricmp(param[0], "z8002"))
+ {
+ z8k_segm = false;
+ z8k_segm_mode = Z8K_SEGM_MODE_NONSEG;
+ machine().debugger().console().printf("Disassembler mode set to Z8002/non-segmented\n");
+ }
+ else if (!core_strnicmp(param[0], "automatic", len))
+ {
+ z8k_segm_mode = Z8K_SEGM_MODE_AUTO;
+ machine().debugger().console().printf("Disassembler mode set to automatic\n");
+ }
+ else
+ goto usage;
+ }
+ else if (params > 1)
+ {
+ usage:
+ machine().debugger().console().printf("Usage: z8k_disass_mode <mode>\n");
+ machine().debugger().console().printf(" set disassembler mode\n");
+ machine().debugger().console().printf(" mode: \"segmented\" or \"z8001\" - Z8001 mode\n");
+ machine().debugger().console().printf(" \"non-segmented\" or \"z8002\" - Z8002 mode\n");
+ machine().debugger().console().printf(" \"automatic\" - automatic mode\n");
+ }
+ else
+ {
+ machine().debugger().console().printf("Current disassembler mode: ");
+ if (z8k_segm_mode == Z8K_SEGM_MODE_AUTO)
+ machine().debugger().console().printf("automatic, currently ");
+ machine().debugger().console().printf("%s\n", z8k_segm ? "Z8001/segmented" : "Z8002/non-segmented");
+ }
}
void z8001_device::device_start()
@@ -664,7 +705,10 @@ void z8001_device::device_start()
z8000_init_tables();
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
- debug_console_register_command(machine(), "z8k_disass_mode", CMDFLAG_NONE, 0, 0, 1, z8k_disass_mode);
+ {
+ using namespace std::placeholders;
+ machine().debugger().console().register_command("z8k_disass_mode", CMDFLAG_NONE, 0, 0, 1, std::bind(&z8001_device::z8k_disass_mode, this, _1, _2, _3));
+ }
z8k_segm = true;
diff --git a/src/devices/cpu/z8000/z8000.h b/src/devices/cpu/z8000/z8000.h
index 288a2700c99..2a0f00c3266 100644
--- a/src/devices/cpu/z8000/z8000.h
+++ b/src/devices/cpu/z8000/z8000.h
@@ -665,6 +665,9 @@ protected:
virtual UINT32 F_SEG_Z8001() override;
virtual UINT32 PSA_ADDR() override;
virtual UINT32 read_irq_vector() override;
+
+private:
+ void z8k_disass_mode(int ref, int params, const char *param[]);
};
diff --git a/src/devices/machine/aakart.cpp b/src/devices/machine/aakart.cpp
index 7931f1c019d..75c947641d4 100644
--- a/src/devices/machine/aakart.cpp
+++ b/src/devices/machine/aakart.cpp
@@ -165,7 +165,7 @@ void aakart_device::device_timer(emu_timer &timer, device_timer_id id, int param
READ8_MEMBER( aakart_device::read )
{
m_out_tx_cb(CLEAR_LINE);
- //debugger_break(machine());
+ //machine().debugger().debug_break();
return m_rx;
}
diff --git a/src/devices/machine/atahle.cpp b/src/devices/machine/atahle.cpp
index 6bd963f946c..a57ab19d73a 100644
--- a/src/devices/machine/atahle.cpp
+++ b/src/devices/machine/atahle.cpp
@@ -211,7 +211,7 @@ void ata_hle_device::process_command()
m_status |= IDE_STATUS_ERR;
m_error = IDE_ERROR_ABRT;
set_irq(ASSERT_LINE);
- //debugger_break(device->machine());
+ //machine().debugger().debug_break();
break;
}
}
diff --git a/src/devices/sound/l7a1045_l6028_dsp_a.cpp b/src/devices/sound/l7a1045_l6028_dsp_a.cpp
index 526cbda9d9e..7941c204a28 100644
--- a/src/devices/sound/l7a1045_l6028_dsp_a.cpp
+++ b/src/devices/sound/l7a1045_l6028_dsp_a.cpp
@@ -295,7 +295,7 @@ WRITE16_MEMBER(l7a1045_sound_device::sound_data_w)
READ16_MEMBER(l7a1045_sound_device::sound_data_r)
{
//printf("%04x (%04x %04x)\n",offset,m_audioregister,m_audiochannel);
- //debugger_break(machine());
+ //machine().debugger().debug_break();
l7a1045_voice *vptr = &m_voice[m_audiochannel];
switch(m_audioregister)
diff --git a/src/devices/video/pc_vga.cpp b/src/devices/video/pc_vga.cpp
index 80cbae9b225..50ffe09b115 100644
--- a/src/devices/video/pc_vga.cpp
+++ b/src/devices/video/pc_vga.cpp
@@ -2664,7 +2664,7 @@ UINT8 s3_vga_device::s3_crtc_reg_read(UINT8 index)
break;
default:
res = vga.crtc.data[index];
- //debugger_break(machine);
+ //machine().debugger().debug_break();
//printf("%02x\n",index);
break;
}
diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp
index 0ee23f94638..ad1359baa28 100644
--- a/src/emu/debug/debugcmd.cpp
+++ b/src/emu/debug/debugcmd.cpp
@@ -26,144 +26,10 @@
CONSTANTS
***************************************************************************/
-#define MAX_GLOBALS 1000
-
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-struct global_entry
-{
- void * base;
- UINT32 size;
-};
-
-
-struct cheat_map
-{
- UINT64 offset;
- UINT64 first_value;
- UINT64 previous_value;
- UINT8 state:1;
- UINT8 undo:7;
-};
-
-
-struct cheat_system
-{
- char cpu[2];
- UINT8 width;
- std::vector<cheat_map> cheatmap;
- UINT8 undo;
- UINT8 signed_cheat;
- UINT8 swapped_cheat;
-};
-
-
-struct cheat_region_map
-{
- UINT64 offset;
- UINT64 endoffset;
- const char *share;
- UINT8 disabled;
-};
-
-
-
-/***************************************************************************
- GLOBAL VARIABLES
-***************************************************************************/
-
-static global_entry global_array[MAX_GLOBALS];
-static cheat_system cheat;
-
-
-
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-static void debug_command_exit(running_machine &machine);
-
-static UINT64 execute_min(symbol_table &table, void *ref, int params, const UINT64 *param);
-static UINT64 execute_max(symbol_table &table, void *ref, int params, const UINT64 *param);
-static UINT64 execute_if(symbol_table &table, void *ref, int params, const UINT64 *param);
-
-static UINT64 global_get(symbol_table &table, void *ref);
-static void global_set(symbol_table &table, void *ref, UINT64 value);
-
-static void execute_help(running_machine &machine, int ref, int params, const char **param);
-static void execute_print(running_machine &machine, int ref, int params, const char **param);
-static void execute_printf(running_machine &machine, int ref, int params, const char **param);
-static void execute_logerror(running_machine &machine, int ref, int params, const char **param);
-static void execute_tracelog(running_machine &machine, int ref, int params, const char **param);
-static void execute_quit(running_machine &machine, int ref, int params, const char **param);
-static void execute_do(running_machine &machine, int ref, int params, const char **param);
-static void execute_step(running_machine &machine, int ref, int params, const char **param);
-static void execute_over(running_machine &machine, int ref, int params, const char **param);
-static void execute_out(running_machine &machine, int ref, int params, const char **param);
-static void execute_go(running_machine &machine, int ref, int params, const char **param);
-static void execute_go_vblank(running_machine &machine, int ref, int params, const char **param);
-static void execute_go_interrupt(running_machine &machine, int ref, int params, const char **param);
-static void execute_go_time(running_machine &machine, int ref, int params, const char *param[]);
-static void execute_focus(running_machine &machine, int ref, int params, const char **param);
-static void execute_ignore(running_machine &machine, int ref, int params, const char **param);
-static void execute_observe(running_machine &machine, int ref, int params, const char **param);
-static void execute_next(running_machine &machine, int ref, int params, const char **param);
-static void execute_comment_add(running_machine &machine, int ref, int params, const char **param);
-static void execute_comment_del(running_machine &machine, int ref, int params, const char **param);
-static void execute_comment_save(running_machine &machine, int ref, int params, const char **param);
-static void execute_comment_list(running_machine &machine, int ref, int params, const char **param);
-static void execute_comment_commit(running_machine &machine, int ref, int params, const char **param);
-static void execute_bpset(running_machine &machine, int ref, int params, const char **param);
-static void execute_bpclear(running_machine &machine, int ref, int params, const char **param);
-static void execute_bpdisenable(running_machine &machine, int ref, int params, const char **param);
-static void execute_bplist(running_machine &machine, int ref, int params, const char **param);
-static void execute_wpset(running_machine &machine, int ref, int params, const char **param);
-static void execute_wpclear(running_machine &machine, int ref, int params, const char **param);
-static void execute_wpdisenable(running_machine &machine, int ref, int params, const char **param);
-static void execute_wplist(running_machine &machine, int ref, int params, const char **param);
-static void execute_rpset(running_machine &machine, int ref, int params, const char **param);
-static void execute_rpclear(running_machine &machine, int ref, int params, const char **param);
-static void execute_rpdisenable(running_machine &machine, int ref, int params, const char **param);
-static void execute_rplist(running_machine &machine, int ref, int params, const char **param);
-static void execute_hotspot(running_machine &machine, int ref, int params, const char **param);
-static void execute_statesave(running_machine &machine, int ref, int params, const char **param);
-static void execute_stateload(running_machine &machine, int ref, int params, const char **param);
-static void execute_save(running_machine &machine, int ref, int params, const char **param);
-static void execute_load(running_machine &machine, int ref, int params, const char **param);
-static void execute_dump(running_machine &machine, int ref, int params, const char **param);
-static void execute_cheatinit(running_machine &machine, int ref, int params, const char **param);
-static void execute_cheatnext(running_machine &machine, int ref, int params, const char **param);
-static void execute_cheatlist(running_machine &machine, int ref, int params, const char **param);
-static void execute_cheatundo(running_machine &machine, int ref, int params, const char **param);
-static void execute_dasm(running_machine &machine, int ref, int params, const char **param);
-static void execute_find(running_machine &machine, int ref, int params, const char **param);
-static void execute_trace(running_machine &machine, int ref, int params, const char **param);
-static void execute_traceover(running_machine &machine, int ref, int params, const char **param);
-static void execute_traceflush(running_machine &machine, int ref, int params, const char **param);
-static void execute_history(running_machine &machine, int ref, int params, const char **param);
-static void execute_trackpc(running_machine &machine, int ref, int params, const char **param);
-static void execute_trackmem(running_machine &machine, int ref, int params, const char **param);
-static void execute_pcatmem(running_machine &machine, int ref, int params, const char **param);
-static void execute_snap(running_machine &machine, int ref, int params, const char **param);
-static void execute_source(running_machine &machine, int ref, int params, const char **param);
-static void execute_map(running_machine &machine, int ref, int params, const char **param);
-static void execute_memdump(running_machine &machine, int ref, int params, const char **param);
-static void execute_symlist(running_machine &machine, int ref, int params, const char **param);
-static void execute_softreset(running_machine &machine, int ref, int params, const char **param);
-static void execute_hardreset(running_machine &machine, int ref, int params, const char **param);
-static void execute_images(running_machine &machine, int ref, int params, const char **param);
-static void execute_mount(running_machine &machine, int ref, int params, const char **param);
-static void execute_unmount(running_machine &machine, int ref, int params, const char **param);
-static void execute_input(running_machine &machine, int ref, int params, const char **param);
-static void execute_dumpkbd(running_machine &machine, int ref, int params, const char **param);
-
+const size_t debugger_commands::MAX_GLOBALS = 1000;
/***************************************************************************
- INLINE FUNCTIONS
+ FUNCTIONS
***************************************************************************/
/*-------------------------------------------------
@@ -171,9 +37,9 @@ static void execute_dumpkbd(running_machine &machine, int ref, int params, const
given address is valid for cheating
-------------------------------------------------*/
-static inline int cheat_address_is_valid(address_space &space, offs_t address)
+bool debugger_commands::cheat_address_is_valid(address_space &space, offs_t address)
{
- return debug_cpu_translate(space, TRANSLATE_READ, &address) && (space.get_write_ptr(address) != nullptr);
+ return m_cpu.translate(space, TRANSLATE_READ, &address) && (space.get_write_ptr(address) != nullptr);
}
@@ -182,7 +48,7 @@ static inline int cheat_address_is_valid(address_space &space, offs_t address)
the current cheat width, if signed
-------------------------------------------------*/
-static inline UINT64 cheat_sign_extend(const cheat_system *cheatsys, UINT64 value)
+UINT64 debugger_commands::cheat_sign_extend(const cheat_system *cheatsys, UINT64 value)
{
if (cheatsys->signed_cheat)
{
@@ -195,11 +61,12 @@ static inline UINT64 cheat_sign_extend(const cheat_system *cheatsys, UINT64 valu
}
return value;
}
+
/*-------------------------------------------------
cheat_byte_swap - swap a value
-------------------------------------------------*/
-static inline UINT64 cheat_byte_swap(const cheat_system *cheatsys, UINT64 value)
+UINT64 debugger_commands::cheat_byte_swap(const cheat_system *cheatsys, UINT64 value)
{
if (cheatsys->swapped_cheat)
{
@@ -220,41 +87,34 @@ static inline UINT64 cheat_byte_swap(const cheat_system *cheatsys, UINT64 value)
and swapping if necessary
-------------------------------------------------*/
-static inline UINT64 cheat_read_extended(const cheat_system *cheatsys, address_space &space, offs_t address)
+UINT64 debugger_commands::cheat_read_extended(const cheat_system *cheatsys, address_space &space, offs_t address)
{
- return cheat_sign_extend(cheatsys, cheat_byte_swap(cheatsys, debug_read_memory(space, address, cheatsys->width, TRUE)));
+ return cheat_sign_extend(cheatsys, cheat_byte_swap(cheatsys, m_cpu.read_memory(space, address, cheatsys->width, TRUE)));
}
-
-
-/***************************************************************************
- INITIALIZATION
-***************************************************************************/
-
-/*-------------------------------------------------
- debug_command_init - initializes the command
- system
--------------------------------------------------*/
-
-void debug_command_init(running_machine &machine)
+debugger_commands::debugger_commands(running_machine& machine, debugger_cpu& cpu, debugger_console& console)
+ : m_machine(machine)
+ , m_cpu(cpu)
+ , m_console(console)
{
- symbol_table *symtable = debug_cpu_get_global_symtable(machine);
- const char *name;
- int itemnum;
+ m_global_array = auto_alloc_array_clear(m_machine, global_entry, MAX_GLOBALS);
+
+ symbol_table *symtable = m_cpu.get_global_symtable();
/* add a few simple global functions */
- symtable->add("min", nullptr, 2, 2, execute_min);
- symtable->add("max", nullptr, 2, 2, execute_max);
- symtable->add("if", nullptr, 3, 3, execute_if);
+ using namespace std::placeholders;
+ symtable->add("min", nullptr, 2, 2, std::bind(&debugger_commands::execute_min, this, _1, _2, _3, _4));
+ symtable->add("max", nullptr, 2, 2, std::bind(&debugger_commands::execute_max, this, _1, _2, _3, _4));
+ symtable->add("if", nullptr, 3, 3, std::bind(&debugger_commands::execute_if, this, _1, _2, _3, _4));
/* add all single-entry save state globals */
- for (itemnum = 0; itemnum < MAX_GLOBALS; itemnum++)
+ for (int itemnum = 0; itemnum < MAX_GLOBALS; itemnum++)
{
UINT32 valsize, valcount;
void *base;
/* stop when we run out of items */
- name = machine.save().indexed_item(itemnum, base, valsize, valcount);
+ const char* name = m_machine.save().indexed_item(itemnum, base, valsize, valcount);
if (name == nullptr)
break;
@@ -263,181 +123,164 @@ void debug_command_init(running_machine &machine)
{
char symname[100];
sprintf(symname, ".%s", strrchr(name, '/') + 1);
- global_array[itemnum].base = base;
- global_array[itemnum].size = valsize;
- symtable->add(symname, &global_array, global_get, global_set);
+ m_global_array[itemnum].base = base;
+ m_global_array[itemnum].size = valsize;
+ symtable->add(symname, &m_global_array, std::bind(&debugger_commands::global_get, this, _1, _2), std::bind(&debugger_commands::global_set, this, _1, _2, _3));
}
}
/* add all the commands */
- debug_console_register_command(machine, "help", CMDFLAG_NONE, 0, 0, 1, execute_help);
- debug_console_register_command(machine, "print", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, execute_print);
- debug_console_register_command(machine, "printf", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, execute_printf);
- debug_console_register_command(machine, "logerror", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, execute_logerror);
- debug_console_register_command(machine, "tracelog", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, execute_tracelog);
- debug_console_register_command(machine, "quit", CMDFLAG_NONE, 0, 0, 0, execute_quit);
- debug_console_register_command(machine, "exit", CMDFLAG_NONE, 0, 0, 0, execute_quit);
- debug_console_register_command(machine, "do", CMDFLAG_NONE, 0, 1, 1, execute_do);
- debug_console_register_command(machine, "step", CMDFLAG_NONE, 0, 0, 1, execute_step);
- debug_console_register_command(machine, "s", CMDFLAG_NONE, 0, 0, 1, execute_step);
- debug_console_register_command(machine, "over", CMDFLAG_NONE, 0, 0, 1, execute_over);
- debug_console_register_command(machine, "o", CMDFLAG_NONE, 0, 0, 1, execute_over);
- debug_console_register_command(machine, "out" , CMDFLAG_NONE, 0, 0, 0, execute_out);
- debug_console_register_command(machine, "go", CMDFLAG_NONE, 0, 0, 1, execute_go);
- debug_console_register_command(machine, "g", CMDFLAG_NONE, 0, 0, 1, execute_go);
- debug_console_register_command(machine, "gvblank", CMDFLAG_NONE, 0, 0, 0, execute_go_vblank);
- debug_console_register_command(machine, "gv", CMDFLAG_NONE, 0, 0, 0, execute_go_vblank);
- debug_console_register_command(machine, "gint", CMDFLAG_NONE, 0, 0, 1, execute_go_interrupt);
- debug_console_register_command(machine, "gi", CMDFLAG_NONE, 0, 0, 1, execute_go_interrupt);
- debug_console_register_command(machine, "gtime", CMDFLAG_NONE, 0, 0, 1, execute_go_time);
- debug_console_register_command(machine, "gt", CMDFLAG_NONE, 0, 0, 1, execute_go_time);
- debug_console_register_command(machine, "next", CMDFLAG_NONE, 0, 0, 0, execute_next);
- debug_console_register_command(machine, "n", CMDFLAG_NONE, 0, 0, 0, execute_next);
- debug_console_register_command(machine, "focus", CMDFLAG_NONE, 0, 1, 1, execute_focus);
- debug_console_register_command(machine, "ignore", CMDFLAG_NONE, 0, 0, MAX_COMMAND_PARAMS, execute_ignore);
- debug_console_register_command(machine, "observe", CMDFLAG_NONE, 0, 0, MAX_COMMAND_PARAMS, execute_observe);
-
- debug_console_register_command(machine, "comadd", CMDFLAG_NONE, 0, 1, 2, execute_comment_add);
- debug_console_register_command(machine, "//", CMDFLAG_NONE, 0, 1, 2, execute_comment_add);
- debug_console_register_command(machine, "comdelete", CMDFLAG_NONE, 0, 1, 1, execute_comment_del);
- debug_console_register_command(machine, "comsave", CMDFLAG_NONE, 0, 0, 0, execute_comment_save);
- debug_console_register_command(machine, "comlist", CMDFLAG_NONE, 0, 0, 0, execute_comment_list);
- debug_console_register_command(machine, "commit", CMDFLAG_NONE, 0, 1, 2, execute_comment_commit);
- debug_console_register_command(machine, "/*", CMDFLAG_NONE, 0, 1, 2, execute_comment_commit);
-
- debug_console_register_command(machine, "bpset", CMDFLAG_NONE, 0, 1, 3, execute_bpset);
- debug_console_register_command(machine, "bp", CMDFLAG_NONE, 0, 1, 3, execute_bpset);
- debug_console_register_command(machine, "bpclear", CMDFLAG_NONE, 0, 0, 1, execute_bpclear);
- debug_console_register_command(machine, "bpdisable", CMDFLAG_NONE, 0, 0, 1, execute_bpdisenable);
- debug_console_register_command(machine, "bpenable", CMDFLAG_NONE, 1, 0, 1, execute_bpdisenable);
- debug_console_register_command(machine, "bplist", CMDFLAG_NONE, 0, 0, 0, execute_bplist);
-
- debug_console_register_command(machine, "wpset", CMDFLAG_NONE, AS_PROGRAM, 3, 5, execute_wpset);
- debug_console_register_command(machine, "wp", CMDFLAG_NONE, AS_PROGRAM, 3, 5, execute_wpset);
- debug_console_register_command(machine, "wpdset", CMDFLAG_NONE, AS_DATA, 3, 5, execute_wpset);
- debug_console_register_command(machine, "wpd", CMDFLAG_NONE, AS_DATA, 3, 5, execute_wpset);
- debug_console_register_command(machine, "wpiset", CMDFLAG_NONE, AS_IO, 3, 5, execute_wpset);
- debug_console_register_command(machine, "wpi", CMDFLAG_NONE, AS_IO, 3, 5, execute_wpset);
- debug_console_register_command(machine, "wpclear", CMDFLAG_NONE, 0, 0, 1, execute_wpclear);
- debug_console_register_command(machine, "wpdisable", CMDFLAG_NONE, 0, 0, 1, execute_wpdisenable);
- debug_console_register_command(machine, "wpenable", CMDFLAG_NONE, 1, 0, 1, execute_wpdisenable);
- debug_console_register_command(machine, "wplist", CMDFLAG_NONE, 0, 0, 0, execute_wplist);
-
- debug_console_register_command(machine, "rpset", CMDFLAG_NONE, 0, 1, 2, execute_rpset);
- debug_console_register_command(machine, "rp", CMDFLAG_NONE, 0, 1, 2, execute_rpset);
- debug_console_register_command(machine, "rpclear", CMDFLAG_NONE, 0, 0, 1, execute_rpclear);
- debug_console_register_command(machine, "rpdisable", CMDFLAG_NONE, 0, 0, 1, execute_rpdisenable);
- debug_console_register_command(machine, "rpenable", CMDFLAG_NONE, 1, 0, 1, execute_rpdisenable);
- debug_console_register_command(machine, "rplist", CMDFLAG_NONE, 0, 0, 0, execute_rplist);
-
- debug_console_register_command(machine, "hotspot", CMDFLAG_NONE, 0, 0, 3, execute_hotspot);
-
- debug_console_register_command(machine, "statesave", CMDFLAG_NONE, 0, 1, 1, execute_statesave);
- debug_console_register_command(machine, "ss", CMDFLAG_NONE, 0, 1, 1, execute_statesave);
- debug_console_register_command(machine, "stateload", CMDFLAG_NONE, 0, 1, 1, execute_stateload);
- debug_console_register_command(machine, "sl", CMDFLAG_NONE, 0, 1, 1, execute_stateload);
-
- debug_console_register_command(machine, "save", CMDFLAG_NONE, AS_PROGRAM, 3, 4, execute_save);
- debug_console_register_command(machine, "saved", CMDFLAG_NONE, AS_DATA, 3, 4, execute_save);
- debug_console_register_command(machine, "savei", CMDFLAG_NONE, AS_IO, 3, 4, execute_save);
-
- debug_console_register_command(machine, "load", CMDFLAG_NONE, AS_PROGRAM, 3, 4, execute_load);
- debug_console_register_command(machine, "loadd", CMDFLAG_NONE, AS_DATA, 3, 4, execute_load);
- debug_console_register_command(machine, "loadi", CMDFLAG_NONE, AS_IO, 3, 4, execute_load);
-
- debug_console_register_command(machine, "dump", CMDFLAG_NONE, AS_PROGRAM, 3, 6, execute_dump);
- debug_console_register_command(machine, "dumpd", CMDFLAG_NONE, AS_DATA, 3, 6, execute_dump);
- debug_console_register_command(machine, "dumpi", CMDFLAG_NONE, AS_IO, 3, 6, execute_dump);
-
- debug_console_register_command(machine, "cheatinit", CMDFLAG_NONE, 0, 0, 4, execute_cheatinit);
- debug_console_register_command(machine, "ci", CMDFLAG_NONE, 0, 0, 4, execute_cheatinit);
-
- debug_console_register_command(machine, "cheatrange",CMDFLAG_NONE, 1, 2, 2, execute_cheatinit);
- debug_console_register_command(machine, "cr", CMDFLAG_NONE, 1, 2, 2, execute_cheatinit);
-
- debug_console_register_command(machine, "cheatnext", CMDFLAG_NONE, 0, 1, 2, execute_cheatnext);
- debug_console_register_command(machine, "cn", CMDFLAG_NONE, 0, 1, 2, execute_cheatnext);
- debug_console_register_command(machine, "cheatnextf",CMDFLAG_NONE, 1, 1, 2, execute_cheatnext);
- debug_console_register_command(machine, "cnf", CMDFLAG_NONE, 1, 1, 2, execute_cheatnext);
-
- debug_console_register_command(machine, "cheatlist", CMDFLAG_NONE, 0, 0, 1, execute_cheatlist);
- debug_console_register_command(machine, "cl", CMDFLAG_NONE, 0, 0, 1, execute_cheatlist);
-
- debug_console_register_command(machine, "cheatundo", CMDFLAG_NONE, 0, 0, 0, execute_cheatundo);
- debug_console_register_command(machine, "cu", CMDFLAG_NONE, 0, 0, 0, execute_cheatundo);
-
- debug_console_register_command(machine, "f", CMDFLAG_KEEP_QUOTES, AS_PROGRAM, 3, MAX_COMMAND_PARAMS, execute_find);
- debug_console_register_command(machine, "find", CMDFLAG_KEEP_QUOTES, AS_PROGRAM, 3, MAX_COMMAND_PARAMS, execute_find);
- debug_console_register_command(machine, "fd", CMDFLAG_KEEP_QUOTES, AS_DATA, 3, MAX_COMMAND_PARAMS, execute_find);
- debug_console_register_command(machine, "findd", CMDFLAG_KEEP_QUOTES, AS_DATA, 3, MAX_COMMAND_PARAMS, execute_find);
- debug_console_register_command(machine, "fi", CMDFLAG_KEEP_QUOTES, AS_IO, 3, MAX_COMMAND_PARAMS, execute_find);
- debug_console_register_command(machine, "findi", CMDFLAG_KEEP_QUOTES, AS_IO, 3, MAX_COMMAND_PARAMS, execute_find);
-
- debug_console_register_command(machine, "dasm", CMDFLAG_NONE, 0, 3, 5, execute_dasm);
-
- debug_console_register_command(machine, "trace", CMDFLAG_NONE, 0, 1, 3, execute_trace);
- debug_console_register_command(machine, "traceover", CMDFLAG_NONE, 0, 1, 3, execute_traceover);
- debug_console_register_command(machine, "traceflush",CMDFLAG_NONE, 0, 0, 0, execute_traceflush);
-
- debug_console_register_command(machine, "history", CMDFLAG_NONE, 0, 0, 2, execute_history);
- debug_console_register_command(machine, "trackpc", CMDFLAG_NONE, 0, 0, 3, execute_trackpc);
-
- debug_console_register_command(machine, "trackmem", CMDFLAG_NONE, 0, 0, 3, execute_trackmem);
- debug_console_register_command(machine, "pcatmemp", CMDFLAG_NONE, AS_PROGRAM, 1, 2, execute_pcatmem);
- debug_console_register_command(machine, "pcatmemd", CMDFLAG_NONE, AS_DATA, 1, 2, execute_pcatmem);
- debug_console_register_command(machine, "pcatmemi", CMDFLAG_NONE, AS_IO, 1, 2, execute_pcatmem);
-
- debug_console_register_command(machine, "snap", CMDFLAG_NONE, 0, 0, 1, execute_snap);
-
- debug_console_register_command(machine, "source", CMDFLAG_NONE, 0, 1, 1, execute_source);
-
- debug_console_register_command(machine, "map", CMDFLAG_NONE, AS_PROGRAM, 1, 1, execute_map);
- debug_console_register_command(machine, "mapd", CMDFLAG_NONE, AS_DATA, 1, 1, execute_map);
- debug_console_register_command(machine, "mapi", CMDFLAG_NONE, AS_IO, 1, 1, execute_map);
- debug_console_register_command(machine, "memdump", CMDFLAG_NONE, 0, 0, 1, execute_memdump);
-
- debug_console_register_command(machine, "symlist", CMDFLAG_NONE, 0, 0, 1, execute_symlist);
-
- debug_console_register_command(machine, "softreset", CMDFLAG_NONE, 0, 0, 1, execute_softreset);
- debug_console_register_command(machine, "hardreset", CMDFLAG_NONE, 0, 0, 1, execute_hardreset);
-
- debug_console_register_command(machine, "images", CMDFLAG_NONE, 0, 0, 0, execute_images);
- debug_console_register_command(machine, "mount", CMDFLAG_NONE, 0, 2, 2, execute_mount);
- debug_console_register_command(machine, "unmount", CMDFLAG_NONE, 0, 1, 1, execute_unmount);
-
- debug_console_register_command(machine, "input", CMDFLAG_NONE, 0, 1, 1, execute_input);
- debug_console_register_command(machine, "dumpkbd", CMDFLAG_NONE, 0, 0, 1, execute_dumpkbd);
+ m_console.register_command("help", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_help, this, _1, _2, _3));
+ m_console.register_command("print", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_print, this, _1, _2, _3));
+ m_console.register_command("printf", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_printf, this, _1, _2, _3));
+ m_console.register_command("logerror", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_logerror, this, _1, _2, _3));
+ m_console.register_command("tracelog", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_tracelog, this, _1, _2, _3));
+ m_console.register_command("quit", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_quit, this, _1, _2, _3));
+ m_console.register_command("exit", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_quit, this, _1, _2, _3));
+ m_console.register_command("do", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_do, this, _1, _2, _3));
+ m_console.register_command("step", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_step, this, _1, _2, _3));
+ m_console.register_command("s", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_step, this, _1, _2, _3));
+ m_console.register_command("over", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_over, this, _1, _2, _3));
+ m_console.register_command("o", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_over, this, _1, _2, _3));
+ m_console.register_command("out" , CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_out, this, _1, _2, _3));
+ m_console.register_command("go", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_go, this, _1, _2, _3));
+ m_console.register_command("g", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_go, this, _1, _2, _3));
+ m_console.register_command("gvblank", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_go_vblank, this, _1, _2, _3));
+ m_console.register_command("gv", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_go_vblank, this, _1, _2, _3));
+ m_console.register_command("gint", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_go_interrupt, this, _1, _2, _3));
+ m_console.register_command("gi", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_go_interrupt, this, _1, _2, _3));
+ m_console.register_command("gtime", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_go_time, this, _1, _2, _3));
+ m_console.register_command("gt", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_go_time, this, _1, _2, _3));
+ m_console.register_command("next", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_next, this, _1, _2, _3));
+ m_console.register_command("n", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_next, this, _1, _2, _3));
+ m_console.register_command("focus", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_focus, this, _1, _2, _3));
+ m_console.register_command("ignore", CMDFLAG_NONE, 0, 0, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_ignore, this, _1, _2, _3));
+ m_console.register_command("observe", CMDFLAG_NONE, 0, 0, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_observe, this, _1, _2, _3));
+
+ m_console.register_command("comadd", CMDFLAG_NONE, 0, 1, 2, std::bind(&debugger_commands::execute_comment_add, this, _1, _2, _3));
+ m_console.register_command("//", CMDFLAG_NONE, 0, 1, 2, std::bind(&debugger_commands::execute_comment_add, this, _1, _2, _3));
+ m_console.register_command("comdelete", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_comment_del, this, _1, _2, _3));
+ m_console.register_command("comsave", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_comment_save, this, _1, _2, _3));
+ m_console.register_command("comlist", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_comment_list, this, _1, _2, _3));
+ m_console.register_command("commit", CMDFLAG_NONE, 0, 1, 2, std::bind(&debugger_commands::execute_comment_commit, this, _1, _2, _3));
+ m_console.register_command("/*", CMDFLAG_NONE, 0, 1, 2, std::bind(&debugger_commands::execute_comment_commit, this, _1, _2, _3));
+
+ m_console.register_command("bpset", CMDFLAG_NONE, 0, 1, 3, std::bind(&debugger_commands::execute_bpset, this, _1, _2, _3));
+ m_console.register_command("bp", CMDFLAG_NONE, 0, 1, 3, std::bind(&debugger_commands::execute_bpset, this, _1, _2, _3));
+ m_console.register_command("bpclear", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_bpclear, this, _1, _2, _3));
+ m_console.register_command("bpdisable", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_bpdisenable, this, _1, _2, _3));
+ m_console.register_command("bpenable", CMDFLAG_NONE, 1, 0, 1, std::bind(&debugger_commands::execute_bpdisenable, this, _1, _2, _3));
+ m_console.register_command("bplist", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_bplist, this, _1, _2, _3));
+
+ m_console.register_command("wpset", CMDFLAG_NONE, AS_PROGRAM, 3, 5, std::bind(&debugger_commands::execute_wpset, this, _1, _2, _3));
+ m_console.register_command("wp", CMDFLAG_NONE, AS_PROGRAM, 3, 5, std::bind(&debugger_commands::execute_wpset, this, _1, _2, _3));
+ m_console.register_command("wpdset", CMDFLAG_NONE, AS_DATA, 3, 5, std::bind(&debugger_commands::execute_wpset, this, _1, _2, _3));
+ m_console.register_command("wpd", CMDFLAG_NONE, AS_DATA, 3, 5, std::bind(&debugger_commands::execute_wpset, this, _1, _2, _3));
+ m_console.register_command("wpiset", CMDFLAG_NONE, AS_IO, 3, 5, std::bind(&debugger_commands::execute_wpset, this, _1, _2, _3));
+ m_console.register_command("wpi", CMDFLAG_NONE, AS_IO, 3, 5, std::bind(&debugger_commands::execute_wpset, this, _1, _2, _3));
+ m_console.register_command("wpclear", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_wpclear, this, _1, _2, _3));
+ m_console.register_command("wpdisable", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_wpdisenable, this, _1, _2, _3));
+ m_console.register_command("wpenable", CMDFLAG_NONE, 1, 0, 1, std::bind(&debugger_commands::execute_wpdisenable, this, _1, _2, _3));
+ m_console.register_command("wplist", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_wplist, this, _1, _2, _3));
+
+ m_console.register_command("rpset", CMDFLAG_NONE, 0, 1, 2, std::bind(&debugger_commands::execute_rpset, this, _1, _2, _3));
+ m_console.register_command("rp", CMDFLAG_NONE, 0, 1, 2, std::bind(&debugger_commands::execute_rpset, this, _1, _2, _3));
+ m_console.register_command("rpclear", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_rpclear, this, _1, _2, _3));
+ m_console.register_command("rpdisable", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_rpdisenable, this, _1, _2, _3));
+ m_console.register_command("rpenable", CMDFLAG_NONE, 1, 0, 1, std::bind(&debugger_commands::execute_rpdisenable, this, _1, _2, _3));
+ m_console.register_command("rplist", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_rplist, this, _1, _2, _3));
+
+ m_console.register_command("hotspot", CMDFLAG_NONE, 0, 0, 3, std::bind(&debugger_commands::execute_hotspot, this, _1, _2, _3));
+
+ m_console.register_command("statesave", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_statesave, this, _1, _2, _3));
+ m_console.register_command("ss", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_statesave, this, _1, _2, _3));
+ m_console.register_command("stateload", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_stateload, this, _1, _2, _3));
+ m_console.register_command("sl", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_stateload, this, _1, _2, _3));
+
+ m_console.register_command("save", CMDFLAG_NONE, AS_PROGRAM, 3, 4, std::bind(&debugger_commands::execute_save, this, _1, _2, _3));
+ m_console.register_command("saved", CMDFLAG_NONE, AS_DATA, 3, 4, std::bind(&debugger_commands::execute_save, this, _1, _2, _3));
+ m_console.register_command("savei", CMDFLAG_NONE, AS_IO, 3, 4, std::bind(&debugger_commands::execute_save, this, _1, _2, _3));
+
+ m_console.register_command("load", CMDFLAG_NONE, AS_PROGRAM, 3, 4, std::bind(&debugger_commands::execute_load, this, _1, _2, _3));
+ m_console.register_command("loadd", CMDFLAG_NONE, AS_DATA, 3, 4, std::bind(&debugger_commands::execute_load, this, _1, _2, _3));
+ m_console.register_command("loadi", CMDFLAG_NONE, AS_IO, 3, 4, std::bind(&debugger_commands::execute_load, this, _1, _2, _3));
+
+ m_console.register_command("dump", CMDFLAG_NONE, AS_PROGRAM, 3, 6, std::bind(&debugger_commands::execute_dump, this, _1, _2, _3));
+ m_console.register_command("dumpd", CMDFLAG_NONE, AS_DATA, 3, 6, std::bind(&debugger_commands::execute_dump, this, _1, _2, _3));
+ m_console.register_command("dumpi", CMDFLAG_NONE, AS_IO, 3, 6, std::bind(&debugger_commands::execute_dump, this, _1, _2, _3));
+
+ m_console.register_command("cheatinit", CMDFLAG_NONE, 0, 0, 4, std::bind(&debugger_commands::execute_cheatinit, this, _1, _2, _3));
+ m_console.register_command("ci", CMDFLAG_NONE, 0, 0, 4, std::bind(&debugger_commands::execute_cheatinit, this, _1, _2, _3));
+
+ m_console.register_command("cheatrange",CMDFLAG_NONE, 1, 2, 2, std::bind(&debugger_commands::execute_cheatinit, this, _1, _2, _3));
+ m_console.register_command("cr", CMDFLAG_NONE, 1, 2, 2, std::bind(&debugger_commands::execute_cheatinit, this, _1, _2, _3));
+
+ m_console.register_command("cheatnext", CMDFLAG_NONE, 0, 1, 2, std::bind(&debugger_commands::execute_cheatnext, this, _1, _2, _3));
+ m_console.register_command("cn", CMDFLAG_NONE, 0, 1, 2, std::bind(&debugger_commands::execute_cheatnext, this, _1, _2, _3));
+ m_console.register_command("cheatnextf",CMDFLAG_NONE, 1, 1, 2, std::bind(&debugger_commands::execute_cheatnext, this, _1, _2, _3));
+ m_console.register_command("cnf", CMDFLAG_NONE, 1, 1, 2, std::bind(&debugger_commands::execute_cheatnext, this, _1, _2, _3));
+
+ m_console.register_command("cheatlist", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_cheatlist, this, _1, _2, _3));
+ m_console.register_command("cl", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_cheatlist, this, _1, _2, _3));
+
+ m_console.register_command("cheatundo", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_cheatundo, this, _1, _2, _3));
+ m_console.register_command("cu", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_cheatundo, this, _1, _2, _3));
+
+ m_console.register_command("f", CMDFLAG_KEEP_QUOTES, AS_PROGRAM, 3, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_find, this, _1, _2, _3));
+ m_console.register_command("find", CMDFLAG_KEEP_QUOTES, AS_PROGRAM, 3, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_find, this, _1, _2, _3));
+ m_console.register_command("fd", CMDFLAG_KEEP_QUOTES, AS_DATA, 3, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_find, this, _1, _2, _3));
+ m_console.register_command("findd", CMDFLAG_KEEP_QUOTES, AS_DATA, 3, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_find, this, _1, _2, _3));
+ m_console.register_command("fi", CMDFLAG_KEEP_QUOTES, AS_IO, 3, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_find, this, _1, _2, _3));
+ m_console.register_command("findi", CMDFLAG_KEEP_QUOTES, AS_IO, 3, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_find, this, _1, _2, _3));
+
+ m_console.register_command("dasm", CMDFLAG_NONE, 0, 3, 5, std::bind(&debugger_commands::execute_dasm, this, _1, _2, _3));
+
+ m_console.register_command("trace", CMDFLAG_NONE, 0, 1, 3, std::bind(&debugger_commands::execute_trace, this, _1, _2, _3));
+ m_console.register_command("traceover", CMDFLAG_NONE, 0, 1, 3, std::bind(&debugger_commands::execute_traceover, this, _1, _2, _3));
+ m_console.register_command("traceflush",CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_traceflush, this, _1, _2, _3));
+
+ m_console.register_command("history", CMDFLAG_NONE, 0, 0, 2, std::bind(&debugger_commands::execute_history, this, _1, _2, _3));
+ m_console.register_command("trackpc", CMDFLAG_NONE, 0, 0, 3, std::bind(&debugger_commands::execute_trackpc, this, _1, _2, _3));
+
+ m_console.register_command("trackmem", CMDFLAG_NONE, 0, 0, 3, std::bind(&debugger_commands::execute_trackmem, this, _1, _2, _3));
+ m_console.register_command("pcatmemp", CMDFLAG_NONE, AS_PROGRAM, 1, 2, std::bind(&debugger_commands::execute_pcatmem, this, _1, _2, _3));
+ m_console.register_command("pcatmemd", CMDFLAG_NONE, AS_DATA, 1, 2, std::bind(&debugger_commands::execute_pcatmem, this, _1, _2, _3));
+ m_console.register_command("pcatmemi", CMDFLAG_NONE, AS_IO, 1, 2, std::bind(&debugger_commands::execute_pcatmem, this, _1, _2, _3));
+
+ m_console.register_command("snap", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_snap, this, _1, _2, _3));
+
+ m_console.register_command("source", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_source, this, _1, _2, _3));
+
+ m_console.register_command("map", CMDFLAG_NONE, AS_PROGRAM, 1, 1, std::bind(&debugger_commands::execute_map, this, _1, _2, _3));
+ m_console.register_command("mapd", CMDFLAG_NONE, AS_DATA, 1, 1, std::bind(&debugger_commands::execute_map, this, _1, _2, _3));
+ m_console.register_command("mapi", CMDFLAG_NONE, AS_IO, 1, 1, std::bind(&debugger_commands::execute_map, this, _1, _2, _3));
+ m_console.register_command("memdump", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_memdump, this, _1, _2, _3));
+
+ m_console.register_command("symlist", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_symlist, this, _1, _2, _3));
+
+ m_console.register_command("softreset", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_softreset, this, _1, _2, _3));
+ m_console.register_command("hardreset", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_hardreset, this, _1, _2, _3));
+
+ m_console.register_command("images", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_images, this, _1, _2, _3));
+ m_console.register_command("mount", CMDFLAG_NONE, 0, 2, 2, std::bind(&debugger_commands::execute_mount, this, _1, _2, _3));
+ m_console.register_command("unmount", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_unmount, this, _1, _2, _3));
- machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_command_exit), &machine));
+ m_console.register_command("input", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_input, this, _1, _2, _3));
+ m_console.register_command("dumpkbd", CMDFLAG_NONE, 0, 0, 1, std::bind(&debugger_commands::execute_dumpkbd, this, _1, _2, _3));
/* set up the initial debugscript if specified */
- name = machine.options().debug_script();
+ const char* name = m_machine.options().debug_script();
if (name[0] != 0)
- debug_cpu_source_script(machine, name);
-
- cheat.cpu[0] = cheat.cpu[1] = 0;
-}
-
-
-/*-------------------------------------------------
- debug_command_exit - exit-time cleanup
--------------------------------------------------*/
+ m_cpu.source_script(name);
-static void debug_command_exit(running_machine &machine)
-{
+ m_cheat.cpu[0] = m_cheat.cpu[1] = 0;
}
-
-
-/***************************************************************************
- GLOBAL FUNCTIONS
-***************************************************************************/
-
/*-------------------------------------------------
execute_min - return the minimum of two values
-------------------------------------------------*/
-static UINT64 execute_min(symbol_table &table, void *ref, int params, const UINT64 *param)
+UINT64 debugger_commands::execute_min(symbol_table &table, void *ref, int params, const UINT64 *param)
{
return (param[0] < param[1]) ? param[0] : param[1];
}
@@ -447,7 +290,7 @@ static UINT64 execute_min(symbol_table &table, void *ref, int params, const UINT
execute_max - return the maximum of two values
-------------------------------------------------*/
-static UINT64 execute_max(symbol_table &table, void *ref, int params, const UINT64 *param)
+UINT64 debugger_commands::execute_max(symbol_table &table, void *ref, int params, const UINT64 *param)
{
return (param[0] > param[1]) ? param[0] : param[1];
}
@@ -457,7 +300,7 @@ static UINT64 execute_max(symbol_table &table, void *ref, int params, const UINT
execute_if - if (a) return b; else return c;
-------------------------------------------------*/
-static UINT64 execute_if(symbol_table &table, void *ref, int params, const UINT64 *param)
+UINT64 debugger_commands::execute_if(symbol_table &table, void *ref, int params, const UINT64 *param)
{
return param[0] ? param[1] : param[2];
}
@@ -472,7 +315,7 @@ static UINT64 execute_if(symbol_table &table, void *ref, int params, const UINT6
global_get - symbol table getter for globals
-------------------------------------------------*/
-static UINT64 global_get(symbol_table &table, void *ref)
+UINT64 debugger_commands::global_get(symbol_table &table, void *ref)
{
global_entry *global = (global_entry *)ref;
switch (global->size)
@@ -490,7 +333,7 @@ static UINT64 global_get(symbol_table &table, void *ref)
global_set - symbol table setter for globals
-------------------------------------------------*/
-static void global_set(symbol_table &table, void *ref, UINT64 value)
+void debugger_commands::global_set(symbol_table &table, void *ref, UINT64 value)
{
global_entry *global = (global_entry *)ref;
switch (global->size)
@@ -509,106 +352,104 @@ static void global_set(symbol_table &table, void *ref, UINT64 value)
***************************************************************************/
/*-------------------------------------------------
- debug_command_parameter_number - validates a
+ validate_number_parameter - validates a
number parameter
-------------------------------------------------*/
-int debug_command_parameter_number(running_machine &machine, const char *param, UINT64 *result)
+bool debugger_commands::validate_number_parameter(const char *param, UINT64 *result)
{
/* nullptr parameter does nothing and returns no error */
if (param == nullptr)
- return TRUE;
+ return true;
/* evaluate the expression; success if no error */
try
{
- parsed_expression expression(debug_cpu_get_visible_symtable(machine), param, result);
- return TRUE;
+ parsed_expression expression(m_cpu.get_visible_symtable(), param, result);
+ return true;
}
catch (expression_error &error)
{
/* print an error pointing to the character that caused it */
- debug_console_printf(machine, "Error in expression: %s\n", param);
- debug_console_printf(machine, " %*s^", error.offset(), "");
- debug_console_printf(machine, "%s\n", error.code_string());
- return FALSE;
+ m_console.printf("Error in expression: %s\n", param);
+ m_console.printf(" %*s^", error.offset(), "");
+ m_console.printf("%s\n", error.code_string());
+ return false;
}
}
/*-------------------------------------------------
- debug_command_parameter_cpu - validates a
+ validate_cpu_parameter - validates a
parameter as a cpu
-------------------------------------------------*/
-int debug_command_parameter_cpu(running_machine &machine, const char *param, device_t **result)
+bool debugger_commands::validate_cpu_parameter(const char *param, device_t **result)
{
- UINT64 cpunum;
-
/* if no parameter, use the visible CPU */
if (param == nullptr)
{
- *result = debug_cpu_get_visible_cpu(machine);
+ *result = m_cpu.get_visible_cpu();
if (*result == nullptr)
{
- debug_console_printf(machine, "No valid CPU is currently selected\n");
- return FALSE;
+ m_console.printf("No valid CPU is currently selected\n");
+ return false;
}
- return TRUE;
+ return true;
}
/* first look for a tag match */
- *result = machine.device(param);
+ *result = m_machine.device(param);
if (*result != nullptr)
- return TRUE;
+ return true;
/* then evaluate as an expression; on an error assume it was a tag */
+ UINT64 cpunum;
try
{
- parsed_expression expression(debug_cpu_get_visible_symtable(machine), param, &cpunum);
+ parsed_expression expression(m_cpu.get_visible_symtable(), param, &cpunum);
}
catch (expression_error &)
{
- debug_console_printf(machine, "Unable to find CPU '%s'\n", param);
- return FALSE;
+ m_console.printf("Unable to find CPU '%s'\n", param);
+ return false;
}
/* if we got a valid one, return */
- device_execute_interface *exec = execute_interface_iterator(machine.root_device()).byindex(cpunum);
+ device_execute_interface *exec = execute_interface_iterator(m_machine.root_device()).byindex(cpunum);
if (exec != nullptr)
{
*result = &exec->device();
- return TRUE;
+ return true;
}
/* if out of range, complain */
- debug_console_printf(machine, "Invalid CPU index %d\n", (int)cpunum);
- return FALSE;
+ m_console.printf("Invalid CPU index %d\n", (int)cpunum);
+ return false;
}
/*-------------------------------------------------
- debug_command_parameter_cpu_space - validates
+ validate_cpu_space_parameter - validates
a parameter as a cpu and retrieves the given
address space
-------------------------------------------------*/
-int debug_command_parameter_cpu_space(running_machine &machine, const char *param, int spacenum, address_space *&result)
+bool debugger_commands::validate_cpu_space_parameter(const char *param, int spacenum, address_space *&result)
{
- device_t *cpu;
-
/* first do the standard CPU thing */
- if (!debug_command_parameter_cpu(machine, param, &cpu))
- return FALSE;
+ device_t *cpu;
+ if (!validate_cpu_parameter(param, &cpu))
+ return false;
/* fetch the space pointer */
if (!cpu->memory().has_space(spacenum))
{
- debug_console_printf(machine, "No matching memory space found for CPU '%s'\n", cpu->tag());
- return FALSE;
+ m_console.printf("No matching memory space found for CPU '%s'\n", cpu->tag());
+ return false;
}
result = &cpu->memory().space(spacenum);
- return TRUE;
+ return true;
}
@@ -617,25 +458,25 @@ int debug_command_parameter_cpu_space(running_machine &machine, const char *para
an expression parameter
-------------------------------------------------*/
-static int debug_command_parameter_expression(running_machine &machine, const char *param, parsed_expression &result)
+bool debugger_commands::debug_command_parameter_expression(const char *param, parsed_expression &result)
{
/* nullptr parameter does nothing and returns no error */
if (param == nullptr)
- return TRUE;
+ return true;
/* parse the expression; success if no error */
try
{
result.parse(param);
- return TRUE;
+ return true;
}
catch (expression_error &err)
{
/* output an error */
- debug_console_printf(machine, "Error in expression: %s\n", param);
- debug_console_printf(machine, " %*s^", err.offset(), "");
- debug_console_printf(machine, "%s\n", err.code_string());
- return FALSE;
+ m_console.printf("Error in expression: %s\n", param);
+ m_console.printf(" %*s^", err.offset(), "");
+ m_console.printf("%s\n", err.code_string());
+ return false;
}
}
@@ -645,42 +486,34 @@ static int debug_command_parameter_expression(running_machine &machine, const ch
command parameter
-------------------------------------------------*/
-static int debug_command_parameter_command(running_machine &machine, const char *param)
+bool debugger_commands::debug_command_parameter_command(const char *param)
{
- CMDERR err;
-
/* nullptr parameter does nothing and returns no error */
if (param == nullptr)
- return TRUE;
+ return true;
/* validate the comment; success if no error */
- err = debug_console_validate_command(machine, param);
+ CMDERR err = m_console.validate_command(param);
if (err == CMDERR_NONE)
- return TRUE;
+ return true;
/* output an error */
- debug_console_printf(machine, "Error in command: %s\n", param);
- debug_console_printf(machine, " %*s^", CMDERR_ERROR_OFFSET(err), "");
- debug_console_printf(machine, "%s\n", debug_cmderr_to_string(err));
+ m_console.printf("Error in command: %s\n", param);
+ m_console.printf(" %*s^", CMDERR_ERROR_OFFSET(err), "");
+ m_console.printf("%s\n", debugger_console::cmderr_to_string(err));
return 0;
}
-
-
-/***************************************************************************
- COMMAND HELPERS
-***************************************************************************/
-
/*-------------------------------------------------
execute_help - execute the help command
-------------------------------------------------*/
-static void execute_help(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_help(int ref, int params, const char *param[])
{
if (params == 0)
- debug_console_printf_wrap(machine, 80, "%s\n", debug_get_help(""));
+ m_console.printf_wrap(80, "%s\n", debug_get_help(""));
else
- debug_console_printf_wrap(machine, 80, "%s\n", debug_get_help(param[0]));
+ m_console.printf_wrap(80, "%s\n", debug_get_help(param[0]));
}
@@ -688,20 +521,18 @@ static void execute_help(running_machine &machine, int ref, int params, const ch
execute_print - execute the print command
-------------------------------------------------*/
-static void execute_print(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_print(int ref, int params, const char *param[])
{
- UINT64 values[MAX_COMMAND_PARAMS];
- int i;
-
/* validate the other parameters */
- for (i = 0; i < params; i++)
- if (!debug_command_parameter_number(machine, param[i], &values[i]))
+ UINT64 values[MAX_COMMAND_PARAMS];
+ for (int i = 0; i < params; i++)
+ if (!validate_number_parameter(param[i], &values[i]))
return;
/* then print each one */
- for (i = 0; i < params; i++)
- debug_console_printf(machine, "%X", values[i]);
- debug_console_printf(machine, "\n");
+ for (int i = 0; i < params; i++)
+ m_console.printf("%X", values[i]);
+ m_console.printf("\n");
}
@@ -709,7 +540,7 @@ static void execute_print(running_machine &machine, int ref, int params, const c
mini_printf - safe printf to a buffer
-------------------------------------------------*/
-static int mini_printf(running_machine &machine, char *buffer, const char *format, int params, UINT64 *param)
+int debugger_commands::mini_printf(char *buffer, const char *format, int params, UINT64 *param)
{
const char *f = format;
char *p = buffer;
@@ -762,7 +593,7 @@ static int mini_printf(running_machine &machine, char *buffer, const char *forma
case 'x':
if (params == 0)
{
- debug_console_printf(machine, "Not enough parameters for format!\n");
+ m_console.printf("Not enough parameters for format!\n");
return 0;
}
if ((UINT32)(*param >> 32) != 0)
@@ -778,7 +609,7 @@ static int mini_printf(running_machine &machine, char *buffer, const char *forma
case 'd':
if (params == 0)
{
- debug_console_printf(machine, "Not enough parameters for format!\n");
+ m_console.printf("Not enough parameters for format!\n");
return 0;
}
p += sprintf(p, zerofill ? "%0*d" : "%*d", width, (UINT32)*param);
@@ -803,20 +634,18 @@ static int mini_printf(running_machine &machine, char *buffer, const char *forma
execute_printf - execute the printf command
-------------------------------------------------*/
-static void execute_printf(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_printf(int ref, int params, const char *param[])
{
- UINT64 values[MAX_COMMAND_PARAMS];
- char buffer[1024];
- int i;
-
/* validate the other parameters */
- for (i = 1; i < params; i++)
- if (!debug_command_parameter_number(machine, param[i], &values[i]))
+ UINT64 values[MAX_COMMAND_PARAMS];
+ for (int i = 1; i < params; i++)
+ if (!validate_number_parameter(param[i], &values[i]))
return;
/* then do a printf */
- if (mini_printf(machine, buffer, param[0], params - 1, &values[1]))
- debug_console_printf(machine, "%s\n", buffer);
+ char buffer[1024];
+ if (mini_printf(buffer, param[0], params - 1, &values[1]))
+ m_console.printf("%s\n", buffer);
}
@@ -824,20 +653,18 @@ static void execute_printf(running_machine &machine, int ref, int params, const
execute_logerror - execute the logerror command
-------------------------------------------------*/
-static void execute_logerror(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_logerror(int ref, int params, const char *param[])
{
- UINT64 values[MAX_COMMAND_PARAMS];
- char buffer[1024];
- int i;
-
/* validate the other parameters */
- for (i = 1; i < params; i++)
- if (!debug_command_parameter_number(machine, param[i], &values[i]))
+ UINT64 values[MAX_COMMAND_PARAMS];
+ for (int i = 1; i < params; i++)
+ if (!validate_number_parameter(param[i], &values[i]))
return;
/* then do a printf */
- if (mini_printf(machine, buffer, param[0], params - 1, &values[1]))
- machine.logerror("%s", buffer);
+ char buffer[1024];
+ if (mini_printf(buffer, param[0], params - 1, &values[1]))
+ m_machine.logerror("%s", buffer);
}
@@ -845,20 +672,18 @@ static void execute_logerror(running_machine &machine, int ref, int params, cons
execute_tracelog - execute the tracelog command
-------------------------------------------------*/
-static void execute_tracelog(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_tracelog(int ref, int params, const char *param[])
{
- UINT64 values[MAX_COMMAND_PARAMS];
- char buffer[1024];
- int i;
-
/* validate the other parameters */
- for (i = 1; i < params; i++)
- if (!debug_command_parameter_number(machine, param[i], &values[i]))
+ UINT64 values[MAX_COMMAND_PARAMS];
+ for (int i = 1; i < params; i++)
+ if (!validate_number_parameter(param[i], &values[i]))
return;
/* then do a printf */
- if (mini_printf(machine, buffer, param[0], params - 1, &values[1]))
- debug_cpu_get_visible_cpu(machine)->debug()->trace_printf("%s", buffer);
+ char buffer[1024];
+ if (mini_printf(buffer, param[0], params - 1, &values[1]))
+ m_cpu.get_visible_cpu()->debug()->trace_printf("%s", buffer);
}
@@ -866,10 +691,10 @@ static void execute_tracelog(running_machine &machine, int ref, int params, cons
execute_quit - execute the quit command
-------------------------------------------------*/
-static void execute_quit(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_quit(int ref, int params, const char *param[])
{
osd_printf_error("Exited via the debugger\n");
- machine.schedule_exit();
+ m_machine.schedule_exit();
}
@@ -877,10 +702,10 @@ static void execute_quit(running_machine &machine, int ref, int params, const ch
execute_do - execute the do command
-------------------------------------------------*/
-static void execute_do(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_do(int ref, int params, const char *param[])
{
UINT64 dummy;
- debug_command_parameter_number(machine, param[0], &dummy);
+ validate_number_parameter(param[0], &dummy);
}
@@ -888,15 +713,14 @@ static void execute_do(running_machine &machine, int ref, int params, const char
execute_step - execute the step command
-------------------------------------------------*/
-static void execute_step(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_step(int ref, int params, const char *param[])
{
+ /* if we have a parameter, use it */
UINT64 steps = 1;
-
- /* if we have a parameter, use it instead */
- if (!debug_command_parameter_number(machine, param[0], &steps))
+ if (!validate_number_parameter(param[0], &steps))
return;
- debug_cpu_get_visible_cpu(machine)->debug()->single_step(steps);
+ m_cpu.get_visible_cpu()->debug()->single_step(steps);
}
@@ -904,15 +728,14 @@ static void execute_step(running_machine &machine, int ref, int params, const ch
execute_over - execute the over command
-------------------------------------------------*/
-static void execute_over(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_over(int ref, int params, const char *param[])
{
+ /* if we have a parameter, use it */
UINT64 steps = 1;
-
- /* if we have a parameter, use it instead */
- if (!debug_command_parameter_number(machine, param[0], &steps))
+ if (!validate_number_parameter(param[0], &steps))
return;
- debug_cpu_get_visible_cpu(machine)->debug()->single_step_over(steps);
+ m_cpu.get_visible_cpu()->debug()->single_step_over(steps);
}
@@ -920,9 +743,9 @@ static void execute_over(running_machine &machine, int ref, int params, const ch
execute_out - execute the out command
-------------------------------------------------*/
-static void execute_out(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_out(int ref, int params, const char *param[])
{
- debug_cpu_get_visible_cpu(machine)->debug()->single_step_out();
+ m_cpu.get_visible_cpu()->debug()->single_step_out();
}
@@ -930,15 +753,15 @@ static void execute_out(running_machine &machine, int ref, int params, const cha
execute_go - execute the go command
-------------------------------------------------*/
-static void execute_go(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_go(int ref, int params, const char *param[])
{
UINT64 addr = ~0;
/* if we have a parameter, use it instead */
- if (!debug_command_parameter_number(machine, param[0], &addr))
+ if (!validate_number_parameter(param[0], &addr))
return;
- debug_cpu_get_visible_cpu(machine)->debug()->go(addr);
+ m_cpu.get_visible_cpu()->debug()->go(addr);
}
@@ -947,9 +770,9 @@ static void execute_go(running_machine &machine, int ref, int params, const char
command
-------------------------------------------------*/
-static void execute_go_vblank(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_go_vblank(int ref, int params, const char *param[])
{
- debug_cpu_get_visible_cpu(machine)->debug()->go_vblank();
+ m_cpu.get_visible_cpu()->debug()->go_vblank();
}
@@ -957,15 +780,15 @@ static void execute_go_vblank(running_machine &machine, int ref, int params, con
execute_go_interrupt - execute the goint command
-------------------------------------------------*/
-static void execute_go_interrupt(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_go_interrupt(int ref, int params, const char *param[])
{
UINT64 irqline = -1;
/* if we have a parameter, use it instead */
- if (!debug_command_parameter_number(machine, param[0], &irqline))
+ if (!validate_number_parameter(param[0], &irqline))
return;
- debug_cpu_get_visible_cpu(machine)->debug()->go_interrupt(irqline);
+ m_cpu.get_visible_cpu()->debug()->go_interrupt(irqline);
}
@@ -973,15 +796,15 @@ static void execute_go_interrupt(running_machine &machine, int ref, int params,
execute_go_time - execute the gtime command
-------------------------------------------------*/
-static void execute_go_time(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_go_time(int ref, int params, const char *param[])
{
UINT64 milliseconds = -1;
/* if we have a parameter, use it instead */
- if (!debug_command_parameter_number(machine, param[0], &milliseconds))
+ if (!validate_number_parameter(param[0], &milliseconds))
return;
- debug_cpu_get_visible_cpu(machine)->debug()->go_milliseconds(milliseconds);
+ m_cpu.get_visible_cpu()->debug()->go_milliseconds(milliseconds);
}
@@ -989,9 +812,9 @@ static void execute_go_time(running_machine &machine, int ref, int params, const
execute_next - execute the next command
-------------------------------------------------*/
-static void execute_next(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_next(int ref, int params, const char *param[])
{
- debug_cpu_get_visible_cpu(machine)->debug()->go_next_device();
+ m_cpu.get_visible_cpu()->debug()->go_next_device();
}
@@ -999,21 +822,21 @@ static void execute_next(running_machine &machine, int ref, int params, const ch
execute_focus - execute the focus command
-------------------------------------------------*/
-static void execute_focus(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_focus(int ref, int params, const char *param[])
{
/* validate params */
device_t *cpu;
- if (!debug_command_parameter_cpu(machine, param[0], &cpu))
+ if (!validate_cpu_parameter(param[0], &cpu))
return;
/* first clear the ignore flag on the focused CPU */
cpu->debug()->ignore(false);
/* then loop over CPUs and set the ignore flags on all other CPUs */
- for (device_execute_interface &exec : execute_interface_iterator(machine.root_device()))
+ for (device_execute_interface &exec : execute_interface_iterator(m_machine.root_device()))
if (&exec.device() != cpu)
exec.device().debug()->ignore(true);
- debug_console_printf(machine, "Now focused on CPU '%s'\n", cpu->tag());
+ m_console.printf("Now focused on CPU '%s'\n", cpu->tag());
}
@@ -1021,7 +844,7 @@ static void execute_focus(running_machine &machine, int ref, int params, const c
execute_ignore - execute the ignore command
-------------------------------------------------*/
-static void execute_ignore(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_ignore(int ref, int params, const char *param[])
{
/* if there are no parameters, dump the ignore list */
if (params == 0)
@@ -1029,7 +852,7 @@ static void execute_ignore(running_machine &machine, int ref, int params, const
std::string buffer;
/* loop over all executable devices */
- for (device_execute_interface &exec : execute_interface_iterator(machine.root_device()))
+ for (device_execute_interface &exec : execute_interface_iterator(m_machine.root_device()))
/* build up a comma-separated list */
if (!exec.device().debug()->observing())
@@ -1043,7 +866,7 @@ static void execute_ignore(running_machine &machine, int ref, int params, const
/* special message for none */
if (buffer.empty())
buffer = string_format("Not currently ignoring any devices");
- debug_console_printf(machine, "%s\n", buffer.c_str());
+ m_console.printf("%s\n", buffer.c_str());
}
/* otherwise clear the ignore flag on all requested CPUs */
@@ -1053,7 +876,7 @@ static void execute_ignore(running_machine &machine, int ref, int params, const
/* validate parameters */
for (int paramnum = 0; paramnum < params; paramnum++)
- if (!debug_command_parameter_cpu(machine, param[paramnum], &devicelist[paramnum]))
+ if (!validate_cpu_parameter(param[paramnum], &devicelist[paramnum]))
return;
/* set the ignore flags */
@@ -1061,7 +884,7 @@ static void execute_ignore(running_machine &machine, int ref, int params, const
{
/* make sure this isn't the last live CPU */
bool gotone = false;
- for (device_execute_interface &exec : execute_interface_iterator(machine.root_device()))
+ for (device_execute_interface &exec : execute_interface_iterator(m_machine.root_device()))
if (&exec.device() != devicelist[paramnum] && exec.device().debug()->observing())
{
gotone = true;
@@ -1069,12 +892,12 @@ static void execute_ignore(running_machine &machine, int ref, int params, const
}
if (!gotone)
{
- debug_console_printf(machine, "Can't ignore all devices!\n");
+ m_console.printf("Can't ignore all devices!\n");
return;
}
devicelist[paramnum]->debug()->ignore(true);
- debug_console_printf(machine, "Now ignoring device '%s'\n", devicelist[paramnum]->tag());
+ m_console.printf("Now ignoring device '%s'\n", devicelist[paramnum]->tag());
}
}
}
@@ -1084,7 +907,7 @@ static void execute_ignore(running_machine &machine, int ref, int params, const
execute_observe - execute the observe command
-------------------------------------------------*/
-static void execute_observe(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_observe(int ref, int params, const char *param[])
{
/* if there are no parameters, dump the ignore list */
if (params == 0)
@@ -1092,7 +915,7 @@ static void execute_observe(running_machine &machine, int ref, int params, const
std::string buffer;
/* loop over all executable devices */
- for (device_execute_interface &exec : execute_interface_iterator(machine.root_device()))
+ for (device_execute_interface &exec : execute_interface_iterator(m_machine.root_device()))
/* build up a comma-separated list */
if (exec.device().debug()->observing())
@@ -1106,7 +929,7 @@ static void execute_observe(running_machine &machine, int ref, int params, const
/* special message for none */
if (buffer.empty())
buffer = string_format("Not currently observing any devices");
- debug_console_printf(machine, "%s\n", buffer.c_str());
+ m_console.printf("%s\n", buffer.c_str());
}
/* otherwise set the ignore flag on all requested CPUs */
@@ -1116,14 +939,14 @@ static void execute_observe(running_machine &machine, int ref, int params, const
/* validate parameters */
for (int paramnum = 0; paramnum < params; paramnum++)
- if (!debug_command_parameter_cpu(machine, param[paramnum], &devicelist[paramnum]))
+ if (!validate_cpu_parameter(param[paramnum], &devicelist[paramnum]))
return;
/* clear the ignore flags */
for (int paramnum = 0; paramnum < params; paramnum++)
{
devicelist[paramnum]->debug()->ignore(false);
- debug_console_printf(machine, "Now observing device '%s'\n", devicelist[paramnum]->tag());
+ m_console.printf("Now observing device '%s'\n", devicelist[paramnum]->tag());
}
}
}
@@ -1133,23 +956,23 @@ static void execute_observe(running_machine &machine, int ref, int params, const
execute_comment - add a comment to a line
-------------------------------------------------*/
-static void execute_comment_add(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_comment_add(int ref, int params, const char *param[])
{
device_t *cpu;
UINT64 address;
/* param 1 is the address for the comment */
- if (!debug_command_parameter_number(machine, param[0], &address))
+ if (!validate_number_parameter(param[0], &address))
return;
/* CPU parameter is implicit */
- if (!debug_command_parameter_cpu(machine, nullptr, &cpu))
+ if (!validate_cpu_parameter(nullptr, &cpu))
return;
/* make sure param 2 exists */
if (strlen(param[1]) == 0)
{
- debug_console_printf(machine, "Error : comment text empty\n");
+ m_console.printf("Error : comment text empty\n");
return;
}
@@ -1163,17 +986,17 @@ static void execute_comment_add(running_machine &machine, int ref, int params, c
execute_comment_del - remove a comment from an addr
--------------------------------------------------------*/
-static void execute_comment_del(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_comment_del(int ref, int params, const char *param[])
{
device_t *cpu;
UINT64 address;
/* param 1 can either be a command or the address for the comment */
- if (!debug_command_parameter_number(machine, param[0], &address))
+ if (!validate_number_parameter(param[0], &address))
return;
/* CPU parameter is implicit */
- if (!debug_command_parameter_cpu(machine, nullptr, &cpu))
+ if (!validate_cpu_parameter(nullptr, &cpu))
return;
/* If it's a number, it must be an address */
@@ -1189,10 +1012,10 @@ static void execute_comment_del(running_machine &machine, int ref, int params, c
*
*/
-static void execute_comment_list(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_comment_list(int ref, int params, const char *param[])
{
- if (debug_comment_load(machine,false) == false)
- debug_console_printf(machine, "Error while parsing XML file\n");
+ if (!m_machine.debugger().cpu().comment_load(false))
+ m_console.printf("Error while parsing XML file\n");
}
/**
@@ -1201,22 +1024,22 @@ static void execute_comment_list(running_machine &machine, int ref, int params,
*
*/
-static void execute_comment_commit(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_comment_commit(int ref, int params, const char *param[])
{
- execute_comment_add(machine,ref,params,param);
- execute_comment_save(machine,ref,params,param);
+ execute_comment_add(ref, params, param);
+ execute_comment_save(ref, params, param);
}
/*-------------------------------------------------
execute_comment - add a comment to a line
-------------------------------------------------*/
-static void execute_comment_save(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_comment_save(int ref, int params, const char *param[])
{
- if (debug_comment_save(machine))
- debug_console_printf(machine, "Comment successfully saved\n");
+ if (m_cpu.comment_save())
+ m_console.printf("Comment successfully saved\n");
else
- debug_console_printf(machine, "Comment not saved\n");
+ m_console.printf("Comment not saved\n");
}
// TODO: add color hex editing capabilities for comments, see below for more info
@@ -1238,7 +1061,7 @@ static void execute_comment_save(running_machine &machine, int ref, int params,
command
-------------------------------------------------*/
-static void execute_bpset(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_bpset(int ref, int params, const char *param[])
{
device_t *cpu;
const char *action = nullptr;
@@ -1246,25 +1069,25 @@ static void execute_bpset(running_machine &machine, int ref, int params, const c
int bpnum;
/* CPU is implicit */
- if (!debug_command_parameter_cpu(machine, nullptr, &cpu))
+ if (!validate_cpu_parameter(nullptr, &cpu))
return;
/* param 1 is the address */
- if (!debug_command_parameter_number(machine, param[0], &address))
+ if (!validate_number_parameter(param[0], &address))
return;
/* param 2 is the condition */
parsed_expression condition(&cpu->debug()->symtable());
- if (!debug_command_parameter_expression(machine, param[1], condition))
+ if (!debug_command_parameter_expression(param[1], condition))
return;
/* param 3 is the action */
- if (!debug_command_parameter_command(machine, action = param[2]))
+ if (!debug_command_parameter_command(action = param[2]))
return;
/* set the breakpoint */
bpnum = cpu->debug()->breakpoint_set(address, (condition.is_empty()) ? nullptr : condition.original_string(), action);
- debug_console_printf(machine, "Breakpoint %X set\n", bpnum);
+ m_console.printf("Breakpoint %X set\n", bpnum);
}
@@ -1273,31 +1096,31 @@ static void execute_bpset(running_machine &machine, int ref, int params, const c
clear command
-------------------------------------------------*/
-static void execute_bpclear(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_bpclear(int ref, int params, const char *param[])
{
UINT64 bpindex;
/* if 0 parameters, clear all */
if (params == 0)
{
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
device.debug()->breakpoint_clear_all();
- debug_console_printf(machine, "Cleared all breakpoints\n");
+ m_console.printf("Cleared all breakpoints\n");
}
/* otherwise, clear the specific one */
- else if (!debug_command_parameter_number(machine, param[0], &bpindex))
+ else if (!validate_number_parameter(param[0], &bpindex))
return;
else
{
bool found = false;
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug()->breakpoint_clear(bpindex))
found = true;
if (found)
- debug_console_printf(machine, "Breakpoint %X cleared\n", (UINT32)bpindex);
+ m_console.printf("Breakpoint %X cleared\n", (UINT32)bpindex);
else
- debug_console_printf(machine, "Invalid breakpoint number %X\n", (UINT32)bpindex);
+ m_console.printf("Invalid breakpoint number %X\n", (UINT32)bpindex);
}
}
@@ -1307,34 +1130,34 @@ static void execute_bpclear(running_machine &machine, int ref, int params, const
disable/enable commands
-------------------------------------------------*/
-static void execute_bpdisenable(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_bpdisenable(int ref, int params, const char *param[])
{
UINT64 bpindex;
/* if 0 parameters, clear all */
if (params == 0)
{
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
device.debug()->breakpoint_enable_all(ref);
if (ref == 0)
- debug_console_printf(machine, "Disabled all breakpoints\n");
+ m_console.printf("Disabled all breakpoints\n");
else
- debug_console_printf(machine, "Enabled all breakpoints\n");
+ m_console.printf("Enabled all breakpoints\n");
}
/* otherwise, clear the specific one */
- else if (!debug_command_parameter_number(machine, param[0], &bpindex))
+ else if (!validate_number_parameter(param[0], &bpindex))
return;
else
{
bool found = false;
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug()->breakpoint_enable(bpindex, ref))
found = true;
if (found)
- debug_console_printf(machine, "Breakpoint %X %s\n", (UINT32)bpindex, ref ? "enabled" : "disabled");
+ m_console.printf("Breakpoint %X %s\n", (UINT32)bpindex, ref ? "enabled" : "disabled");
else
- debug_console_printf(machine, "Invalid breakpoint number %X\n", (UINT32)bpindex);
+ m_console.printf("Invalid breakpoint number %X\n", (UINT32)bpindex);
}
}
@@ -1344,16 +1167,16 @@ static void execute_bpdisenable(running_machine &machine, int ref, int params, c
command
-------------------------------------------------*/
-static void execute_bplist(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_bplist(int ref, int params, const char *param[])
{
int printed = 0;
std::string buffer;
/* loop over all CPUs */
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug()->breakpoint_first() != nullptr)
{
- debug_console_printf(machine, "Device '%s' breakpoints:\n", device.tag());
+ 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())
@@ -1363,13 +1186,13 @@ static void execute_bplist(running_machine &machine, int ref, int params, const
buffer.append(string_format(" if %s", bp->condition()));
if (std::string(bp->action()).compare("") != 0)
buffer.append(string_format(" do %s", bp->action()));
- debug_console_printf(machine, "%s\n", buffer.c_str());
+ m_console.printf("%s\n", buffer.c_str());
printed++;
}
}
if (printed == 0)
- debug_console_printf(machine, "No breakpoints currently installed\n");
+ m_console.printf("No breakpoints currently installed\n");
}
@@ -1378,7 +1201,7 @@ static void execute_bplist(running_machine &machine, int ref, int params, const
command
-------------------------------------------------*/
-static void execute_wpset(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_wpset(int ref, int params, const char *param[])
{
address_space *space;
const char *action = nullptr;
@@ -1387,15 +1210,15 @@ static void execute_wpset(running_machine &machine, int ref, int params, const c
int wpnum;
/* CPU is implicit */
- if (!debug_command_parameter_cpu_space(machine, nullptr, ref, space))
+ if (!validate_cpu_space_parameter(nullptr, ref, space))
return;
/* param 1 is the address */
- if (!debug_command_parameter_number(machine, param[0], &address))
+ if (!validate_number_parameter(param[0], &address))
return;
/* param 2 is the length */
- if (!debug_command_parameter_number(machine, param[1], &length))
+ if (!validate_number_parameter(param[1], &length))
return;
/* param 3 is the type */
@@ -1407,22 +1230,22 @@ static void execute_wpset(running_machine &machine, int ref, int params, const c
type = WATCHPOINT_READWRITE;
else
{
- debug_console_printf(machine, "Invalid watchpoint type: expected r, w, or rw\n");
+ m_console.printf("Invalid watchpoint type: expected r, w, or rw\n");
return;
}
/* param 4 is the condition */
parsed_expression condition(&space->device().debug()->symtable());
- if (!debug_command_parameter_expression(machine, param[3], condition))
+ if (!debug_command_parameter_expression(param[3], condition))
return;
/* param 5 is the action */
- if (!debug_command_parameter_command(machine, action = param[4]))
+ if (!debug_command_parameter_command(action = param[4]))
return;
/* set the watchpoint */
wpnum = space->device().debug()->watchpoint_set(*space, type, address, length, (condition.is_empty()) ? nullptr : condition.original_string(), action);
- debug_console_printf(machine, "Watchpoint %X set\n", wpnum);
+ m_console.printf("Watchpoint %X set\n", wpnum);
}
@@ -1431,31 +1254,31 @@ static void execute_wpset(running_machine &machine, int ref, int params, const c
clear command
-------------------------------------------------*/
-static void execute_wpclear(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_wpclear(int ref, int params, const char *param[])
{
UINT64 wpindex;
/* if 0 parameters, clear all */
if (params == 0)
{
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
device.debug()->watchpoint_clear_all();
- debug_console_printf(machine, "Cleared all watchpoints\n");
+ m_console.printf("Cleared all watchpoints\n");
}
/* otherwise, clear the specific one */
- else if (!debug_command_parameter_number(machine, param[0], &wpindex))
+ else if (!validate_number_parameter(param[0], &wpindex))
return;
else
{
bool found = false;
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug()->watchpoint_clear(wpindex))
found = true;
if (found)
- debug_console_printf(machine, "Watchpoint %X cleared\n", (UINT32)wpindex);
+ m_console.printf("Watchpoint %X cleared\n", (UINT32)wpindex);
else
- debug_console_printf(machine, "Invalid watchpoint number %X\n", (UINT32)wpindex);
+ m_console.printf("Invalid watchpoint number %X\n", (UINT32)wpindex);
}
}
@@ -1465,34 +1288,34 @@ static void execute_wpclear(running_machine &machine, int ref, int params, const
disable/enable commands
-------------------------------------------------*/
-static void execute_wpdisenable(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_wpdisenable(int ref, int params, const char *param[])
{
UINT64 wpindex;
/* if 0 parameters, clear all */
if (params == 0)
{
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
device.debug()->watchpoint_enable_all(ref);
if (ref == 0)
- debug_console_printf(machine, "Disabled all watchpoints\n");
+ m_console.printf("Disabled all watchpoints\n");
else
- debug_console_printf(machine, "Enabled all watchpoints\n");
+ m_console.printf("Enabled all watchpoints\n");
}
/* otherwise, clear the specific one */
- else if (!debug_command_parameter_number(machine, param[0], &wpindex))
+ else if (!validate_number_parameter(param[0], &wpindex))
return;
else
{
bool found = false;
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug()->watchpoint_enable(wpindex, ref))
found = true;
if (found)
- debug_console_printf(machine, "Watchpoint %X %s\n", (UINT32)wpindex, ref ? "enabled" : "disabled");
+ m_console.printf("Watchpoint %X %s\n", (UINT32)wpindex, ref ? "enabled" : "disabled");
else
- debug_console_printf(machine, "Invalid watchpoint number %X\n", (UINT32)wpindex);
+ m_console.printf("Invalid watchpoint number %X\n", (UINT32)wpindex);
}
}
@@ -1502,19 +1325,19 @@ static void execute_wpdisenable(running_machine &machine, int ref, int params, c
command
-------------------------------------------------*/
-static void execute_wplist(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_wplist(int ref, int params, const char *param[])
{
int printed = 0;
std::string buffer;
/* loop over all CPUs */
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; ++spacenum)
if (device.debug()->watchpoint_first(spacenum) != nullptr)
{
static const char *const types[] = { "unkn ", "read ", "write", "r/w " };
- debug_console_printf(machine, "Device '%s' %s space watchpoints:\n", device.tag(),
+ m_console.printf("Device '%s' %s space watchpoints:\n", device.tag(),
device.debug()->watchpoint_first(spacenum)->space().name());
/* loop over the watchpoints */
@@ -1528,13 +1351,13 @@ static void execute_wplist(running_machine &machine, int ref, int params, const
buffer.append(string_format(" if %s", wp->condition()));
if (std::string(wp->action()).compare("") != 0)
buffer.append(string_format(" do %s", wp->action()));
- debug_console_printf(machine, "%s\n", buffer.c_str());
+ m_console.printf("%s\n", buffer.c_str());
printed++;
}
}
if (printed == 0)
- debug_console_printf(machine, "No watchpoints currently installed\n");
+ m_console.printf("No watchpoints currently installed\n");
}
@@ -1543,28 +1366,28 @@ static void execute_wplist(running_machine &machine, int ref, int params, const
command
-------------------------------------------------*/
-static void execute_rpset(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_rpset(int ref, int params, const char *param[])
{
device_t *cpu;
const char *action = nullptr;
int bpnum;
/* CPU is implicit */
- if (!debug_command_parameter_cpu(machine, nullptr, &cpu))
+ if (!validate_cpu_parameter(nullptr, &cpu))
return;
/* param 1 is the condition */
parsed_expression condition(&cpu->debug()->symtable());
- if (!debug_command_parameter_expression(machine, param[0], condition))
+ if (!debug_command_parameter_expression(param[0], condition))
return;
/* param 2 is the action */
- if (!debug_command_parameter_command(machine, action = param[1]))
+ if (!debug_command_parameter_command(action = param[1]))
return;
/* set the breakpoint */
bpnum = cpu->debug()->registerpoint_set(condition.original_string(), action);
- debug_console_printf(machine, "Registerpoint %X set\n", bpnum);
+ m_console.printf("Registerpoint %X set\n", bpnum);
}
@@ -1573,31 +1396,31 @@ static void execute_rpset(running_machine &machine, int ref, int params, const c
clear command
-------------------------------------------------*/
-static void execute_rpclear(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_rpclear(int ref, int params, const char *param[])
{
UINT64 rpindex;
/* if 0 parameters, clear all */
if (params == 0)
{
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
device.debug()->registerpoint_clear_all();
- debug_console_printf(machine, "Cleared all registerpoints\n");
+ m_console.printf("Cleared all registerpoints\n");
}
/* otherwise, clear the specific one */
- else if (!debug_command_parameter_number(machine, param[0], &rpindex))
+ else if (!validate_number_parameter(param[0], &rpindex))
return;
else
{
bool found = false;
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug()->registerpoint_clear(rpindex))
found = true;
if (found)
- debug_console_printf(machine, "Registerpoint %X cleared\n", (UINT32)rpindex);
+ m_console.printf("Registerpoint %X cleared\n", (UINT32)rpindex);
else
- debug_console_printf(machine, "Invalid registerpoint number %X\n", (UINT32)rpindex);
+ m_console.printf("Invalid registerpoint number %X\n", (UINT32)rpindex);
}
}
@@ -1607,34 +1430,34 @@ static void execute_rpclear(running_machine &machine, int ref, int params, const
disable/enable commands
-------------------------------------------------*/
-static void execute_rpdisenable(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_rpdisenable(int ref, int params, const char *param[])
{
UINT64 rpindex;
/* if 0 parameters, clear all */
if (params == 0)
{
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
device.debug()->registerpoint_enable_all(ref);
if (ref == 0)
- debug_console_printf(machine, "Disabled all registerpoints\n");
+ m_console.printf("Disabled all registerpoints\n");
else
- debug_console_printf(machine, "Enabled all registeroints\n");
+ m_console.printf("Enabled all registeroints\n");
}
/* otherwise, clear the specific one */
- else if (!debug_command_parameter_number(machine, param[0], &rpindex))
+ else if (!validate_number_parameter(param[0], &rpindex))
return;
else
{
bool found = false;
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug()->registerpoint_enable(rpindex, ref))
found = true;
if (found)
- debug_console_printf(machine, "Registerpoint %X %s\n", (UINT32)rpindex, ref ? "enabled" : "disabled");
+ m_console.printf("Registerpoint %X %s\n", (UINT32)rpindex, ref ? "enabled" : "disabled");
else
- debug_console_printf(machine, "Invalid registerpoint number %X\n", (UINT32)rpindex);
+ m_console.printf("Invalid registerpoint number %X\n", (UINT32)rpindex);
}
}
@@ -1644,16 +1467,16 @@ static void execute_rpdisenable(running_machine &machine, int ref, int params, c
command
-------------------------------------------------*/
-static void execute_rplist(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_rplist(int ref, int params, const char *param[])
{
int printed = 0;
std::string buffer;
/* loop over all CPUs */
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug()->registerpoint_first() != nullptr)
{
- debug_console_printf(machine, "Device '%s' registerpoints:\n", device.tag());
+ 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())
@@ -1661,13 +1484,13 @@ static void execute_rplist(running_machine &machine, int ref, int params, const
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()));
- debug_console_printf(machine, "%s\n", buffer.c_str());
+ m_console.printf("%s\n", buffer.c_str());
printed++;
}
}
if (printed == 0)
- debug_console_printf(machine, "No registerpoints currently installed\n");
+ m_console.printf("No registerpoints currently installed\n");
}
@@ -1676,7 +1499,7 @@ static void execute_rplist(running_machine &machine, int ref, int params, const
command
-------------------------------------------------*/
-static void execute_hotspot(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_hotspot(int ref, int params, const char *param[])
{
/* if no params, and there are live hotspots, clear them */
if (params == 0)
@@ -1684,11 +1507,11 @@ static void execute_hotspot(running_machine &machine, int ref, int params, const
bool cleared = false;
/* loop over CPUs and find live spots */
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug()->hotspot_tracking_enabled())
{
device.debug()->hotspot_track(0, 0);
- debug_console_printf(machine, "Cleared hotspot tracking on CPU '%s'\n", device.tag());
+ m_console.printf("Cleared hotspot tracking on CPU '%s'\n", device.tag());
cleared = true;
}
@@ -1699,18 +1522,18 @@ static void execute_hotspot(running_machine &machine, int ref, int params, const
/* extract parameters */
device_t *device = nullptr;
- if (!debug_command_parameter_cpu(machine, (params > 0) ? param[0] : nullptr, &device))
+ if (!validate_cpu_parameter((params > 0) ? param[0] : nullptr, &device))
return;
UINT64 count = 64;
- if (!debug_command_parameter_number(machine, param[1], &count))
+ if (!validate_number_parameter(param[1], &count))
return;
UINT64 threshhold = 250;
- if (!debug_command_parameter_number(machine, param[2], &threshhold))
+ if (!validate_number_parameter(param[2], &threshhold))
return;
/* attempt to install */
device->debug()->hotspot_track(count, threshhold);
- debug_console_printf(machine, "Now tracking hotspots on CPU '%s' using %d slots with a threshold of %d\n", device->tag(), (int)count, (int)threshhold);
+ m_console.printf("Now tracking hotspots on CPU '%s' using %d slots with a threshold of %d\n", device->tag(), (int)count, (int)threshhold);
}
@@ -1718,11 +1541,11 @@ static void execute_hotspot(running_machine &machine, int ref, int params, const
execute_statesave - execute the statesave command
-------------------------------------------------*/
-static void execute_statesave(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_statesave(int ref, int params, const char *param[])
{
std::string filename(param[0]);
- machine.immediate_save(filename.c_str());
- debug_console_printf(machine, "State save attempted. Please refer to window message popup for results.\n");
+ m_machine.immediate_save(filename.c_str());
+ m_console.printf("State save attempted. Please refer to window message popup for results.\n");
}
@@ -1730,18 +1553,18 @@ static void execute_statesave(running_machine &machine, int ref, int params, con
execute_stateload - execute the stateload command
-------------------------------------------------*/
-static void execute_stateload(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_stateload(int ref, int params, const char *param[])
{
std::string filename(param[0]);
- machine.immediate_load(filename.c_str());
+ m_machine.immediate_load(filename.c_str());
// Clear all PC & memory tracks
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
{
device.debug()->track_pc_data_clear();
device.debug()->track_mem_data_clear();
}
- debug_console_printf(machine, "State load attempted. Please refer to window message popup for results.\n");
+ m_console.printf("State load attempted. Please refer to window message popup for results.\n");
}
@@ -1749,7 +1572,7 @@ static void execute_stateload(running_machine &machine, int ref, int params, con
execute_save - execute the save command
-------------------------------------------------*/
-static void execute_save(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_save(int ref, int params, const char *param[])
{
UINT64 offset, endoffset, length;
address_space *space;
@@ -1757,11 +1580,11 @@ static void execute_save(running_machine &machine, int ref, int params, const ch
UINT64 i;
/* validate parameters */
- if (!debug_command_parameter_number(machine, param[1], &offset))
+ if (!validate_number_parameter(param[1], &offset))
return;
- if (!debug_command_parameter_number(machine, param[2], &length))
+ if (!validate_number_parameter(param[2], &length))
return;
- if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : nullptr, ref, space))
+ if (!validate_cpu_space_parameter((params > 3) ? param[3] : nullptr, ref, space))
return;
/* determine the addresses to write */
@@ -1772,20 +1595,20 @@ static void execute_save(running_machine &machine, int ref, int params, const ch
f = fopen(param[0], "wb");
if (!f)
{
- debug_console_printf(machine, "Error opening file '%s'\n", param[0]);
+ m_console.printf("Error opening file '%s'\n", param[0]);
return;
}
/* now write the data out */
for (i = offset; i <= endoffset; i++)
{
- UINT8 byte = debug_read_byte(*space, i, TRUE);
+ UINT8 byte = m_cpu.read_byte(*space, i, TRUE);
fwrite(&byte, 1, 1, f);
}
/* close the file */
fclose(f);
- debug_console_printf(machine, "Data saved successfully\n");
+ m_console.printf("Data saved successfully\n");
}
@@ -1793,7 +1616,7 @@ static void execute_save(running_machine &machine, int ref, int params, const ch
execute_load - execute the load command
-------------------------------------------------*/
-static void execute_load(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_load(int ref, int params, const char *param[])
{
UINT64 offset, endoffset, length;
address_space *space;
@@ -1801,11 +1624,11 @@ static void execute_load(running_machine &machine, int ref, int params, const ch
UINT64 i;
/* validate parameters */
- if (!debug_command_parameter_number(machine, param[1], &offset))
+ if (!validate_number_parameter(param[1], &offset))
return;
- if (!debug_command_parameter_number(machine, param[2], &length))
+ if (!validate_number_parameter(param[2], &length))
return;
- if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : nullptr, ref, space))
+ if (!validate_cpu_space_parameter((params > 3) ? param[3] : nullptr, ref, space))
return;
/* determine the addresses to read */
@@ -1816,7 +1639,7 @@ static void execute_load(running_machine &machine, int ref, int params, const ch
f = fopen(param[0], "rb");
if (!f)
{
- debug_console_printf(machine, "Error opening file '%s'\n", param[0]);
+ m_console.printf("Error opening file '%s'\n", param[0]);
return;
}
@@ -1828,14 +1651,14 @@ static void execute_load(running_machine &machine, int ref, int params, const ch
/* check if end of file has been reached and stop loading if it has */
if (feof(f))
break;
- debug_write_byte(*space, i, byte, TRUE);
+ m_cpu.write_byte(*space, i, byte, true);
}
/* close the file */
fclose(f);
if ( i == offset)
- debug_console_printf(machine, "Length specified too large, load failed\n");
+ m_console.printf("Length specified too large, load failed\n");
else
- debug_console_printf(machine, "Data loaded successfully to memory : 0x%X to 0x%X\n", offset, i-1);
+ m_console.printf("Data loaded successfully to memory : 0x%X to 0x%X\n", offset, i-1);
}
@@ -1843,23 +1666,27 @@ static void execute_load(running_machine &machine, int ref, int params, const ch
execute_dump - execute the dump command
-------------------------------------------------*/
-static void execute_dump(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_dump(int ref, int params, const char *param[])
{
- UINT64 offset, endoffset, length, width = 0, ascii = 1;
- address_space *space;
- FILE *f;
- UINT64 i, j;
-
/* validate parameters */
- if (!debug_command_parameter_number(machine, param[1], &offset))
+ UINT64 offset;
+ if (!validate_number_parameter(param[1], &offset))
return;
- if (!debug_command_parameter_number(machine, param[2], &length))
+
+ UINT64 length;
+ if (!validate_number_parameter(param[2], &length))
return;
- if (!debug_command_parameter_number(machine, param[3], &width))
+
+ UINT64 width = 0;
+ if (!validate_number_parameter(param[3], &width))
return;
- if (!debug_command_parameter_number(machine, param[4], &ascii))
+
+ UINT64 ascii = 1;
+ if (!validate_number_parameter(param[4], &ascii))
return;
- if (!debug_command_parameter_cpu_space(machine, (params > 5) ? param[5] : nullptr, ref, space))
+
+ address_space *space;
+ if (!validate_cpu_space_parameter((params > 5) ? param[5] : nullptr, ref, space))
return;
/* further validation */
@@ -1869,24 +1696,24 @@ static void execute_dump(running_machine &machine, int ref, int params, const ch
width = space->address_to_byte(1);
if (width != 1 && width != 2 && width != 4 && width != 8)
{
- debug_console_printf(machine, "Invalid width! (must be 1,2,4 or 8)\n");
+ m_console.printf("Invalid width! (must be 1,2,4 or 8)\n");
return;
}
- endoffset = space->address_to_byte(offset + length - 1) & space->bytemask();
+ UINT64 endoffset = space->address_to_byte(offset + length - 1) & space->bytemask();
offset = space->address_to_byte(offset) & space->bytemask();
/* open the file */
- f = fopen(param[0], "w");
+ FILE* f = fopen(param[0], "w");
if (!f)
{
- debug_console_printf(machine, "Error opening file '%s'\n", param[0]);
+ m_console.printf("Error opening file '%s'\n", param[0]);
return;
}
/* now write the data out */
util::ovectorstream output;
output.reserve(200);
- for (i = offset; i <= endoffset; i += 16)
+ for (UINT64 i = offset; i <= endoffset; i += 16)
{
output.clear();
output.rdbuf()->clear();
@@ -1895,18 +1722,20 @@ static void execute_dump(running_machine &machine, int ref, int params, const ch
util::stream_format(output, "%0*X: ", space->logaddrchars(), (UINT32)space->byte_to_address(i));
/* print the bytes */
- for (j = 0; j < 16; j += width)
+ for (UINT64 j = 0; j < 16; j += width)
{
if (i + j <= endoffset)
{
offs_t curaddr = i + j;
- if (debug_cpu_translate(*space, TRANSLATE_READ_DEBUG, &curaddr))
+ if (m_cpu.translate(*space, TRANSLATE_READ_DEBUG, &curaddr))
{
- UINT64 value = debug_read_memory(*space, i + j, width, TRUE);
+ UINT64 value = m_cpu.read_memory(*space, i + j, width, TRUE);
util::stream_format(output, " %0*X", width * 2, value);
}
else
+ {
util::stream_format(output, " %.*s", width * 2, "****************");
+ }
}
else
util::stream_format(output, " %*s", width * 2, "");
@@ -1916,16 +1745,18 @@ static void execute_dump(running_machine &machine, int ref, int params, const ch
if (ascii)
{
util::stream_format(output, " ");
- for (j = 0; j < 16 && (i + j) <= endoffset; j++)
+ for (UINT64 j = 0; j < 16 && (i + j) <= endoffset; j++)
{
offs_t curaddr = i + j;
- if (debug_cpu_translate(*space, TRANSLATE_READ_DEBUG, &curaddr))
+ if (m_cpu.translate(*space, TRANSLATE_READ_DEBUG, &curaddr))
{
- UINT8 byte = debug_read_byte(*space, i + j, TRUE);
+ UINT8 byte = m_cpu.read_byte(*space, i + j, TRUE);
util::stream_format(output, "%c", (byte >= 32 && byte < 127) ? byte : '.');
}
else
+ {
util::stream_format(output, " ");
+ }
}
}
@@ -1936,7 +1767,7 @@ static void execute_dump(running_machine &machine, int ref, int params, const ch
/* close the file */
fclose(f);
- debug_console_printf(machine, "Data dumped successfully\n");
+ m_console.printf("Data dumped successfully\n");
}
@@ -1944,7 +1775,7 @@ static void execute_dump(running_machine &machine, int ref, int params, const ch
execute_cheatinit - initialize the cheat system
-------------------------------------------------*/
-static void execute_cheatinit(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_cheatinit(int ref, int params, const char *param[])
{
UINT64 offset, length = 0, real_length = 0;
address_space *space;
@@ -1957,46 +1788,46 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con
memset(cheat_region, 0, sizeof(cheat_region));
/* validate parameters */
- if (!debug_command_parameter_cpu_space(machine, (params > 3) ? param[3] : nullptr, AS_PROGRAM, space))
+ if (!validate_cpu_space_parameter((params > 3) ? param[3] : nullptr, AS_PROGRAM, space))
return;
if (ref == 0)
{
- cheat.width = 1;
- cheat.signed_cheat = FALSE;
- cheat.swapped_cheat = FALSE;
+ m_cheat.width = 1;
+ m_cheat.signed_cheat = FALSE;
+ m_cheat.swapped_cheat = FALSE;
if (params > 0)
{
char *srtpnt = (char*)param[0];
if (*srtpnt == 's')
- cheat.signed_cheat = TRUE;
+ m_cheat.signed_cheat = TRUE;
else if (*srtpnt == 'u')
- cheat.signed_cheat = FALSE;
+ m_cheat.signed_cheat = FALSE;
else
{
- debug_console_printf(machine, "Invalid sign: expected s or u\n");
+ m_console.printf("Invalid sign: expected s or u\n");
return;
}
if (*(++srtpnt) == 'b')
- cheat.width = 1;
+ m_cheat.width = 1;
else if (*srtpnt == 'w')
- cheat.width = 2;
+ m_cheat.width = 2;
else if (*srtpnt == 'd')
- cheat.width = 4;
+ m_cheat.width = 4;
else if (*srtpnt == 'q')
- cheat.width = 8;
+ m_cheat.width = 8;
else
{
- debug_console_printf(machine, "Invalid width: expected b, w, d or q\n");
+ m_console.printf("Invalid width: expected b, w, d or q\n");
return;
}
if (*(++srtpnt) == 's')
- cheat.swapped_cheat = TRUE;
+ m_cheat.swapped_cheat = TRUE;
else
- cheat.swapped_cheat = FALSE;
+ m_cheat.swapped_cheat = FALSE;
}
}
@@ -2023,9 +1854,9 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con
else
{
/* validate parameters */
- if (!debug_command_parameter_number(machine, param[(ref == 0) ? 1 : 0], &offset))
+ if (!validate_number_parameter(param[(ref == 0) ? 1 : 0], &offset))
return;
- if (!debug_command_parameter_number(machine, param[(ref == 0) ? 2 : 1], &length))
+ if (!validate_number_parameter(param[(ref == 0) ? 2 : 1], &length))
return;
/* force region to the specified range */
@@ -2039,57 +1870,57 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con
/* determine the writable extent of each region in total */
for (i = 0; i < region_count; i++)
if (!cheat_region[i].disabled)
- for (curaddr = cheat_region[i].offset; curaddr <= cheat_region[i].endoffset; curaddr += cheat.width)
+ for (curaddr = cheat_region[i].offset; curaddr <= cheat_region[i].endoffset; curaddr += m_cheat.width)
if (cheat_address_is_valid(*space, curaddr))
real_length++;
if (real_length == 0)
{
- debug_console_printf(machine, "No writable bytes found in this area\n");
+ m_console.printf("No writable bytes found in this area\n");
return;
}
if (ref == 0)
{
/* initialize new cheat system */
- cheat.cheatmap.resize(real_length);
- cheat.undo = 0;
- cheat.cpu[0] = (params > 3) ? *param[3] : '0';
+ m_cheat.cheatmap.resize(real_length);
+ m_cheat.undo = 0;
+ m_cheat.cpu[0] = (params > 3) ? *param[3] : '0';
}
else
{
/* add range to cheat system */
- if (cheat.cpu[0] == 0)
+ if (m_cheat.cpu[0] == 0)
{
- debug_console_printf(machine, "Use cheatinit before cheatrange\n");
+ m_console.printf("Use cheatinit before cheatrange\n");
return;
}
- if (!debug_command_parameter_cpu_space(machine, cheat.cpu, AS_PROGRAM, space))
+ if (!validate_cpu_space_parameter(m_cheat.cpu, AS_PROGRAM, space))
return;
- active_cheat = cheat.cheatmap.size();
- cheat.cheatmap.resize(cheat.cheatmap.size() + real_length);
+ active_cheat = m_cheat.cheatmap.size();
+ m_cheat.cheatmap.resize(m_cheat.cheatmap.size() + real_length);
}
/* initialize cheatmap in the selected space */
for (i = 0; i < region_count; i++)
if (!cheat_region[i].disabled)
- for (curaddr = cheat_region[i].offset; curaddr <= cheat_region[i].endoffset; curaddr += cheat.width)
+ for (curaddr = cheat_region[i].offset; curaddr <= cheat_region[i].endoffset; curaddr += m_cheat.width)
if (cheat_address_is_valid(*space, curaddr))
{
- cheat.cheatmap[active_cheat].previous_value = cheat_read_extended(&cheat, *space, curaddr);
- cheat.cheatmap[active_cheat].first_value = cheat.cheatmap[active_cheat].previous_value;
- cheat.cheatmap[active_cheat].offset = curaddr;
- cheat.cheatmap[active_cheat].state = 1;
- cheat.cheatmap[active_cheat].undo = 0;
+ m_cheat.cheatmap[active_cheat].previous_value = cheat_read_extended(&m_cheat, *space, curaddr);
+ m_cheat.cheatmap[active_cheat].first_value = m_cheat.cheatmap[active_cheat].previous_value;
+ m_cheat.cheatmap[active_cheat].offset = curaddr;
+ m_cheat.cheatmap[active_cheat].state = 1;
+ m_cheat.cheatmap[active_cheat].undo = 0;
active_cheat++;
}
/* give a detailed init message to avoid searches being mistakingly carried out on the wrong CPU */
device_t *cpu = nullptr;
- debug_command_parameter_cpu(machine, cheat.cpu, &cpu);
- debug_console_printf(machine, "%u cheat initialized for CPU index %s ( aka %s )\n", active_cheat, cheat.cpu, cpu->tag());
+ validate_cpu_parameter(m_cheat.cpu, &cpu);
+ m_console.printf("%u cheat initialized for CPU index %s ( aka %s )\n", active_cheat, m_cheat.cpu, cpu->tag());
}
@@ -2097,7 +1928,7 @@ static void execute_cheatinit(running_machine &machine, int ref, int params, con
execute_cheatnext - execute the search
-------------------------------------------------*/
-static void execute_cheatnext(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_cheatnext(int ref, int params, const char *param[])
{
address_space *space;
UINT64 cheatindex;
@@ -2123,18 +1954,18 @@ static void execute_cheatnext(running_machine &machine, int ref, int params, con
CHEAT_CHANGEDBY
};
- if (cheat.cpu[0] == 0)
+ if (m_cheat.cpu[0] == 0)
{
- debug_console_printf(machine, "Use cheatinit before cheatnext\n");
+ m_console.printf("Use cheatinit before cheatnext\n");
return;
}
- if (!debug_command_parameter_cpu_space(machine, cheat.cpu, AS_PROGRAM, space))
+ if (!validate_cpu_space_parameter(m_cheat.cpu, AS_PROGRAM, space))
return;
- if (params > 1 && !debug_command_parameter_number(machine, param[1], &comp_value))
+ if (params > 1 && !validate_number_parameter(param[1], &comp_value))
return;
- comp_value = cheat_sign_extend(&cheat, comp_value);
+ comp_value = cheat_sign_extend(&m_cheat, comp_value);
/* decode contidion */
if (!strcmp(param[0], "all"))
@@ -2159,18 +1990,18 @@ static void execute_cheatnext(running_machine &machine, int ref, int params, con
condition = CHEAT_CHANGEDBY;
else
{
- debug_console_printf(machine, "Invalid condition type\n");
+ m_console.printf("Invalid condition type\n");
return;
}
- cheat.undo++;
+ m_cheat.undo++;
/* execute the search */
- for (cheatindex = 0; cheatindex < cheat.cheatmap.size(); cheatindex += 1)
- if (cheat.cheatmap[cheatindex].state == 1)
+ for (cheatindex = 0; cheatindex < m_cheat.cheatmap.size(); cheatindex += 1)
+ if (m_cheat.cheatmap[cheatindex].state == 1)
{
- UINT64 cheat_value = cheat_read_extended(&cheat, *space, cheat.cheatmap[cheatindex].offset);
- UINT64 comp_byte = (ref == 0) ? cheat.cheatmap[cheatindex].previous_value : cheat.cheatmap[cheatindex].first_value;
+ UINT64 cheat_value = cheat_read_extended(&m_cheat, *space, m_cheat.cheatmap[cheatindex].offset);
+ UINT64 comp_byte = (ref == 0) ? m_cheat.cheatmap[cheatindex].previous_value : m_cheat.cheatmap[cheatindex].first_value;
UINT8 disable_byte = FALSE;
switch (condition)
@@ -2195,28 +2026,28 @@ static void execute_cheatnext(running_machine &machine, int ref, int params, con
break;
case CHEAT_DECREASE:
- if (cheat.signed_cheat)
+ if (m_cheat.signed_cheat)
disable_byte = ((INT64)cheat_value >= (INT64)comp_byte);
else
disable_byte = ((UINT64)cheat_value >= (UINT64)comp_byte);
break;
case CHEAT_INCREASE:
- if (cheat.signed_cheat)
+ if (m_cheat.signed_cheat)
disable_byte = ((INT64)cheat_value <= (INT64)comp_byte);
else
disable_byte = ((UINT64)cheat_value <= (UINT64)comp_byte);
break;
case CHEAT_DECREASE_OR_EQUAL:
- if (cheat.signed_cheat)
+ if (m_cheat.signed_cheat)
disable_byte = ((INT64)cheat_value > (INT64)comp_byte);
else
disable_byte = ((UINT64)cheat_value > (UINT64)comp_byte);
break;
case CHEAT_INCREASE_OR_EQUAL:
- if (cheat.signed_cheat)
+ if (m_cheat.signed_cheat)
disable_byte = ((INT64)cheat_value < (INT64)comp_byte);
else
disable_byte = ((UINT64)cheat_value < (UINT64)comp_byte);
@@ -2231,14 +2062,14 @@ static void execute_cheatnext(running_machine &machine, int ref, int params, con
break;
case CHEAT_SMALLEROF:
- if (cheat.signed_cheat)
+ if (m_cheat.signed_cheat)
disable_byte = ((INT64)cheat_value >= (INT64)comp_value);
else
disable_byte = ((UINT64)cheat_value >= (UINT64)comp_value);
break;
case CHEAT_GREATEROF:
- if (cheat.signed_cheat)
+ if (m_cheat.signed_cheat)
disable_byte = ((INT64)cheat_value <= (INT64)comp_value);
else
disable_byte = ((UINT64)cheat_value <= (UINT64)comp_value);
@@ -2253,20 +2084,20 @@ static void execute_cheatnext(running_machine &machine, int ref, int params, con
if (disable_byte)
{
- cheat.cheatmap[cheatindex].state = 0;
- cheat.cheatmap[cheatindex].undo = cheat.undo;
+ m_cheat.cheatmap[cheatindex].state = 0;
+ m_cheat.cheatmap[cheatindex].undo = m_cheat.undo;
}
else
active_cheat++;
/* update previous value */
- cheat.cheatmap[cheatindex].previous_value = cheat_value;
+ m_cheat.cheatmap[cheatindex].previous_value = cheat_value;
}
if (active_cheat <= 5)
- execute_cheatlist(machine, 0, 0, nullptr);
+ execute_cheatlist(0, 0, nullptr);
- debug_console_printf(machine, "%u cheats found\n", active_cheat);
+ m_console.printf("%u cheats found\n", active_cheat);
}
@@ -2274,7 +2105,7 @@ static void execute_cheatnext(running_machine &machine, int ref, int params, con
execute_cheatlist - show a list of active cheat
-------------------------------------------------*/
-static void execute_cheatlist(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_cheatlist(int ref, int params, const char *param[])
{
char spaceletter, sizeletter;
address_space *space;
@@ -2284,10 +2115,10 @@ static void execute_cheatlist(running_machine &machine, int ref, int params, con
UINT64 sizemask;
FILE *f = nullptr;
- if (!debug_command_parameter_cpu_space(machine, cheat.cpu, AS_PROGRAM, space))
+ if (!validate_cpu_space_parameter(m_cheat.cpu, AS_PROGRAM, space))
return;
- if (!debug_command_parameter_cpu(machine, cheat.cpu, &cpu))
+ if (!validate_cpu_parameter(m_cheat.cpu, &cpu))
return;
if (params > 0)
@@ -2301,7 +2132,7 @@ static void execute_cheatlist(running_machine &machine, int ref, int params, con
case AS_IO: spaceletter = 'i'; break;
}
- switch (cheat.width)
+ switch (m_cheat.width)
{
default:
case 1: sizeletter = 'b'; sizemask = 0xff; break;
@@ -2312,12 +2143,12 @@ static void execute_cheatlist(running_machine &machine, int ref, int params, con
/* write the cheat list */
util::ovectorstream output;
- for (cheatindex = 0; cheatindex < cheat.cheatmap.size(); cheatindex += 1)
+ for (cheatindex = 0; cheatindex < m_cheat.cheatmap.size(); cheatindex += 1)
{
- if (cheat.cheatmap[cheatindex].state == 1)
+ if (m_cheat.cheatmap[cheatindex].state == 1)
{
- UINT64 value = cheat_byte_swap(&cheat, cheat_read_extended(&cheat, *space, cheat.cheatmap[cheatindex].offset)) & sizemask;
- offs_t address = space->byte_to_address(cheat.cheatmap[cheatindex].offset);
+ UINT64 value = cheat_byte_swap(&m_cheat, cheat_read_extended(&m_cheat, *space, m_cheat.cheatmap[cheatindex].offset)) & sizemask;
+ offs_t address = space->byte_to_address(m_cheat.cheatmap[cheatindex].offset);
if (params > 0)
{
@@ -2331,18 +2162,18 @@ static void execute_cheatlist(running_machine &machine, int ref, int params, con
" <action>%s.p%c%c@%0*X=%0*X</action>\n"
" </script>\n"
" </cheat>\n\n",
- active_cheat, space->logaddrchars(), address, cheat.width * 2, value,
- cpu->tag(), spaceletter, sizeletter, space->logaddrchars(), address, cheat.width * 2, cheat_byte_swap(&cheat, cheat.cheatmap[cheatindex].first_value) & sizemask);
+ active_cheat, space->logaddrchars(), address, m_cheat.width * 2, value,
+ cpu->tag(), spaceletter, sizeletter, space->logaddrchars(), address, m_cheat.width * 2, cheat_byte_swap(&m_cheat, m_cheat.cheatmap[cheatindex].first_value) & sizemask);
auto const &text(output.vec());
fprintf(f, "%.*s", int(unsigned(text.size())), &text[0]);
}
else
{
- debug_console_printf(
- machine, "Address=%0*X Start=%0*X Current=%0*X\n",
+ m_console.printf(
+ "Address=%0*X Start=%0*X Current=%0*X\n",
space->logaddrchars(), address,
- cheat.width * 2, cheat_byte_swap(&cheat, cheat.cheatmap[cheatindex].first_value) & sizemask,
- cheat.width * 2, value);
+ m_cheat.width * 2, cheat_byte_swap(&m_cheat, m_cheat.cheatmap[cheatindex].first_value) & sizemask,
+ m_cheat.width * 2, value);
}
}
}
@@ -2355,28 +2186,28 @@ static void execute_cheatlist(running_machine &machine, int ref, int params, con
execute_cheatundo - undo the last search
-------------------------------------------------*/
-static void execute_cheatundo(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_cheatundo(int ref, int params, const char *param[])
{
UINT64 cheatindex;
UINT32 undo_count = 0;
- if (cheat.undo > 0)
+ if (m_cheat.undo > 0)
{
- for (cheatindex = 0; cheatindex < cheat.cheatmap.size(); cheatindex += 1)
+ for (cheatindex = 0; cheatindex < m_cheat.cheatmap.size(); cheatindex += 1)
{
- if (cheat.cheatmap[cheatindex].undo == cheat.undo)
+ if (m_cheat.cheatmap[cheatindex].undo == m_cheat.undo)
{
- cheat.cheatmap[cheatindex].state = 1;
- cheat.cheatmap[cheatindex].undo = 0;
+ m_cheat.cheatmap[cheatindex].state = 1;
+ m_cheat.cheatmap[cheatindex].undo = 0;
undo_count++;
}
}
- cheat.undo--;
- debug_console_printf(machine, "%u cheat reactivated\n", undo_count);
+ m_cheat.undo--;
+ m_console.printf("%u cheat reactivated\n", undo_count);
}
else
- debug_console_printf(machine, "Maximum undo reached\n");
+ m_console.printf("Maximum undo reached\n");
}
@@ -2384,7 +2215,7 @@ static void execute_cheatundo(running_machine &machine, int ref, int params, con
execute_find - execute the find command
-------------------------------------------------*/
-static void execute_find(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_find(int ref, int params, const char *param[])
{
UINT64 offset, endoffset, length;
address_space *space;
@@ -2396,11 +2227,11 @@ static void execute_find(running_machine &machine, int ref, int params, const ch
int j;
/* validate parameters */
- if (!debug_command_parameter_number(machine, param[0], &offset))
+ if (!validate_number_parameter(param[0], &offset))
return;
- if (!debug_command_parameter_number(machine, param[1], &length))
+ if (!validate_number_parameter(param[1], &length))
return;
- if (!debug_command_parameter_cpu_space(machine, nullptr, ref, space))
+ if (!validate_cpu_space_parameter(nullptr, ref, space))
return;
/* further validation */
@@ -2441,7 +2272,7 @@ static void execute_find(running_machine &machine, int ref, int params, const ch
data_size[data_count++] |= 0x10;
/* otherwise, validate as a number */
- else if (!debug_command_parameter_number(machine, pdata, &data_to_find[data_count++]))
+ else if (!validate_number_parameter(pdata, &data_to_find[data_count++]))
return;
}
}
@@ -2457,10 +2288,10 @@ static void execute_find(running_machine &machine, int ref, int params, const ch
{
switch (data_size[j])
{
- case 1: match = ((UINT8)debug_read_byte(*space, i + suboffset, TRUE) == (UINT8)data_to_find[j]); break;
- case 2: match = ((UINT16)debug_read_word(*space, i + suboffset, TRUE) == (UINT16)data_to_find[j]); break;
- case 4: match = ((UINT32)debug_read_dword(*space, i + suboffset, TRUE) == (UINT32)data_to_find[j]); break;
- case 8: match = ((UINT64)debug_read_qword(*space, i + suboffset, TRUE) == (UINT64)data_to_find[j]); break;
+ case 1: match = ((UINT8)m_cpu.read_byte(*space, i + suboffset, TRUE) == (UINT8)data_to_find[j]); break;
+ case 2: match = ((UINT16)m_cpu.read_word(*space, i + suboffset, TRUE) == (UINT16)data_to_find[j]); break;
+ case 4: match = ((UINT32)m_cpu.read_dword(*space, i + suboffset, TRUE) == (UINT32)data_to_find[j]); break;
+ case 8: match = ((UINT64)m_cpu.read_qword(*space, i + suboffset, TRUE) == (UINT64)data_to_find[j]); break;
default: /* all other cases are wildcards */ break;
}
suboffset += data_size[j] & 0x0f;
@@ -2470,13 +2301,13 @@ static void execute_find(running_machine &machine, int ref, int params, const ch
if (match)
{
found++;
- debug_console_printf(machine, "Found at %0*X\n", space->addrchars(), (UINT32)space->byte_to_address(i));
+ m_console.printf("Found at %0*X\n", space->addrchars(), (UINT32)space->byte_to_address(i));
}
}
/* print something if not found */
if (found == 0)
- debug_console_printf(machine, "Not found\n");
+ m_console.printf("Not found\n");
}
@@ -2484,7 +2315,7 @@ static void execute_find(running_machine &machine, int ref, int params, const ch
execute_dasm - execute the dasm command
-------------------------------------------------*/
-static void execute_dasm(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_dasm(int ref, int params, const char *param[])
{
UINT64 offset, length, bytes = 1;
int minbytes, maxbytes, byteswidth;
@@ -2493,15 +2324,15 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch
int j;
/* validate parameters */
- if (!debug_command_parameter_number(machine, param[1], &offset))
+ if (!validate_number_parameter(param[1], &offset))
return;
- if (!debug_command_parameter_number(machine, param[2], &length))
+ if (!validate_number_parameter(param[2], &length))
return;
- if (!debug_command_parameter_number(machine, param[3], &bytes))
+ if (!validate_number_parameter(param[3], &bytes))
return;
- if (!debug_command_parameter_cpu_space(machine, (params > 4) ? param[4] : nullptr, AS_PROGRAM, space))
+ if (!validate_cpu_space_parameter((params > 4) ? param[4] : nullptr, AS_PROGRAM, space))
return;
- if (!debug_command_parameter_cpu_space(machine, (params > 4) ? param[4] : nullptr, AS_DECRYPTED_OPCODES, decrypted_space))
+ if (!validate_cpu_space_parameter((params > 4) ? param[4] : nullptr, AS_DECRYPTED_OPCODES, decrypted_space))
decrypted_space = space;
/* determine the width of the bytes */
@@ -2519,7 +2350,7 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch
f = fopen(param[0], "w");
if (!f)
{
- debug_console_printf(machine, "Error opening file '%s'\n", param[0]);
+ m_console.printf("Error opening file '%s'\n", param[0]);
return;
}
@@ -2541,15 +2372,15 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch
/* make sure we can translate the address */
tempaddr = pcbyte;
- if (debug_cpu_translate(*space, TRANSLATE_FETCH_DEBUG, &tempaddr))
+ if (m_cpu.translate(*space, TRANSLATE_FETCH_DEBUG, &tempaddr))
{
UINT8 opbuf[64], argbuf[64];
/* fetch the bytes up to the maximum */
for (numbytes = 0; numbytes < maxbytes; numbytes++)
{
- opbuf[numbytes] = debug_read_opcode(*decrypted_space, pcbyte + numbytes, 1);
- argbuf[numbytes] = debug_read_opcode(*space, pcbyte + numbytes, 1);
+ opbuf[numbytes] = m_cpu.read_opcode(*decrypted_space, pcbyte + numbytes, 1);
+ argbuf[numbytes] = m_cpu.read_opcode(*space, pcbyte + numbytes, 1);
}
/* disassemble the result */
@@ -2562,7 +2393,7 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch
auto const startdex = output.tellp();
numbytes = space->address_to_byte(numbytes);
for (j = 0; j < numbytes; j += minbytes)
- stream_format(output, "%0*X ", minbytes * 2, debug_read_opcode(*decrypted_space, pcbyte + j, minbytes));
+ stream_format(output, "%0*X ", minbytes * 2, m_cpu.read_opcode(*decrypted_space, pcbyte + j, minbytes));
if ((output.tellp() - startdex) < byteswidth)
stream_format(output, "%*s", byteswidth - (output.tellp() - startdex), "");
stream_format(output, " ");
@@ -2594,7 +2425,7 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch
/* close the file */
fclose(f);
- debug_console_printf(machine, "Data dumped successfully\n");
+ m_console.printf("Data dumped successfully\n");
}
@@ -2603,7 +2434,7 @@ static void execute_dasm(running_machine &machine, int ref, int params, const ch
trace over and trace info
-------------------------------------------------*/
-static void execute_trace_internal(running_machine &machine, int ref, int params, const char *param[], int trace_over)
+void debugger_commands::execute_trace_internal(int ref, int params, const char *param[], bool trace_over)
{
const char *action = nullptr;
device_t *cpu;
@@ -2612,12 +2443,12 @@ static void execute_trace_internal(running_machine &machine, int ref, int params
std::string filename = param[0];
/* replace macros */
- strreplace(filename, "{game}", machine.basename());
+ strreplace(filename, "{game}", m_machine.basename());
/* validate parameters */
- if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : nullptr, &cpu))
+ if (!validate_cpu_parameter((params > 1) ? param[1] : nullptr, &cpu))
return;
- if (!debug_command_parameter_command(machine, action = param[2]))
+ if (!debug_command_parameter_command(action = param[2]))
return;
/* open the file */
@@ -2635,7 +2466,7 @@ static void execute_trace_internal(running_machine &machine, int ref, int params
f = fopen(filename.c_str(), mode);
if (!f)
{
- debug_console_printf(machine, "Error opening file '%s'\n", param[0]);
+ m_console.printf("Error opening file '%s'\n", param[0]);
return;
}
}
@@ -2643,9 +2474,9 @@ static void execute_trace_internal(running_machine &machine, int ref, int params
/* do it */
cpu->debug()->trace(f, trace_over, action);
if (f)
- debug_console_printf(machine, "Tracing CPU '%s' to file %s\n", cpu->tag(), filename.c_str());
+ m_console.printf("Tracing CPU '%s' to file %s\n", cpu->tag(), filename.c_str());
else
- debug_console_printf(machine, "Stopped tracing on CPU '%s'\n", cpu->tag());
+ m_console.printf("Stopped tracing on CPU '%s'\n", cpu->tag());
}
@@ -2653,9 +2484,9 @@ static void execute_trace_internal(running_machine &machine, int ref, int params
execute_trace - execute the trace command
-------------------------------------------------*/
-static void execute_trace(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_trace(int ref, int params, const char *param[])
{
- execute_trace_internal(machine, ref, params, param, 0);
+ execute_trace_internal(ref, params, param, false);
}
@@ -2663,9 +2494,9 @@ static void execute_trace(running_machine &machine, int ref, int params, const c
execute_traceover - execute the trace over command
-------------------------------------------------*/
-static void execute_traceover(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_traceover(int ref, int params, const char *param[])
{
- execute_trace_internal(machine, ref, params, param, 1);
+ execute_trace_internal(ref, params, param, true);
}
@@ -2673,9 +2504,9 @@ static void execute_traceover(running_machine &machine, int ref, int params, con
execute_traceflush - execute the trace flush command
-------------------------------------------------*/
-static void execute_traceflush(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_traceflush(int ref, int params, const char *param[])
{
- debug_cpu_flush_traces(machine);
+ m_cpu.flush_traces();
}
@@ -2683,17 +2514,17 @@ static void execute_traceflush(running_machine &machine, int ref, int params, co
execute_history - execute the history command
-------------------------------------------------*/
-static void execute_history(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_history(int ref, int params, const char *param[])
{
/* validate parameters */
address_space *space, *decrypted_space;
- if (!debug_command_parameter_cpu_space(machine, (params > 0) ? param[0] : nullptr, AS_PROGRAM, space))
+ if (!validate_cpu_space_parameter((params > 0) ? param[0] : nullptr, AS_PROGRAM, space))
return;
- if (!debug_command_parameter_cpu_space(machine, (params > 0) ? param[0] : nullptr, AS_DECRYPTED_OPCODES, decrypted_space))
+ if (!validate_cpu_space_parameter((params > 0) ? param[0] : nullptr, AS_DECRYPTED_OPCODES, decrypted_space))
decrypted_space = space;
UINT64 count = device_debug::HISTORY_SIZE;
- if (!debug_command_parameter_number(machine, param[1], &count))
+ if (!validate_number_parameter(param[1], &count))
return;
/* further validation */
@@ -2713,14 +2544,14 @@ static void execute_history(running_machine &machine, int ref, int params, const
UINT8 opbuf[64], argbuf[64];
for (int numbytes = 0; numbytes < maxbytes; numbytes++)
{
- opbuf[numbytes] = debug_read_opcode(*decrypted_space, pcbyte + numbytes, 1);
- argbuf[numbytes] = debug_read_opcode(*space, pcbyte + numbytes, 1);
+ opbuf[numbytes] = m_cpu.read_opcode(*decrypted_space, pcbyte + numbytes, 1);
+ argbuf[numbytes] = m_cpu.read_opcode(*space, pcbyte + numbytes, 1);
}
char buffer[200];
debug->disassemble(buffer, pc, opbuf, argbuf);
- debug_console_printf(machine, "%0*X: %s\n", space->logaddrchars(), pc, buffer);
+ m_console.printf("%0*X: %s\n", space->logaddrchars(), pc, buffer);
}
}
@@ -2729,37 +2560,37 @@ static void execute_history(running_machine &machine, int ref, int params, const
execute_trackpc - execute the trackpc command
-------------------------------------------------*/
-static void execute_trackpc(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_trackpc(int ref, int params, const char *param[])
{
// Gather the on/off switch (if present)
UINT64 turnOn = true;
- if (!debug_command_parameter_number(machine, param[0], &turnOn))
+ if (!validate_number_parameter(param[0], &turnOn))
return;
// Gather the cpu id (if present)
device_t *cpu = nullptr;
- if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : nullptr, &cpu))
+ if (!validate_cpu_parameter((params > 1) ? param[1] : nullptr, &cpu))
return;
// Should we clear the existing data?
UINT64 clear = false;
- if (!debug_command_parameter_number(machine, param[2], &clear))
+ if (!validate_number_parameter(param[2], &clear))
return;
cpu->debug()->set_track_pc((bool)turnOn);
if (turnOn)
{
// Insert current pc
- if (debug_cpu_get_visible_cpu(machine) == cpu)
+ if (m_cpu.get_visible_cpu() == cpu)
{
const offs_t pc = cpu->debug()->pc();
cpu->debug()->set_track_pc_visited(pc);
}
- debug_console_printf(machine, "PC tracking enabled\n");
+ m_console.printf("PC tracking enabled\n");
}
else
{
- debug_console_printf(machine, "PC tracking disabled\n");
+ m_console.printf("PC tracking disabled\n");
}
if (clear)
@@ -2771,26 +2602,26 @@ static void execute_trackpc(running_machine &machine, int ref, int params, const
execute_trackmem - execute the trackmem command
-------------------------------------------------*/
-static void execute_trackmem(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_trackmem(int ref, int params, const char *param[])
{
// Gather the on/off switch (if present)
UINT64 turnOn = true;
- if (!debug_command_parameter_number(machine, param[0], &turnOn))
+ if (!validate_number_parameter(param[0], &turnOn))
return;
// Gather the cpu id (if present)
device_t *cpu = nullptr;
- if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : nullptr, &cpu))
+ if (!validate_cpu_parameter((params > 1) ? param[1] : nullptr, &cpu))
return;
// Should we clear the existing data?
UINT64 clear = false;
- if (!debug_command_parameter_number(machine, param[2], &clear))
+ if (!validate_number_parameter(param[2], &clear))
return;
// Get the address space for the given cpu
address_space *space;
- if (!debug_command_parameter_cpu_space(machine, (params > 1) ? param[1] : nullptr, AS_PROGRAM, space))
+ if (!validate_cpu_space_parameter((params > 1) ? param[1] : nullptr, AS_PROGRAM, space))
return;
// Inform the CPU it's time to start tracking memory writes
@@ -2809,37 +2640,34 @@ static void execute_trackmem(running_machine &machine, int ref, int params, cons
execute_pcatmem - execute the pcatmem command
-------------------------------------------------*/
-static void execute_pcatmem(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_pcatmem(int ref, int params, const char *param[])
{
// Gather the required address parameter
UINT64 address;
- if (!debug_command_parameter_number(machine, param[0], &address))
+ if (!validate_number_parameter(param[0], &address))
return;
// Gather the cpu id (if present)
device_t *cpu = nullptr;
- if (!debug_command_parameter_cpu(machine, (params > 1) ? param[1] : nullptr, &cpu))
+ if (!validate_cpu_parameter((params > 1) ? param[1] : nullptr, &cpu))
return;
// Get the address space for the given cpu
address_space *space;
- if (!debug_command_parameter_cpu_space(machine, (params > 1) ? param[1] : nullptr, ref, space))
+ if (!validate_cpu_space_parameter((params > 1) ? param[1] : nullptr, ref, space))
return;
// Get the value of memory at the address
- const int nativeDataWidth = space->data_width() / 8;
- const UINT64 data = debug_read_memory(*space,
- space->address_to_byte(address),
- nativeDataWidth,
- true);
+ const int native_data_width = space->data_width() / 8;
+ const UINT64 data = m_cpu.read_memory(*space, space->address_to_byte(address), native_data_width, true);
// Recover the pc & print
- const address_spacenum spaceNum = (address_spacenum)ref;
- const offs_t result = space->device().debug()->track_mem_pc_from_space_address_data(spaceNum, address, data);
+ const address_spacenum space_num = (address_spacenum)ref;
+ const offs_t result = space->device().debug()->track_mem_pc_from_space_address_data(space_num, address, data);
if (result != (offs_t)(-1))
- debug_console_printf(machine, "%02x\n", result);
+ m_console.printf("%02x\n", result);
else
- debug_console_printf(machine, "UNKNOWN PC\n");
+ m_console.printf("UNKNOWN PC\n");
}
@@ -2847,13 +2675,13 @@ static void execute_pcatmem(running_machine &machine, int ref, int params, const
execute_snap - execute the snapshot command
-------------------------------------------------*/
-static void execute_snap(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_snap(int ref, int params, const char *param[])
{
/* if no params, use the default behavior */
if (params == 0)
{
- machine.video().save_active_screen_snapshots();
- debug_console_printf(machine, "Saved snapshot\n");
+ m_machine.video().save_active_screen_snapshots();
+ m_console.printf("Saved snapshot\n");
}
/* otherwise, we have to open the file ourselves */
@@ -2862,29 +2690,29 @@ static void execute_snap(running_machine &machine, int ref, int params, const ch
const char *filename = param[0];
int scrnum = (params > 1) ? atoi(param[1]) : 0;
- screen_device_iterator iter(machine.root_device());
+ screen_device_iterator iter(m_machine.root_device());
screen_device *screen = iter.byindex(scrnum);
- if ((screen == nullptr) || !machine.render().is_live(*screen))
+ if ((screen == nullptr) || !m_machine.render().is_live(*screen))
{
- debug_console_printf(machine, "Invalid screen number '%d'\n", scrnum);
+ m_console.printf("Invalid screen number '%d'\n", scrnum);
return;
}
std::string fname(filename);
if (fname.find(".png") == -1)
fname.append(".png");
- emu_file file(machine.options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
+ emu_file file(m_machine.options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
osd_file::error filerr = file.open(fname.c_str());
if (filerr != osd_file::error::NONE)
{
- debug_console_printf(machine, "Error creating file '%s'\n", filename);
+ m_console.printf("Error creating file '%s'\n", filename);
return;
}
screen->machine().video().save_snapshot(screen, file);
- debug_console_printf(machine, "Saved screen #%d snapshot as '%s'\n", scrnum, filename);
+ m_console.printf("Saved screen #%d snapshot as '%s'\n", scrnum, filename);
}
}
@@ -2893,9 +2721,9 @@ static void execute_snap(running_machine &machine, int ref, int params, const ch
execute_source - execute the source command
-------------------------------------------------*/
-static void execute_source(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_source(int ref, int params, const char *param[])
{
- debug_cpu_source_script(machine, param[0]);
+ m_cpu.source_script(param[0]);
}
@@ -2903,7 +2731,7 @@ static void execute_source(running_machine &machine, int ref, int params, const
execute_map - execute the map command
-------------------------------------------------*/
-static void execute_map(running_machine &machine, int ref, int params, const char *param[])
+void debugger_commands::execute_map(int ref, int params, const char *param[])
{
address_space *space;
offs_t taddress;
@@ -2911,11 +2739,11 @@ static void execute_map(running_machine &machine, int ref, int params, const cha
int intention;
/* validate parameters */
- if (!debug_command_parameter_number(machine, param[0], &address))
+ if (!validate_number_parameter(param[0], &address))
return;
/* CPU is implicit */
- if (!debug_command_parameter_cpu_space(machine, nullptr, ref, space))
+ if (!validate_cpu_space_parameter(nullptr, ref, space))
return;
/* do the translation first */
@@ -2923,18 +2751,18 @@ static void execute_map(running_machine &machine, int ref, int params, const cha
{
static const char *const intnames[] = { "Read", "Write", "Fetch" };
taddress = space->address_to_byte(address) & space->bytemask();
- if (debug_cpu_translate(*space, intention, &taddress))
+ if (m_cpu.translate(*space, intention, &taddress))
{
const char *mapname = space->get_handler_string((intention == TRANSLATE_WRITE_DEBUG) ? ROW_WRITE : ROW_READ, taddress);
- debug_console_printf(
- machine, "%7s: %0*X logical == %0*X physical -> %s\n",
+ m_console.printf(
+ "%7s: %0*X logical == %0*X physical -> %s\n",
intnames[intention & 3],
space->logaddrchars(), address,
space->addrchars(), space->byte_to_address(taddress),
mapname);
}
else
- debug_console_printf(machine, "%7s: %0*X logical is unmapped\n", intnames[intention & 3], space->logaddrchars(), address);
+ m_console.printf("%7s: %0*X logical is unmapped\n", intnames[intention & 3], space->logaddrchars(), address);
}
}
@@ -2943,19 +2771,19 @@ static void execute_map(running_machine &machine, int ref, int params, const cha
execute_memdump - execute the memdump command
-------------------------------------------------*/
-static void execute_memdump(running_machine &machine, int ref, int params, const char **param)
+void debugger_commands::execute_memdump(int ref, int params, const char **param)
{
FILE *file;
const char *filename;
filename = (params == 0) ? "memdump.log" : param[0];
- debug_console_printf(machine, "Dumping memory to %s\n", filename);
+ m_console.printf("Dumping memory to %s\n", filename);
file = fopen(filename, "w");
if (file)
{
- machine.memory().dump(file);
+ m_machine.memory().dump(file);
fclose(file);
}
}
@@ -2972,7 +2800,7 @@ static int CLIB_DECL symbol_sort_compare(const void *item1, const void *item2)
return strcmp(str1, str2);
}
-static void execute_symlist(running_machine &machine, int ref, int params, const char **param)
+void debugger_commands::execute_symlist(int ref, int params, const char **param)
{
device_t *cpu = nullptr;
const char *namelist[1000];
@@ -2983,15 +2811,15 @@ static void execute_symlist(running_machine &machine, int ref, int params, const
if (param[0] != nullptr)
{
/* validate parameters */
- if (!debug_command_parameter_cpu(machine, param[0], &cpu))
+ if (!validate_cpu_parameter(param[0], &cpu))
return;
symtable = &cpu->debug()->symtable();
- debug_console_printf(machine, "CPU '%s' symbols:\n", cpu->tag());
+ m_console.printf("CPU '%s' symbols:\n", cpu->tag());
}
else
{
- symtable = debug_cpu_get_global_symtable(machine);
- debug_console_printf(machine, "Global symbols:\n");
+ symtable = m_cpu.get_global_symtable();
+ m_console.printf("Global symbols:\n");
}
/* gather names for all symbols */
@@ -3018,10 +2846,10 @@ static void execute_symlist(running_machine &machine, int ref, int params, const
UINT64 value = entry->value();
/* only display "register" type symbols */
- debug_console_printf(machine, "%s = %X", namelist[symnum], value);
+ m_console.printf("%s = %X", namelist[symnum], value);
if (!entry->is_lval())
- debug_console_printf(machine, " (read-only)");
- debug_console_printf(machine, "\n");
+ m_console.printf(" (read-only)");
+ m_console.printf("\n");
}
}
@@ -3030,9 +2858,9 @@ static void execute_symlist(running_machine &machine, int ref, int params, const
execute_softreset - execute the softreset command
-------------------------------------------------*/
-static void execute_softreset(running_machine &machine, int ref, int params, const char **param)
+void debugger_commands::execute_softreset(int ref, int params, const char **param)
{
- machine.schedule_soft_reset();
+ m_machine.schedule_soft_reset();
}
@@ -3040,9 +2868,9 @@ static void execute_softreset(running_machine &machine, int ref, int params, con
execute_hardreset - execute the hardreset command
-------------------------------------------------*/
-static void execute_hardreset(running_machine &machine, int ref, int params, const char **param)
+void debugger_commands::execute_hardreset(int ref, int params, const char **param)
{
- machine.schedule_hard_reset();
+ m_machine.schedule_hard_reset();
}
/*-------------------------------------------------
@@ -3050,57 +2878,57 @@ static void execute_hardreset(running_machine &machine, int ref, int params, con
mounted files
-------------------------------------------------*/
-static void execute_images(running_machine &machine, int ref, int params, const char **param)
+void debugger_commands::execute_images(int ref, int params, const char **param)
{
- image_interface_iterator iter(machine.root_device());
+ image_interface_iterator iter(m_machine.root_device());
for (device_image_interface &img : iter)
- debug_console_printf(machine, "%s: %s\n", img.brief_instance_name(), img.exists() ? img.filename() : "[empty slot]");
+ m_console.printf("%s: %s\n", img.brief_instance_name(), img.exists() ? img.filename() : "[empty slot]");
if (iter.first() == nullptr)
- debug_console_printf(machine, "No image devices in this driver\n");
+ m_console.printf("No image devices in this driver\n");
}
/*-------------------------------------------------
execute_mount - execute the image mount command
-------------------------------------------------*/
-static void execute_mount(running_machine &machine, int ref, int params, const char **param)
+void debugger_commands::execute_mount(int ref, int params, const char **param)
{
bool done = false;
- for (device_image_interface &img : image_interface_iterator(machine.root_device()))
+ for (device_image_interface &img : image_interface_iterator(m_machine.root_device()))
{
if (strcmp(img.brief_instance_name(),param[0]) == 0)
{
if (img.load(param[1])==IMAGE_INIT_FAIL)
- debug_console_printf(machine, "Unable to mount file %s on %s\n",param[1],param[0]);
+ m_console.printf("Unable to mount file %s on %s\n",param[1],param[0]);
else
- debug_console_printf(machine, "File %s mounted on %s\n",param[1],param[0]);
+ m_console.printf("File %s mounted on %s\n",param[1],param[0]);
done = true;
break;
}
}
if (!done)
- debug_console_printf(machine, "There is no image device :%s\n",param[0]);
+ m_console.printf("There is no image device :%s\n",param[0]);
}
/*-------------------------------------------------
execute_unmount - execute the image unmount command
-------------------------------------------------*/
-static void execute_unmount(running_machine &machine, int ref, int params, const char **param)
+void debugger_commands::execute_unmount(int ref, int params, const char **param)
{
bool done = false;
- for (device_image_interface &img : image_interface_iterator(machine.root_device()))
+ for (device_image_interface &img : image_interface_iterator(m_machine.root_device()))
{
if (strcmp(img.brief_instance_name(),param[0]) == 0)
{
img.unload();
- debug_console_printf(machine, "Unmounted file from : %s\n",param[0]);
+ m_console.printf("Unmounted file from : %s\n",param[0]);
done = true;
break;
}
}
if (!done)
- debug_console_printf(machine, "There is no image device :%s\n",param[0]);
+ m_console.printf("There is no image device :%s\n",param[0]);
}
@@ -3109,9 +2937,9 @@ static void execute_unmount(running_machine &machine, int ref, int params, const
natural keyboard input
-------------------------------------------------*/
-static void execute_input(running_machine &machine, int ref, int params, const char **param)
+void debugger_commands::execute_input(int ref, int params, const char **param)
{
- machine.ioport().natkeyboard().post_coded(param[0]);
+ m_machine.ioport().natkeyboard().post_coded(param[0]);
}
@@ -3120,7 +2948,7 @@ static void execute_input(running_machine &machine, int ref, int params, const c
keyboard codes
-------------------------------------------------*/
-static void execute_dumpkbd(running_machine &machine, int ref, int params, const char **param)
+void debugger_commands::execute_dumpkbd(int ref, int params, const char **param)
{
// was there a file specified?
const char *filename = (params > 0) ? param[0] : nullptr;
@@ -3131,19 +2959,19 @@ static void execute_dumpkbd(running_machine &machine, int ref, int params, const
file = fopen(filename, "w");
if (file == nullptr)
{
- debug_console_printf(machine, "Cannot open \"%s\"\n", filename);
+ m_console.printf("Cannot open \"%s\"\n", filename);
return;
}
}
// loop through all codes
- std::string buffer = machine.ioport().natkeyboard().dump();
+ std::string buffer = m_machine.ioport().natkeyboard().dump();
// and output it as appropriate
if (file != nullptr)
fprintf(file, "%s\n", buffer.c_str());
else
- debug_console_printf(machine, "%s\n", buffer.c_str());
+ m_console.printf("%s\n", buffer.c_str());
// cleanup
if (file != nullptr)
diff --git a/src/emu/debug/debugcmd.h b/src/emu/debug/debugcmd.h
index 311f19e5dbd..b771aa84174 100644
--- a/src/emu/debug/debugcmd.h
+++ b/src/emu/debug/debugcmd.h
@@ -1,5 +1,5 @@
// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
+// copyright-holders:Aaron Giles,Ryan Holtz
/*********************************************************************
debugcmd.h
@@ -8,31 +8,163 @@
*********************************************************************/
+#pragma once
+
#ifndef __DEBUGCMD_H__
#define __DEBUGCMD_H__
#include "emu.h"
+#include "debugcpu.h"
+#include "debugcon.h"
+
+class parsed_expression;
+class symbol_table;
+
+class debugger_commands
+{
+public:
+ debugger_commands(running_machine& machine, debugger_cpu& cpu, debugger_console& console);
+
+ /* validates a parameter as a numeric value */
+ bool validate_number_parameter(const char *param, UINT64 *result);
+
+ /* validates a parameter as a cpu */
+ bool validate_cpu_parameter(const char *param, device_t **result);
+
+ /* validates a parameter as a cpu and retrieves the given address space */
+ bool validate_cpu_space_parameter(const char *param, int spacenum, address_space *&result);
+
+private:
+ struct global_entry
+ {
+ void * base;
+ UINT32 size;
+ };
+
+
+ struct cheat_map
+ {
+ UINT64 offset;
+ UINT64 first_value;
+ UINT64 previous_value;
+ UINT8 state:1;
+ UINT8 undo:7;
+ };
+
+ // TODO [RH 31 May 2016]: Move this cheat stuff into its own class
+ struct cheat_system
+ {
+ char cpu[2];
+ UINT8 width;
+ std::vector<cheat_map> cheatmap;
+ UINT8 undo;
+ UINT8 signed_cheat;
+ UINT8 swapped_cheat;
+ };
+
+
+ struct cheat_region_map
+ {
+ UINT64 offset;
+ UINT64 endoffset;
+ const char *share;
+ UINT8 disabled;
+ };
+
+ bool debug_command_parameter_expression(const char *param, parsed_expression &result);
+ bool debug_command_parameter_command(const char *param);
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
+ bool cheat_address_is_valid(address_space &space, offs_t address);
+ UINT64 cheat_sign_extend(const cheat_system *cheatsys, UINT64 value);
+ UINT64 cheat_byte_swap(const cheat_system *cheatsys, UINT64 value);
+ UINT64 cheat_read_extended(const cheat_system *cheatsys, address_space &space, offs_t address);
-/* ----- initialization ----- */
+ UINT64 execute_min(symbol_table &table, void *ref, int params, const UINT64 *param);
+ UINT64 execute_max(symbol_table &table, void *ref, int params, const UINT64 *param);
+ UINT64 execute_if(symbol_table &table, void *ref, int params, const UINT64 *param);
-/* initializes the command system */
-void debug_command_init(running_machine &machine);
+ UINT64 global_get(symbol_table &table, void *ref);
+ void global_set(symbol_table &table, void *ref, UINT64 value);
+ int mini_printf(char *buffer, const char *format, int params, UINT64 *param);
+ void execute_trace_internal(int ref, int params, const char *param[], bool trace_over);
-/* ----- parameter validation ----- */
+ void execute_help(int ref, int params, const char **param);
+ void execute_print(int ref, int params, const char **param);
+ void execute_printf(int ref, int params, const char **param);
+ void execute_logerror(int ref, int params, const char **param);
+ void execute_tracelog(int ref, int params, const char **param);
+ void execute_quit(int ref, int params, const char **param);
+ void execute_do(int ref, int params, const char **param);
+ void execute_step(int ref, int params, const char **param);
+ void execute_over(int ref, int params, const char **param);
+ void execute_out(int ref, int params, const char **param);
+ void execute_go(int ref, int params, const char **param);
+ void execute_go_vblank(int ref, int params, const char **param);
+ void execute_go_interrupt(int ref, int params, const char **param);
+ void execute_go_time(int ref, int params, const char *param[]);
+ void execute_focus(int ref, int params, const char **param);
+ void execute_ignore(int ref, int params, const char **param);
+ void execute_observe(int ref, int params, const char **param);
+ void execute_next(int ref, int params, const char **param);
+ void execute_comment_add(int ref, int params, const char **param);
+ void execute_comment_del(int ref, int params, const char **param);
+ void execute_comment_save(int ref, int params, const char **param);
+ void execute_comment_list(int ref, int params, const char **param);
+ void execute_comment_commit(int ref, int params, const char **param);
+ void execute_bpset(int ref, int params, const char **param);
+ void execute_bpclear(int ref, int params, const char **param);
+ void execute_bpdisenable(int ref, int params, const char **param);
+ void execute_bplist(int ref, int params, const char **param);
+ void execute_wpset(int ref, int params, const char **param);
+ void execute_wpclear(int ref, int params, const char **param);
+ void execute_wpdisenable(int ref, int params, const char **param);
+ void execute_wplist(int ref, int params, const char **param);
+ void execute_rpset(int ref, int params, const char **param);
+ void execute_rpclear(int ref, int params, const char **param);
+ void execute_rpdisenable(int ref, int params, const char **param);
+ void execute_rplist(int ref, int params, const char **param);
+ void execute_hotspot(int ref, int params, const char **param);
+ void execute_statesave(int ref, int params, const char **param);
+ void execute_stateload(int ref, int params, const char **param);
+ void execute_save(int ref, int params, const char **param);
+ void execute_load(int ref, int params, const char **param);
+ void execute_dump(int ref, int params, const char **param);
+ void execute_cheatinit(int ref, int params, const char **param);
+ void execute_cheatnext(int ref, int params, const char **param);
+ void execute_cheatlist(int ref, int params, const char **param);
+ void execute_cheatundo(int ref, int params, const char **param);
+ void execute_dasm(int ref, int params, const char **param);
+ void execute_find(int ref, int params, const char **param);
+ void execute_trace(int ref, int params, const char **param);
+ void execute_traceover(int ref, int params, const char **param);
+ void execute_traceflush(int ref, int params, const char **param);
+ void execute_history(int ref, int params, const char **param);
+ void execute_trackpc(int ref, int params, const char **param);
+ void execute_trackmem(int ref, int params, const char **param);
+ void execute_pcatmem(int ref, int params, const char **param);
+ void execute_snap(int ref, int params, const char **param);
+ void execute_source(int ref, int params, const char **param);
+ void execute_map(int ref, int params, const char **param);
+ void execute_memdump(int ref, int params, const char **param);
+ void execute_symlist(int ref, int params, const char **param);
+ void execute_softreset(int ref, int params, const char **param);
+ void execute_hardreset(int ref, int params, const char **param);
+ void execute_images(int ref, int params, const char **param);
+ void execute_mount(int ref, int params, const char **param);
+ void execute_unmount(int ref, int params, const char **param);
+ void execute_input(int ref, int params, const char **param);
+ void execute_dumpkbd(int ref, int params, const char **param);
-/* validates a number parameter */
-int debug_command_parameter_number(running_machine &machine, const char *param, UINT64 *result);
+ running_machine& m_machine;
+ debugger_cpu& m_cpu;
+ debugger_console& m_console;
-/* validates a parameter as a cpu */
-int debug_command_parameter_cpu(running_machine &machine, const char *param, device_t **result);
+ global_entry *m_global_array;
+ cheat_system m_cheat;
-/* validates a parameter as a cpu and retrieves the given address space */
-int debug_command_parameter_cpu_space(running_machine &machine, const char *param, int spacenum, address_space **result);
+ static const size_t MAX_GLOBALS;
+};
#endif
diff --git a/src/emu/debug/debugcon.cpp b/src/emu/debug/debugcon.cpp
index 2ff355f9c27..9ce385554ee 100644
--- a/src/emu/debug/debugcon.cpp
+++ b/src/emu/debug/debugcon.cpp
@@ -16,8 +16,6 @@
#include "debugger.h"
#include <ctype.h>
-
-
/***************************************************************************
CONSTANTS
***************************************************************************/
@@ -28,96 +26,61 @@
#define ERRORLOG_BUF_SIZE (1024 * 1024)
#define ERRORLOG_MAX_LINES (ERRORLOG_BUF_SIZE / 20)
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-struct debug_command
-{
- debug_command * next;
- char command[32];
- const char * params;
- const char * help;
- void (*handler)(running_machine &machine, int ref, int params, const char **param);
- void (*handler_ex)(int ref);
- UINT32 flags;
- int ref;
- int minparams;
- int maxparams;
-};
-
-
-
-/***************************************************************************
- LOCAL VARIABLES
-***************************************************************************/
-
-static text_buffer *console_textbuf;
-static text_buffer *errorlog_textbuf;
-
-static debug_command *commandlist;
-
-
-
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-static void debug_console_exit(running_machine &machine);
-
-
-
/***************************************************************************
Initialization and tear down
***************************************************************************/
-/*-------------------------------------------------
- debug_console_init - initializes the console
- system
--------------------------------------------------*/
-
-void debug_console_init(running_machine &machine)
+debugger_console::debugger_console(running_machine &machine)
+ : m_machine(machine)
+ , m_console_textbuf(nullptr)
+ , m_errorlog_textbuf(nullptr)
+ , m_commandlist(nullptr)
{
/* allocate text buffers */
- console_textbuf = text_buffer_alloc(CONSOLE_BUF_SIZE, CONSOLE_MAX_LINES);
- if (!console_textbuf)
+ m_console_textbuf = text_buffer_alloc(CONSOLE_BUF_SIZE, CONSOLE_MAX_LINES);
+ if (!m_console_textbuf)
return;
- errorlog_textbuf = text_buffer_alloc(ERRORLOG_BUF_SIZE, ERRORLOG_MAX_LINES);
- if (!errorlog_textbuf)
+ m_errorlog_textbuf = text_buffer_alloc(ERRORLOG_BUF_SIZE, ERRORLOG_MAX_LINES);
+ if (!m_errorlog_textbuf)
return;
/* print the opening lines */
- debug_console_printf(machine, "%s debugger version %s\n", emulator_info::get_appname(), emulator_info::get_build_version());
- debug_console_printf(machine, "Currently targeting %s (%s)\n", machine.system().name, machine.system().description);
+ printf("%s debugger version %s\n", emulator_info::get_appname(), emulator_info::get_build_version());
+ printf("Currently targeting %s (%s)\n", m_machine.system().name, m_machine.system().description);
/* request callback upon exiting */
- machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_console_exit), &machine));
+ m_machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debugger_console::exit), this));
+
+ /* listen in on the errorlog */
+ using namespace std::placeholders;
+ m_machine.add_logerror_callback(std::bind(&debugger_console::errorlog_write_line, this, _1));
}
/*-------------------------------------------------
- debug_console_exit - frees the console
- system
+ exit - frees the console system
-------------------------------------------------*/
-static void debug_console_exit(running_machine &machine)
+void debugger_console::exit()
{
/* free allocated memory */
- if (console_textbuf)
- text_buffer_free(console_textbuf);
- console_textbuf = nullptr;
+ if (m_console_textbuf)
+ {
+ text_buffer_free(m_console_textbuf);
+ }
+ m_console_textbuf = nullptr;
- if (errorlog_textbuf)
- text_buffer_free(errorlog_textbuf);
- errorlog_textbuf = nullptr;
+ if (m_errorlog_textbuf)
+ {
+ text_buffer_free(m_errorlog_textbuf);
+ }
+ m_errorlog_textbuf = nullptr;
/* free the command list */
- commandlist = nullptr;
+ m_commandlist = nullptr;
}
@@ -133,16 +96,16 @@ static void debug_console_exit(running_machine &machine)
command
-------------------------------------------------*/
-static void trim_parameter(char **paramptr, int keep_quotes)
+void debugger_console::trim_parameter(char **paramptr, bool keep_quotes)
{
char *param = *paramptr;
size_t len = strlen(param);
- int repeat;
+ bool repeat;
/* loop until all adornments are gone */
do
{
- repeat = 0;
+ repeat = false;
/* check for begin/end quotes */
if (len >= 2 && param[0] == '"' && param[len - 1] == '"')
@@ -161,7 +124,7 @@ static void trim_parameter(char **paramptr, int keep_quotes)
param[len - 1] = 0;
param++;
len -= 2;
- repeat = 1;
+ repeat = true;
}
/* check for leading spaces */
@@ -169,7 +132,7 @@ static void trim_parameter(char **paramptr, int keep_quotes)
{
param++;
len--;
- repeat = 1;
+ repeat = true;
}
/* check for trailing spaces */
@@ -177,7 +140,7 @@ static void trim_parameter(char **paramptr, int keep_quotes)
{
param[len - 1] = 0;
len--;
- repeat = 1;
+ repeat = true;
}
} while (repeat);
@@ -190,7 +153,7 @@ static void trim_parameter(char **paramptr, int keep_quotes)
command
-------------------------------------------------*/
-static CMDERR internal_execute_command(running_machine &machine, int execute, int params, char **param)
+CMDERR debugger_console::internal_execute_command(bool execute, int params, char **param)
{
debug_command *cmd, *found = nullptr;
int i, foundcount = 0;
@@ -221,7 +184,7 @@ static CMDERR internal_execute_command(running_machine &machine, int execute, in
/* search the command list */
len = strlen(command);
- for (cmd = commandlist; cmd != nullptr; cmd = cmd->next)
+ for (cmd = m_commandlist; cmd != nullptr; cmd = cmd->next)
if (!strncmp(command, cmd->command, len))
{
foundcount++;
@@ -255,7 +218,7 @@ static CMDERR internal_execute_command(running_machine &machine, int execute, in
/* execute the handler */
if (execute)
- (*found->handler)(machine, found->ref, params, (const char **)param);
+ found->handler(found->ref, params, (const char **)param);
return CMDERR_NONE;
}
@@ -265,7 +228,7 @@ static CMDERR internal_execute_command(running_machine &machine, int execute, in
and either executes or just validates it
-------------------------------------------------*/
-static CMDERR internal_parse_command(running_machine &machine, const char *original_command, int execute)
+CMDERR debugger_console::internal_parse_command(const char *original_command, bool execute)
{
char command[MAX_COMMAND_LENGTH], parens[MAX_COMMAND_LENGTH];
char *params[MAX_COMMAND_PARAMS] = { nullptr };
@@ -338,7 +301,7 @@ static CMDERR internal_parse_command(running_machine &machine, const char *origi
try
{
UINT64 expresult;
- parsed_expression expression(debug_cpu_get_visible_symtable(machine), command_start, &expresult);
+ parsed_expression expression(m_machine.debugger().cpu().get_visible_symtable(), command_start, &expresult);
}
catch (expression_error &err)
{
@@ -347,7 +310,7 @@ static CMDERR internal_parse_command(running_machine &machine, const char *origi
}
else
{
- result = internal_execute_command(machine, execute, paramcount, &params[0]);
+ result = internal_execute_command(execute, paramcount, &params[0]);
if (result != CMDERR_NONE)
return MAKE_CMDERR(CMDERR_ERROR_CLASS(result), command_start - command);
}
@@ -357,64 +320,59 @@ static CMDERR internal_parse_command(running_machine &machine, const char *origi
/*-------------------------------------------------
- debug_console_execute_command - execute a
- command string
+ execute_command - execute a command string
-------------------------------------------------*/
-CMDERR debug_console_execute_command(running_machine &machine, const char *command, int echo)
+CMDERR debugger_console::execute_command(const char *command, bool echo)
{
CMDERR result;
/* echo if requested */
if (echo)
- debug_console_printf(machine, ">%s\n", command);
+ printf(">%s\n", command);
/* parse and execute */
- result = internal_parse_command(machine, command, TRUE);
+ result = internal_parse_command(command, TRUE);
/* display errors */
if (result != CMDERR_NONE)
{
if (!echo)
- debug_console_printf(machine, ">%s\n", command);
- debug_console_printf(machine, " %*s^\n", CMDERR_ERROR_OFFSET(result), "");
- debug_console_printf(machine, "%s\n", debug_cmderr_to_string(result));
+ printf(">%s\n", command);
+ printf(" %*s^\n", CMDERR_ERROR_OFFSET(result), "");
+ printf("%s\n", cmderr_to_string(result));
}
/* update all views */
if (echo)
{
- machine.debug_view().update_all();
- machine.debugger().refresh_display();
+ m_machine.debug_view().update_all();
+ m_machine.debugger().refresh_display();
}
return result;
}
/*-------------------------------------------------
- debug_console_validate_command - validate a
- command string
+ validate_command - validate a command string
-------------------------------------------------*/
-CMDERR debug_console_validate_command(running_machine &machine, const char *command)
+CMDERR debugger_console::validate_command(const char *command)
{
- return internal_parse_command(machine, command, FALSE);
+ return internal_parse_command(command, false);
}
/*-------------------------------------------------
- debug_console_register_command - register a
- command handler
+ register_command - register a command handler
-------------------------------------------------*/
-void debug_console_register_command(running_machine &machine, const char *command, UINT32 flags, int ref, int minparams, int maxparams, void (*handler)(running_machine &machine, int ref, int params, const char **param))
+void debugger_console::register_command(const char *command, UINT32 flags, int ref, int minparams, int maxparams, std::function<void(int, int, const char **)> handler)
{
- debug_command *cmd;
-
- assert_always(machine.phase() == MACHINE_PHASE_INIT, "Can only call debug_console_register_command() at init time!");
- assert_always((machine.debug_flags & DEBUG_FLAG_ENABLED) != 0, "Cannot call debug_console_register_command() when debugger is not running");
+ assert_always(m_machine.phase() == MACHINE_PHASE_INIT, "Can only call register_command() at init time!");
+ assert_always((m_machine.debug_flags & DEBUG_FLAG_ENABLED) != 0, "Cannot call register_command() when debugger is not running");
- cmd = auto_alloc_clear(machine, <debug_command>());
+ debug_command *cmd = auto_alloc_clear(m_machine, <debug_command>());
/* fill in the command */
strcpy(cmd->command, command);
@@ -425,8 +383,8 @@ void debug_console_register_command(running_machine &machine, const char *comman
cmd->handler = handler;
/* link it */
- cmd->next = commandlist;
- commandlist = cmd;
+ cmd->next = m_commandlist;
+ m_commandlist = cmd;
}
@@ -438,11 +396,11 @@ void debug_console_register_command(running_machine &machine, const char *comman
***************************************************************************/
/*-------------------------------------------------
- debug_cmderr_to_string - return a friendly
- string for a given command error
+ cmderr_to_string - return a friendly string
+ for a given command error
-------------------------------------------------*/
-const char *debug_cmderr_to_string(CMDERR error)
+const char *debugger_console::cmderr_to_string(CMDERR error)
{
switch (CMDERR_ERROR_CLASS(error))
{
@@ -466,83 +424,61 @@ const char *debug_cmderr_to_string(CMDERR error)
***************************************************************************/
/*-------------------------------------------------
- debug_console_vprintf - vprintfs the given
- arguments using the format to the debug
- console
+ vprintf - vprintfs the given arguments using
+ the format to the debug console
-------------------------------------------------*/
-void debug_console_vprintf(running_machine &machine, util::format_argument_pack<std::ostream> const &args)
+void debugger_console::vprintf(util::format_argument_pack<std::ostream> const &args)
{
- text_buffer_print(console_textbuf, util::string_format(args).c_str());
+ text_buffer_print(m_console_textbuf, util::string_format(args).c_str());
/* force an update of any console views */
- machine.debug_view().update_all(DVT_CONSOLE);
+ m_machine.debug_view().update_all(DVT_CONSOLE);
}
-void debug_console_vprintf(running_machine &machine, util::format_argument_pack<std::ostream> &&args)
+void debugger_console::vprintf(util::format_argument_pack<std::ostream> &&args)
{
- text_buffer_print(console_textbuf, util::string_format(std::move(args)).c_str());
+ text_buffer_print(m_console_textbuf, util::string_format(std::move(args)).c_str());
/* force an update of any console views */
- machine.debug_view().update_all(DVT_CONSOLE);
+ m_machine.debug_view().update_all(DVT_CONSOLE);
}
/*-------------------------------------------------
- debug_console_vprintf_wrap - vprintfs the given
- arguments using the format to the debug
- console
+ vprintf_wrap - vprintfs the given arguments
+ using the format to the debug console
-------------------------------------------------*/
-void debug_console_vprintf_wrap(running_machine &machine, int wrapcol, util::format_argument_pack<std::ostream> const &args)
+void debugger_console::vprintf_wrap(int wrapcol, util::format_argument_pack<std::ostream> const &args)
{
- text_buffer_print_wrap(console_textbuf, util::string_format(args).c_str(), wrapcol);
+ text_buffer_print_wrap(m_console_textbuf, util::string_format(args).c_str(), wrapcol);
/* force an update of any console views */
- machine.debug_view().update_all(DVT_CONSOLE);
+ m_machine.debug_view().update_all(DVT_CONSOLE);
}
-void debug_console_vprintf_wrap(running_machine &machine, int wrapcol, util::format_argument_pack<std::ostream> &&args)
+void debugger_console::vprintf_wrap(int wrapcol, util::format_argument_pack<std::ostream> &&args)
{
- text_buffer_print_wrap(console_textbuf, util::string_format(std::move(args)).c_str(), wrapcol);
+ text_buffer_print_wrap(m_console_textbuf, util::string_format(std::move(args)).c_str(), wrapcol);
/* force an update of any console views */
- machine.debug_view().update_all(DVT_CONSOLE);
-}
-
-
-/*-------------------------------------------------
- debug_console_get_textbuf - return a pointer
- to the console text buffer
--------------------------------------------------*/
-
-text_buffer *debug_console_get_textbuf(void)
-{
- return console_textbuf;
+ m_machine.debug_view().update_all(DVT_CONSOLE);
}
/*-------------------------------------------------
- debug_errorlog_write_line - writes a line to
- the errorlog ring buffer
+ errorlog_write_line - writes a line to the
+ errorlog ring buffer
-------------------------------------------------*/
-void debug_errorlog_write_line(const running_machine &machine, const char *line)
+void debugger_console::errorlog_write_line(const char *line)
{
- if (errorlog_textbuf)
- text_buffer_print(errorlog_textbuf, line);
+ if (m_errorlog_textbuf)
+ {
+ text_buffer_print(m_errorlog_textbuf, line);
+ }
/* force an update of any log views */
- machine.debug_view().update_all(DVT_LOG);
-}
-
-
-/*-------------------------------------------------
- debug_errorlog_get_textbuf - return a pointer
- to the errorlog text buffer
--------------------------------------------------*/
-
-text_buffer *debug_errorlog_get_textbuf(void)
-{
- return errorlog_textbuf;
+ m_machine.debug_view().update_all(DVT_LOG);
}
diff --git a/src/emu/debug/debugcon.h b/src/emu/debug/debugcon.h
index 95aa2e0f8c8..5e04d349454 100644
--- a/src/emu/debug/debugcon.h
+++ b/src/emu/debug/debugcon.h
@@ -11,10 +11,11 @@
#ifndef __DEBUGCON_H__
#define __DEBUGCON_H__
+#include <functional>
+
#include "emu.h"
#include "textbuf.h"
-
/***************************************************************************
CONSTANTS
***************************************************************************/
@@ -68,42 +69,67 @@
/* CMDERR is an error code for command evaluation */
typedef UINT32 CMDERR;
-
-
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-/* initialization */
-void debug_console_init(running_machine &machine);
-
-/* command handling */
-CMDERR debug_console_execute_command(running_machine &machine, const char *command, int echo);
-CMDERR debug_console_validate_command(running_machine &machine, const char *command);
-void debug_console_register_command(running_machine &machine, const char *command, UINT32 flags, int ref, int minparams, int maxparams, void (*handler)(running_machine &machine, int ref, int params, const char **param));
-const char * debug_cmderr_to_string(CMDERR error);
-
-/* console management */
-void debug_console_vprintf(running_machine &machine, util::format_argument_pack<std::ostream> const &args);
-void debug_console_vprintf(running_machine &machine, util::format_argument_pack<std::ostream> &&args);
-void debug_console_vprintf_wrap(running_machine &machine, int wrapcol, util::format_argument_pack<std::ostream> const &args);
-void debug_console_vprintf_wrap(running_machine &machine, int wrapcol, util::format_argument_pack<std::ostream> &&args);
-text_buffer * debug_console_get_textbuf(void);
-
-/* errorlog management */
-void debug_errorlog_write_line(const running_machine &machine, const char *line);
-text_buffer * debug_errorlog_get_textbuf(void);
-
-/* convenience templates */
-template <typename Format, typename... Params>
-inline void debug_console_printf(running_machine &machine, Format &&fmt, Params &&...args)
-{
- debug_console_vprintf(machine, util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
-}
-template <typename Format, typename... Params>
-inline void debug_console_printf_wrap(running_machine &machine, int wrapcol, Format &&fmt, Params &&...args)
+class debugger_console
{
- debug_console_vprintf_wrap(machine, wrapcol, util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
-}
+public:
+ debugger_console(running_machine &machine);
+
+ /* command handling */
+ CMDERR execute_command(const char *command, bool echo);
+ CMDERR validate_command(const char *command);
+ void register_command(const char *command, UINT32 flags, int ref, int minparams, int maxparams, std::function<void(int, int, const char **)> handler);
+
+ /* console management */
+ void vprintf(util::format_argument_pack<std::ostream> const &args);
+ void vprintf(util::format_argument_pack<std::ostream> &&args);
+ void vprintf_wrap(int wrapcol, util::format_argument_pack<std::ostream> const &args);
+ void vprintf_wrap(int wrapcol, util::format_argument_pack<std::ostream> &&args);
+ text_buffer * get_console_textbuf() const { return m_console_textbuf; }
+
+ /* errorlog management */
+ void errorlog_write_line(const char *line);
+ text_buffer * get_errorlog_textbuf() const { return m_errorlog_textbuf; }
+
+ /* convenience templates */
+ template <typename Format, typename... Params>
+ inline void printf(Format &&fmt, Params &&...args)
+ {
+ vprintf(util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
+ }
+ template <typename Format, typename... Params>
+ inline void printf_wrap(int wrapcol, Format &&fmt, Params &&...args)
+ {
+ vprintf_wrap(wrapcol, util::make_format_argument_pack(std::forward<Format>(fmt), std::forward<Params>(args)...));
+ }
+
+ static const char * cmderr_to_string(CMDERR error);
+
+private:
+ void exit();
+
+ void trim_parameter(char **paramptr, bool keep_quotes);
+ CMDERR internal_execute_command(bool execute, int params, char **param);
+ CMDERR internal_parse_command(const char *original_command, bool execute);
+
+ struct debug_command
+ {
+ debug_command * next;
+ char command[32];
+ const char * params;
+ const char * help;
+ std::function<void(int, int, const char **)> handler;
+ UINT32 flags;
+ int ref;
+ int minparams;
+ int maxparams;
+ };
+
+ running_machine &m_machine;
+
+ text_buffer *m_console_textbuf;
+ text_buffer *m_errorlog_textbuf;
+
+ debug_command *m_commandlist;
+};
#endif
diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp
index 01f15cb3e46..7c2806ba601 100644
--- a/src/emu/debug/debugcpu.cpp
+++ b/src/emu/debug/debugcpu.cpp
@@ -21,157 +21,93 @@
#include "coreutil.h"
#include <ctype.h>
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-#define NUM_TEMP_VARIABLES 10
-
enum
{
EXECUTION_STATE_STOPPED,
EXECUTION_STATE_RUNNING
};
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-struct debugcpu_private
-{
- device_t *livecpu;
- device_t *visiblecpu;
- device_t *breakcpu;
-
- FILE * source_file; /* script source file */
-
- symbol_table * symtable; /* global symbol table */
-
- bool within_instruction_hook;
- bool vblank_occurred;
- bool memory_modified;
- bool debugger_access;
-
- int execution_state;
- device_t * m_stop_when_not_device; // stop execution when the device ceases to be this
-
- UINT32 bpindex;
- UINT32 wpindex;
- UINT32 rpindex;
-
- UINT64 wpdata;
- UINT64 wpaddr;
- UINT64 tempvar[NUM_TEMP_VARIABLES];
-
- osd_ticks_t last_periodic_update_time;
-
- bool comments_loaded;
-};
-
-
-
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-/* internal helpers */
-static void debug_cpu_exit(running_machine &machine);
-static void on_vblank(running_machine &machine, screen_device &device, bool vblank_state);
-static void reset_transient_flags(running_machine &machine);
-static void process_source_file(running_machine &machine);
-
-/* expression handlers */
-static UINT64 expression_read_memory(void *param, const char *name, expression_space space, UINT32 address, int size);
-static UINT64 expression_read_program_direct(address_space &space, int opcode, offs_t address, int size);
-static UINT64 expression_read_memory_region(running_machine &machine, const char *rgntag, offs_t address, int size);
-static void expression_write_memory(void *param, const char *name, expression_space space, UINT32 address, int size, UINT64 data);
-static void expression_write_program_direct(address_space &space, int opcode, offs_t address, int size, UINT64 data);
-static void expression_write_memory_region(running_machine &machine, const char *rgntag, offs_t address, int size, UINT64 data);
-static expression_error::error_code expression_validate(void *param, const char *name, expression_space space);
-
-/* variable getters/setters */
-static UINT64 get_cpunum(symbol_table &table, void *ref);
-static UINT64 get_beamx(symbol_table &table, void *ref);
-static UINT64 get_beamy(symbol_table &table, void *ref);
-static UINT64 get_frame(symbol_table &table, void *ref);
-
-
-
-/***************************************************************************
- INITIALIZATION AND CLEANUP
-***************************************************************************/
+const size_t debugger_cpu::NUM_TEMP_VARIABLES = 10;
/*-------------------------------------------------
- debug_cpu_init - initialize the CPU
+ constructor - initialize the CPU
information for debugging
-------------------------------------------------*/
-void debug_cpu_init(running_machine &machine)
-{
- screen_device *first_screen = machine.first_screen();
- debugcpu_private *global;
- int regnum;
-
- /* allocate and reset globals */
- machine.debugcpu_data = global = auto_alloc_clear(machine, <debugcpu_private>());
- global->execution_state = EXECUTION_STATE_STOPPED;
- global->bpindex = 1;
- global->wpindex = 1;
- global->rpindex = 1;
+debugger_cpu::debugger_cpu(running_machine &machine)
+ : m_machine(machine)
+ , m_livecpu(nullptr)
+ , m_visiblecpu(nullptr)
+ , m_breakcpu(nullptr)
+ , m_source_file(nullptr)
+ , m_symtable(nullptr)
+ , m_execution_state(EXECUTION_STATE_STOPPED)
+ , m_bpindex(1)
+ , m_wpindex(1)
+ , m_rpindex(1)
+ , m_wpdata(0)
+ , m_wpaddr(0)
+ , m_comments_loaded(false)
+{
+ screen_device *first_screen = m_machine.first_screen();
+
+ m_tempvar = make_unique_clear<UINT64[]>(NUM_TEMP_VARIABLES);
/* create a global symbol table */
- global->symtable = global_alloc(symbol_table(&machine));
+ m_symtable = global_alloc(symbol_table(&m_machine));
// configure our base memory accessors
- debug_cpu_configure_memory(machine, *global->symtable);
+ configure_memory(*m_symtable);
/* add "wpaddr", "wpdata", "cycles", "cpunum", "logunmap" to the global symbol table */
- global->symtable->add("wpaddr", symbol_table::READ_ONLY, &global->wpaddr);
- global->symtable->add("wpdata", symbol_table::READ_ONLY, &global->wpdata);
- global->symtable->add("cpunum", nullptr, get_cpunum);
- global->symtable->add("beamx", (void *)first_screen, get_beamx);
- global->symtable->add("beamy", (void *)first_screen, get_beamy);
- global->symtable->add("frame", (void *)first_screen, get_frame);
+ m_symtable->add("wpaddr", symbol_table::READ_ONLY, &m_wpaddr);
+ m_symtable->add("wpdata", symbol_table::READ_ONLY, &m_wpdata);
+
+ using namespace std::placeholders;
+ m_symtable->add("cpunum", nullptr, std::bind(&debugger_cpu::get_cpunum, this, _1, _2));
+ m_symtable->add("beamx", (void *)first_screen, std::bind(&debugger_cpu::get_beamx, this, _1, _2));
+ m_symtable->add("beamy", (void *)first_screen, std::bind(&debugger_cpu::get_beamy, this, _1, _2));
+ m_symtable->add("frame", (void *)first_screen, std::bind(&debugger_cpu::get_frame, this, _1, _2));
/* add the temporary variables to the global symbol table */
- for (regnum = 0; regnum < NUM_TEMP_VARIABLES; regnum++)
+ for (int regnum = 0; regnum < NUM_TEMP_VARIABLES; regnum++)
{
char symname[10];
sprintf(symname, "temp%d", regnum);
- global->symtable->add(symname, symbol_table::READ_WRITE, &global->tempvar[regnum]);
+ m_symtable->add(symname, symbol_table::READ_WRITE, &m_tempvar[regnum]);
}
/* first CPU is visible by default */
- global->visiblecpu = machine.firstcpu;
+ m_visiblecpu = m_machine.firstcpu;
/* add callback for breaking on VBLANK */
- if (machine.first_screen() != nullptr)
- machine.first_screen()->register_vblank_callback(vblank_state_delegate(FUNC(on_vblank), &machine));
+ if (m_machine.first_screen() != nullptr)
+ m_machine.first_screen()->register_vblank_callback(vblank_state_delegate(FUNC(debugger_cpu::on_vblank), this));
- machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_cpu_exit), &machine));
+ machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debugger_cpu::exit), this));
}
-
-void debug_cpu_configure_memory(running_machine &machine, symbol_table &table)
+void debugger_cpu::configure_memory(symbol_table &table)
{
- table.configure_memory(&machine, expression_validate, expression_read_memory, expression_write_memory);
+ using namespace std::placeholders;
+ table.configure_memory(
+ &m_machine,
+ std::bind(&debugger_cpu::expression_validate, this, _1, _2, _3),
+ std::bind(&debugger_cpu::expression_read_memory, this, _1, _2, _3, _4, _5),
+ std::bind(&debugger_cpu::expression_write_memory, this, _1, _2, _3, _4, _5, _6));
}
-
/*-------------------------------------------------
- debug_cpu_flush_traces - flushes all traces;
- this is useful if a trace is going on when we
+ flush_traces - flushes all traces; this is
+ useful if a trace is going on when we
fatalerror
-------------------------------------------------*/
-void debug_cpu_flush_traces(running_machine &machine)
+void debugger_cpu::flush_traces()
{
/* this can be called on exit even when no debugging is enabled, so
make sure the devdebug is valid before proceeding */
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug() != nullptr)
device.debug()->trace_flush();
}
@@ -183,90 +119,86 @@ void debug_cpu_flush_traces(running_machine &machine)
***************************************************************************/
/*-------------------------------------------------
- cpu_get_visible_cpu - return the visible CPU
+ get_visible_cpu - return the visible CPU
device (the one that commands should apply to)
-------------------------------------------------*/
-device_t *debug_cpu_get_visible_cpu(running_machine &machine)
+device_t* debugger_cpu::get_visible_cpu()
{
- return machine.debugcpu_data->visiblecpu;
+ return m_visiblecpu;
}
/*-------------------------------------------------
- debug_cpu_within_instruction_hook - true if
- the debugger is currently live
+ within_instruction_hook - true if the debugger
+ is currently live
-------------------------------------------------*/
-int debug_cpu_within_instruction_hook(running_machine &machine)
+bool debugger_cpu::within_instruction_hook()
{
- return machine.debugcpu_data->within_instruction_hook;
+ return m_within_instruction_hook;
}
/*-------------------------------------------------
- debug_cpu_is_stopped - return true if the
+ is_stopped - return true if the
current execution state is stopped
-------------------------------------------------*/
-int debug_cpu_is_stopped(running_machine &machine)
+bool debugger_cpu::is_stopped()
{
- debugcpu_private *global = machine.debugcpu_data;
- return (global != nullptr) ? (global->execution_state == EXECUTION_STATE_STOPPED) : false;
+ return m_execution_state == EXECUTION_STATE_STOPPED;
}
-
/***************************************************************************
SYMBOL TABLE INTERFACES
***************************************************************************/
/*-------------------------------------------------
- debug_cpu_get_global_symtable - return the
- global symbol table
+ get_global_symtable - return the global
+ symbol table
-------------------------------------------------*/
-symbol_table *debug_cpu_get_global_symtable(running_machine &machine)
+symbol_table* debugger_cpu::get_global_symtable()
{
- return machine.debugcpu_data->symtable;
+ return m_symtable;
}
/*-------------------------------------------------
- debug_cpu_get_visible_symtable - return the
+ get_visible_symtable - return the
locally-visible symbol table
-------------------------------------------------*/
-symbol_table *debug_cpu_get_visible_symtable(running_machine &machine)
+symbol_table* debugger_cpu::get_visible_symtable()
{
- return &machine.debugcpu_data->visiblecpu->debug()->symtable();
+ return &m_visiblecpu->debug()->symtable();
}
/*-------------------------------------------------
- debug_cpu_source_script - specifies a debug
- command script to execute
+ source_script - specifies a debug command
+ script to execute
-------------------------------------------------*/
-void debug_cpu_source_script(running_machine &machine, const char *file)
+void debugger_cpu::source_script(const char *file)
{
- debugcpu_private *global = machine.debugcpu_data;
-
/* close any existing source file */
- if (global->source_file != nullptr)
+ if (m_source_file != nullptr)
{
- fclose(global->source_file);
- global->source_file = nullptr;
+ fclose(m_source_file);
+ m_source_file = nullptr;
}
/* open a new one if requested */
if (file != nullptr)
{
- global->source_file = fopen(file, "r");
- if (!global->source_file)
+ m_source_file = fopen(file, "r");
+ if (!m_source_file)
{
- if (machine.phase() == MACHINE_PHASE_RUNNING)
- debug_console_printf(machine, "Cannot open command file '%s'\n", file);
+ if (m_machine.phase() == MACHINE_PHASE_RUNNING)
+ m_machine.debugger().console().printf("Cannot open command file '%s'\n", file);
else
fatalerror("Cannot open command file '%s'\n", file);
}
@@ -280,11 +212,11 @@ void debug_cpu_source_script(running_machine &machine, const char *file)
//**************************************************************************
//-------------------------------------------------
-// debug_comment_save - save all comments for
-// the given machine
+// omment_save - save all comments for the given
+// machine
//-------------------------------------------------
-bool debug_comment_save(running_machine &machine)
+bool debugger_cpu::comment_save()
{
bool comments_saved = false;
@@ -306,11 +238,11 @@ bool debug_comment_save(running_machine &machine)
xml_data_node *systemnode = xml_add_child(commentnode, "system", nullptr);
if (systemnode == nullptr)
throw emu_exception();
- xml_set_attribute(systemnode, "name", machine.system().name);
+ xml_set_attribute(systemnode, "name", m_machine.system().name);
// for each device
bool found_comments = false;
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
if (device.debug() && device.debug()->comment_count() > 0)
{
// create a node for this device
@@ -328,8 +260,8 @@ bool debug_comment_save(running_machine &machine)
// flush the file
if (found_comments)
{
- emu_file file(machine.options().comment_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- osd_file::error filerr = file.open(machine.basename(), ".cmt");
+ emu_file file(m_machine.options().comment_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
+ osd_file::error filerr = file.open(m_machine.basename(), ".cmt");
if (filerr == osd_file::error::NONE)
{
xml_file_write(root, file);
@@ -349,15 +281,15 @@ bool debug_comment_save(running_machine &machine)
}
//-------------------------------------------------
-// debug_comment_load - load all comments for
-// the given machine
+// comment_load - load all comments for the given
+// machine
//-------------------------------------------------
-bool debug_comment_load(running_machine &machine,bool is_inline)
+bool debugger_cpu::comment_load(bool is_inline)
{
// open the file
- emu_file file(machine.options().comment_directory(), OPEN_FLAG_READ);
- osd_file::error filerr = file.open(machine.basename(), ".cmt");
+ emu_file file(m_machine.options().comment_directory(), OPEN_FLAG_READ);
+ osd_file::error filerr = file.open(m_machine.basename(), ".cmt");
// if an error, just return false
if (filerr != osd_file::error::NONE)
@@ -384,18 +316,18 @@ bool debug_comment_load(running_machine &machine,bool is_inline)
// check to make sure the file is applicable
xml_data_node *systemnode = xml_get_sibling(commentnode->child, "system");
const char *name = xml_get_attribute_string(systemnode, "name", "");
- if (strcmp(name, machine.system().name) != 0)
+ if (strcmp(name, m_machine.system().name) != 0)
throw emu_exception();
// iterate over devices
for (xml_data_node *cpunode = xml_get_sibling(systemnode->child, "cpu"); cpunode; cpunode = xml_get_sibling(cpunode->next, "cpu"))
{
const char *cputag_name = xml_get_attribute_string(cpunode, "tag", "");
- device_t *device = machine.device(cputag_name);
+ device_t *device = m_machine.device(cputag_name);
if (device != nullptr)
{
if(is_inline == false)
- debug_console_printf(machine,"@%s\n",cputag_name);
+ m_machine.debugger().console().printf("@%s\n", cputag_name);
if (!device->debug()->comment_import(*cpunode,is_inline))
throw emu_exception();
@@ -422,12 +354,11 @@ bool debug_comment_load(running_machine &machine,bool is_inline)
***************************************************************************/
/*-------------------------------------------------
- debug_cpu_translate - return the physical
- address corresponding to the given logical
- address
+ translate - return the physical address
+ corresponding to the given logical address
-------------------------------------------------*/
-int debug_cpu_translate(address_space &space, int intention, offs_t *address)
+bool debugger_cpu::translate(address_space &space, int intention, offs_t *address)
{
device_memory_interface *memory;
if (space.device().interface(memory))
@@ -441,58 +372,57 @@ int debug_cpu_translate(address_space &space, int intention, offs_t *address)
***************************************************************************/
/*-------------------------------------------------
- debug_read_byte - return a byte from the
- the specified memory space
+ read_byte - return a byte from the specified
+ memory space
-------------------------------------------------*/
-UINT8 debug_read_byte(address_space &space, offs_t address, int apply_translation)
+UINT8 debugger_cpu::read_byte(address_space &space, offs_t address, int apply_translation)
{
- debugcpu_private *global = space.machine().debugcpu_data;
- UINT64 custom;
- UINT8 result;
-
/* mask against the logical byte mask */
address &= space.logbytemask();
/* all accesses from this point on are for the debugger */
- space.set_debugger_access(global->debugger_access = true);
+ m_debugger_access = true;
+ space.set_debugger_access(true);
/* translate if necessary; if not mapped, return 0xff */
- if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+ UINT64 custom;
+ UINT8 result;
+ if (apply_translation && !translate(space, TRANSLATE_READ_DEBUG, &address))
+ {
result = 0xff;
-
- /* if there is a custom read handler, and it returns true, use that value */
+ }
else if (space.device().memory().read(space.spacenum(), address, 1, custom))
+ { /* if there is a custom read handler, and it returns true, use that value */
result = custom;
-
- /* otherwise, call the byte reading function for the translated address */
+ }
else
+ { /* otherwise, call the byte reading function for the translated address */
result = space.read_byte(address);
+ }
/* no longer accessing via the debugger */
- space.set_debugger_access(global->debugger_access = false);
+ m_debugger_access = false;
+ space.set_debugger_access(false);
return result;
}
/*-------------------------------------------------
- debug_read_word - return a word from the
- specified memory space
+ read_word - return a word from the specified
+ memory space
-------------------------------------------------*/
-UINT16 debug_read_word(address_space &space, offs_t address, int apply_translation)
+UINT16 debugger_cpu::read_word(address_space &space, offs_t address, int apply_translation)
{
- debugcpu_private *global = space.machine().debugcpu_data;
- UINT16 result;
-
/* mask against the logical byte mask */
address &= space.logbytemask();
- /* if this is misaligned read, or if there are no word readers, just read two bytes */
+ UINT16 result;
if (!WORD_ALIGNED(address))
- {
- UINT8 byte0 = debug_read_byte(space, address + 0, apply_translation);
- UINT8 byte1 = debug_read_byte(space, address + 1, apply_translation);
+ { /* if this is misaligned read, or if there are no word readers, just read two bytes */
+ UINT8 byte0 = read_byte(space, address + 0, apply_translation);
+ UINT8 byte1 = read_byte(space, address + 1, apply_translation);
/* based on the endianness, the result is assembled differently */
if (space.endianness() == ENDIANNESS_LITTLE)
@@ -500,29 +430,31 @@ UINT16 debug_read_word(address_space &space, offs_t address, int apply_translati
else
result = byte1 | (byte0 << 8);
}
-
- /* otherwise, this proceeds like the byte case */
else
- {
- UINT64 custom;
+ { /* otherwise, this proceeds like the byte case */
/* all accesses from this point on are for the debugger */
- space.set_debugger_access(global->debugger_access = true);
+ m_debugger_access = true;
+ space.set_debugger_access(true);
/* translate if necessary; if not mapped, return 0xffff */
- if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+ UINT64 custom;
+ if (apply_translation && !translate(space, TRANSLATE_READ_DEBUG, &address))
+ {
result = 0xffff;
-
- /* if there is a custom read handler, and it returns true, use that value */
+ }
else if (space.device().memory().read(space.spacenum(), address, 2, custom))
+ { /* if there is a custom read handler, and it returns true, use that value */
result = custom;
-
- /* otherwise, call the byte reading function for the translated address */
+ }
else
+ { /* otherwise, call the byte reading function for the translated address */
result = space.read_word(address);
+ }
/* no longer accessing via the debugger */
- space.set_debugger_access(global->debugger_access = false);
+ m_debugger_access = false;
+ space.set_debugger_access(false);
}
return result;
@@ -530,23 +462,20 @@ UINT16 debug_read_word(address_space &space, offs_t address, int apply_translati
/*-------------------------------------------------
- debug_read_dword - return a dword from the
- specified memory space
+ read_dword - return a dword from the specified
+ memory space
-------------------------------------------------*/
-UINT32 debug_read_dword(address_space &space, offs_t address, int apply_translation)
+UINT32 debugger_cpu::read_dword(address_space &space, offs_t address, int apply_translation)
{
- debugcpu_private *global = space.machine().debugcpu_data;
- UINT32 result;
-
/* mask against the logical byte mask */
address &= space.logbytemask();
- /* if this is misaligned read, or if there are no dword readers, just read two words */
+ UINT32 result;
if (!DWORD_ALIGNED(address))
- {
- UINT16 word0 = debug_read_word(space, address + 0, apply_translation);
- UINT16 word1 = debug_read_word(space, address + 2, apply_translation);
+ { /* if this is a misaligned read, or if there are no dword readers, just read two words */
+ UINT16 word0 = read_word(space, address + 0, apply_translation);
+ UINT16 word1 = read_word(space, address + 2, apply_translation);
/* based on the endianness, the result is assembled differently */
if (space.endianness() == ENDIANNESS_LITTLE)
@@ -554,29 +483,30 @@ UINT32 debug_read_dword(address_space &space, offs_t address, int apply_translat
else
result = word1 | (word0 << 16);
}
-
- /* otherwise, this proceeds like the byte case */
else
- {
- UINT64 custom;
+ { /* otherwise, this proceeds like the byte case */
/* all accesses from this point on are for the debugger */
- space.set_debugger_access(global->debugger_access = true);
+ m_debugger_access = true;
+ space.set_debugger_access(true);
- /* translate if necessary; if not mapped, return 0xffffffff */
- if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+ UINT64 custom;
+ if (apply_translation && !translate(space, TRANSLATE_READ_DEBUG, &address))
+ { /* translate if necessary; if not mapped, return 0xffffffff */
result = 0xffffffff;
-
- /* if there is a custom read handler, and it returns true, use that value */
+ }
else if (space.device().memory().read(space.spacenum(), address, 4, custom))
+ { /* if there is a custom read handler, and it returns true, use that value */
result = custom;
-
- /* otherwise, call the byte reading function for the translated address */
+ }
else
+ { /* otherwise, call the byte reading function for the translated address */
result = space.read_dword(address);
+ }
/* no longer accessing via the debugger */
- space.set_debugger_access(global->debugger_access = false);
+ m_debugger_access = false;
+ space.set_debugger_access(false);
}
return result;
@@ -584,23 +514,20 @@ UINT32 debug_read_dword(address_space &space, offs_t address, int apply_translat
/*-------------------------------------------------
- debug_read_qword - return a qword from the
- specified memory space
+ read_qword - return a qword from the specified
+ memory space
-------------------------------------------------*/
-UINT64 debug_read_qword(address_space &space, offs_t address, int apply_translation)
+UINT64 debugger_cpu::read_qword(address_space &space, offs_t address, int apply_translation)
{
- debugcpu_private *global = space.machine().debugcpu_data;
- UINT64 result;
-
/* mask against the logical byte mask */
address &= space.logbytemask();
- /* if this is misaligned read, or if there are no qword readers, just read two dwords */
+ UINT64 result;
if (!QWORD_ALIGNED(address))
- {
- UINT32 dword0 = debug_read_dword(space, address + 0, apply_translation);
- UINT32 dword1 = debug_read_dword(space, address + 4, apply_translation);
+ { /* if this is a misaligned read, or if there are no qword readers, just read two dwords */
+ UINT32 dword0 = read_dword(space, address + 0, apply_translation);
+ UINT32 dword1 = read_dword(space, address + 4, apply_translation);
/* based on the endianness, the result is assembled differently */
if (space.endianness() == ENDIANNESS_LITTLE)
@@ -608,29 +535,31 @@ UINT64 debug_read_qword(address_space &space, offs_t address, int apply_translat
else
result = dword1 | ((UINT64)dword0 << 32);
}
-
- /* otherwise, this proceeds like the byte case */
else
- {
- UINT64 custom;
+ { /* otherwise, this proceeds like the byte case */
/* all accesses from this point on are for the debugger */
- space.set_debugger_access(global->debugger_access = true);
+ m_debugger_access = true;
+ space.set_debugger_access(true);
/* translate if necessary; if not mapped, return 0xffffffffffffffff */
- if (apply_translation && !debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+ UINT64 custom;
+ if (apply_translation && !translate(space, TRANSLATE_READ_DEBUG, &address))
+ {
result = ~(UINT64)0;
-
- /* if there is a custom read handler, and it returns true, use that value */
+ }
else if (space.device().memory().read(space.spacenum(), address, 8, custom))
+ { /* if there is a custom read handler, and it returns true, use that value */
result = custom;
-
- /* otherwise, call the byte reading function for the translated address */
+ }
else
+ { /* otherwise, call the byte reading function for the translated address */
result = space.read_qword(address);
+ }
/* no longer accessing via the debugger */
- space.set_debugger_access(global->debugger_access = false);
+ m_debugger_access = false;
+ space.set_debugger_access(false);
}
return result;
@@ -638,41 +567,40 @@ UINT64 debug_read_qword(address_space &space, offs_t address, int apply_translat
/*-------------------------------------------------
- debug_read_memory - return 1,2,4 or 8 bytes
+ read_memory - return 1,2,4 or 8 bytes
from the specified memory space
-------------------------------------------------*/
-UINT64 debug_read_memory(address_space &space, offs_t address, int size, int apply_translation)
+UINT64 debugger_cpu::read_memory(address_space &space, offs_t address, int size, int apply_translation)
{
UINT64 result = ~(UINT64)0 >> (64 - 8*size);
switch (size)
{
- case 1: result = debug_read_byte(space, address, apply_translation); break;
- case 2: result = debug_read_word(space, address, apply_translation); break;
- case 4: result = debug_read_dword(space, address, apply_translation); break;
- case 8: result = debug_read_qword(space, address, apply_translation); break;
+ case 1: result = read_byte(space, address, apply_translation); break;
+ case 2: result = read_word(space, address, apply_translation); break;
+ case 4: result = read_dword(space, address, apply_translation); break;
+ case 8: result = read_qword(space, address, apply_translation); break;
}
return result;
}
/*-------------------------------------------------
- debug_write_byte - write a byte to the
- specified memory space
+ write_byte - write a byte to the specified
+ memory space
-------------------------------------------------*/
-void debug_write_byte(address_space &space, offs_t address, UINT8 data, int apply_translation)
+void debugger_cpu::write_byte(address_space &space, offs_t address, UINT8 data, int apply_translation)
{
- debugcpu_private *global = space.machine().debugcpu_data;
-
/* mask against the logical byte mask */
address &= space.logbytemask();
/* all accesses from this point on are for the debugger */
- space.set_debugger_access(global->debugger_access = true);
+ m_debugger_access = true;
+ space.set_debugger_access(true);
/* translate if necessary; if not mapped, we're done */
- if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address))
+ if (apply_translation && !translate(space, TRANSLATE_WRITE_DEBUG, &address))
;
/* if there is a custom write handler, and it returns true, use that */
@@ -684,20 +612,20 @@ void debug_write_byte(address_space &space, offs_t address, UINT8 data, int appl
space.write_byte(address, data);
/* no longer accessing via the debugger */
- space.set_debugger_access(global->debugger_access = false);
- global->memory_modified = true;
+ m_debugger_access = false;
+ space.set_debugger_access(false);
+
+ m_memory_modified = true;
}
/*-------------------------------------------------
- debug_write_word - write a word to the
- specified memory space
+ write_word - write a word to the specified
+ memory space
-------------------------------------------------*/
-void debug_write_word(address_space &space, offs_t address, UINT16 data, int apply_translation)
+void debugger_cpu::write_word(address_space &space, offs_t address, UINT16 data, int apply_translation)
{
- debugcpu_private *global = space.machine().debugcpu_data;
-
/* mask against the logical byte mask */
address &= space.logbytemask();
@@ -706,13 +634,13 @@ void debug_write_word(address_space &space, offs_t address, UINT16 data, int app
{
if (space.endianness() == ENDIANNESS_LITTLE)
{
- debug_write_byte(space, address + 0, data >> 0, apply_translation);
- debug_write_byte(space, address + 1, data >> 8, apply_translation);
+ write_byte(space, address + 0, data >> 0, apply_translation);
+ write_byte(space, address + 1, data >> 8, apply_translation);
}
else
{
- debug_write_byte(space, address + 0, data >> 8, apply_translation);
- debug_write_byte(space, address + 1, data >> 0, apply_translation);
+ write_byte(space, address + 0, data >> 8, apply_translation);
+ write_byte(space, address + 1, data >> 0, apply_translation);
}
}
@@ -720,10 +648,11 @@ void debug_write_word(address_space &space, offs_t address, UINT16 data, int app
else
{
/* all accesses from this point on are for the debugger */
- space.set_debugger_access(global->debugger_access = true);
+ m_debugger_access = true;
+ space.set_debugger_access(true);
/* translate if necessary; if not mapped, we're done */
- if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address))
+ if (apply_translation && !translate(space, TRANSLATE_WRITE_DEBUG, &address))
;
/* if there is a custom write handler, and it returns true, use that */
@@ -735,21 +664,21 @@ void debug_write_word(address_space &space, offs_t address, UINT16 data, int app
space.write_word(address, data);
/* no longer accessing via the debugger */
- space.set_debugger_access(global->debugger_access = false);
- global->memory_modified = true;
+ m_debugger_access = false;
+ space.set_debugger_access(false);
+
+ m_memory_modified = true;
}
}
/*-------------------------------------------------
- debug_write_dword - write a dword to the
- specified memory space
+ write_dword - write a dword to the specified
+ memory space
-------------------------------------------------*/
-void debug_write_dword(address_space &space, offs_t address, UINT32 data, int apply_translation)
+void debugger_cpu::write_dword(address_space &space, offs_t address, UINT32 data, int apply_translation)
{
- debugcpu_private *global = space.machine().debugcpu_data;
-
/* mask against the logical byte mask */
address &= space.logbytemask();
@@ -758,13 +687,13 @@ void debug_write_dword(address_space &space, offs_t address, UINT32 data, int ap
{
if (space.endianness() == ENDIANNESS_LITTLE)
{
- debug_write_word(space, address + 0, data >> 0, apply_translation);
- debug_write_word(space, address + 2, data >> 16, apply_translation);
+ write_word(space, address + 0, data >> 0, apply_translation);
+ write_word(space, address + 2, data >> 16, apply_translation);
}
else
{
- debug_write_word(space, address + 0, data >> 16, apply_translation);
- debug_write_word(space, address + 2, data >> 0, apply_translation);
+ write_word(space, address + 0, data >> 16, apply_translation);
+ write_word(space, address + 2, data >> 0, apply_translation);
}
}
@@ -772,10 +701,10 @@ void debug_write_dword(address_space &space, offs_t address, UINT32 data, int ap
else
{
/* all accesses from this point on are for the debugger */
- space.set_debugger_access(global->debugger_access = true);
+ space.set_debugger_access(m_debugger_access = true);
/* translate if necessary; if not mapped, we're done */
- if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address))
+ if (apply_translation && !translate(space, TRANSLATE_WRITE_DEBUG, &address))
;
/* if there is a custom write handler, and it returns true, use that */
@@ -787,21 +716,21 @@ void debug_write_dword(address_space &space, offs_t address, UINT32 data, int ap
space.write_dword(address, data);
/* no longer accessing via the debugger */
- space.set_debugger_access(global->debugger_access = false);
- global->memory_modified = true;
+ m_debugger_access = false;
+ space.set_debugger_access(false);
+
+ m_memory_modified = true;
}
}
/*-------------------------------------------------
- debug_write_qword - write a qword to the
- specified memory space
+ write_qword - write a qword to the specified
+ memory space
-------------------------------------------------*/
-void debug_write_qword(address_space &space, offs_t address, UINT64 data, int apply_translation)
+void debugger_cpu::write_qword(address_space &space, offs_t address, UINT64 data, int apply_translation)
{
- debugcpu_private *global = space.machine().debugcpu_data;
-
/* mask against the logical byte mask */
address &= space.logbytemask();
@@ -810,13 +739,13 @@ void debug_write_qword(address_space &space, offs_t address, UINT64 data, int ap
{
if (space.endianness() == ENDIANNESS_LITTLE)
{
- debug_write_dword(space, address + 0, data >> 0, apply_translation);
- debug_write_dword(space, address + 4, data >> 32, apply_translation);
+ write_dword(space, address + 0, data >> 0, apply_translation);
+ write_dword(space, address + 4, data >> 32, apply_translation);
}
else
{
- debug_write_dword(space, address + 0, data >> 32, apply_translation);
- debug_write_dword(space, address + 4, data >> 0, apply_translation);
+ write_dword(space, address + 0, data >> 32, apply_translation);
+ write_dword(space, address + 4, data >> 0, apply_translation);
}
}
@@ -824,10 +753,11 @@ void debug_write_qword(address_space &space, offs_t address, UINT64 data, int ap
else
{
/* all accesses from this point on are for the debugger */
- space.set_debugger_access(global->debugger_access = true);
+ m_debugger_access = true;
+ space.set_debugger_access(true);
/* translate if necessary; if not mapped, we're done */
- if (apply_translation && !debug_cpu_translate(space, TRANSLATE_WRITE_DEBUG, &address))
+ if (apply_translation && !translate(space, TRANSLATE_WRITE_DEBUG, &address))
;
/* if there is a custom write handler, and it returns true, use that */
@@ -839,48 +769,51 @@ void debug_write_qword(address_space &space, offs_t address, UINT64 data, int ap
space.write_qword(address, data);
/* no longer accessing via the debugger */
- space.set_debugger_access(global->debugger_access = false);
- global->memory_modified = true;
+ m_debugger_access = false;
+ space.set_debugger_access(false);
+
+ m_memory_modified = true;
}
}
/*-------------------------------------------------
- debug_write_memory - write 1,2,4 or 8 bytes
- to the specified memory space
+ write_memory - write 1,2,4 or 8 bytes to the
+ specified memory space
-------------------------------------------------*/
-void debug_write_memory(address_space &space, offs_t address, UINT64 data, int size, int apply_translation)
+void debugger_cpu::write_memory(address_space &space, offs_t address, UINT64 data, int size, int apply_translation)
{
switch (size)
{
- case 1: debug_write_byte(space, address, data, apply_translation); break;
- case 2: debug_write_word(space, address, data, apply_translation); break;
- case 4: debug_write_dword(space, address, data, apply_translation); break;
- case 8: debug_write_qword(space, address, data, apply_translation); break;
+ case 1: write_byte(space, address, data, apply_translation); break;
+ case 2: write_word(space, address, data, apply_translation); break;
+ case 4: write_dword(space, address, data, apply_translation); break;
+ case 8: write_qword(space, address, data, apply_translation); break;
}
}
/*-------------------------------------------------
- debug_read_opcode - read 1,2,4 or 8 bytes at
- the given offset from opcode space
+ read_opcode - read 1,2,4 or 8 bytes at the
+ given offset from opcode space
-------------------------------------------------*/
-UINT64 debug_read_opcode(address_space &space, offs_t address, int size)
+UINT64 debugger_cpu::read_opcode(address_space &space, offs_t address, int size)
{
UINT64 result = ~(UINT64)0 & (~(UINT64)0 >> (64 - 8*size)), result2;
- debugcpu_private *global = space.machine().debugcpu_data;
/* keep in logical range */
address &= space.logbytemask();
/* return early if we got the result directly */
- space.set_debugger_access(global->debugger_access = true);
+ m_debugger_access = true;
+ space.set_debugger_access(true);
device_memory_interface *memory;
if (space.device().interface(memory) && memory->readop(address, size, result2))
{
- space.set_debugger_access(global->debugger_access = false);
+ m_debugger_access = false;
+ space.set_debugger_access(false);
return result2;
}
@@ -888,8 +821,8 @@ UINT64 debug_read_opcode(address_space &space, offs_t address, int size)
if (size > space.data_width() / 8)
{
int halfsize = size / 2;
- UINT64 r0 = debug_read_opcode(space, address + 0, halfsize);
- UINT64 r1 = debug_read_opcode(space, address + halfsize, halfsize);
+ UINT64 r0 = read_opcode(space, address + 0, halfsize);
+ UINT64 r1 = read_opcode(space, address + halfsize, halfsize);
if (space.endianness() == ENDIANNESS_LITTLE)
return r0 | (r1 << (8 * halfsize));
@@ -898,7 +831,7 @@ UINT64 debug_read_opcode(address_space &space, offs_t address, int size)
}
/* translate to physical first */
- if (!debug_cpu_translate(space, TRANSLATE_FETCH_DEBUG, &address))
+ if (!translate(space, TRANSLATE_FETCH_DEBUG, &address))
return result;
/* keep in physical range */
@@ -953,12 +886,15 @@ UINT64 debug_read_opcode(address_space &space, offs_t address, int size)
break;
default:
- fatalerror("debug_read_opcode: unknown type = %d\n", space.data_width() / 8 * 10 + size);
+ fatalerror("read_opcode: unknown type = %d\n", space.data_width() / 8 * 10 + size);
}
/* turn on debugger access */
- if (!global->debugger_access)
- space.set_debugger_access(global->debugger_access = true);
+ if (!m_debugger_access)
+ {
+ m_debugger_access = true;
+ space.set_debugger_access(true);
+ }
/* switch off the size and handle unaligned accesses */
switch (size)
@@ -1007,7 +943,9 @@ UINT64 debug_read_opcode(address_space &space, offs_t address, int size)
}
/* no longer accessing via the debugger */
- space.set_debugger_access(global->debugger_access = false);
+ m_debugger_access = false;
+ space.set_debugger_access(false);
+
return result;
}
@@ -1018,16 +956,12 @@ UINT64 debug_read_opcode(address_space &space, offs_t address, int size)
***************************************************************************/
/*-------------------------------------------------
- debug_cpu_exit - free all memory
+ exit - free all memory
-------------------------------------------------*/
-static void debug_cpu_exit(running_machine &machine)
+void debugger_cpu::exit()
{
- debugcpu_private *global = machine.debugcpu_data;
-
- /* free the global symbol table */
- if (global != nullptr)
- global_free(global->symtable);
+ global_free(m_symtable);
}
@@ -1035,11 +969,10 @@ static void debug_cpu_exit(running_machine &machine)
on_vblank - called when a VBLANK hits
-------------------------------------------------*/
-static void on_vblank(running_machine &machine, screen_device &device, bool vblank_state)
+void debugger_cpu::on_vblank(screen_device &device, bool vblank_state)
{
/* just set a global flag to be consumed later */
- if (vblank_state)
- device.machine().debugcpu_data->vblank_occurred = true;
+ m_vblank_occurred = true;
}
@@ -1048,12 +981,12 @@ static void on_vblank(running_machine &machine, screen_device &device, bool vbla
flags on all CPUs
-------------------------------------------------*/
-static void reset_transient_flags(running_machine &machine)
+void debugger_cpu::reset_transient_flags()
{
/* loop over CPUs and reset the transient flags */
- for (device_t &device : device_iterator(machine.root_device()))
+ for (device_t &device : device_iterator(m_machine.root_device()))
device.debug()->reset_transient_flag();
- machine.debugcpu_data->m_stop_when_not_device = nullptr;
+ m_stop_when_not_device = nullptr;
}
@@ -1062,42 +995,37 @@ static void reset_transient_flags(running_machine &machine)
a source file
-------------------------------------------------*/
-static void process_source_file(running_machine &machine)
+void debugger_cpu::process_source_file()
{
- debugcpu_private *global = machine.debugcpu_data;
-
/* loop until the file is exhausted or until we are executing again */
- while (global->source_file != nullptr && global->execution_state == EXECUTION_STATE_STOPPED)
+ while (m_source_file != nullptr && m_execution_state == EXECUTION_STATE_STOPPED)
{
- char buf[512];
- int i;
- char *s;
-
/* stop at the end of file */
- if (feof(global->source_file))
+ if (feof(m_source_file))
{
- fclose(global->source_file);
- global->source_file = nullptr;
+ fclose(m_source_file);
+ m_source_file = nullptr;
return;
}
/* fetch the next line */
+ char buf[512];
memset(buf, 0, sizeof(buf));
- fgets(buf, sizeof(buf), global->source_file);
+ fgets(buf, sizeof(buf), m_source_file);
/* strip out comments (text after '//') */
- s = strstr(buf, "//");
+ char *s = strstr(buf, "//");
if (s)
*s = '\0';
/* strip whitespace */
- i = (int)strlen(buf);
+ int i = (int)strlen(buf);
while((i > 0) && (isspace((UINT8)buf[i-1])))
buf[--i] = '\0';
/* execute the command */
if (buf[0])
- debug_console_execute_command(machine, buf, 1);
+ m_machine.debugger().console().execute_command(buf, true);
}
}
@@ -1112,12 +1040,12 @@ static void process_source_file(running_machine &machine)
based on a case insensitive tag search
-------------------------------------------------*/
-static device_t *expression_get_device(running_machine &machine, const char *tag)
+device_t* debugger_cpu::expression_get_device(const char *tag)
{
// convert to lowercase then lookup the name (tags are enforced to be all lower case)
std::string fullname(tag);
strmakelower(fullname);
- return machine.device(fullname.c_str());
+ return m_machine.device(fullname.c_str());
}
@@ -1127,63 +1055,69 @@ static device_t *expression_get_device(running_machine &machine, const char *tag
space
-------------------------------------------------*/
-static UINT64 expression_read_memory(void *param, const char *name, expression_space spacenum, UINT32 address, int size)
+UINT64 debugger_cpu::expression_read_memory(void *param, const char *name, expression_space spacenum, UINT32 address, int size)
{
- running_machine &machine = *(running_machine *)param;
- UINT64 result = ~(UINT64)0 >> (64 - 8*size);
- device_t *device = nullptr;
-
switch (spacenum)
{
case EXPSPACE_PROGRAM_LOGICAL:
case EXPSPACE_DATA_LOGICAL:
case EXPSPACE_IO_LOGICAL:
case EXPSPACE_SPACE3_LOGICAL:
+ {
+ device_t *device = nullptr;
if (name != nullptr)
- device = expression_get_device(machine, name);
+ device = expression_get_device(name);
if (device == nullptr)
- device = debug_cpu_get_visible_cpu(machine);
+ device = m_machine.debugger().cpu().get_visible_cpu();
if (device->memory().has_space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL)))
{
address_space &space = device->memory().space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL));
- result = debug_read_memory(space, space.address_to_byte(address), size, true);
+ return read_memory(space, space.address_to_byte(address), size, true);
}
break;
+ }
case EXPSPACE_PROGRAM_PHYSICAL:
case EXPSPACE_DATA_PHYSICAL:
case EXPSPACE_IO_PHYSICAL:
case EXPSPACE_SPACE3_PHYSICAL:
+ {
+ device_t *device = nullptr;
if (name != nullptr)
- device = expression_get_device(machine, name);
+ device = expression_get_device(name);
if (device == nullptr)
- device = debug_cpu_get_visible_cpu(machine);
+ device = m_machine.debugger().cpu().get_visible_cpu();
if (device->memory().has_space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL)))
{
address_space &space = device->memory().space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL));
- result = debug_read_memory(space, space.address_to_byte(address), size, false);
+ return read_memory(space, space.address_to_byte(address), size, false);
}
break;
+ }
case EXPSPACE_OPCODE:
case EXPSPACE_RAMWRITE:
+ {
+ device_t *device = nullptr;
if (name != nullptr)
- device = expression_get_device(machine, name);
+ device = expression_get_device(name);
if (device == nullptr)
- device = debug_cpu_get_visible_cpu(machine);
- result = expression_read_program_direct(device->memory().space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size);
+ device = m_machine.debugger().cpu().get_visible_cpu();
+ return expression_read_program_direct(device->memory().space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size);
break;
+ }
case EXPSPACE_REGION:
if (name == nullptr)
break;
- result = expression_read_memory_region(machine, name, address, size);
+ return expression_read_memory_region(name, address, size);
break;
default:
break;
}
- return result;
+
+ return 0;
}
@@ -1192,9 +1126,8 @@ static UINT64 expression_read_memory(void *param, const char *name, expression_s
directly from an opcode or RAM pointer
-------------------------------------------------*/
-static UINT64 expression_read_program_direct(address_space &space, int opcode, offs_t address, int size)
+UINT64 debugger_cpu::expression_read_program_direct(address_space &space, int opcode, offs_t address, int size)
{
- UINT64 result = ~(UINT64)0 >> (64 - 8*size);
UINT8 *base;
/* adjust the address into a byte address, but not if being called recursively */
@@ -1205,17 +1138,16 @@ static UINT64 expression_read_program_direct(address_space &space, int opcode, o
if (size > 1)
{
int halfsize = size / 2;
- UINT64 r0, r1;
/* read each half, from lower address to upper address */
- r0 = expression_read_program_direct(space, opcode | 2, address + 0, halfsize);
- r1 = expression_read_program_direct(space, opcode | 2, address + halfsize, halfsize);
+ UINT64 r0 = expression_read_program_direct(space, opcode | 2, address + 0, halfsize);
+ UINT64 r1 = expression_read_program_direct(space, opcode | 2, address + halfsize, halfsize);
/* assemble based on the target endianness */
if (space.endianness() == ENDIANNESS_LITTLE)
- result = r0 | (r1 << (8 * halfsize));
+ return r0 | (r1 << (8 * halfsize));
else
- result = r1 | (r0 << (8 * halfsize));
+ return r1 | (r0 << (8 * halfsize));
}
/* handle the byte-sized final requests */
@@ -1231,12 +1163,13 @@ static UINT64 expression_read_program_direct(address_space &space, int opcode, o
if (base != nullptr)
{
if (space.endianness() == ENDIANNESS_LITTLE)
- result = base[BYTE8_XOR_LE(address) & lowmask];
+ return base[BYTE8_XOR_LE(address) & lowmask];
else
- result = base[BYTE8_XOR_BE(address) & lowmask];
+ return base[BYTE8_XOR_BE(address) & lowmask];
}
}
- return result;
+
+ return 0;
}
@@ -1245,9 +1178,9 @@ static UINT64 expression_read_program_direct(address_space &space, int opcode, o
from a memory region
-------------------------------------------------*/
-static UINT64 expression_read_memory_region(running_machine &machine, const char *rgntag, offs_t address, int size)
+UINT64 debugger_cpu::expression_read_memory_region(const char *rgntag, offs_t address, int size)
{
- memory_region *region = machine.root_device().memregion(rgntag);
+ memory_region *region = m_machine.root_device().memregion(rgntag);
UINT64 result = ~(UINT64)0 >> (64 - 8*size);
/* make sure we get a valid base before proceeding */
@@ -1260,8 +1193,8 @@ static UINT64 expression_read_memory_region(running_machine &machine, const char
UINT64 r0, r1;
/* read each half, from lower address to upper address */
- r0 = expression_read_memory_region(machine, rgntag, address + 0, halfsize);
- r1 = expression_read_memory_region(machine, rgntag, address + halfsize, halfsize);
+ r0 = expression_read_memory_region(rgntag, address + 0, halfsize);
+ r1 = expression_read_memory_region(rgntag, address + halfsize, halfsize);
/* assemble based on the target endianness */
if (region->endianness() == ENDIANNESS_LITTLE)
@@ -1294,9 +1227,8 @@ static UINT64 expression_read_memory_region(running_machine &machine, const char
space
-------------------------------------------------*/
-static void expression_write_memory(void *param, const char *name, expression_space spacenum, UINT32 address, int size, UINT64 data)
+void debugger_cpu::expression_write_memory(void *param, const char *name, expression_space spacenum, UINT32 address, int size, UINT64 data)
{
- running_machine &machine = *(running_machine *)param;
device_t *device = nullptr;
switch (spacenum)
@@ -1306,13 +1238,13 @@ static void expression_write_memory(void *param, const char *name, expression_sp
case EXPSPACE_IO_LOGICAL:
case EXPSPACE_SPACE3_LOGICAL:
if (name != nullptr)
- device = expression_get_device(machine, name);
+ device = expression_get_device(name);
if (device == nullptr)
- device = debug_cpu_get_visible_cpu(machine);
+ device = m_machine.debugger().cpu().get_visible_cpu();
if (device->memory().has_space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL)))
{
address_space &space = device->memory().space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_LOGICAL));
- debug_write_memory(space, space.address_to_byte(address), data, size, true);
+ write_memory(space, space.address_to_byte(address), data, size, true);
}
break;
@@ -1321,29 +1253,29 @@ static void expression_write_memory(void *param, const char *name, expression_sp
case EXPSPACE_IO_PHYSICAL:
case EXPSPACE_SPACE3_PHYSICAL:
if (name != nullptr)
- device = expression_get_device(machine, name);
+ device = expression_get_device(name);
if (device == nullptr)
- device = debug_cpu_get_visible_cpu(machine);
+ device = m_machine.debugger().cpu().get_visible_cpu();
if (device->memory().has_space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL)))
{
address_space &space = device->memory().space(AS_PROGRAM + (spacenum - EXPSPACE_PROGRAM_PHYSICAL));
- debug_write_memory(space, space.address_to_byte(address), data, size, false);
+ write_memory(space, space.address_to_byte(address), data, size, false);
}
break;
case EXPSPACE_OPCODE:
case EXPSPACE_RAMWRITE:
if (name != nullptr)
- device = expression_get_device(machine, name);
+ device = expression_get_device(name);
if (device == nullptr)
- device = debug_cpu_get_visible_cpu(machine);
+ device = m_machine.debugger().cpu().get_visible_cpu();
expression_write_program_direct(device->memory().space(AS_PROGRAM), (spacenum == EXPSPACE_OPCODE), address, size, data);
break;
case EXPSPACE_REGION:
if (name == nullptr)
break;
- expression_write_memory_region(machine, name, address, size, data);
+ expression_write_memory_region(name, address, size, data);
break;
default:
@@ -1357,11 +1289,8 @@ static void expression_write_memory(void *param, const char *name, expression_sp
directly to an opcode or RAM pointer
-------------------------------------------------*/
-static void expression_write_program_direct(address_space &space, int opcode, offs_t address, int size, UINT64 data)
+void debugger_cpu::expression_write_program_direct(address_space &space, int opcode, offs_t address, int size, UINT64 data)
{
- debugcpu_private *global = space.machine().debugcpu_data;
- UINT8 *base;
-
/* adjust the address into a byte address, but not if being called recursively */
if ((opcode & 2) == 0)
address = space.address_to_byte(address);
@@ -1370,10 +1299,10 @@ static void expression_write_program_direct(address_space &space, int opcode, of
if (size > 1)
{
int halfsize = size / 2;
- UINT64 r0, r1, halfmask;
/* break apart based on the target endianness */
- halfmask = ~(UINT64)0 >> (64 - 8 * halfsize);
+ UINT64 halfmask = ~(UINT64)0 >> (64 - 8 * halfsize);
+ UINT64 r0, r1;
if (space.endianness() == ENDIANNESS_LITTLE)
{
r0 = data & halfmask;
@@ -1397,7 +1326,7 @@ static void expression_write_program_direct(address_space &space, int opcode, of
offs_t lowmask = space.data_width() / 8 - 1;
/* get the base of memory, aligned to the address minus the lowbits */
- base = (UINT8 *)space.get_read_ptr(address & ~lowmask);
+ UINT8 *base = (UINT8 *)space.get_read_ptr(address & ~lowmask);
/* if we have a valid base, write the appropriate byte */
if (base != nullptr)
@@ -1406,7 +1335,7 @@ static void expression_write_program_direct(address_space &space, int opcode, of
base[BYTE8_XOR_LE(address) & lowmask] = data;
else
base[BYTE8_XOR_BE(address) & lowmask] = data;
- global->memory_modified = true;
+ m_memory_modified = true;
}
}
}
@@ -1417,10 +1346,9 @@ static void expression_write_program_direct(address_space &space, int opcode, of
from a memory region
-------------------------------------------------*/
-static void expression_write_memory_region(running_machine &machine, const char *rgntag, offs_t address, int size, UINT64 data)
+void debugger_cpu::expression_write_memory_region(const char *rgntag, offs_t address, int size, UINT64 data)
{
- debugcpu_private *global = machine.debugcpu_data;
- memory_region *region = machine.root_device().memregion(rgntag);
+ memory_region *region = m_machine.root_device().memregion(rgntag);
/* make sure we get a valid base before proceeding */
if (region != nullptr)
@@ -1429,10 +1357,10 @@ static void expression_write_memory_region(running_machine &machine, const char
if (size > 1)
{
int halfsize = size / 2;
- UINT64 r0, r1, halfmask;
/* break apart based on the target endianness */
- halfmask = ~(UINT64)0 >> (64 - 8 * halfsize);
+ UINT64 halfmask = ~(UINT64)0 >> (64 - 8 * halfsize);
+ UINT64 r0, r1;
if (region->endianness() == ENDIANNESS_LITTLE)
{
r0 = data & halfmask;
@@ -1445,8 +1373,8 @@ static void expression_write_memory_region(running_machine &machine, const char
}
/* write each half, from lower address to upper address */
- expression_write_memory_region(machine, rgntag, address + 0, halfsize, r0);
- expression_write_memory_region(machine, rgntag, address + halfsize, halfsize, r1);
+ expression_write_memory_region(rgntag, address + 0, halfsize, r0);
+ expression_write_memory_region(rgntag, address + halfsize, halfsize, r1);
}
/* only process if we're within range */
@@ -1458,10 +1386,14 @@ static void expression_write_memory_region(running_machine &machine, const char
/* if we have a valid base, set the appropriate byte */
if (region->endianness() == ENDIANNESS_LITTLE)
+ {
base[BYTE8_XOR_LE(address) & lowmask] = data;
+ }
else
+ {
base[BYTE8_XOR_BE(address) & lowmask] = data;
- global->memory_modified = true;
+ }
+ m_memory_modified = true;
}
}
}
@@ -1473,9 +1405,8 @@ static void expression_write_memory_region(running_machine &machine, const char
appropriate name
-------------------------------------------------*/
-static expression_error::error_code expression_validate(void *param, const char *name, expression_space space)
+expression_error::error_code debugger_cpu::expression_validate(void *param, const char *name, expression_space space)
{
- running_machine &machine = *reinterpret_cast<running_machine *>(param);
device_t *device = nullptr;
switch (space)
@@ -1486,12 +1417,12 @@ static expression_error::error_code expression_validate(void *param, const char
case EXPSPACE_SPACE3_LOGICAL:
if (name)
{
- device = expression_get_device(machine, name);
+ device = expression_get_device(name);
if (!device)
return expression_error::INVALID_MEMORY_NAME;
}
if (!device)
- device = debug_cpu_get_visible_cpu(machine);
+ device = m_machine.debugger().cpu().get_visible_cpu();
if (!device->memory().has_space(AS_PROGRAM + (space - EXPSPACE_PROGRAM_LOGICAL)))
return expression_error::NO_SUCH_MEMORY_SPACE;
break;
@@ -1502,12 +1433,12 @@ static expression_error::error_code expression_validate(void *param, const char
case EXPSPACE_SPACE3_PHYSICAL:
if (name)
{
- device = expression_get_device(machine, name);
+ device = expression_get_device(name);
if (!device)
return expression_error::INVALID_MEMORY_NAME;
}
if (!device)
- device = debug_cpu_get_visible_cpu(machine);
+ device = m_machine.debugger().cpu().get_visible_cpu();
if (!device->memory().has_space(AS_PROGRAM + (space - EXPSPACE_PROGRAM_PHYSICAL)))
return expression_error::NO_SUCH_MEMORY_SPACE;
break;
@@ -1516,12 +1447,12 @@ static expression_error::error_code expression_validate(void *param, const char
case EXPSPACE_RAMWRITE:
if (name)
{
- device = expression_get_device(machine, name);
+ device = expression_get_device(name);
if (!device)
return expression_error::INVALID_MEMORY_NAME;
}
if (!device)
- device = debug_cpu_get_visible_cpu(machine);
+ device = m_machine.debugger().cpu().get_visible_cpu();
if (!device->memory().has_space(AS_PROGRAM))
return expression_error::NO_SUCH_MEMORY_SPACE;
break;
@@ -1529,7 +1460,7 @@ static expression_error::error_code expression_validate(void *param, const char
case EXPSPACE_REGION:
if (!name)
return expression_error::MISSING_MEMORY_NAME;
- if (!machine.root_device().memregion(name) || !machine.root_device().memregion(name)->base())
+ if (!m_machine.root_device().memregion(name) || !m_machine.root_device().memregion(name)->base())
return expression_error::INVALID_MEMORY_NAME;
break;
@@ -1549,7 +1480,7 @@ static expression_error::error_code expression_validate(void *param, const char
get_beamx - get beam horizontal position
-------------------------------------------------*/
-static UINT64 get_beamx(symbol_table &table, void *ref)
+UINT64 debugger_cpu::get_beamx(symbol_table &table, void *ref)
{
screen_device *screen = reinterpret_cast<screen_device *>(ref);
return (screen != nullptr) ? screen->hpos() : 0;
@@ -1560,7 +1491,7 @@ static UINT64 get_beamx(symbol_table &table, void *ref)
get_beamy - get beam vertical position
-------------------------------------------------*/
-static UINT64 get_beamy(symbol_table &table, void *ref)
+UINT64 debugger_cpu::get_beamy(symbol_table &table, void *ref)
{
screen_device *screen = reinterpret_cast<screen_device *>(ref);
return (screen != nullptr) ? screen->vpos() : 0;
@@ -1571,7 +1502,7 @@ static UINT64 get_beamy(symbol_table &table, void *ref)
get_frame - get current frame number
-------------------------------------------------*/
-static UINT64 get_frame(symbol_table &table, void *ref)
+UINT64 debugger_cpu::get_frame(symbol_table &table, void *ref)
{
screen_device *screen = reinterpret_cast<screen_device *>(ref);
return (screen != nullptr) ? screen->frame_number() : 0;
@@ -1583,16 +1514,116 @@ static UINT64 get_frame(symbol_table &table, void *ref)
'cpunum' symbol
-------------------------------------------------*/
-static UINT64 get_cpunum(symbol_table &table, void *ref)
+UINT64 debugger_cpu::get_cpunum(symbol_table &table, void *ref)
{
- running_machine &machine = *reinterpret_cast<running_machine *>(table.globalref());
- device_t *target = machine.debugcpu_data->visiblecpu;
+ execute_interface_iterator iter(m_machine.root_device());
+ return iter.indexof(m_visiblecpu->execute());
+}
+
+
+void debugger_cpu::start_hook(device_t *device, bool stop_on_vblank)
+{
+ // stash a pointer to the current live CPU
+ assert(m_livecpu == nullptr);
+ m_livecpu = device;
+
+ // if we're a new device, stop now
+ if (m_stop_when_not_device != nullptr && m_stop_when_not_device != device)
+ {
+ m_stop_when_not_device = nullptr;
+ m_execution_state = EXECUTION_STATE_STOPPED;
+ reset_transient_flags();
+ }
- execute_interface_iterator iter(machine.root_device());
- return iter.indexof(target->execute());
+ // if we're running, do some periodic updating
+ if (m_execution_state != EXECUTION_STATE_STOPPED)
+ {
+ if (device == m_visiblecpu && osd_ticks() > m_last_periodic_update_time + osd_ticks_per_second() / 4)
+ { // check for periodic updates
+ m_machine.debug_view().update_all();
+ m_machine.debug_view().flush_osd_updates();
+ m_last_periodic_update_time = osd_ticks();
+ }
+ else if (device == m_breakcpu)
+ { // check for pending breaks
+ m_execution_state = EXECUTION_STATE_STOPPED;
+ m_breakcpu = nullptr;
+ }
+
+ // if a VBLANK occurred, check on things
+ if (m_vblank_occurred)
+ {
+ m_vblank_occurred = false;
+
+ // if we were waiting for a VBLANK, signal it now
+ if (stop_on_vblank)
+ {
+ m_execution_state = EXECUTION_STATE_STOPPED;
+ m_machine.debugger().console().printf("Stopped at VBLANK\n");
+ }
+ }
+ // check for debug keypresses
+ if (m_machine.ui_input().pressed(IPT_UI_DEBUG_BREAK))
+ m_visiblecpu->debug()->halt_on_next_instruction("User-initiated break\n");
+ }
}
+void debugger_cpu::stop_hook(device_t *device)
+{
+ assert(m_livecpu == device);
+ // clear the live CPU
+ m_livecpu = nullptr;
+}
+
+void debugger_cpu::ensure_comments_loaded()
+{
+ if (!m_comments_loaded)
+ {
+ comment_load(true);
+ m_comments_loaded = true;
+ }
+}
+
+
+//-------------------------------------------------
+// go_next_device - execute until we hit the next
+// device
+//-------------------------------------------------
+
+void debugger_cpu::go_next_device(device_t *device)
+{
+ m_stop_when_not_device = device;
+ m_execution_state = EXECUTION_STATE_RUNNING;
+}
+
+void debugger_cpu::go_vblank()
+{
+ m_vblank_occurred = false;
+ m_execution_state = EXECUTION_STATE_RUNNING;
+}
+
+void debugger_cpu::halt_on_next_instruction(device_t *device, util::format_argument_pack<std::ostream> &&args)
+{
+ // if something is pending on this CPU already, ignore this request
+ if (device == m_breakcpu)
+ return;
+
+ // output the message to the console
+ m_machine.debugger().console().vprintf(std::move(args));
+
+ // if we are live, stop now, otherwise note that we want to break there
+ if (device == m_livecpu)
+ {
+ m_execution_state = EXECUTION_STATE_STOPPED;
+ if (m_livecpu != nullptr)
+ m_livecpu->debug()->compute_debug_flags();
+ }
+ else
+ {
+ m_breakcpu = device;
+ }
+}
//**************************************************************************
// DEVICE DEBUG
@@ -1603,36 +1634,36 @@ static UINT64 get_cpunum(symbol_table &table, void *ref)
//-------------------------------------------------
device_debug::device_debug(device_t &device)
- : m_device(device),
- m_exec(nullptr),
- m_memory(nullptr),
- m_state(nullptr),
- m_disasm(nullptr),
- m_flags(0),
- m_symtable(&device, debug_cpu_get_global_symtable(device.machine())),
- m_instrhook(nullptr),
- m_dasm_override(nullptr),
- m_opwidth(0),
- m_stepaddr(0),
- m_stepsleft(0),
- m_stopaddr(0),
- m_stoptime(attotime::zero),
- m_stopirq(0),
- m_stopexception(0),
- m_endexectime(attotime::zero),
- m_total_cycles(0),
- m_last_total_cycles(0),
- m_pc_history_index(0),
- m_bplist(nullptr),
- m_rplist(nullptr),
- m_trace(nullptr),
- m_hotspot_threshhold(0),
- m_track_pc_set(),
- m_track_pc(false),
- m_comment_set(),
- m_comment_change(0),
- m_track_mem_set(),
- m_track_mem(false)
+ : m_device(device)
+ , m_exec(nullptr)
+ , m_memory(nullptr)
+ , m_state(nullptr)
+ , m_disasm(nullptr)
+ , m_flags(0)
+ , m_symtable(&device, device.machine().debugger().cpu().get_global_symtable())
+ , m_instrhook(nullptr)
+ , m_dasm_override(nullptr)
+ , m_opwidth(0)
+ , m_stepaddr(0)
+ , m_stepsleft(0)
+ , m_stopaddr(0)
+ , m_stoptime(attotime::zero)
+ , m_stopirq(0)
+ , m_stopexception(0)
+ , m_endexectime(attotime::zero)
+ , m_total_cycles(0)
+ , m_last_total_cycles(0)
+ , m_pc_history_index(0)
+ , m_bplist(nullptr)
+ , m_rplist(nullptr)
+ , m_trace(nullptr)
+ , m_hotspot_threshhold(0)
+ , m_track_pc_set()
+ , m_track_pc(false)
+ , m_comment_set()
+ , m_comment_change(0)
+ , m_track_mem_set()
+ , m_track_mem(false)
{
memset(m_pc_history, 0, sizeof(m_pc_history));
memset(m_wplist, 0, sizeof(m_wplist));
@@ -1699,7 +1730,6 @@ device_debug::~device_debug()
registerpoint_clear_all();
}
-
//-------------------------------------------------
// start_hook - the scheduler calls this hook
// before beginning execution for the given device
@@ -1707,60 +1737,13 @@ device_debug::~device_debug()
void device_debug::start_hook(const attotime &endtime)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert((m_device.machine().debug_flags & DEBUG_FLAG_ENABLED) != 0);
- // stash a pointer to the current live CPU
- assert(global->livecpu == nullptr);
- global->livecpu = &m_device;
-
- // if we're a new device, stop now
- if (global->m_stop_when_not_device != nullptr && global->m_stop_when_not_device != &m_device)
- {
- global->m_stop_when_not_device = nullptr;
- global->execution_state = EXECUTION_STATE_STOPPED;
- reset_transient_flags(m_device.machine());
- }
+ m_device.machine().debugger().cpu().start_hook(&m_device, (m_flags & DEBUG_FLAG_STOP_VBLANK) != 0);
// update the target execution end time
m_endexectime = endtime;
- // if we're running, do some periodic updating
- if (global->execution_state != EXECUTION_STATE_STOPPED)
- {
- // check for periodic updates
- if (&m_device == global->visiblecpu && osd_ticks() > global->last_periodic_update_time + osd_ticks_per_second()/4)
- {
- m_device.machine().debug_view().update_all();
- m_device.machine().debug_view().flush_osd_updates();
- global->last_periodic_update_time = osd_ticks();
- }
-
- // check for pending breaks
- else if (&m_device == global->breakcpu)
- {
- global->execution_state = EXECUTION_STATE_STOPPED;
- global->breakcpu = nullptr;
- }
-
- // if a VBLANK occurred, check on things
- if (global->vblank_occurred)
- {
- global->vblank_occurred = false;
-
- // if we were waiting for a VBLANK, signal it now
- if ((m_flags & DEBUG_FLAG_STOP_VBLANK) != 0)
- {
- global->execution_state = EXECUTION_STATE_STOPPED;
- debug_console_printf(m_device.machine(), "Stopped at VBLANK\n");
- }
- }
- // check for debug keypresses
- if (m_device.machine().ui_input().pressed(IPT_UI_DEBUG_BREAK))
- global->visiblecpu->debug()->halt_on_next_instruction("User-initiated break\n");
- }
-
// recompute the debugging mode
compute_debug_flags();
}
@@ -1773,12 +1756,7 @@ void device_debug::start_hook(const attotime &endtime)
void device_debug::stop_hook()
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
- assert(global->livecpu == &m_device);
-
- // clear the live CPU
- global->livecpu = nullptr;
+ m_device.machine().debugger().cpu().stop_hook(&m_device);
}
@@ -1789,13 +1767,11 @@ void device_debug::stop_hook()
void device_debug::interrupt_hook(int irqline)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
// see if this matches a pending interrupt request
if ((m_flags & DEBUG_FLAG_STOP_INTERRUPT) != 0 && (m_stopirq == -1 || m_stopirq == irqline))
{
- global->execution_state = EXECUTION_STATE_STOPPED;
- debug_console_printf(m_device.machine(), "Stopped on interrupt (CPU '%s', IRQ %d)\n", m_device.tag(), irqline);
+ m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_STOPPED);
+ m_device.machine().debugger().console().printf("Stopped on interrupt (CPU '%s', IRQ %d)\n", m_device.tag(), irqline);
compute_debug_flags();
}
}
@@ -1808,13 +1784,11 @@ void device_debug::interrupt_hook(int irqline)
void device_debug::exception_hook(int exception)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
// see if this matches a pending interrupt request
if ((m_flags & DEBUG_FLAG_STOP_EXCEPTION) != 0 && (m_stopexception == -1 || m_stopexception == exception))
{
- global->execution_state = EXECUTION_STATE_STOPPED;
- debug_console_printf(m_device.machine(), "Stopped on exception (CPU '%s', exception %d)\n", m_device.tag(), exception);
+ m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_STOPPED);
+ m_device.machine().debugger().console().printf("Stopped on exception (CPU '%s', exception %d)\n", m_device.tag(), exception);
compute_debug_flags();
}
}
@@ -1828,10 +1802,10 @@ void device_debug::exception_hook(int exception)
void device_debug::instruction_hook(offs_t curpc)
{
running_machine &machine = m_device.machine();
- debugcpu_private *global = machine.debugcpu_data;
+ debugger_cpu& debugcpu = machine.debugger().cpu();
// note that we are in the debugger code
- global->within_instruction_hook = true;
+ debugcpu.set_within_instruction(true);
// update the history
m_pc_history[m_pc_history_index++ % HISTORY_SIZE] = curpc;
@@ -1852,11 +1826,11 @@ void device_debug::instruction_hook(offs_t curpc)
m_trace->update(curpc);
// per-instruction hook?
- if (global->execution_state != EXECUTION_STATE_STOPPED && (m_flags & DEBUG_FLAG_HOOKED) != 0 && (*m_instrhook)(m_device, curpc))
- global->execution_state = EXECUTION_STATE_STOPPED;
+ if (debugcpu.execution_state() != EXECUTION_STATE_STOPPED && (m_flags & DEBUG_FLAG_HOOKED) != 0 && (*m_instrhook)(m_device, curpc))
+ debugcpu.set_execution_state(EXECUTION_STATE_STOPPED);
// handle single stepping
- if (global->execution_state != EXECUTION_STATE_STOPPED && (m_flags & DEBUG_FLAG_STEPPING_ANY) != 0)
+ if (debugcpu.execution_state() != EXECUTION_STATE_STOPPED && (m_flags & DEBUG_FLAG_STEPPING_ANY) != 0)
{
// is this an actual step?
if (m_stepaddr == ~0 || curpc == m_stepaddr)
@@ -1867,7 +1841,7 @@ void device_debug::instruction_hook(offs_t curpc)
// if we hit 0, stop
if (m_stepsleft == 0)
- global->execution_state = EXECUTION_STATE_STOPPED;
+ debugcpu.set_execution_state(EXECUTION_STATE_STOPPED);
// update every 100 steps until we are within 200 of the end
else if ((m_flags & DEBUG_FLAG_STEPPING_OUT) == 0 && (m_stepsleft < 200 || m_stepsleft % 100 == 0))
@@ -1880,20 +1854,20 @@ void device_debug::instruction_hook(offs_t curpc)
}
// handle breakpoints
- if (global->execution_state != EXECUTION_STATE_STOPPED && (m_flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0)
+ if (debugcpu.execution_state() != EXECUTION_STATE_STOPPED && (m_flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0)
{
// see if we hit a target time
if ((m_flags & DEBUG_FLAG_STOP_TIME) != 0 && machine.time() >= m_stoptime)
{
- debug_console_printf(machine, "Stopped at time interval %.1g\n", machine.time().as_double());
- global->execution_state = EXECUTION_STATE_STOPPED;
+ machine.debugger().console().printf("Stopped at time interval %.1g\n", machine.time().as_double());
+ debugcpu.set_execution_state(EXECUTION_STATE_STOPPED);
}
// check the temp running breakpoint and break if we hit it
else if ((m_flags & DEBUG_FLAG_STOP_PC) != 0 && m_stopaddr == curpc)
{
- debug_console_printf(machine, "Stopped at temporary breakpoint %X on CPU '%s'\n", m_stopaddr, m_device.tag());
- global->execution_state = EXECUTION_STATE_STOPPED;
+ machine.debugger().console().printf("Stopped at temporary breakpoint %X on CPU '%s'\n", m_stopaddr, m_device.tag());
+ debugcpu.set_execution_state(EXECUTION_STATE_STOPPED);
}
// check for execution breakpoints
@@ -1902,23 +1876,19 @@ void device_debug::instruction_hook(offs_t curpc)
}
// if we are supposed to halt, do it now
- if (global->execution_state == EXECUTION_STATE_STOPPED)
+ if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED)
{
bool firststop = true;
// load comments if we haven't yet
- if (!global->comments_loaded)
- {
- debug_comment_load(m_device.machine(),true);
- global->comments_loaded = true;
- }
+ debugcpu.ensure_comments_loaded();
// reset any transient state
- reset_transient_flags(m_device.machine());
- global->breakcpu = nullptr;
+ debugcpu.reset_transient_flags();
+ debugcpu.set_break_cpu(nullptr);
// remember the last visible CPU in the debugger
- global->visiblecpu = &m_device;
+ debugcpu.set_visible_cpu(&m_device);
// update all views
machine.debug_view().update_all();
@@ -1926,7 +1896,7 @@ void device_debug::instruction_hook(offs_t curpc)
// wait for the debugger; during this time, disable sound output
m_device.machine().sound().debugger_mute(true);
- while (global->execution_state == EXECUTION_STATE_STOPPED)
+ while (debugcpu.execution_state() == EXECUTION_STATE_STOPPED)
{
// flush any pending updates before waiting again
machine.debug_view().flush_osd_updates();
@@ -1934,29 +1904,29 @@ void device_debug::instruction_hook(offs_t curpc)
emulator_info::periodic_check();
// clear the memory modified flag and wait
- global->memory_modified = false;
+ debugcpu.set_memory_modified(false);
if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)
machine.osd().wait_for_debugger(m_device, firststop);
firststop = false;
// if something modified memory, update the screen
- if (global->memory_modified)
+ if (debugcpu.memory_modified())
{
machine.debug_view().update_all(DVT_DISASSEMBLY);
machine.debugger().refresh_display();
}
// check for commands in the source file
- process_source_file(m_device.machine());
+ machine.debugger().cpu().process_source_file();
// if an event got scheduled, resume
if (machine.scheduled_event_pending())
- global->execution_state = EXECUTION_STATE_RUNNING;
+ debugcpu.set_execution_state(EXECUTION_STATE_RUNNING);
}
m_device.machine().sound().debugger_mute(false);
// remember the last visible CPU in the debugger
- global->visiblecpu = &m_device;
+ debugcpu.set_visible_cpu(&m_device);
}
// handle step out/over on the instruction we are about to execute
@@ -1964,7 +1934,7 @@ void device_debug::instruction_hook(offs_t curpc)
prepare_for_step_overout(pc());
// no longer in debugger code
- global->within_instruction_hook = false;
+ debugcpu.set_within_instruction(false);
}
@@ -2060,8 +2030,6 @@ offs_t device_debug::disassemble(char *buffer, offs_t pc, const UINT8 *oprom, co
void device_debug::ignore(bool ignore)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert(m_exec != nullptr);
if (ignore)
@@ -2069,8 +2037,11 @@ void device_debug::ignore(bool ignore)
else
m_flags |= DEBUG_FLAG_OBSERVING;
- if (&m_device == global->livecpu && ignore)
+ if (&m_device == m_device.machine().debugger().cpu().live_cpu() && ignore)
+ {
+ assert(m_exec != nullptr);
go_next_device();
+ }
}
@@ -2081,14 +2052,12 @@ void device_debug::ignore(bool ignore)
void device_debug::single_step(int numsteps)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert(m_exec != nullptr);
m_stepsleft = numsteps;
m_stepaddr = ~0;
m_flags |= DEBUG_FLAG_STEPPING;
- global->execution_state = EXECUTION_STATE_RUNNING;
+ m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING);
}
@@ -2099,14 +2068,12 @@ void device_debug::single_step(int numsteps)
void device_debug::single_step_over(int numsteps)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert(m_exec != nullptr);
m_stepsleft = numsteps;
m_stepaddr = ~0;
m_flags |= DEBUG_FLAG_STEPPING_OVER;
- global->execution_state = EXECUTION_STATE_RUNNING;
+ m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING);
}
@@ -2117,14 +2084,12 @@ void device_debug::single_step_over(int numsteps)
void device_debug::single_step_out()
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert(m_exec != nullptr);
m_stepsleft = 100;
m_stepaddr = ~0;
m_flags |= DEBUG_FLAG_STEPPING_OUT;
- global->execution_state = EXECUTION_STATE_RUNNING;
+ m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING);
}
@@ -2135,13 +2100,11 @@ void device_debug::single_step_out()
void device_debug::go(offs_t targetpc)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert(m_exec != nullptr);
m_stopaddr = targetpc;
m_flags |= DEBUG_FLAG_STOP_PC;
- global->execution_state = EXECUTION_STATE_RUNNING;
+ m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING);
}
@@ -2151,13 +2114,10 @@ void device_debug::go(offs_t targetpc)
void device_debug::go_vblank()
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert(m_exec != nullptr);
- global->vblank_occurred = false;
m_flags |= DEBUG_FLAG_STOP_VBLANK;
- global->execution_state = EXECUTION_STATE_RUNNING;
+ m_device.machine().debugger().cpu().go_vblank();
}
@@ -2168,15 +2128,17 @@ void device_debug::go_vblank()
void device_debug::go_interrupt(int irqline)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert(m_exec != nullptr);
m_stopirq = irqline;
m_flags |= DEBUG_FLAG_STOP_INTERRUPT;
- global->execution_state = EXECUTION_STATE_RUNNING;
+ m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING);
}
+void device_debug::go_next_device()
+{
+ m_device.machine().debugger().cpu().go_next_device(&m_device);
+}
//-------------------------------------------------
// go_exception - execute until the specified
@@ -2185,13 +2147,11 @@ void device_debug::go_interrupt(int irqline)
void device_debug::go_exception(int exception)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert(m_exec != nullptr);
m_stopexception = exception;
m_flags |= DEBUG_FLAG_STOP_EXCEPTION;
- global->execution_state = EXECUTION_STATE_RUNNING;
+ m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING);
}
@@ -2202,62 +2162,27 @@ void device_debug::go_exception(int exception)
void device_debug::go_milliseconds(UINT64 milliseconds)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert(m_exec != nullptr);
m_stoptime = m_device.machine().time() + attotime::from_msec(milliseconds);
m_flags |= DEBUG_FLAG_STOP_TIME;
- global->execution_state = EXECUTION_STATE_RUNNING;
-}
-
-
-//-------------------------------------------------
-// go_next_device - execute until we hit the next
-// device
-//-------------------------------------------------
-
-void device_debug::go_next_device()
-{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
- assert(m_exec != nullptr);
-
- global->m_stop_when_not_device = &m_device;
- global->execution_state = EXECUTION_STATE_RUNNING;
+ m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING);
}
//-------------------------------------------------
-// halt_on_next_instruction - halt in the
-// debugger on the next instruction
+// halt_on_next_instruction_impl - halt in the
+// debugger on the next instruction, internal
+// implementation which is necessary solely due
+// to templates in C++ being janky as all get out
//-------------------------------------------------
void device_debug::halt_on_next_instruction_impl(util::format_argument_pack<std::ostream> &&args)
{
- debugcpu_private *global = m_device.machine().debugcpu_data;
-
assert(m_exec != nullptr);
-
- // if something is pending on this CPU already, ignore this request
- if (&m_device == global->breakcpu)
- return;
-
- // output the message to the console
- debug_console_vprintf(m_device.machine(), std::move(args));
-
- // if we are live, stop now, otherwise note that we want to break there
- if (&m_device == global->livecpu)
- {
- global->execution_state = EXECUTION_STATE_STOPPED;
- if (global->livecpu != nullptr)
- global->livecpu->debug()->compute_debug_flags();
- }
- else
- global->breakcpu = &m_device;
+ m_device.machine().debugger().cpu().halt_on_next_instruction(&m_device, std::move(args));
}
-
//-------------------------------------------------
// breakpoint_set - set a new breakpoint,
// returning its index
@@ -2266,7 +2191,8 @@ void device_debug::halt_on_next_instruction_impl(util::format_argument_pack<std:
int device_debug::breakpoint_set(offs_t address, const char *condition, const char *action)
{
// allocate a new one
- breakpoint *bp = auto_alloc(m_device.machine(), breakpoint(this, m_symtable, m_device.machine().debugcpu_data->bpindex++, address, condition, action));
+ UINT32 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;
@@ -2357,7 +2283,8 @@ int device_debug::watchpoint_set(address_space &space, int type, offs_t address,
assert(space.spacenum() < ARRAY_LENGTH(m_wplist));
// allocate a new one
- watchpoint *wp = auto_alloc(m_device.machine(), watchpoint(this, m_symtable, m_device.machine().debugcpu_data->wpindex++, space, type, address, length, condition, action));
+ UINT32 id = m_device.machine().debugger().cpu().get_watchpoint_index();
+ watchpoint *wp = auto_alloc(m_device.machine(), watchpoint(this, m_symtable, id, space, type, address, length, condition, action));
// hook it into our list
wp->m_next = m_wplist[space.spacenum()];
@@ -2451,7 +2378,8 @@ void device_debug::watchpoint_enable_all(bool enable)
int device_debug::registerpoint_set(const char *condition, const char *action)
{
// allocate a new one
- registerpoint *rp = auto_alloc(m_device.machine(), registerpoint(m_symtable, m_device.machine().debugcpu_data->rpindex++, condition, action));
+ UINT32 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;
@@ -2713,7 +2641,7 @@ bool device_debug::comment_import(xml_data_node &cpunode,bool is_inline)
if(is_inline == true)
m_comment_set.insert(dasm_comment(address, crc, datanode->value, color));
else
- debug_console_printf(m_device.machine()," %08X - %s\n",address,datanode->value);
+ m_device.machine().debugger().console().printf(" %08X - %s\n", address, datanode->value);
}
return true;
}
@@ -2739,8 +2667,8 @@ UINT32 device_debug::compute_opcode_crc32(offs_t pc) const
int maxbytes = max_opcode_bytes();
for (int numbytes = 0; numbytes < maxbytes; numbytes++)
{
- opbuf[numbytes] = debug_read_opcode(decrypted_space, pcbyte + numbytes, 1);
- argbuf[numbytes] = debug_read_opcode(space, pcbyte + numbytes, 1);
+ opbuf[numbytes] = m_device.machine().debugger().cpu().read_opcode(decrypted_space, pcbyte + numbytes, 1);
+ argbuf[numbytes] = m_device.machine().debugger().cpu().read_opcode(space, pcbyte + numbytes, 1);
}
// disassemble to our buffer
@@ -2793,7 +2721,7 @@ void device_debug::trace_printf(const char *fmt, ...)
void device_debug::compute_debug_flags()
{
running_machine &machine = m_device.machine();
- debugcpu_private *global = machine.debugcpu_data;
+ debugger_cpu& debugcpu = machine.debugger().cpu();
// clear out global flags by default, keep DEBUG_FLAG_OSD_ENABLED
machine.debug_flags &= DEBUG_FLAG_OSD_ENABLED;
@@ -2804,7 +2732,7 @@ void device_debug::compute_debug_flags()
return;
// if we're stopped, keep calling the hook
- if (global->execution_state == EXECUTION_STATE_STOPPED)
+ if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED)
machine.debug_flags |= DEBUG_FLAG_CALL_HOOK;
// if we're tracking history, or we're hooked, or stepping, or stopping at a breakpoint
@@ -2885,9 +2813,8 @@ void device_debug::breakpoint_update_flags()
}
// push the flags out globally
- debugcpu_private *global = m_device.machine().debugcpu_data;
- if (global->livecpu != nullptr)
- global->livecpu->debug()->compute_debug_flags();
+ if (m_device.machine().debugger().cpu().live_cpu() != nullptr)
+ m_device.machine().debugger().cpu().live_cpu()->debug()->compute_debug_flags();
}
@@ -2898,21 +2825,22 @@ void device_debug::breakpoint_update_flags()
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))
{
// halt in the debugger by default
- debugcpu_private *global = m_device.machine().debugcpu_data;
- global->execution_state = EXECUTION_STATE_STOPPED;
+ debugcpu.set_execution_state(EXECUTION_STATE_STOPPED);
// if we hit, evaluate the action
if (!bp->m_action.empty())
- debug_console_execute_command(m_device.machine(), bp->m_action.c_str(), 0);
+ m_device.machine().debugger().console().execute_command(bp->m_action.c_str(), false);
// print a notification, unless the action made us go again
- if (global->execution_state == EXECUTION_STATE_STOPPED)
- debug_console_printf(m_device.machine(), "Stopped at breakpoint %X\n", bp->m_index);
+ if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED)
+ m_device.machine().debugger().console().printf("Stopped at breakpoint %X\n", bp->m_index);
break;
}
@@ -2922,19 +2850,18 @@ void device_debug::breakpoint_check(offs_t pc)
if (rp->hit())
{
// halt in the debugger by default
- debugcpu_private *global = m_device.machine().debugcpu_data;
- global->execution_state = EXECUTION_STATE_STOPPED;
+ debugcpu.set_execution_state(EXECUTION_STATE_STOPPED);
// if we hit, evaluate the action
if (!rp->m_action.empty())
{
- debug_console_execute_command(m_device.machine(), rp->m_action.c_str(), 0);
+ m_device.machine().debugger().console().execute_command(rp->m_action.c_str(), false);
}
// print a notification, unless the action made us go again
- if (global->execution_state == EXECUTION_STATE_STOPPED)
+ if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED)
{
- debug_console_printf(m_device.machine(), "Stopped at registerpoint %X\n", rp->m_index);
+ m_device.machine().debugger().console().printf("Stopped at registerpoint %X\n", rp->m_index);
}
break;
}
@@ -2976,14 +2903,18 @@ void device_debug::watchpoint_update_flags(address_space &space)
// for a given CPU and address space
//-------------------------------------------------
-void device_debug::watchpoint_check(address_space &space, int type, offs_t address, UINT64 value_to_write, UINT64 mem_mask)
+void device_debug::watchpoint_check(address_space& space, int type, offs_t address, UINT64 value_to_write, UINT64 mem_mask)
{
- debugcpu_private *global = space.machine().debugcpu_data;
+ space.machine().debugger().cpu().watchpoint_check(space, type, address, value_to_write, mem_mask, m_wplist);
+}
+void debugger_cpu::watchpoint_check(address_space& space, int type, offs_t address, UINT64 value_to_write, UINT64 mem_mask, device_debug::watchpoint** wplist)
+{
// if we're within debugger code, don't stop
- if (global->within_instruction_hook || global->debugger_access)
+ if (m_within_instruction_hook || m_debugger_access)
return;
- global->within_instruction_hook = true;
+
+ m_within_instruction_hook = true;
// adjust address, size & value_to_write based on mem_mask.
offs_t size = 0;
@@ -3024,48 +2955,48 @@ void device_debug::watchpoint_check(address_space &space, int type, offs_t addre
}
// if we are a write watchpoint, stash the value that will be written
- global->wpaddr = address;
+ m_wpaddr = address;
if (type & WATCHPOINT_WRITE)
- global->wpdata = value_to_write;
+ m_wpdata = value_to_write;
// see if we match
- for (watchpoint *wp = m_wplist[space.spacenum()]; wp != nullptr; wp = wp->m_next)
+ for (device_debug::watchpoint *wp = wplist[space.spacenum()]; wp != nullptr; wp = wp->next())
if (wp->hit(type, address, size))
{
// halt in the debugger by default
- global->execution_state = EXECUTION_STATE_STOPPED;
+ m_execution_state = EXECUTION_STATE_STOPPED;
// if we hit, evaluate the action
- if (!wp->m_action.empty())
- debug_console_execute_command(space.machine(), wp->m_action.c_str(), 0);
+ if (strlen(wp->action()) > 0)
+ m_machine.debugger().console().execute_command(wp->action(), false);
// print a notification, unless the action made us go again
- if (global->execution_state == EXECUTION_STATE_STOPPED)
+ if (m_execution_state == EXECUTION_STATE_STOPPED)
{
static const char *const sizes[] =
{
"0bytes", "byte", "word", "3bytes", "dword", "5bytes", "6bytes", "7bytes", "qword"
};
- offs_t pc = (space.device().debug()->m_state != nullptr) ? space.device().debug()->m_state->pc() : 0;
+ offs_t pc = space.device().debug()->pc();
std::string buffer;
if (type & WATCHPOINT_WRITE)
{
- buffer = string_format("Stopped at watchpoint %X writing %s to %08X (PC=%X)", wp->m_index, sizes[size], space.byte_to_address(address), pc);
+ buffer = string_format("Stopped at watchpoint %X writing %s to %08X (PC=%X)", wp->index(), sizes[size], space.byte_to_address(address), pc);
if (value_to_write >> 32)
buffer.append(string_format(" (data=%X%08X)", (UINT32)(value_to_write >> 32), (UINT32)value_to_write));
else
buffer.append(string_format(" (data=%X)", (UINT32)value_to_write));
}
else
- buffer = string_format("Stopped at watchpoint %X reading %s from %08X (PC=%X)", wp->m_index, sizes[size], space.byte_to_address(address), pc);
- debug_console_printf(space.machine(), "%s\n", buffer.c_str());
+ buffer = string_format("Stopped at watchpoint %X reading %s from %08X (PC=%X)", wp->index(), sizes[size], space.byte_to_address(address), pc);
+ m_machine.debugger().console().printf("%s\n", buffer.c_str());
space.device().debug()->compute_debug_flags();
}
break;
}
- global->within_instruction_hook = false;
+ m_within_instruction_hook = false;
}
@@ -3090,7 +3021,7 @@ void device_debug::hotspot_check(address_space &space, offs_t address)
// if the bottom of the list is over the threshold, print it
hotspot_entry &spot = m_hotspots[m_hotspots.size() - 1];
if (spot.m_count > m_hotspot_threshhold)
- debug_console_printf(space.machine(), "Hotspot @ %s %08X (PC=%08X) hit %d times (fell off bottom)\n", space.name(), spot.m_access, spot.m_pc, spot.m_count);
+ space.machine().debugger().console().printf("Hotspot @ %s %08X (PC=%08X) hit %d times (fell off bottom)\n", space.name(), spot.m_access, spot.m_pc, spot.m_count);
// move everything else down and insert this one at the top
memmove(&m_hotspots[1], &m_hotspots[0], sizeof(m_hotspots[0]) * (m_hotspots.size() - 1));
@@ -3134,8 +3065,8 @@ UINT32 device_debug::dasm_wrapped(std::string &buffer, offs_t pc)
int maxbytes = max_opcode_bytes();
for (int numbytes = 0; numbytes < maxbytes; numbytes++)
{
- opbuf[numbytes] = debug_read_opcode(decrypted_space, pcbyte + numbytes, 1);
- argbuf[numbytes] = debug_read_opcode(space, pcbyte + numbytes, 1);
+ opbuf[numbytes] = m_device.machine().debugger().cpu().read_opcode(decrypted_space, pcbyte + numbytes, 1);
+ argbuf[numbytes] = m_device.machine().debugger().cpu().read_opcode(space, pcbyte + numbytes, 1);
}
// disassemble to our buffer
@@ -3481,7 +3412,7 @@ void device_debug::tracer::update(offs_t pc)
// execute any trace actions first
if (!m_action.empty())
- debug_console_execute_command(m_debug.m_device.machine(), m_action.c_str(), 0);
+ m_debug.m_device.machine().debugger().console().execute_command(m_action.c_str(), false);
// print the address
std::string buffer;
diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h
index 604a6d168b3..2acfba9ea67 100644
--- a/src/emu/debug/debugcpu.h
+++ b/src/emu/debug/debugcpu.h
@@ -42,6 +42,8 @@ struct xml_data_node;
// ======================> device_debug
+// [TODO] This whole thing is terrible.
+
class device_debug
{
typedef offs_t (*dasm_override_func)(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options);
@@ -118,10 +120,10 @@ public:
// setters
void setEnabled(bool value) { m_enabled = value; }
- private:
// internals
bool hit(int type, offs_t address, int size);
+ private:
const device_debug * m_debugInterface; // the interface we were created from
watchpoint * m_next; // next in the list
address_space & m_space; // address space
@@ -209,6 +211,7 @@ public:
void go_exception(int exception);
void go_milliseconds(UINT64 milliseconds);
void go_next_device();
+
template <typename Format, typename... Params>
void halt_on_next_instruction(Format &&fmt, Params &&... args)
{
@@ -278,11 +281,13 @@ public:
static const int HISTORY_SIZE = 256;
+ // debugger_cpu helpers
+ void compute_debug_flags();
+
private:
void halt_on_next_instruction_impl(util::format_argument_pack<std::ostream> &&args);
// internal helpers
- void compute_debug_flags();
void prepare_for_step_overout(offs_t pc);
UINT32 dasm_wrapped(std::string &buffer, offs_t pc);
@@ -462,100 +467,178 @@ private:
DEBUG_FLAG_STOP_INTERRUPT | DEBUG_FLAG_STOP_EXCEPTION | DEBUG_FLAG_STOP_VBLANK | DEBUG_FLAG_STOP_TIME;
};
-
-
//**************************************************************************
-// FUNCTION PROTOTYPES
+// CPU DEBUGGING
//**************************************************************************
-/* ----- initialization and cleanup ----- */
+class debugger_cpu
+{
+public:
+ debugger_cpu(running_machine &machine);
+
+ /* ----- initialization and cleanup ----- */
+
+ /* flushes all traces; this is useful if a trace is going on when we fatalerror */
+ void flush_traces();
-/* initialize the CPU tracking for the debugger */
-void debug_cpu_init(running_machine &machine);
-void debug_cpu_configure_memory(running_machine &machine, symbol_table &table);
+ void configure_memory(symbol_table &table);
-/* flushes all traces; this is useful if a trace is going on when we fatalerror */
-void debug_cpu_flush_traces(running_machine &machine);
+ /* ----- debugging status & information ----- */
+ /* return the visible CPU device (the one that commands should apply to) */
+ device_t *get_visible_cpu();
-/* ----- debugging status & information ----- */
+ /* true if the debugger is currently stopped within an instruction hook callback */
+ bool within_instruction_hook();
-/* return the visible CPU device (the one that commands should apply to) */
-device_t *debug_cpu_get_visible_cpu(running_machine &machine);
+ /* return true if the current execution state is stopped */
+ bool is_stopped();
-/* TRUE if the debugger is currently stopped within an instruction hook callback */
-int debug_cpu_within_instruction_hook(running_machine &machine);
-/* return TRUE if the current execution state is stopped */
-int debug_cpu_is_stopped(running_machine &machine);
+ /* ----- symbol table interfaces ----- */
+ /* return the global symbol table */
+ symbol_table *get_global_symtable();
+ /* return the locally-visible symbol table */
+ symbol_table *get_visible_symtable();
-/* ----- symbol table interfaces ----- */
-/* return the global symbol table */
-symbol_table *debug_cpu_get_global_symtable(running_machine &machine);
+ /* ----- misc debugger functions ----- */
-/* return the locally-visible symbol table */
-symbol_table *debug_cpu_get_visible_symtable(running_machine &machine);
+ /* specifies a debug command script to execute */
+ void source_script(const char *file);
+ /* ----- debugger comment helpers ----- */
-/* ----- misc debugger functions ----- */
+ // save all comments for a given machine
+ bool comment_save();
-/* specifies a debug command script to execute */
-void debug_cpu_source_script(running_machine &machine, const char *file);
+ // load all comments for a given machine
+ bool comment_load(bool is_inline);
+ /* ----- debugger memory accessors ----- */
-/* ----- debugger comment helpers ----- */
+ /* return the physical address corresponding to the given logical address */
+ bool translate(address_space &space, int intention, offs_t *address);
-// save all comments for a given machine
-bool debug_comment_save(running_machine &machine);
+ /* return a byte from the specified memory space */
+ UINT8 read_byte(address_space &space, offs_t address, int apply_translation);
-// load all comments for a given machine
-bool debug_comment_load(running_machine &machine,bool is_inline);
+ /* return a word from the specified memory space */
+ UINT16 read_word(address_space &space, offs_t address, int apply_translation);
+ /* return a dword from the specified memory space */
+ UINT32 read_dword(address_space &space, offs_t address, int apply_translation);
+ /* return a qword from the specified memory space */
+ UINT64 read_qword(address_space &space, offs_t address, int apply_translation);
-/* ----- debugger memory accessors ----- */
+ /* return 1,2,4 or 8 bytes from the specified memory space */
+ UINT64 read_memory(address_space &space, offs_t address, int size, int apply_translation);
-/* return the physical address corresponding to the given logical address */
-int debug_cpu_translate(address_space &space, int intention, offs_t *address);
+ /* write a byte to the specified memory space */
+ void write_byte(address_space &space, offs_t address, UINT8 data, int apply_translation);
-/* return a byte from the specified memory space */
-UINT8 debug_read_byte(address_space &space, offs_t address, int apply_translation);
+ /* write a word to the specified memory space */
+ void write_word(address_space &space, offs_t address, UINT16 data, int apply_translation);
-/* return a word from the specified memory space */
-UINT16 debug_read_word(address_space &space, offs_t address, int apply_translation);
+ /* write a dword to the specified memory space */
+ void write_dword(address_space &space, offs_t address, UINT32 data, int apply_translation);
-/* return a dword from the specified memory space */
-UINT32 debug_read_dword(address_space &space, offs_t address, int apply_translation);
+ /* write a qword to the specified memory space */
+ void write_qword(address_space &space, offs_t address, UINT64 data, int apply_translation);
-/* return a qword from the specified memory space */
-UINT64 debug_read_qword(address_space &space, offs_t address, int apply_translation);
+ /* write 1,2,4 or 8 bytes to the specified memory space */
+ void write_memory(address_space &space, offs_t address, UINT64 data, int size, int apply_translation);
-/* return 1,2,4 or 8 bytes from the specified memory space */
-UINT64 debug_read_memory(address_space &space, offs_t address, int size, int apply_translation);
+ /* read 1,2,4 or 8 bytes at the given offset from opcode space */
+ UINT64 read_opcode(address_space &space, offs_t offset, int size);
-/* write a byte to the specified memory space */
-void debug_write_byte(address_space &space, offs_t address, UINT8 data, int apply_translation);
+ // getters
+ bool within_instruction_hook() const { return m_within_instruction_hook; }
+ bool memory_modified() const { return m_memory_modified; }
+ int execution_state() const { return m_execution_state; }
+ device_t *live_cpu() { return m_livecpu; }
+ UINT32 get_breakpoint_index() { return m_bpindex++; }
+ UINT32 get_watchpoint_index() { return m_wpindex++; }
+ UINT32 get_registerpoint_index() { return m_rpindex++; }
+
+ // setters
+ void set_visible_cpu(device_t * visiblecpu) { m_visiblecpu = visiblecpu; }
+ void set_break_cpu(device_t * breakcpu) { m_breakcpu = breakcpu; }
+ void set_within_instruction(bool within_instruction) { m_within_instruction_hook = within_instruction; }
+ void set_memory_modified(bool memory_modified) { m_memory_modified = memory_modified; }
+ void set_execution_state(int execution_state) { m_execution_state = execution_state; }
+
+ // device_debug helpers
+ // [TODO] [RH]: Look into this more later, can possibly merge these two classes
+ void start_hook(device_t *device, bool stop_on_vblank);
+ void stop_hook(device_t *device);
+ void go_next_device(device_t *device);
+ void go_vblank();
+ void halt_on_next_instruction(device_t *device, util::format_argument_pack<std::ostream> &&args);
+ void ensure_comments_loaded();
+ void reset_transient_flags();
+ void process_source_file();
+ void watchpoint_check(address_space& space, int type, offs_t address, UINT64 value_to_write, UINT64 mem_mask, device_debug::watchpoint** wplist);
+
+private:
+ static const size_t NUM_TEMP_VARIABLES;
+
+ /* expression handlers */
+ UINT64 expression_read_memory(void *param, const char *name, expression_space space, UINT32 address, int size);
+ UINT64 expression_read_program_direct(address_space &space, int opcode, offs_t address, int size);
+ UINT64 expression_read_memory_region(const char *rgntag, offs_t address, int size);
+ void expression_write_memory(void *param, const char *name, expression_space space, UINT32 address, int size, UINT64 data);
+ void expression_write_program_direct(address_space &space, int opcode, offs_t address, int size, UINT64 data);
+ void expression_write_memory_region(const char *rgntag, offs_t address, int size, UINT64 data);
+ expression_error::error_code expression_validate(void *param, const char *name, expression_space space);
+ device_t* expression_get_device(const char *tag);
+
+ /* variable getters/setters */
+ UINT64 get_cpunum(symbol_table &table, void *ref);
+ UINT64 get_beamx(symbol_table &table, void *ref);
+ UINT64 get_beamy(symbol_table &table, void *ref);
+ UINT64 get_frame(symbol_table &table, void *ref);
+
+ /* internal helpers */
+ void exit();
+ void on_vblank(screen_device &device, bool vblank_state);
-/* write a word to the specified memory space */
-void debug_write_word(address_space &space, offs_t address, UINT16 data, int apply_translation);
+ running_machine& m_machine;
-/* write a dword to the specified memory space */
-void debug_write_dword(address_space &space, offs_t address, UINT32 data, int apply_translation);
+ device_t * m_livecpu;
+ device_t * m_visiblecpu;
+ device_t * m_breakcpu;
-/* write a qword to the specified memory space */
-void debug_write_qword(address_space &space, offs_t address, UINT64 data, int apply_translation);
+ FILE * m_source_file; // script source file
-/* write 1,2,4 or 8 bytes to the specified memory space */
-void debug_write_memory(address_space &space, offs_t address, UINT64 data, int size, int apply_translation);
+ symbol_table * m_symtable; // global symbol table
-/* read 1,2,4 or 8 bytes at the given offset from opcode space */
-UINT64 debug_read_opcode(address_space &space, offs_t offset, int size);
+ bool m_within_instruction_hook;
+ bool m_vblank_occurred;
+ bool m_memory_modified;
+ bool m_debugger_access;
+ int m_execution_state;
+ device_t * m_stop_when_not_device; // stop execution when the device ceases to be this
+
+ UINT32 m_bpindex;
+ UINT32 m_wpindex;
+ UINT32 m_rpindex;
+
+ UINT64 m_wpdata;
+ UINT64 m_wpaddr;
+ std::unique_ptr<UINT64[]> m_tempvar;
+
+ osd_ticks_t m_last_periodic_update_time;
+
+ bool m_comments_loaded;
+};
#endif
+
diff --git a/src/emu/debug/debugvw.cpp b/src/emu/debug/debugvw.cpp
index 135ac5fb76e..09842dc349e 100644
--- a/src/emu/debug/debugvw.cpp
+++ b/src/emu/debug/debugvw.cpp
@@ -18,6 +18,7 @@
#include "dvbpoints.h"
#include "dvwpoints.h"
#include "debugcpu.h"
+#include "debugger.h"
#include <ctype.h>
@@ -452,11 +453,11 @@ debug_view *debug_view_manager::append(debug_view *view)
//-------------------------------------------------
debug_view_expression::debug_view_expression(running_machine &machine)
- : m_machine(machine),
- m_dirty(true),
- m_result(0),
- m_parsed(debug_cpu_get_global_symtable(machine)),
- m_string("0")
+ : m_machine(machine)
+ , m_dirty(true)
+ , m_result(0)
+ , m_parsed(machine.debugger().cpu().get_global_symtable())
+ , m_string("0")
{
}
@@ -477,7 +478,7 @@ debug_view_expression::~debug_view_expression()
void debug_view_expression::set_context(symbol_table *context)
{
- m_parsed.set_symbols((context != nullptr) ? context : debug_cpu_get_global_symtable(machine()));
+ m_parsed.set_symbols((context != nullptr) ? context : m_machine.debugger().cpu().get_global_symtable());
m_dirty = true;
}
diff --git a/src/emu/debug/dvdisasm.cpp b/src/emu/debug/dvdisasm.cpp
index c0ed17bdde0..a2aad9162cf 100644
--- a/src/emu/debug/dvdisasm.cpp
+++ b/src/emu/debug/dvdisasm.cpp
@@ -12,7 +12,7 @@
#include "debugvw.h"
#include "dvdisasm.h"
#include "debugcpu.h"
-
+#include "debugger.h"
//**************************************************************************
@@ -254,8 +254,8 @@ offs_t debug_view_disasm::find_pc_backwards(offs_t targetpc, int numinstrs)
while (curpcbyte < fillpcbyte)
{
fillpcbyte--;
- opbuf[1000 + fillpcbyte - targetpcbyte] = debug_read_opcode(source.m_decrypted_space, fillpcbyte, 1);
- argbuf[1000 + fillpcbyte - targetpcbyte] = debug_read_opcode(source.m_space, fillpcbyte, 1);
+ opbuf[1000 + fillpcbyte - targetpcbyte] = machine().debugger().cpu().read_opcode(source.m_decrypted_space, fillpcbyte, 1);
+ argbuf[1000 + fillpcbyte - targetpcbyte] = machine().debugger().cpu().read_opcode(source.m_space, fillpcbyte, 1);
}
// loop until we get past the target instruction
@@ -269,7 +269,7 @@ offs_t debug_view_disasm::find_pc_backwards(offs_t targetpc, int numinstrs)
// get the disassembly, but only if mapped
instlen = 1;
- if (debug_cpu_translate(source.m_space, TRANSLATE_FETCH, &physpcbyte))
+ if (machine().debugger().cpu().translate(source.m_space, TRANSLATE_FETCH, &physpcbyte))
{
char dasmbuffer[100];
instlen = source.device()->debug()->disassemble(dasmbuffer, scanpc, &opbuf[1000 + scanpcbyte - targetpcbyte], &argbuf[1000 + scanpcbyte - targetpcbyte]) & DASMFLAG_LENGTHMASK;
@@ -315,12 +315,12 @@ void debug_view_disasm::generate_bytes(offs_t pcbyte, int numbytes, int minbytes
// output the first value
int offset = 0;
if (maxchars >= char_num * minbytes)
- offset += util::stream_format(m_dasm, source.m_space.is_octal() ? "%0*o" : "%0*X", minbytes * char_num, debug_read_opcode(source.m_decrypted_space, pcbyte, minbytes));
+ offset += util::stream_format(m_dasm, source.m_space.is_octal() ? "%0*o" : "%0*X", minbytes * char_num, machine().debugger().cpu().read_opcode(source.m_decrypted_space, pcbyte, minbytes));
// output subsequent values
int byte;
for (byte = minbytes; byte < numbytes && offset + 1 + char_num * minbytes < maxchars; byte += minbytes)
- offset += util::stream_format(m_dasm, source.m_space.is_octal() ? " %0*o" : " %0*X", minbytes * char_num, debug_read_opcode(encrypted ? source.m_space : source.m_decrypted_space, pcbyte + byte, minbytes));
+ offset += util::stream_format(m_dasm, source.m_space.is_octal() ? " %0*o" : " %0*X", minbytes * char_num, machine().debugger().cpu().read_opcode(encrypted ? source.m_space : source.m_decrypted_space, pcbyte + byte, minbytes));
// if we ran out of room, indicate more
if ((byte < numbytes) && (byte != minbytes) && (maxchars > 3))
@@ -395,15 +395,15 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines)
char buffer[100];
int numbytes = 0;
offs_t physpcbyte = pcbyte;
- if (debug_cpu_translate(source.m_space, TRANSLATE_FETCH_DEBUG, &physpcbyte))
+ if (machine().debugger().cpu().translate(source.m_space, TRANSLATE_FETCH_DEBUG, &physpcbyte))
{
UINT8 opbuf[64], argbuf[64];
// fetch the bytes up to the maximum
for (numbytes = 0; numbytes < maxbytes; numbytes++)
{
- opbuf[numbytes] = debug_read_opcode(source.m_decrypted_space, pcbyte + numbytes, 1);
- argbuf[numbytes] = debug_read_opcode(source.m_space, pcbyte + numbytes, 1);
+ opbuf[numbytes] = machine().debugger().cpu().read_opcode(source.m_decrypted_space, pcbyte + numbytes, 1);
+ argbuf[numbytes] = machine().debugger().cpu().read_opcode(source.m_space, pcbyte + numbytes, 1);
}
// disassemble the result
diff --git a/src/emu/debug/dvmemory.cpp b/src/emu/debug/dvmemory.cpp
index 0724f9fa27d..8307812b365 100644
--- a/src/emu/debug/dvmemory.cpp
+++ b/src/emu/debug/dvmemory.cpp
@@ -12,6 +12,7 @@
#include "debugvw.h"
#include "dvmemory.h"
#include "debugcpu.h"
+#include "debugger.h"
#include <ctype.h>
@@ -747,10 +748,10 @@ bool debug_view_memory::read(UINT8 size, offs_t offs, UINT64 &data)
{
switch (size)
{
- case 1: data = debug_read_byte(*source.m_space, offs, !m_no_translation); break;
- case 2: data = debug_read_word(*source.m_space, offs, !m_no_translation); break;
- case 4: data = debug_read_dword(*source.m_space, offs, !m_no_translation); break;
- case 8: data = debug_read_qword(*source.m_space, offs, !m_no_translation); break;
+ case 1: data = machine().debugger().cpu().read_byte(*source.m_space, offs, !m_no_translation); break;
+ case 2: data = machine().debugger().cpu().read_word(*source.m_space, offs, !m_no_translation); break;
+ case 4: data = machine().debugger().cpu().read_dword(*source.m_space, offs, !m_no_translation); break;
+ case 8: data = machine().debugger().cpu().read_qword(*source.m_space, offs, !m_no_translation); break;
}
}
return ismapped;
@@ -819,10 +820,10 @@ void debug_view_memory::write(UINT8 size, offs_t offs, UINT64 data)
{
switch (size)
{
- case 1: debug_write_byte(*source.m_space, offs, data, !m_no_translation); break;
- case 2: debug_write_word(*source.m_space, offs, data, !m_no_translation); break;
- case 4: debug_write_dword(*source.m_space, offs, data, !m_no_translation); break;
- case 8: debug_write_qword(*source.m_space, offs, data, !m_no_translation); break;
+ case 1: machine().debugger().cpu().write_byte(*source.m_space, offs, data, !m_no_translation); break;
+ case 2: machine().debugger().cpu().write_word(*source.m_space, offs, data, !m_no_translation); break;
+ case 4: machine().debugger().cpu().write_dword(*source.m_space, offs, data, !m_no_translation); break;
+ case 8: machine().debugger().cpu().write_qword(*source.m_space, offs, data, !m_no_translation); break;
}
return;
}
diff --git a/src/emu/debug/dvtext.cpp b/src/emu/debug/dvtext.cpp
index ce1d8abdb1b..af4bbba1852 100644
--- a/src/emu/debug/dvtext.cpp
+++ b/src/emu/debug/dvtext.cpp
@@ -12,8 +12,7 @@
#include "debugvw.h"
#include "dvtext.h"
#include "debugcon.h"
-
-
+#include "debugger.h"
//**************************************************************************
// DEBUG VIEW TEXTBUF
@@ -135,7 +134,7 @@ void debug_view_textbuf::view_notify(debug_view_notification type)
//-------------------------------------------------
debug_view_console::debug_view_console(running_machine &machine, debug_view_osd_update_func osdupdate, void *osdprivate)
- : debug_view_textbuf(machine, DVT_CONSOLE, osdupdate, osdprivate, *debug_console_get_textbuf())
+ : debug_view_textbuf(machine, DVT_CONSOLE, osdupdate, osdprivate, *machine.debugger().console().get_console_textbuf())
{
}
@@ -150,6 +149,6 @@ debug_view_console::debug_view_console(running_machine &machine, debug_view_osd_
//-------------------------------------------------
debug_view_log::debug_view_log(running_machine &machine, debug_view_osd_update_func osdupdate, void *osdprivate)
- : debug_view_textbuf(machine, DVT_LOG, osdupdate, osdprivate, *debug_errorlog_get_textbuf())
+ : debug_view_textbuf(machine, DVT_LOG, osdupdate, osdprivate, *machine.debugger().console().get_errorlog_textbuf())
{
}
diff --git a/src/emu/debug/express.cpp b/src/emu/debug/express.cpp
index eb2477a1374..f10a48bcd11 100644
--- a/src/emu/debug/express.cpp
+++ b/src/emu/debug/express.cpp
@@ -274,7 +274,7 @@ bool integer_symbol_entry::is_lval() const
UINT64 integer_symbol_entry::value() const
{
- return (*m_getter)(m_table, m_ref);
+ return m_getter(m_table, m_ref);
}
@@ -285,7 +285,7 @@ UINT64 integer_symbol_entry::value() const
void integer_symbol_entry::set_value(UINT64 newvalue)
{
if (m_setter != nullptr)
- (*m_setter)(m_table, m_ref, newvalue);
+ m_setter(m_table, m_ref, newvalue);
else
throw emu_fatalerror("Symbol '%s' is read-only", m_name.c_str());
}
@@ -371,7 +371,7 @@ UINT64 function_symbol_entry::execute(int numparams, const UINT64 *paramlist)
throw emu_fatalerror("Function '%s' requires at least %d parameters", m_name.c_str(), m_minparams);
if (numparams > m_maxparams)
throw emu_fatalerror("Function '%s' accepts no more than %d parameters", m_name.c_str(), m_maxparams);
- return (*m_execute)(m_table, m_ref, numparams, paramlist);
+ return m_execute(m_table, m_ref, numparams, paramlist);
}
@@ -504,7 +504,7 @@ expression_error::error_code symbol_table::memory_valid(const char *name, expres
for (symbol_table *symtable = this; symtable != nullptr; symtable = symtable->m_parent)
if (symtable->m_memory_valid != nullptr)
{
- expression_error::error_code err = (*symtable->m_memory_valid)(symtable->m_memory_param, name, space);
+ expression_error::error_code err = symtable->m_memory_valid(symtable->m_memory_param, name, space);
if (err != expression_error::NO_SUCH_MEMORY_SPACE)
return err;
}
@@ -522,9 +522,9 @@ UINT64 symbol_table::memory_value(const char *name, expression_space space, UINT
for (symbol_table *symtable = this; symtable != nullptr; symtable = symtable->m_parent)
if (symtable->m_memory_valid != nullptr)
{
- expression_error::error_code err = (*symtable->m_memory_valid)(symtable->m_memory_param, name, space);
+ expression_error::error_code err = symtable->m_memory_valid(symtable->m_memory_param, name, space);
if (err != expression_error::NO_SUCH_MEMORY_SPACE && symtable->m_memory_read != nullptr)
- return (*symtable->m_memory_read)(symtable->m_memory_param, name, space, offset, size);
+ return symtable->m_memory_read(symtable->m_memory_param, name, space, offset, size);
return 0;
}
return 0;
@@ -541,9 +541,9 @@ void symbol_table::set_memory_value(const char *name, expression_space space, UI
for (symbol_table *symtable = this; symtable != nullptr; symtable = symtable->m_parent)
if (symtable->m_memory_valid != nullptr)
{
- expression_error::error_code err = (*symtable->m_memory_valid)(symtable->m_memory_param, name, space);
+ expression_error::error_code err = symtable->m_memory_valid(symtable->m_memory_param, name, space);
if (err != expression_error::NO_SUCH_MEMORY_SPACE && symtable->m_memory_write != nullptr)
- (*symtable->m_memory_write)(symtable->m_memory_param, name, space, offset, size, value);
+ symtable->m_memory_write(symtable->m_memory_param, name, space, offset, size, value);
return;
}
}
diff --git a/src/emu/debug/express.h b/src/emu/debug/express.h
index 5eb961606e4..c07f5ecc6f0 100644
--- a/src/emu/debug/express.h
+++ b/src/emu/debug/express.h
@@ -13,6 +13,8 @@
#ifndef __EXPRESS_H__
#define __EXPRESS_H__
+#include <functional>
+
#include "emu.h"
@@ -148,16 +150,16 @@ class symbol_table
{
public:
// callback functions for getting/setting a symbol value
- typedef UINT64 (*getter_func)(symbol_table &table, void *symref);
- typedef void (*setter_func)(symbol_table &table, void *symref, UINT64 value);
+ typedef std::function<UINT64(symbol_table &table, void *symref)> getter_func;
+ typedef std::function<void(symbol_table &table, void *symref, UINT64 value)> setter_func;
// callback functions for function execution
- typedef UINT64 (*execute_func)(symbol_table &table, void *symref, int numparams, const UINT64 *paramlist);
+ typedef std::function<UINT64(symbol_table &table, void *symref, int numparams, const UINT64 *paramlist)> execute_func;
// callback functions for memory reads/writes
- typedef expression_error::error_code (*valid_func)(void *cbparam, const char *name, expression_space space);
- typedef UINT64 (*read_func)(void *cbparam, const char *name, expression_space space, UINT32 offset, int size);
- typedef void (*write_func)(void *cbparam, const char *name, expression_space space, UINT32 offset, int size, UINT64 value);
+ typedef std::function<expression_error::error_code(void *cbparam, const char *name, expression_space space)> valid_func;
+ typedef std::function<UINT64(void *cbparam, const char *name, expression_space space, UINT32 offset, int size)> read_func;
+ typedef std::function<void(void *cbparam, const char *name, expression_space space, UINT32 offset, int size, UINT64 value)> write_func;
enum read_write
{
diff --git a/src/emu/debugger.cpp b/src/emu/debugger.cpp
index 849b16d068d..ca7f86030d1 100644
--- a/src/emu/debugger.cpp
+++ b/src/emu/debugger.cpp
@@ -23,6 +23,95 @@
static running_machine *g_machine = nullptr;
static int g_atexit_registered = FALSE;
+/*-------------------------------------------------
+ debugger_instruction_hook - CPU cores call
+ this once per instruction from CPU cores
+-------------------------------------------------*/
+
+void debugger_instruction_hook(device_t *device, offs_t curpc)
+{
+#ifndef MAME_DEBUG_FAST
+ if ((device->machine().debug_flags & DEBUG_FLAG_CALL_HOOK) != 0)
+ device->debug()->instruction_hook(curpc);
+#endif
+}
+
+
+/*-------------------------------------------------
+ debugger_exception_hook - CPU cores call this
+ anytime an exception is generated
+-------------------------------------------------*/
+
+void debugger_exception_hook(device_t *device, int exception)
+{
+ if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ device->debug()->exception_hook(exception);
+}
+
+/*-------------------------------------------------
+ debugger_start_cpu_hook - the CPU execution
+ system calls this hook before beginning
+ execution for the given CPU
+-------------------------------------------------*/
+
+void debugger_start_cpu_hook(device_t *device, const attotime &endtime)
+{
+ if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ device->debug()->start_hook(endtime);
+}
+
+
+/*-------------------------------------------------
+ debugger_stop_cpu_hook - the CPU execution
+ system calls this hook when ending execution
+ for the given CPU
+-------------------------------------------------*/
+
+void debugger_stop_cpu_hook(device_t *device)
+{
+ if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ device->debug()->stop_hook();
+}
+
+
+/*-------------------------------------------------
+ debugger_interrupt_hook - the CPU execution
+ system calls this hook when an interrupt is
+ acknowledged
+-------------------------------------------------*/
+
+void debugger_interrupt_hook(device_t *device, int irqline)
+{
+ if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ device->debug()->interrupt_hook(irqline);
+}
+
+/*-------------------------------------------------
+ debug_break - stop in the debugger at the next
+ opportunity
+-------------------------------------------------*/
+
+void debugger_manager::debug_break()
+{
+ if ((m_machine.debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ m_cpu->get_visible_cpu()->debug()->halt_on_next_instruction("Internal breakpoint\n");
+}
+
+
+/*-------------------------------------------------
+ within_instruction_hook - call this to
+ determine if the debugger is currently halted
+ within the instruction hook
+-------------------------------------------------*/
+
+bool debugger_manager::within_instruction_hook()
+{
+ if ((m_machine.debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ return m_cpu->within_instruction_hook();
+ return false;
+}
+
+
//**************************************************************************
// DEBUGGER MANAGER
//**************************************************************************
@@ -35,8 +124,9 @@ debugger_manager::debugger_manager(running_machine &machine)
: m_machine(machine)
{
/* initialize the submodules */
- debug_cpu_init(machine);
- debug_command_init(machine);
+ m_cpu = std::make_unique<debugger_cpu>(machine);
+ m_console = std::make_unique<debugger_console>(machine);
+ m_commands = std::make_unique<debugger_commands>(machine, cpu(), console());
g_machine = &machine;
@@ -45,9 +135,6 @@ debugger_manager::debugger_manager(running_machine &machine)
atexit(debugger_flush_all_traces_on_abnormal_exit);
g_atexit_registered = TRUE;
- /* listen in on the errorlog */
- machine.add_logerror_callback(debug_errorlog_write_line);
-
/* initialize osd debugger features */
machine.osd().init_debugger();
}
@@ -61,15 +148,6 @@ debugger_manager::~debugger_manager()
g_machine = nullptr;
}
-void debugger_manager::initialize()
-{
- /* only if debugging is enabled */
- if (machine().debug_flags & DEBUG_FLAG_ENABLED)
- {
- debug_console_init(machine());
- }
-}
-
/*-------------------------------------------------
refresh_display - redraw the current
video display
@@ -89,8 +167,8 @@ void debugger_manager::refresh_display()
void debugger_flush_all_traces_on_abnormal_exit(void)
{
- if(g_machine!=nullptr)
+ if(g_machine != nullptr)
{
- debug_cpu_flush_traces(*g_machine);
+ g_machine->debugger().cpu().flush_traces();
}
}
diff --git a/src/emu/debugger.h b/src/emu/debugger.h
index 4efcc5c3de6..786df8b27d5 100644
--- a/src/emu/debugger.h
+++ b/src/emu/debugger.h
@@ -9,10 +9,12 @@
#pragma once
-#ifndef __DEBUGGER_H__
-#define __DEBUGGER_H__
+#ifndef EMU_DEBUGGER_H
+#define EMU_DEBUGGER_H
-#include "debug/debugcpu.h"
+class debugger_commands;
+class debugger_cpu;
+class debugger_console;
// ======================> debugger_manager
@@ -24,16 +26,26 @@ public:
debugger_manager(running_machine &machine);
~debugger_manager();
- void initialize();
+ // break into the debugger
+ void debug_break();
- /* redraw the current video display */
+ bool within_instruction_hook();
+
+ // redraw the current video display
void refresh_display();
// getters
running_machine &machine() const { return m_machine; }
+ debugger_commands &commands() const { return *m_commands; }
+ debugger_cpu &cpu() const { return *m_cpu; }
+ debugger_console &console() const { return *m_console; }
+
private:
- // internal state
- running_machine & m_machine; // reference to our machine
+ running_machine & m_machine;
+
+ std::unique_ptr<debugger_commands> m_commands;
+ std::unique_ptr<debugger_cpu> m_cpu;
+ std::unique_ptr<debugger_console> m_console;
};
@@ -47,108 +59,21 @@ void debugger_flush_all_traces_on_abnormal_exit(void);
/***************************************************************************
- CPU CORE INLINE FUNCTIONS
+ CPU CORE STATIC FUNCTIONS
***************************************************************************/
-/*-------------------------------------------------
- debugger_instruction_hook - CPU cores call
- this once per instruction from CPU cores
--------------------------------------------------*/
-
-static inline void debugger_instruction_hook(device_t *device, offs_t curpc)
-{
-#ifndef MAME_DEBUG_FAST
- if ((device->machine().debug_flags & DEBUG_FLAG_CALL_HOOK) != 0)
- device->debug()->instruction_hook(curpc);
-#endif
-}
-
-
-/*-------------------------------------------------
- debugger_exception_hook - CPU cores call this
- anytime an exception is generated
--------------------------------------------------*/
-
-static inline void debugger_exception_hook(device_t *device, int exception)
-{
- if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
- device->debug()->exception_hook(exception);
-}
+void debugger_instruction_hook(device_t *device, offs_t curpc);
+void debugger_exception_hook(device_t *device, int exception);
/***************************************************************************
- CPU EXECUTION SYSTEM INLINE FUNCTIONS
+ CPU EXECUTION SYSTEM STATIC FUNCTIONS
***************************************************************************/
-/*-------------------------------------------------
- debugger_start_cpu_hook - the CPU execution
- system calls this hook before beginning
- execution for the given CPU
--------------------------------------------------*/
-
-static inline void debugger_start_cpu_hook(device_t *device, const attotime &endtime)
-{
- if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
- device->debug()->start_hook(endtime);
-}
-
-
-/*-------------------------------------------------
- debugger_stop_cpu_hook - the CPU execution
- system calls this hook when ending execution
- for the given CPU
--------------------------------------------------*/
-
-static inline void debugger_stop_cpu_hook(device_t *device)
-{
- if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
- device->debug()->stop_hook();
-}
-
-
-/*-------------------------------------------------
- debugger_interrupt_hook - the CPU execution
- system calls this hook when an interrupt is
- acknowledged
--------------------------------------------------*/
-
-static inline void debugger_interrupt_hook(device_t *device, int irqline)
-{
- if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
- device->debug()->interrupt_hook(irqline);
-}
-
-
-
-/***************************************************************************
- GENERAL INLINE FUNCTIONS
-***************************************************************************/
-
-/*-------------------------------------------------
- debugger_break - stop in the debugger at the
- next opportunity
--------------------------------------------------*/
-
-static inline void debugger_break(running_machine &machine)
-{
- if ((machine.debug_flags & DEBUG_FLAG_ENABLED) != 0)
- debug_cpu_get_visible_cpu(machine)->debug()->halt_on_next_instruction("Internal breakpoint\n");
-}
-
-
-/*-------------------------------------------------
- debugger_within_instruction_hook - call this
- to determine if the debugger is currently
- halted within the instruction hook
--------------------------------------------------*/
-
-static inline int debugger_within_instruction_hook(running_machine &machine)
-{
- if ((machine.debug_flags & DEBUG_FLAG_ENABLED) != 0)
- return debug_cpu_within_instruction_hook(machine);
- return FALSE;
-}
+void debugger_start_cpu_hook(device_t *device, const attotime &endtime);
+void debugger_stop_cpu_hook(device_t *device);
+void debugger_interrupt_hook(device_t *device, int irqline);
#endif /* __DEBUGGER_H__ */
diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp
index 12c127f0e03..5485e2f56e1 100644
--- a/src/emu/machine.cpp
+++ b/src/emu/machine.cpp
@@ -78,6 +78,7 @@
#include "crsshair.h"
#include "unzip.h"
#include "debug/debugvw.h"
+#include "debug/debugcpu.h"
#include "image.h"
#include "network.h"
#include "ui/uimain.h"
@@ -108,7 +109,6 @@ running_machine::running_machine(const machine_config &_config, machine_manager
: firstcpu(nullptr),
primary_screen(nullptr),
debug_flags(0),
- debugcpu_data(nullptr),
m_config(_config),
m_system(_config.gamedrv()),
m_manager(manager),
@@ -245,7 +245,6 @@ void running_machine::start()
{
m_debug_view = std::make_unique<debug_view_manager>(*this);
m_debugger = std::make_unique<debugger_manager>(*this);
- m_debugger->initialize();
}
m_render->resolve_tags();
@@ -293,7 +292,9 @@ int running_machine::run(bool quiet)
m_logfile = std::make_unique<emu_file>(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
osd_file::error filerr = m_logfile->open("error.log");
assert_always(filerr == osd_file::error::NONE, "unable to open log file");
- add_logerror_callback(logfile_callback);
+
+ using namespace std::placeholders;
+ add_logerror_callback(std::bind(&running_machine::logfile_callback, this, _1));
}
// then finish setting up our local machine
@@ -883,12 +884,12 @@ void running_machine::soft_reset(void *ptr, INT32 param)
// logfile
//-------------------------------------------------
-void running_machine::logfile_callback(const running_machine &machine, const char *buffer)
+void running_machine::logfile_callback(const char *buffer)
{
- if (machine.m_logfile != nullptr)
+ if (m_logfile != nullptr)
{
- machine.m_logfile->puts(buffer);
- machine.m_logfile->flush();
+ m_logfile->puts(buffer);
+ m_logfile->flush();
}
}
@@ -959,7 +960,7 @@ void running_machine::stop_all_devices()
{
// first let the debugger save comments
if ((debug_flags & DEBUG_FLAG_ENABLED) != 0)
- debug_comment_save(*this);
+ debugger().cpu().comment_save();
// iterate over devices and stop them
for (device_t &device : device_iterator(root_device()))
diff --git a/src/emu/machine.h b/src/emu/machine.h
index 91cb551be33..c15a26d3bb0 100644
--- a/src/emu/machine.h
+++ b/src/emu/machine.h
@@ -17,6 +17,8 @@
#ifndef __MACHINE_H__
#define __MACHINE_H__
+#include <functional>
+
#include "strformat.h"
#include "vecstream.h"
@@ -99,7 +101,6 @@ class rom_load_manager;
class debugger_manager;
class osd_interface;
enum class config_type;
-struct debugcpu_private;
// ======================> system_time
@@ -144,7 +145,7 @@ class running_machine
friend class sound_manager;
- typedef void (*logerror_callback)(const running_machine &machine, const char *string);
+ typedef std::function<void(const char*)> logerror_callback;
// must be at top of member variables
resource_pool m_respool; // pool of resources for this machine
@@ -245,9 +246,6 @@ public:
// debugger-related information
UINT32 debug_flags; // the current debug flags
- // internal core information
- debugcpu_private * debugcpu_data; // internal data from debugcpu.c
-
private:
// internal helpers
template <typename T> struct is_null { template <typename U> static bool value(U &&x) { return false; } };
@@ -264,7 +262,7 @@ private:
void popup_message(util::format_argument_pack<std::ostream> const &args) const;
// internal callbacks
- static void logfile_callback(const running_machine &machine, const char *buffer);
+ void logfile_callback(const char *buffer);
// internal device helpers
void start_all_devices();
@@ -401,7 +399,7 @@ inline void running_machine::logerror(Format &&fmt, Params &&... args) const
// log to all callbacks
char const *const str(&m_string_buffer.vec()[0]);
for (auto &cb : m_logerror_list)
- (cb->m_func)(*this, str);
+ cb->m_func(str);
g_profiler.stop();
}
diff --git a/src/emu/video.cpp b/src/emu/video.cpp
index 0f534f759e1..d62b865f5cc 100644
--- a/src/emu/video.cpp
+++ b/src/emu/video.cpp
@@ -253,7 +253,7 @@ void video_manager::frame_update(bool debug)
{
// reset partial updates if we're paused or if the debugger is active
screen_device *screen = machine().first_screen();
- if (screen != nullptr && (machine().paused() || debug || debugger_within_instruction_hook(machine())))
+ if (screen != nullptr && (machine().paused() || debug || machine().debugger().within_instruction_hook()))
screen->reset_partial_updates();
}
}
diff --git a/src/frontend/mame/cheat.cpp b/src/frontend/mame/cheat.cpp
index a2d4eeadc1f..0a9bedbb44a 100644
--- a/src/frontend/mame/cheat.cpp
+++ b/src/frontend/mame/cheat.cpp
@@ -1078,10 +1078,10 @@ cheat_manager::cheat_manager(running_machine &machine)
// we rely on the debugger expression callbacks; if the debugger isn't
// enabled, we must jumpstart them manually
if ((machine.debug_flags & DEBUG_FLAG_ENABLED) == 0)
- debug_cpu_init(machine);
+ m_cpu = std::make_unique<debugger_cpu>(machine);
// configure for memory access (shared with debugger)
- debug_cpu_configure_memory(machine, m_symtable);
+ m_cpu->configure_memory(m_symtable);
// load the cheats
reload();
diff --git a/src/frontend/mame/cheat.h b/src/frontend/mame/cheat.h
index cc6dcf14e59..80851653d13 100644
--- a/src/frontend/mame/cheat.h
+++ b/src/frontend/mame/cheat.h
@@ -14,6 +14,7 @@
#define __CHEAT_H__
#include "debug/express.h"
+#include "debug/debugcpu.h"
//**************************************************************************
@@ -48,8 +49,10 @@ class number_and_format
public:
// construction/destruction
number_and_format(UINT64 value = 0, int format = 0)
- : m_value(value),
- m_format(format) { }
+ : m_value(value)
+ , m_format(format)
+ {
+ }
// pass-through to look like a regular number
operator UINT64 &() { return m_value; }
@@ -307,6 +310,7 @@ private:
INT8 m_lastline; // last line used for output
bool m_disabled; // true if the cheat engine is disabled
symbol_table m_symtable; // global symbol table
+ std::unique_ptr<debugger_cpu> m_cpu; // debugger interface for cpus/memory
// constants
static constexpr int CHEAT_VERSION = 1;
diff --git a/src/frontend/mame/ui/slider.cpp b/src/frontend/mame/ui/slider.cpp
new file mode 100644
index 00000000000..f9eb861c994
--- /dev/null
+++ b/src/frontend/mame/ui/slider.cpp
@@ -0,0 +1,20 @@
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+/***************************************************************************
+
+ ui/slider.h
+
+ Internal data representation for an adjustment slider.
+
+***************************************************************************/
+
+#include "slider.h"
+
+slider_state::slider_state()
+{
+}
+
+slider_state::~slider_state()
+{
+}
diff --git a/src/mame/drivers/atvtrack.cpp b/src/mame/drivers/atvtrack.cpp
index fbc6b31012d..7c469da67f6 100644
--- a/src/mame/drivers/atvtrack.cpp
+++ b/src/mame/drivers/atvtrack.cpp
@@ -167,7 +167,7 @@ inline UINT32 atvtrack_state::decode64_32(offs_t offset64, UINT64 data, UINT64 m
return (UINT32)(data >> 32);
}
logerror("Wrong word size in external access\n");
- //debugger_break(nullptr);
+ //machine().debugger().debug_break();
return 0;
}
diff --git a/src/mame/drivers/chihiro.cpp b/src/mame/drivers/chihiro.cpp
index 386586330e6..d6c8bc74346 100644
--- a/src/mame/drivers/chihiro.cpp
+++ b/src/mame/drivers/chihiro.cpp
@@ -366,6 +366,8 @@ Thanks to Alex, Mr Mudkips, and Philip Burke for this info.
*/
+#include <functional>
+
#include "emu.h"
#include "cpu/i386/i386.h"
#include "machine/pic8259.h"
@@ -376,6 +378,7 @@ Thanks to Alex, Mr Mudkips, and Philip Burke for this info.
#include "debug/debugcon.h"
#include "debug/debugcmd.h"
#include "debug/debugcpu.h"
+#include "debugger.h"
#include "includes/chihiro.h"
#include "includes/xbox.h"
@@ -475,6 +478,12 @@ public:
int usbhack_counter;
UINT8 *dimm_board_memory;
UINT32 dimm_board_memory_size;
+
+private:
+ void jamtable_disasm(address_space &space, UINT32 address, UINT32 size);
+ void jamtable_disasm_command(int ref, int params, const char **param);
+ void help_command(int ref, int params, const char **param);
+ void debug_commands(int ref, int params, const char **param);
};
/* jamtable instructions for Chihiro (different from Xbox console)
@@ -493,29 +502,28 @@ St. Instr. Comment
*/
/* jamtable disassembler */
-static void jamtable_disasm(running_machine &machine, address_space &space, UINT32 address, UINT32 size) // 0xff000080 == fff00080
+void chihiro_state::jamtable_disasm(address_space &space, UINT32 address, UINT32 size) // 0xff000080 == fff00080
{
- offs_t base, addr;
- UINT32 opcode, op1, op2;
- char sop1[16];
- char sop2[16];
- char pcrel[16];
-
- addr = (offs_t)address;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &addr))
+ offs_t addr = (offs_t)address;
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &addr))
{
- debug_console_printf(machine, "Address is unmapped.\n");
+ machine().debugger().console().printf("Address is unmapped.\n");
return;
}
while (1)
{
- base = addr;
- opcode = space.read_byte(addr);
+ offs_t base = addr;
+
+ UINT32 opcode = space.read_byte(addr);
addr++;
- op1 = space.read_dword_unaligned(addr);
+ UINT32 op1 = space.read_dword_unaligned(addr);
addr += 4;
- op2 = space.read_dword_unaligned(addr);
+ UINT32 op2 = space.read_dword_unaligned(addr);
addr += 4;
+
+ char sop1[16];
+ char sop2[16];
+ char pcrel[16];
if (opcode == 0xe1)
{
opcode = op2 & 255;
@@ -531,7 +539,7 @@ static void jamtable_disasm(running_machine &machine, address_space &space, UINT
sprintf(sop1, "%08X", op1);
sprintf(pcrel, "%08X", base + 9 + op1);
}
- debug_console_printf(machine, "%08X ", base);
+ machine().debugger().console().printf("%08X ", base);
// dl=instr ebx=par1 eax=par2
switch (opcode)
{
@@ -546,39 +554,39 @@ static void jamtable_disasm(running_machine &machine, address_space &space, UINT
// | | Reserved | Bus Number | Device Number | Function Number | Register Number |0|0|
// +-+----------+------------+---------------+-----------------+-----------------+-+-+
// 31 - Enable bit
- debug_console_printf(machine, "POKEPCI PCICONF[%s]=%s\n", sop2, sop1);
+ machine().debugger().console().printf("POKEPCI PCICONF[%s]=%s\n", sop2, sop1);
break;
case 0x02:
- debug_console_printf(machine, "OUTB PORT[%s]=%s\n", sop2, sop1);
+ machine().debugger().console().printf("OUTB PORT[%s]=%s\n", sop2, sop1);
break;
case 0x03:
- debug_console_printf(machine, "POKE MEM[%s]=%s\n", sop2, sop1);
+ machine().debugger().console().printf("POKE MEM[%s]=%s\n", sop2, sop1);
break;
case 0x04:
- debug_console_printf(machine, "BNE IF ACC != %s THEN PC=%s\n", sop2, pcrel);
+ machine().debugger().console().printf("BNE IF ACC != %s THEN PC=%s\n", sop2, pcrel);
break;
case 0x05:
// out cf8,op2
// in acc,cfc
- debug_console_printf(machine, "PEEKPCI ACC=PCICONF[%s]\n", sop2);
+ machine().debugger().console().printf("PEEKPCI ACC=PCICONF[%s]\n", sop2);
break;
case 0x06:
- debug_console_printf(machine, "AND/OR ACC=(ACC & %s) | %s\n", sop2, sop1);
+ machine().debugger().console().printf("AND/OR ACC=(ACC & %s) | %s\n", sop2, sop1);
break;
case 0x07:
- debug_console_printf(machine, "BRA PC=%s\n", pcrel);
+ machine().debugger().console().printf("BRA PC=%s\n", pcrel);
break;
case 0x08:
- debug_console_printf(machine, "INB ACC=PORT[%s]\n", sop2);
+ machine().debugger().console().printf("INB ACC=PORT[%s]\n", sop2);
break;
case 0x09:
- debug_console_printf(machine, "PEEK ACC=MEM[%s]\n", sop2);
+ machine().debugger().console().printf("PEEK ACC=MEM[%s]\n", sop2);
break;
case 0xee:
- debug_console_printf(machine, "END\n");
+ machine().debugger().console().printf("END\n");
break;
default:
- debug_console_printf(machine, "NOP ????\n");
+ machine().debugger().console().printf("NOP ????\n");
break;
}
if (opcode == 0xee)
@@ -589,36 +597,35 @@ static void jamtable_disasm(running_machine &machine, address_space &space, UINT
}
}
-static void jamtable_disasm_command(running_machine &machine, int ref, int params, const char **param)
+void chihiro_state::jamtable_disasm_command(int ref, int params, const char **param)
{
- chihiro_state *state = machine.driver_data<chihiro_state>();
- address_space &space = state->m_maincpu->space();
+ address_space &space = m_maincpu->space();
UINT64 addr, size;
if (params < 2)
return;
- if (!debug_command_parameter_number(machine, param[0], &addr))
+ if (!machine().debugger().commands().validate_number_parameter(param[0], &addr))
return;
- if (!debug_command_parameter_number(machine, param[1], &size))
+ if (!machine().debugger().commands().validate_number_parameter(param[1], &size))
return;
- jamtable_disasm(machine, space, (UINT32)addr, (UINT32)size);
+ jamtable_disasm(space, (UINT32)addr, (UINT32)size);
}
-static void help_command(running_machine &machine, int ref, int params, const char **param)
+void chihiro_state::help_command(int ref, int params, const char **param)
{
- debug_console_printf(machine, "Available Chihiro commands:\n");
- debug_console_printf(machine, " chihiro jamdis,<start>,<size> -- Disassemble <size> bytes of JamTable instructions starting at <start>\n");
- debug_console_printf(machine, " chihiro help -- this list\n");
+ machine().debugger().console().printf("Available Chihiro commands:\n");
+ machine().debugger().console().printf(" chihiro jamdis,<start>,<size> -- Disassemble <size> bytes of JamTable instructions starting at <start>\n");
+ machine().debugger().console().printf(" chihiro help -- this list\n");
}
-static void chihiro_debug_commands(running_machine &machine, int ref, int params, const char **param)
+void chihiro_state::debug_commands(int ref, int params, const char **param)
{
if (params < 1)
return;
if (strcmp("jamdis", param[0]) == 0)
- jamtable_disasm_command(machine, ref, params - 1, param + 1);
+ jamtable_disasm_command(ref, params - 1, param + 1);
else
- help_command(machine, ref, params - 1, param + 1);
+ help_command(ref, params - 1, param + 1);
}
void chihiro_state::hack_eeprom()
@@ -1099,7 +1106,10 @@ void chihiro_state::machine_start()
dimm_board_memory = chihiro_devs.dimmboard->memory(dimm_board_memory_size);
}
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
- debug_console_register_command(machine(), "chihiro", CMDFLAG_NONE, 0, 1, 4, chihiro_debug_commands);
+ {
+ using namespace std::placeholders;
+ machine().debugger().console().register_command("chihiro", CMDFLAG_NONE, 0, 1, 4, std::bind(&chihiro_state::debug_commands, this, _1, _2, _3));
+ }
usbhack_index = -1;
for (int a = 1; a < 3; a++)
if (strcmp(machine().basename(), hacks[a].game_name) == 0) {
diff --git a/src/mame/drivers/icatel.cpp b/src/mame/drivers/icatel.cpp
index 79a4c32509d..a7ef81e9aad 100644
--- a/src/mame/drivers/icatel.cpp
+++ b/src/mame/drivers/icatel.cpp
@@ -171,8 +171,8 @@ WRITE8_MEMBER(icatel_state::ci8_w)
READ8_MEMBER(icatel_state::ci15_r)
{
/* TODO: Implement-me! */
-// debugger_break(machine());
-// logerror("read: ci15\n");
+ //machine().debugger().debug_break();
+ //logerror("read: ci15\n");
return (1 << 3) | (1 << 0);
}
diff --git a/src/mame/drivers/naomi.cpp b/src/mame/drivers/naomi.cpp
index e3fcb568072..e7a85e12ac8 100644
--- a/src/mame/drivers/naomi.cpp
+++ b/src/mame/drivers/naomi.cpp
@@ -1817,7 +1817,7 @@ inline int naomi_state::decode_reg32_64(UINT32 offset, UINT64 mem_mask, UINT64 *
if ((mem_mask != U64(0xffffffff00000000)) && (mem_mask != U64(0x00000000ffffffff)))
{
osd_printf_verbose("%s:Wrong mask!\n", machine().describe_context());
-// debugger_break(machine);
+ //machine().debugger().debug_break();
}
if (mem_mask == U64(0xffffffff00000000))
diff --git a/src/mame/drivers/nokia_3310.cpp b/src/mame/drivers/nokia_3310.cpp
index 6bb30ff81d8..a8a01540c1b 100644
--- a/src/mame/drivers/nokia_3310.cpp
+++ b/src/mame/drivers/nokia_3310.cpp
@@ -553,7 +553,7 @@ WRITE8_MEMBER(noki3310_state::mad2_io_w)
{
case 0x02:
//printf("DSP %s\n", data & 1 ? "RUN" : "HOLD");
- //if (data & 0x01) debugger_break(machine());
+ //if (data & 0x01) machine().debugger().debug_break();
break;
case 0x08:
ack_fiq(data);
diff --git a/src/mame/drivers/palm.cpp b/src/mame/drivers/palm.cpp
index 57331092f30..da0eca4c26d 100644
--- a/src/mame/drivers/palm.cpp
+++ b/src/mame/drivers/palm.cpp
@@ -17,6 +17,7 @@
#include "machine/ram.h"
#include "sound/dac.h"
#include "debugger.h"
+#include "debug/debugcpu.h"
#include "rendlay.h"
#define MC68328_TAG "dragonball"
diff --git a/src/mame/drivers/pasopia7.cpp b/src/mame/drivers/pasopia7.cpp
index 68e16212e61..0351ad59f16 100644
--- a/src/mame/drivers/pasopia7.cpp
+++ b/src/mame/drivers/pasopia7.cpp
@@ -815,14 +815,14 @@ WRITE8_MEMBER( pasopia7_state::video_misc_w )
---- x--- pal disable
---- xx-- palette selector (both bits enables this, odd hook-up)
*/
-// if(data & 2)
-// {
-// printf("VIDEO MISC %02x\n",data);
-// debugger_break(device->machine());
-// }
+ //if(data & 2)
+ //{
+ // printf("VIDEO MISC %02x\n",data);
+ // machine().debugger().debug_break();
+ //}
m_cursor_blink = data & 0x20;
m_attr_wrap = data & 0x10;
-// m_pal_sel = data & 0x02;
+ //m_pal_sel = data & 0x02;
}
WRITE8_MEMBER( pasopia7_state::nmi_mask_w )
diff --git a/src/mame/drivers/pc8801.cpp b/src/mame/drivers/pc8801.cpp
index a2d9da47c02..fd751075dfa 100644
--- a/src/mame/drivers/pc8801.cpp
+++ b/src/mame/drivers/pc8801.cpp
@@ -2341,7 +2341,7 @@ IRQ_CALLBACK_MEMBER(pc8801_state::pc8801_irq_callback)
}
printf("IRQ triggered but no vector on the bus! %02x %02x %02x %02x\n",m_i8214_irq_level,m_sound_irq_latch,m_vrtc_irq_latch,m_timer_irq_latch);
- debugger_break(machine());
+ machine().debugger().debug_break();
return 4*2; //TODO: mustn't happen
}
diff --git a/src/mame/drivers/raiden2.cpp b/src/mame/drivers/raiden2.cpp
index d0c3377f588..bfb55c9d7ae 100644
--- a/src/mame/drivers/raiden2.cpp
+++ b/src/mame/drivers/raiden2.cpp
@@ -856,7 +856,7 @@ WRITE16_MEMBER(raiden2_state::sprite_prot_src_w)
dst1 += 8;
}
//printf("[%08x] %08x %08x %04x %04x\n",src,dx,dy,dst1,dst2);
- // debugger_break(machine());
+ //machine().debugger().debug_break();
}
READ16_MEMBER(raiden2_state::sprite_prot_dst1_r)
diff --git a/src/mame/drivers/segas24.cpp b/src/mame/drivers/segas24.cpp
index 1b6c6027ca2..1aaa7986b8e 100644
--- a/src/mame/drivers/segas24.cpp
+++ b/src/mame/drivers/segas24.cpp
@@ -749,8 +749,8 @@ void segas24_state::reset_reset()
if(resetcontrol & 2) {
m_subcpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
m_subcpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
-// osd_printf_debug("enable 2nd cpu!\n");
-// debugger_break(machine);
+ //osd_printf_debug("enable 2nd cpu!\n");
+ //machine().debugger().debug_break();
if (m_gground_hack_timer)
{
m_subcpu->set_clock_scale(0.7f); // reduce clock speed temporarily so a check passes, see notes above
diff --git a/src/mame/drivers/xbox.cpp b/src/mame/drivers/xbox.cpp
index f193a4b857c..eda30d3003c 100644
--- a/src/mame/drivers/xbox.cpp
+++ b/src/mame/drivers/xbox.cpp
@@ -22,6 +22,7 @@
#include "debug/debugcon.h"
#include "debug/debugcmd.h"
#include "debug/debugcpu.h"
+#include "debugger.h"
#include "includes/chihiro.h"
#include "includes/xbox.h"
diff --git a/src/mame/includes/dgn_beta.h b/src/mame/includes/dgn_beta.h
index a55d157aaa1..c58b821f5c0 100644
--- a/src/mame/includes/dgn_beta.h
+++ b/src/mame/includes/dgn_beta.h
@@ -220,6 +220,10 @@ public:
required_device<floppy_connector> m_floppy2;
required_device<floppy_connector> m_floppy3;
required_device<palette_device> m_palette;
+
+private:
+ void execute_beta_key_dump(int ref, int params, const char *param[]);
+ void execute_beta_dat_log(int ref, int params, const char *param[]);
};
#endif /* DGN_BETA_H_ */
diff --git a/src/mame/includes/mbc55x.h b/src/mame/includes/mbc55x.h
index 7069084d83e..298c5236590 100644
--- a/src/mame/includes/mbc55x.h
+++ b/src/mame/includes/mbc55x.h
@@ -174,6 +174,10 @@ public:
void keyboard_reset();
void scan_keyboard();
void set_ram_size();
+
+private:
+ void debug_command(int ref, int params, const char *param[]);
+ void video_debug(int ref, int params, const char *param[]);
};
/*----------- defined in drivers/mbc55x.c -----------*/
diff --git a/src/mame/includes/rmnimbus.h b/src/mame/includes/rmnimbus.h
index d22a887a057..73d2f6047d6 100644
--- a/src/mame/includes/rmnimbus.h
+++ b/src/mame/includes/rmnimbus.h
@@ -218,4 +218,8 @@ public:
emu_timer *m_mouse_timer;
} m_nimbus_mouse;
+
+private:
+ void debug_command(int ref, int params, const char *param[]);
+ void video_debug(int ref, int params, const char *param[]);
};
diff --git a/src/mame/includes/xbox.h b/src/mame/includes/xbox.h
index 5b83ccbbbc0..1a7988b4511 100644
--- a/src/mame/includes/xbox.h
+++ b/src/mame/includes/xbox.h
@@ -562,6 +562,22 @@ public:
int debug_irq_number;
required_device<cpu_device> m_maincpu;
ohci_usb_controller *ohci_usb;
+
+private:
+ void dump_string_command(int ref, int params, const char **param);
+ void dump_process_command(int ref, int params, const char **param);
+ void dump_list_command(int ref, int params, const char **param);
+ void dump_dpc_command(int ref, int params, const char **param);
+ void dump_timer_command(int ref, int params, const char **param);
+ void curthread_command(int ref, int params, const char **param);
+ void generate_irq_command(int ref, int params, const char **param);
+ void nv2a_combiners_command(int ref, int params, const char **param);
+ void waitvblank_command(int ref, int params, const char **param);
+ void grab_texture_command(int ref, int params, const char **param);
+ void grab_vprog_command(int ref, int params, const char **param);
+ void vprogdis_command(int ref, int params, const char **param);
+ void help_command(int ref, int params, const char **param);
+ void xbox_debug_commands(int ref, int params, const char **param);
};
ADDRESS_MAP_EXTERN(xbox_base_map, 32);
diff --git a/src/mame/machine/3do.cpp b/src/mame/machine/3do.cpp
index 347ca3822b4..f333745e42a 100644
--- a/src/mame/machine/3do.cpp
+++ b/src/mame/machine/3do.cpp
@@ -1004,7 +1004,7 @@ WRITE32_MEMBER(_3do_state::_3do_clio_w)
case 0x17fc/4:
/* TODO: DSPP enabled just before enabling DSPP irq! */
if(data & 1)
- debugger_break(machine());
+ machine().debugger().debug_break();
//printf("%08x\n",data);
break;
diff --git a/src/mame/machine/dc.cpp b/src/mame/machine/dc.cpp
index 59141504bdb..fbb3a1beccd 100644
--- a/src/mame/machine/dc.cpp
+++ b/src/mame/machine/dc.cpp
@@ -244,7 +244,7 @@ int dc_state::decode_reg32_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift)
if ((mem_mask != U64(0xffffffff00000000)) && (mem_mask != U64(0x00000000ffffffff)))
{
osd_printf_verbose("%s:Wrong mask!\n", machine().describe_context());
-// debugger_break(machine);
+ //machine().debugger().debug_break();
}
if (mem_mask == U64(0xffffffff00000000))
@@ -268,7 +268,7 @@ int dc_state::decode_reg3216_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift)
(mem_mask != U64(0xffffffff00000000)) && (mem_mask != U64(0x00000000ffffffff)))
{
osd_printf_verbose("%s:Wrong mask!\n", machine().describe_context());
-// debugger_break(machine);
+ //machine().debugger().debug_break();
}
if (mem_mask & U64(0x0000ffff00000000))
diff --git a/src/mame/machine/dccons.cpp b/src/mame/machine/dccons.cpp
index 2f1b553e9fb..0a46f22d77c 100644
--- a/src/mame/machine/dccons.cpp
+++ b/src/mame/machine/dccons.cpp
@@ -119,16 +119,17 @@ READ32_MEMBER(dc_cons_state::dc_mess_g1_ctrl_r )
{
case SB_GDSTARD:
printf("G1CTRL: GDSTARD %08x\n", atapi_xferbase); // Hello Kitty reads here
- debugger_break(machine());
+ machine().debugger().debug_break();
return atapi_xferbase;
case SB_GDST:
break;
case SB_GDLEND:
- //debugger_break(machine());
+ //machine().debugger().debug_break();
return atapi_xferlen; // TODO: check me
default:
printf("G1CTRL: Unmapped read %08x\n", 0x5f7400+offset*4);
- debugger_break(machine());
+ machine().debugger().debug_break();
+ break;
}
return g1bus_regs[offset];
}
diff --git a/src/mame/machine/dgn_beta.cpp b/src/mame/machine/dgn_beta.cpp
index 57b68c53879..b3689e67b3d 100644
--- a/src/mame/machine/dgn_beta.cpp
+++ b/src/mame/machine/dgn_beta.cpp
@@ -57,6 +57,8 @@
***************************************************************************/
+#include <functional>
+
#include <math.h>
#include "emu.h"
#include "debug/debugcon.h"
@@ -66,6 +68,7 @@
#include "machine/mos6551.h"
#include "imagedev/flopdrv.h"
+#include "debugger.h"
#include "debug/debugcpu.h"
#include "debug/debugcon.h"
#include "machine/ram.h"
@@ -86,8 +89,6 @@
/* Debugging commands and handlers. */
static offs_t dgnbeta_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options);
-static void execute_beta_dat_log(running_machine &machine, int ref, int params, const char *param[]);
-static void execute_beta_key_dump(running_machine &machine, int ref, int params, const char *param[]);
//static int DMA_NMI; /* DMA cpu has received an NMI */
@@ -174,7 +175,7 @@ void dgn_beta_state::UpdateBanks(int first, int last)
{
readbank = &m_ram->pointer()[MapPage*RamPageSize];
if(m_LogDatWrites)
- debug_console_printf(machine(), "Mapping page %X, pageno=%X, mess_ram)[%X]\n",Page,MapPage,(MapPage*RamPageSize));
+ machine().debugger().console().printf("Mapping page %X, pageno=%X, mess_ram)[%X]\n",Page,MapPage,(MapPage*RamPageSize));
}
else
{
@@ -531,7 +532,7 @@ WRITE_LINE_MEMBER(dgn_beta_state::d_pia0_cb2_w)
m_RowShifter = (m_RowShifter<<1) | ((m_d_pia0_pb_last & KOutDat)>>4);
m_RowShifter &= 0x3FF;
LOG_KEYBOARD(("Rowshifter=$%02X Keyrow=$%02X\n",m_RowShifter,m_Keyrow));
- if (VERBOSE) debug_console_printf(machine(), "rowshifter clocked, value=%3X, RowNo=%d, Keyrow=%2X\n",m_RowShifter,RowNo,m_Keyrow);
+ if (VERBOSE) machine().debugger().console().printf("rowshifter clocked, value=%3X, RowNo=%d, Keyrow=%2X\n",m_RowShifter,RowNo,m_Keyrow);
}
m_d_pia0_cb2_last=state;
@@ -945,10 +946,11 @@ void dgn_beta_state::machine_start()
/* setup debug commands */
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
{
- debug_console_register_command(machine(), "beta_dat_log", CMDFLAG_NONE, 0, 0, 0, execute_beta_dat_log);
- debug_console_register_command(machine(), "beta_key_dump", CMDFLAG_NONE, 0, 0, 0, execute_beta_key_dump);
+ using namespace std::placeholders;
+ machine().debugger().console().register_command("beta_dat_log", CMDFLAG_NONE, 0, 0, 0, std::bind(&dgn_beta_state::execute_beta_dat_log, this, _1, _2, _3));
+ machine().debugger().console().register_command("beta_key_dump", CMDFLAG_NONE, 0, 0, 0, std::bind(&dgn_beta_state::execute_beta_key_dump, this, _1, _2, _3));
}
- m_LogDatWrites=0;
+ m_LogDatWrites = false;
}
@@ -1124,21 +1126,17 @@ static offs_t dgnbeta_dasm_override(device_t &device, char *buffer, offs_t pc, c
return result;
}
-static void execute_beta_dat_log(running_machine &machine, int ref, int params, const char *param[])
+void dgn_beta_state::execute_beta_dat_log(int ref, int params, const char *param[])
{
- dgn_beta_state *state = machine.driver_data<dgn_beta_state>();
- state->m_LogDatWrites=!state->m_LogDatWrites;
+ m_LogDatWrites = !m_LogDatWrites;
- debug_console_printf(machine, "DAT register write info set : %d\n",state->m_LogDatWrites);
+ machine().debugger().console().printf("DAT register write info set : %d\n", m_LogDatWrites);
}
-static void execute_beta_key_dump(running_machine &machine, int ref, int params, const char *param[])
+void dgn_beta_state::execute_beta_key_dump(int ref, int params, const char *param[])
{
- dgn_beta_state *state = machine.driver_data<dgn_beta_state>();
- int Idx;
-
- for(Idx=0;Idx<NoKeyrows;Idx++)
+ for (int idx = 0; idx < NoKeyrows; idx++)
{
- debug_console_printf(machine, "KeyRow[%d]=%2X\n",Idx,state->m_Keyboard[Idx]);
+ machine().debugger().console().printf("KeyRow[%d]=%2X\n", idx, m_Keyboard[idx]);
}
}
diff --git a/src/mame/machine/fddebug.cpp b/src/mame/machine/fddebug.cpp
index f12afaf50e2..a384512642d 100644
--- a/src/mame/machine/fddebug.cpp
+++ b/src/mame/machine/fddebug.cpp
@@ -1,5 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
+
+#include <functional>
+
#include "emu.h"
#include "machine/fddebug.h"
@@ -422,11 +425,9 @@ static inline void set_constraint(fd1094_constraint *constraint, UINT32 pc, UINT
static inline void print_possibilities(running_machine &machine)
{
- int i;
-
- debug_console_printf(machine, "Possibilities @ %06X:\n", posslist[0].basepc);
- for (i = 0; i < posscount; i++)
- debug_console_printf(machine, " %c%2x: %s\n", posslist[i].iffy ? ' ' : '*', i, posslist[i].dasm);
+ machine.debugger().console().printf("Possibilities @ %06X:\n", posslist[0].basepc);
+ for (int i = 0; i < posscount; i++)
+ machine.debugger().console().printf(" %c%2x: %s\n", posslist[i].iffy ? ' ' : '*', i, posslist[i].dasm);
}
@@ -522,23 +523,24 @@ void fd1094_init_debugging(running_machine &machine, const char *cpureg, const c
load_overlay_file(machine);
/* add some commands */
- debug_console_register_command(machine, "fdsave", CMDFLAG_NONE, 0, 0, 0, execute_fdsave);
- debug_console_register_command(machine, "fdoutput", CMDFLAG_NONE, 0, 1, 1, execute_fdoutput);
- debug_console_register_command(machine, "fdseed", CMDFLAG_NONE, 0, 2, 2, execute_fdseed);
- debug_console_register_command(machine, "fdguess", CMDFLAG_NONE, STATUS_GUESS, 1, 1, execute_fdlockguess);
- debug_console_register_command(machine, "fdlock", CMDFLAG_NONE, STATUS_LOCKED, 1, 1, execute_fdlockguess);
- debug_console_register_command(machine, "fdeliminate", CMDFLAG_NONE, 0, 1, 10, execute_fdeliminate);
- debug_console_register_command(machine, "fdunlock", CMDFLAG_NONE, 0, 1, 1, execute_fdunlock);
- debug_console_register_command(machine, "fdignore", CMDFLAG_NONE, 0, 0, 1, execute_fdignore);
- debug_console_register_command(machine, "fdundo", CMDFLAG_NONE, 0, 0, 0, execute_fdundo);
- debug_console_register_command(machine, "fdstatus", CMDFLAG_NONE, 0, 0, 0, execute_fdstatus);
- debug_console_register_command(machine, "fdstate", CMDFLAG_NONE, 0, 0, 1, execute_fdstate);
- debug_console_register_command(machine, "fdpc", CMDFLAG_NONE, 0, 0, 1, execute_fdpc);
- debug_console_register_command(machine, "fdsearch", CMDFLAG_NONE, 0, 0, 0, execute_fdsearch);
- debug_console_register_command(machine, "fddasm", CMDFLAG_NONE, 0, 1, 1, execute_fddasm);
- debug_console_register_command(machine, "fdcset", CMDFLAG_NONE, 0, 2, 4, execute_fdcset);
- debug_console_register_command(machine, "fdclist", CMDFLAG_NONE, 0, 0, 0, execute_fdclist);
- debug_console_register_command(machine, "fdcsearch", CMDFLAG_NONE, 0, 0, 0, execute_fdcsearch);
+ using namespace std::placeholder;
+ machine.debugger().console().register_command("fdsave", CMDFLAG_NONE, 0, 0, 0, std::bind(&execute_fdsave, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdoutput", CMDFLAG_NONE, 0, 1, 1, std::bind(&execute_fdoutput, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdseed", CMDFLAG_NONE, 0, 2, 2, std::bind(&execute_fdseed, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdguess", CMDFLAG_NONE, STATUS_GUESS, 1, 1, std::bind(&execute_fdlockguess, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdlock", CMDFLAG_NONE, STATUS_LOCKED, 1, 1, std::bind(&execute_fdlockguess, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdeliminate", CMDFLAG_NONE, 0, 1, 10, std::bind(&execute_fdeliminate, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdunlock", CMDFLAG_NONE, 0, 1, 1, std::bind(&execute_fdunlock, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdignore", CMDFLAG_NONE, 0, 0, 1, std::bind(&execute_fdignore, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdundo", CMDFLAG_NONE, 0, 0, 0, std::bind(&execute_fdundo, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdstatus", CMDFLAG_NONE, 0, 0, 0, std::bind(&execute_fdstatus, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdstate", CMDFLAG_NONE, 0, 0, 1, std::bind(&execute_fdstate, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdpc", CMDFLAG_NONE, 0, 0, 1, std::bind(&execute_fdpc, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdsearch", CMDFLAG_NONE, 0, 0, 0, std::bind(&execute_fdsearch, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fddasm", CMDFLAG_NONE, 0, 1, 1, std::bind(&execute_fddasm, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdcset", CMDFLAG_NONE, 0, 2, 4, std::bind(&execute_fdcset, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdclist", CMDFLAG_NONE, 0, 0, 0, std::bind(&execute_fdclist, std::ref(machine), _1, _2, _3));
+ machine.debugger().console().register_command("fdcsearch", CMDFLAG_NONE, 0, 0, 0, std::bind(&execute_fdcsearch, std::ref(machine), _1, _2, _3));
/* set up the instruction hook */
machine.device("maincpu")->debug()->set_instruction_hook(instruction_hook);
@@ -743,7 +745,7 @@ static int instruction_hook(device_t &device, offs_t curpc)
static void execute_fdsave(running_machine &machine, int ref, int params, const char **param)
{
save_overlay_file(machine);
- debug_console_printf(machine, "File saved\n");
+ machine.debugger().console().printf("File saved\n");
}
@@ -764,7 +766,7 @@ static void execute_fdoutput(running_machine &machine, int ref, int params, cons
if (filerr == osd_file::error::NONE)
file.write(keyregion, KEY_SIZE);
- debug_console_printf(machine, "File '%s' saved\n", param[0]);
+ machine.debugger().console().printf("File '%s' saved\n", param[0]);
}
@@ -777,9 +779,9 @@ static void execute_fdseed(running_machine &machine, int ref, int params, const
UINT64 num1, num2;
/* extract the parameters */
- if (!debug_command_parameter_number(machine, param[0], &num1))
+ if (!machine.debugger().commands().validate_number_parameter(param[0], &num1))
return;
- if (!debug_command_parameter_number(machine, param[1], &num2))
+ if (!machine.debugger().commands().validate_number_parameter(param[1], &num2))
return;
/* set the global and seed, and then regenerate the key */
@@ -804,13 +806,13 @@ static void execute_fdlockguess(running_machine &machine, int ref, int params, c
UINT64 num1;
/* extract the parameter */
- if (!debug_command_parameter_number(machine, param[0], &num1))
+ if (!machine.debugger().commands().validate_number_parameter(param[0], &num1))
return;
/* make sure it is within range of our recent possibilities */
if (num1 >= posscount)
{
- debug_console_printf(machine, "Possibility of out range (%x max)\n", posscount);
+ machine.debugger().console().printf("Possibility of out range (%x max)\n", posscount);
return;
}
@@ -839,13 +841,13 @@ static void execute_fdeliminate(running_machine &machine, int ref, int params, c
UINT64 num1;
/* extract the parameters */
- if (!debug_command_parameter_number(machine, param[pnum], &num1))
+ if (!machine.debugger().commands().validate_number_parameter(param[pnum], &num1))
return;
/* make sure it is within range of our recent possibilities */
if (num1 >= posscount)
{
- debug_console_printf(machine, "Possibility %x of out range (%x max)\n", (int)num1, posscount);
+ machine.debugger().console().printf("Possibility %x of out range (%x max)\n", (int)num1, posscount);
return;
}
@@ -881,21 +883,20 @@ static void execute_fdeliminate(running_machine &machine, int ref, int params, c
static void execute_fdunlock(running_machine &machine, int ref, int params, const char **param)
{
- device_t *cpu = debug_cpu_get_visible_cpu(machine);
- int reps = keystatus_words / KEY_SIZE;
- int keyaddr, repnum;
- UINT64 offset;
+ device_t *cpu = machine.debugger().cpu().get_visible_cpu();
/* support 0 or 1 parameters */
- if (params != 1 || !debug_command_parameter_number(machine, param[0], &offset))
+ UINT64 offset;
+ if (params != 1 || !machine.debugger().commands().validate_number_parameter(param[0], &offset))
offset = cpu->safe_pc();
- keyaddr = addr_to_keyaddr(offset / 2);
+ int keyaddr = addr_to_keyaddr(offset / 2);
/* toggle the ignore PC status */
- debug_console_printf(machine, "Unlocking PC %06X\n", (int)offset);
+ machine.debugger().console().printf("Unlocking PC %06X\n", (int)offset);
/* iterate over all reps and unlock them */
- for (repnum = 0; repnum < reps; repnum++)
+ const int reps = keystatus_words / KEY_SIZE;
+ for (int repnum = 0; repnum < reps; repnum++)
{
UINT16 *dest = &keystatus[repnum * KEY_SIZE + keyaddr];
if ((*dest & STATUS_MASK) == STATUS_LOCKED)
@@ -919,30 +920,31 @@ static void execute_fdunlock(running_machine &machine, int ref, int params, cons
static void execute_fdignore(running_machine &machine, int ref, int params, const char **param)
{
- device_t *cpu = debug_cpu_get_visible_cpu(machine);
- UINT64 offset;
+ device_t *cpu = machine.debugger().cpu().get_visible_cpu();
/* support 0 or 1 parameters */
if (params == 1 && strcmp(param[0], "all") == 0)
{
ignore_all = TRUE;
- debug_console_printf(machine, "Ignoring all unknown opcodes\n");
+ machine.debugger().console().printf("Ignoring all unknown opcodes\n");
return;
}
- if (params != 1 || !debug_command_parameter_number(machine, param[0], &offset))
+
+ UINT64 offset;
+ if (params != 1 || !machine.debugger().commands().validate_number_parameter(param[0], &offset))
offset = cpu->safe_pc();
offset /= 2;
/* toggle the ignore PC status */
ignorepc[offset] = !ignorepc[offset];
if (ignorepc[offset])
- debug_console_printf(machine, "Ignoring address %06X\n", (int)offset * 2);
+ machine.debugger().console().printf("Ignoring address %06X\n", (int)offset * 2);
else
- debug_console_printf(machine, "No longer ignoring address %06X\n", (int)offset * 2);
+ machine.debugger().console().printf("No longer ignoring address %06X\n", (int)offset * 2);
/* if no parameter given, implicitly run as well */
if (params == 0)
- debug_cpu_get_visible_cpu(machine)->debug()->go();
+ machine.debugger().cpu().get_visible_cpu()->debug()->go();
}
@@ -956,7 +958,7 @@ static void execute_fdundo(running_machine &machine, int ref, int params, const
/* copy the undobuffer back and regenerate the key */
memcpy(keystatus, undobuff, keystatus_words * 2);
fd1094_regenerate_key(machine);
- debug_console_printf(machine, "Undid last change\n");
+ machine.debugger().console().printf("Undid last change\n");
}
@@ -986,9 +988,9 @@ static void execute_fdstatus(running_machine &machine, int ref, int params, cons
else
nomatter++;
}
- debug_console_printf(machine, "%4d/%4d keys locked (%d%%)\n", locked, KEY_SIZE, locked * 100 / KEY_SIZE);
- debug_console_printf(machine, "%4d/%4d keys guessed (%d%%)\n", guesses, KEY_SIZE, guesses * 100 / KEY_SIZE);
- debug_console_printf(machine, "%4d/%4d keys don't matter (%d%%)\n", nomatter, KEY_SIZE, nomatter * 100 / KEY_SIZE);
+ machine.debugger().console().printf("%4d/%4d keys locked (%d%%)\n", locked, KEY_SIZE, locked * 100 / KEY_SIZE);
+ machine.debugger().console().printf("%4d/%4d keys guessed (%d%%)\n", guesses, KEY_SIZE, guesses * 100 / KEY_SIZE);
+ machine.debugger().console().printf("%4d/%4d keys don't matter (%d%%)\n", nomatter, KEY_SIZE, nomatter * 100 / KEY_SIZE);
}
@@ -1004,7 +1006,7 @@ static void execute_fdstate(running_machine &machine, int ref, int params, const
/* set the new state if we got a parameter */
if (params > 0)
{
- if (!debug_command_parameter_number(machine, param[0], &newstate))
+ if (!machine.debugger().commands().validate_number_parameter(param[0], &newstate))
return;
fd1094_set_state(keyregion, newstate);
fd1094_regenerate_key(machine);
@@ -1013,7 +1015,7 @@ static void execute_fdstate(running_machine &machine, int ref, int params, const
}
/* 0 parameters displays the current state */
- debug_console_printf(machine, "FD1094 state = %X\n", fd1094_set_state(keyregion, -1));
+ machine.debugger().console().printf("FD1094 state = %X\n", fd1094_set_state(keyregion, -1));
}
@@ -1024,11 +1026,11 @@ static void execute_fdstate(running_machine &machine, int ref, int params, const
static void execute_fdpc(running_machine &machine, int ref, int params, const char **param)
{
- device_t *cpu = debug_cpu_get_visible_cpu(machine);
- UINT64 newpc;
+ device_t *cpu = machine.debugger().cpu().get_visible_cpu();
/* support 0 or 1 parameters */
- if (!debug_command_parameter_number(machine, param[0], &newpc))
+ UINT64 newpc = 0;
+ if (!machine.debugger().commands().validate_number_parameter(param[0], &newpc))
newpc = cpu->safe_pc();
/* set the new PC */
@@ -1046,7 +1048,7 @@ static void execute_fdpc(running_machine &machine, int ref, int params, const ch
static void execute_fdsearch(running_machine &machine, int ref, int params, const char **param)
{
- address_space &space = debug_cpu_get_visible_cpu(machine)->memory().space(AS_PROGRAM);
+ address_space &space = machine->debugger().cpu().get_visible_cpu()->memory().space(AS_PROGRAM);
int pc = space.device().safe_pc();
int length, first = TRUE;
UINT8 instrdata[2];
@@ -1056,14 +1058,14 @@ static void execute_fdsearch(running_machine &machine, int ref, int params, cons
if (searchsp == 0 || searchstack[searchsp-1] != pc)
{
int pcaddr;
- debug_console_printf(machine, "Starting new search at PC=%06X\n", pc);
+ machine.debugger().console().printf("Starting new search at PC=%06X\n", pc);
searchsp = 0;
for (pcaddr = 0; pcaddr < coderegion_words; pcaddr++)
keystatus[pcaddr] &= ~SEARCH_MASK;
}
else
{
- debug_console_printf(machine, "Resuming search at PC=%06X\n", pc);
+ machine.debugger().console().printf("Resuming search at PC=%06X\n", pc);
searchsp--;
}
@@ -1080,7 +1082,7 @@ static void execute_fdsearch(running_machine &machine, int ref, int params, cons
pc = searchstack[--searchsp];
if ((keystatus[pc/2] & SEARCH_MASK) != 0)
{
- debug_console_printf(machine, "Search stack exhausted\n");
+ machine.debugger().console().printf("Search stack exhausted\n");
break;
}
@@ -1103,7 +1105,7 @@ static void execute_fdsearch(running_machine &machine, int ref, int params, cons
length = -length;
if (length == 0)
{
- debug_console_printf(machine, "Invalid opcode; unable to advance\n");
+ machine.debugger().console().printf("Invalid opcode; unable to advance\n");
break;
}
@@ -1172,7 +1174,7 @@ static void execute_fdsearch(running_machine &machine, int ref, int params, cons
static void execute_fddasm(running_machine &machine, int ref, int params, const char **param)
{
- address_space &space = debug_cpu_get_visible_cpu(machine)->memory().space(AS_PROGRAM);
+ address_space &space = machine->debugger().cpu().get_visible_cpu()->memory().space(AS_PROGRAM);
int origstate = fd1094_set_state(keyregion, -1);
const char *filename;
int skipped = FALSE;
@@ -1186,7 +1188,7 @@ static void execute_fddasm(running_machine &machine, int ref, int params, const
osd_file::error filerr = file.open(filename);
if (filerr != osd_file::error::NONE)
{
- debug_console_printf(machine, "Unable to create file '%s'\n", filename);
+ machine.debugger().console().printf("Unable to create file '%s'\n", filename);
return;
}
@@ -1292,24 +1294,24 @@ static void execute_fdcset(running_machine &machine, int ref, int params, const
int cnum;
/* extract the parameters */
- if (!debug_command_parameter_number(machine, param[0], &pc))
+ if (!machine.debugger().commands().validate_number_parameter(param[0], &pc))
return;
- if (!debug_command_parameter_number(machine, param[1], &value))
+ if (!machine.debugger().commands().validate_number_parameter(param[1], &value))
return;
- if (params >= 3 && !debug_command_parameter_number(machine, param[2], &mask))
+ if (params >= 3 && !machine.debugger().commands().validate_number_parameter(param[2], &mask))
return;
if (params >= 4)
{
if (strcmp(param[3], "irq") == 0)
state = FD1094_STATE_IRQ;
- else if (!debug_command_parameter_number(machine, param[3], &state))
+ else if (!machine.debugger().commands().validate_number_parameter(param[3], &state))
return;
}
/* validate parameters */
if ((pc & 1) != 0 || pc > 0xffffff)
{
- debug_console_printf(machine, "Invalid PC specified (%08X)\n", (UINT32)pc);
+ machine.debugger().console().printf("Invalid PC specified (%08X)\n", (UINT32)pc);
return;
}
@@ -1334,7 +1336,7 @@ static void execute_fdcset(running_machine &machine, int ref, int params, const
set_constraint(&constraints[cnum], pc, state, value, mask);
/* explain what we did */
- debug_console_printf(machine, "Set new constraint at PC=%06X, state=%03X: decrypted & %04X == %04X\n",
+ machine.debugger().console().printf("Set new constraint at PC=%06X, state=%03X: decrypted & %04X == %04X\n",
(int)pc, (int)state, (int)mask, (int)value);
}
@@ -1352,7 +1354,7 @@ static void execute_fdclist(running_machine &machine, int ref, int params, const
for (cnum = 0; cnum < constcount; cnum++)
{
fd1094_constraint *constraint = &constraints[cnum];
- debug_console_printf(machine, " PC=%06X, state=%03X: decrypted & %04X == %04X\n",
+ machine.debugger().console().printf(" PC=%06X, state=%03X: decrypted & %04X == %04X\n",
constraint->pc, constraint->state, constraint->mask, constraint->value);
}
}
@@ -1365,7 +1367,7 @@ static void execute_fdclist(running_machine &machine, int ref, int params, const
static void execute_fdcsearch(running_machine &machine, int ref, int params, const char **param)
{
-// debug_console_printf(machine, "Searching for possible global keys....\n");
+// machine.debugger().console().printf("Searching for possible global keys....\n");
perform_constrained_search(machine);
}
@@ -1565,7 +1567,7 @@ static void tag_possibility(running_machine &machine, fd1094_possibility *possda
nomatter++;
}
- debug_console_printf(machine, "PC=%06X: locked %d, guessed %d, nochange %d\n", possdata->basepc, locked, guessed, nomatter);
+ machine.debugger().console().printf("PC=%06X: locked %d, guessed %d, nochange %d\n", possdata->basepc, locked, guessed, nomatter);
}
@@ -1598,7 +1600,7 @@ static void perform_constrained_search(running_machine &machine)
global = find_global_key_matches(global + 1, output);
if (global == 0)
break;
-// debug_console_printf(machine, "Checking global key %08X (PC=%06X)....\n", global, (output[2] << 16) | output[3]);
+// machine.debugger().console().printf("Checking global key %08X (PC=%06X)....\n", global, (output[2] << 16) | output[3]);
/* use the IRQ handler to find more possibilities */
numseeds = find_constraint_sequence(global, FALSE);
@@ -1606,7 +1608,7 @@ static void perform_constrained_search(running_machine &machine)
{
int i;
for (i = 0; i < numseeds; i++)
- debug_console_printf(machine, " Possible: global=%08X seed=%06X pc=%04X\n", global, possible_seed[i], output[3]);
+ machine.debugger().console().printf(" Possible: global=%08X seed=%06X pc=%04X\n", global, possible_seed[i], output[3]);
}
}
}
@@ -1779,7 +1781,7 @@ static int find_constraint_sequence(UINT32 global, int quick)
{
UINT32 seedlow;
-// debug_console_printf(machine, "Global %08X ... Looking for keys that generate a keyvalue of %02X at %04X\n",
+// machine.debugger().console().printf("Global %08X ... Looking for keys that generate a keyvalue of %02X at %04X\n",
// global, keyvalue, keyaddr);
/* iterate over seed possibilities */
diff --git a/src/mame/machine/fddebug.h b/src/mame/machine/fddebug.h
index 12ff2efabbd..498d4e2ec68 100644
--- a/src/mame/machine/fddebug.h
+++ b/src/mame/machine/fddebug.h
@@ -1,4 +1,5 @@
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
+
void fd1094_regenerate_key(running_machine &machine);
void fd1094_init_debugging(running_machine &machine, const char *cpureg, const char *keyreg, const char *statreg, void (*changed)(running_machine &));
diff --git a/src/mame/machine/mbc55x.cpp b/src/mame/machine/mbc55x.cpp
index 948f40e79bf..a9bb0f557c8 100644
--- a/src/mame/machine/mbc55x.cpp
+++ b/src/mame/machine/mbc55x.cpp
@@ -9,7 +9,10 @@
2011-01-29.
*****************************************************************************/
+#include <functional>
+
#include "includes/mbc55x.h"
+#include "debug/debugcpu.h"
/*-------------------------------------------------------------------------*/
@@ -30,7 +33,6 @@
static void decode_dos21(device_t *device,offs_t pc);
//static void mbc55x_recalculate_ints(running_machine &machine);
-static void mbc55x_debug(running_machine &machine, int ref, int params, const char *param[]);
static int instruction_hook(device_t &device, offs_t curpc);
//static void fdc_reset(running_machine &machine);
//static void set_disk_int(running_machine &machine, int state);
@@ -334,7 +336,8 @@ void mbc55x_state::machine_start()
/* setup debug commands */
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
{
- debug_console_register_command(machine(), "mbc55x_debug", CMDFLAG_NONE, 0, 0, 1, mbc55x_debug);
+ using namespace std::placeholders;
+ machine().debugger().console().register_command("mbc55x_debug", CMDFLAG_NONE, 0, 0, 1, std::bind(&mbc55x_state::debug_command, this, _1, _2, _3));
/* set up the instruction hook */
m_maincpu->debug()->set_instruction_hook(instruction_hook);
@@ -347,18 +350,18 @@ void mbc55x_state::machine_start()
}
-static void mbc55x_debug(running_machine &machine, int ref, int params, const char *param[])
+void mbc55x_state::debug_command(int ref, int params, const char *param[])
{
- mbc55x_state *state = machine.driver_data<mbc55x_state>();
- if(params>0)
+ if (params > 0)
{
int temp;
- sscanf(param[0],"%d",&temp); state->m_debug_machine = temp;
+ sscanf(param[0], "%d", &temp);
+ m_debug_machine = temp;
}
else
{
- debug_console_printf(machine,"Error usage : mbc55x_debug <debuglevel>\n");
- debug_console_printf(machine,"Current debuglevel=%02X\n",state->m_debug_machine);
+ machine().debugger().console().printf("Error usage : mbc55x_debug <debuglevel>\n");
+ machine().debugger().console().printf("Current debuglevel=%02X\n", m_debug_machine);
}
}
@@ -410,5 +413,7 @@ static void decode_dos21(device_t *device,offs_t pc)
device->logerror("=======================================================================\n");
if((ax & 0xff00)==0x0900)
- debugger_break(device->machine());
+ {
+ device->machine().debugger().debug_break();
+ }
}
diff --git a/src/mame/machine/midwayic.cpp b/src/mame/machine/midwayic.cpp
index 6761ab89289..5870482fabd 100644
--- a/src/mame/machine/midwayic.cpp
+++ b/src/mame/machine/midwayic.cpp
@@ -377,7 +377,7 @@ WRITE8_MEMBER(midway_serial_pic2_device::write)
memcpy(m_buffer, m_data, 16);
m_total = 16;
m_index = 0;
- debugger_break(machine());
+ machine().debugger().debug_break();
}
break;
diff --git a/src/mame/machine/rmnimbus.cpp b/src/mame/machine/rmnimbus.cpp
index de3661761ac..f91cf819e95 100644
--- a/src/mame/machine/rmnimbus.cpp
+++ b/src/mame/machine/rmnimbus.cpp
@@ -59,8 +59,11 @@ chdman createhd -o ST125N.chd -chs 41921,1,1 -ss 512
*/
+#include <functional>
+
#include "debugger.h"
#include "debug/debugcon.h"
+#include "debug/debugcpu.h"
#include "imagedev/flopdrv.h"
#include "includes/rmnimbus.h"
@@ -172,8 +175,6 @@ struct t_nimbus_brush
};
-static void nimbus_debug(running_machine &machine, int ref, int params, const char *param[]);
-
static int instruction_hook(device_t &device, offs_t curpc);
static void decode_subbios(device_t *device,offs_t pc, UINT8 raw_flag);
static void decode_dos21(device_t *device,offs_t pc);
@@ -229,7 +230,8 @@ void rmnimbus_state::machine_start()
/* setup debug commands */
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
{
- debug_console_register_command(machine(), "nimbus_debug", CMDFLAG_NONE, 0, 0, 1, nimbus_debug);
+ using namespace std::placeholders;
+ machine().debugger().console().register_command("nimbus_debug", CMDFLAG_NONE, 0, 0, 1, std::bind(&rmnimbus_state::debug_command, this, _1, _2, _3));
/* set up the instruction hook */
m_maincpu->debug()->set_instruction_hook(instruction_hook);
@@ -239,18 +241,18 @@ void rmnimbus_state::machine_start()
m_fdc->dden_w(0);
}
-static void nimbus_debug(running_machine &machine, int ref, int params, const char *param[])
+void rmnimbus_state::debug_command(int ref, int params, const char *param[])
{
- rmnimbus_state *state = machine.driver_data<rmnimbus_state>();
- if(params>0)
+ if (params > 0)
{
int temp;
- sscanf(param[0],"%d",&temp); state->m_debug_machine = temp;
+ sscanf(param[0],"%d",&temp);
+ m_debug_machine = temp;
}
else
{
- debug_console_printf(machine,"Error usage : nimbus_debug <debuglevel>\n");
- debug_console_printf(machine,"Current debuglevel=%02X\n",state->m_debug_machine);
+ machine().debugger().console().printf("Error usage : nimbus_debug <debuglevel>\n");
+ machine().debugger().console().printf("Current debuglevel=%02X\n", m_debug_machine);
}
}
diff --git a/src/mame/machine/tx1.cpp b/src/mame/machine/tx1.cpp
index 76658ae9231..0237f2d6fc0 100644
--- a/src/mame/machine/tx1.cpp
+++ b/src/mame/machine/tx1.cpp
@@ -1241,13 +1241,13 @@ WRITE16_MEMBER(tx1_state::buggyboy_math_w)
else
{
osd_printf_debug("BB_DSEL was not 3 for P->S load!\n");
- debugger_break(machine());
+ machine().debugger().debug_break();
}
}
else
{
osd_printf_debug("Buggy Boy unknown math state!\n");
- debugger_break(machine());
+ machine().debugger().debug_break();
}
if (offset & BB_INSLD)
diff --git a/src/mame/machine/xbox.cpp b/src/mame/machine/xbox.cpp
index 99993ec79c5..7479aec05a2 100644
--- a/src/mame/machine/xbox.cpp
+++ b/src/mame/machine/xbox.cpp
@@ -1,6 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:Samuele Zannoli
+#include <functional>
+
#include "emu.h"
#include "cpu/i386/i386.h"
#include "machine/lpci.h"
@@ -9,6 +11,7 @@
#include "machine/idectrl.h"
#include "video/poly.h"
#include "bitmap.h"
+#include "debugger.h"
#include "debug/debugcon.h"
#include "debug/debugcmd.h"
#include "debug/debugcpu.h"
@@ -20,109 +23,113 @@
//#define LOG_OHCI
#define USB_HACK_ENABLED
-static void dump_string_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::dump_string_command(int ref, int params, const char **param)
{
- xbox_base_state *state = machine.driver_data<xbox_base_state>();
- address_space &space = state->m_maincpu->space();
- UINT64 addr;
- offs_t address;
- UINT32 length, maximumlength;
- offs_t buffer;
+ address_space &space = m_maincpu->space();
if (params < 1)
return;
- if (!debug_command_parameter_number(machine, param[0], &addr))
+
+ UINT64 addr;
+ if (!machine().debugger().commands().validate_number_parameter(param[0], &addr))
return;
- address = (offs_t)addr;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+
+ offs_t address = (offs_t)addr;
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address))
{
- debug_console_printf(machine, "Address is unmapped.\n");
+ machine().debugger().console().printf("Address is unmapped.\n");
return;
}
- length = space.read_word_unaligned(address);
- maximumlength = space.read_word_unaligned(address + 2);
- buffer = space.read_dword_unaligned(address + 4);
- debug_console_printf(machine, "Length %d word\n", length);
- debug_console_printf(machine, "MaximumLength %d word\n", maximumlength);
- debug_console_printf(machine, "Buffer %08X byte* ", buffer);
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &buffer))
+
+ UINT32 length = space.read_word_unaligned(address);
+ UINT32 maximumlength = space.read_word_unaligned(address + 2);
+ offs_t buffer = space.read_dword_unaligned(address + 4);
+ machine().debugger().console().printf("Length %d word\n", length);
+ machine().debugger().console().printf("MaximumLength %d word\n", maximumlength);
+ machine().debugger().console().printf("Buffer %08X byte* ", buffer);
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &buffer))
{
- debug_console_printf(machine, "\nBuffer is unmapped.\n");
+ machine().debugger().console().printf("\nBuffer is unmapped.\n");
return;
}
+
if (length > 256)
length = 256;
+
for (int a = 0; a < length; a++)
{
UINT8 c = space.read_byte(buffer + a);
- debug_console_printf(machine, "%c", c);
+ machine().debugger().console().printf("%c", c);
}
- debug_console_printf(machine, "\n");
+ machine().debugger().console().printf("\n");
}
-static void dump_process_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::dump_process_command(int ref, int params, const char **param)
{
- xbox_base_state *state = machine.driver_data<xbox_base_state>();
- address_space &space = state->m_maincpu->space();
- UINT64 addr;
- offs_t address;
+ address_space &space = m_maincpu->space();
if (params < 1)
return;
- if (!debug_command_parameter_number(machine, param[0], &addr))
+
+ UINT64 addr;
+ if (!machine().debugger().commands().validate_number_parameter(param[0], &addr))
return;
- address = (offs_t)addr;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+
+ offs_t address = (offs_t)addr;
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address))
{
- debug_console_printf(machine, "Address is unmapped.\n");
+ machine().debugger().console().printf("Address is unmapped.\n");
return;
}
- debug_console_printf(machine, "ReadyListHead {%08X,%08X} _LIST_ENTRY\n", space.read_dword_unaligned(address), space.read_dword_unaligned(address + 4));
- debug_console_printf(machine, "ThreadListHead {%08X,%08X} _LIST_ENTRY\n", space.read_dword_unaligned(address + 8), space.read_dword_unaligned(address + 12));
- debug_console_printf(machine, "StackCount %d dword\n", space.read_dword_unaligned(address + 16));
- debug_console_printf(machine, "ThreadQuantum %d dword\n", space.read_dword_unaligned(address + 20));
- debug_console_printf(machine, "BasePriority %d byte\n", space.read_byte(address + 24));
- debug_console_printf(machine, "DisableBoost %d byte\n", space.read_byte(address + 25));
- debug_console_printf(machine, "DisableQuantum %d byte\n", space.read_byte(address + 26));
- debug_console_printf(machine, "_padding %d byte\n", space.read_byte(address + 27));
+ machine().debugger().console().printf("ReadyListHead {%08X,%08X} _LIST_ENTRY\n", space.read_dword_unaligned(address), space.read_dword_unaligned(address + 4));
+ machine().debugger().console().printf("ThreadListHead {%08X,%08X} _LIST_ENTRY\n", space.read_dword_unaligned(address + 8), space.read_dword_unaligned(address + 12));
+ machine().debugger().console().printf("StackCount %d dword\n", space.read_dword_unaligned(address + 16));
+ machine().debugger().console().printf("ThreadQuantum %d dword\n", space.read_dword_unaligned(address + 20));
+ machine().debugger().console().printf("BasePriority %d byte\n", space.read_byte(address + 24));
+ machine().debugger().console().printf("DisableBoost %d byte\n", space.read_byte(address + 25));
+ machine().debugger().console().printf("DisableQuantum %d byte\n", space.read_byte(address + 26));
+ machine().debugger().console().printf("_padding %d byte\n", space.read_byte(address + 27));
}
-static void dump_list_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::dump_list_command(int ref, int params, const char **param)
{
- xbox_base_state *state = machine.driver_data<xbox_base_state>();
- address_space &space = state->m_maincpu->space();
- UINT64 addr, offs, start, old;
- offs_t address, offset;
+ address_space &space = m_maincpu->space();
if (params < 1)
return;
- if (!debug_command_parameter_number(machine, param[0], &addr))
+
+ UINT64 addr;
+ if (!machine().debugger().commands().validate_number_parameter(param[0], &addr))
return;
- offs = 0;
- offset = 0;
+
+ UINT64 offs = 0;
+ offs_t offset = 0;
if (params >= 2)
{
- if (!debug_command_parameter_number(machine, param[1], &offs))
+ if (!machine().debugger().commands().validate_number_parameter(param[1], &offs))
return;
offset = (offs_t)offs;
}
- start = addr;
- address = (offs_t)addr;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+
+ UINT64 start = addr;
+ offs_t address = (offs_t)addr;
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address))
{
- debug_console_printf(machine, "Address is unmapped.\n");
+ machine().debugger().console().printf("Address is unmapped.\n");
return;
}
if (params >= 2)
- debug_console_printf(machine, "Entry Object\n");
+ machine().debugger().console().printf("Entry Object\n");
else
- debug_console_printf(machine, "Entry\n");
+ machine().debugger().console().printf("Entry\n");
+
+ UINT64 old;
for (int num = 0; num < 32; num++)
{
if (params >= 2)
- debug_console_printf(machine, "%08X %08X\n", (UINT32)addr, (offs_t)addr - offset);
+ machine().debugger().console().printf("%08X %08X\n", (UINT32)addr, (offs_t)addr - offset);
else
- debug_console_printf(machine, "%08X\n", (UINT32)addr);
+ machine().debugger().console().printf("%08X\n", (UINT32)addr);
old = addr;
addr = space.read_dword_unaligned(address);
if (addr == start)
@@ -130,159 +137,151 @@ static void dump_list_command(running_machine &machine, int ref, int params, con
if (addr == old)
break;
address = (offs_t)addr;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address))
break;
}
}
-static void dump_dpc_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::dump_dpc_command(int ref, int params, const char **param)
{
- xbox_base_state *state = machine.driver_data<xbox_base_state>();
- address_space &space = state->m_maincpu->space();
- UINT64 addr;
- offs_t address;
+ address_space &space = m_maincpu->space();
if (params < 1)
return;
- if (!debug_command_parameter_number(machine, param[0], &addr))
+
+ UINT64 addr;
+ if (!machine().debugger().commands().validate_number_parameter(param[0], &addr))
return;
- address = (offs_t)addr;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+
+ offs_t address = (offs_t)addr;
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address))
{
- debug_console_printf(machine, "Address is unmapped.\n");
+ machine().debugger().console().printf("Address is unmapped.\n");
return;
}
- debug_console_printf(machine, "Type %d word\n", space.read_word_unaligned(address));
- debug_console_printf(machine, "Inserted %d byte\n", space.read_byte(address + 2));
- debug_console_printf(machine, "Padding %d byte\n", space.read_byte(address + 3));
- debug_console_printf(machine, "DpcListEntry {%08X,%08X} _LIST_ENTRY\n", space.read_dword_unaligned(address + 4), space.read_dword_unaligned(address + 8));
- debug_console_printf(machine, "DeferredRoutine %08X dword\n", space.read_dword_unaligned(address + 12));
- debug_console_printf(machine, "DeferredContext %08X dword\n", space.read_dword_unaligned(address + 16));
- debug_console_printf(machine, "SystemArgument1 %08X dword\n", space.read_dword_unaligned(address + 20));
- debug_console_printf(machine, "SystemArgument2 %08X dword\n", space.read_dword_unaligned(address + 24));
+ machine().debugger().console().printf("Type %d word\n", space.read_word_unaligned(address));
+ machine().debugger().console().printf("Inserted %d byte\n", space.read_byte(address + 2));
+ machine().debugger().console().printf("Padding %d byte\n", space.read_byte(address + 3));
+ machine().debugger().console().printf("DpcListEntry {%08X,%08X} _LIST_ENTRY\n", space.read_dword_unaligned(address + 4), space.read_dword_unaligned(address + 8));
+ machine().debugger().console().printf("DeferredRoutine %08X dword\n", space.read_dword_unaligned(address + 12));
+ machine().debugger().console().printf("DeferredContext %08X dword\n", space.read_dword_unaligned(address + 16));
+ machine().debugger().console().printf("SystemArgument1 %08X dword\n", space.read_dword_unaligned(address + 20));
+ machine().debugger().console().printf("SystemArgument2 %08X dword\n", space.read_dword_unaligned(address + 24));
}
-static void dump_timer_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::dump_timer_command(int ref, int params, const char **param)
{
- xbox_base_state *state = machine.driver_data<xbox_base_state>();
- address_space &space = state->m_maincpu->space();
- UINT64 addr;
- offs_t address;
+ address_space &space = m_maincpu->space();
if (params < 1)
return;
- if (!debug_command_parameter_number(machine, param[0], &addr))
+
+ UINT64 addr;
+ if (!machine().debugger().commands().validate_number_parameter(param[0], &addr))
return;
- address = (offs_t)addr;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+
+ offs_t address = (offs_t)addr;
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address))
{
- debug_console_printf(machine, "Address is unmapped.\n");
+ machine().debugger().console().printf("Address is unmapped.\n");
return;
}
- debug_console_printf(machine, "Header.Type %d byte\n", space.read_byte(address));
- debug_console_printf(machine, "Header.Absolute %d byte\n", space.read_byte(address + 1));
- debug_console_printf(machine, "Header.Size %d byte\n", space.read_byte(address + 2));
- debug_console_printf(machine, "Header.Inserted %d byte\n", space.read_byte(address + 3));
- debug_console_printf(machine, "Header.SignalState %08X dword\n", space.read_dword_unaligned(address + 4));
- debug_console_printf(machine, "Header.WaitListEntry {%08X,%08X} _LIST_ENTRY\n", space.read_dword_unaligned(address + 8), space.read_dword_unaligned(address + 12));
- debug_console_printf(machine, "%s", string_format("DueTime %I64x qword\n", (INT64)space.read_qword_unaligned(address + 16)).c_str());
- debug_console_printf(machine, "TimerListEntry {%08X,%08X} _LIST_ENTRY\n", space.read_dword_unaligned(address + 24), space.read_dword_unaligned(address + 28));
- debug_console_printf(machine, "Dpc %08X dword\n", space.read_dword_unaligned(address + 32));
- debug_console_printf(machine, "Period %d dword\n", space.read_dword_unaligned(address + 36));
+ machine().debugger().console().printf("Header.Type %d byte\n", space.read_byte(address));
+ machine().debugger().console().printf("Header.Absolute %d byte\n", space.read_byte(address + 1));
+ machine().debugger().console().printf("Header.Size %d byte\n", space.read_byte(address + 2));
+ machine().debugger().console().printf("Header.Inserted %d byte\n", space.read_byte(address + 3));
+ machine().debugger().console().printf("Header.SignalState %08X dword\n", space.read_dword_unaligned(address + 4));
+ machine().debugger().console().printf("Header.WaitListEntry {%08X,%08X} _LIST_ENTRY\n", space.read_dword_unaligned(address + 8), space.read_dword_unaligned(address + 12));
+ machine().debugger().console().printf("%s", string_format("DueTime %I64x qword\n", (INT64)space.read_qword_unaligned(address + 16)).c_str());
+ machine().debugger().console().printf("TimerListEntry {%08X,%08X} _LIST_ENTRY\n", space.read_dword_unaligned(address + 24), space.read_dword_unaligned(address + 28));
+ machine().debugger().console().printf("Dpc %08X dword\n", space.read_dword_unaligned(address + 32));
+ machine().debugger().console().printf("Period %d dword\n", space.read_dword_unaligned(address + 36));
}
-static void curthread_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::curthread_command(int ref, int params, const char **param)
{
- xbox_base_state *state = machine.driver_data<xbox_base_state>();
- address_space &space = state->m_maincpu->space();
- UINT64 fsbase;
- UINT32 kthrd, topstack, tlsdata;
- offs_t address;
+ address_space &space = m_maincpu->space();
- fsbase = state->m_maincpu->state_int(44);
- address = (offs_t)fsbase + 0x28;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+ UINT64 fsbase = m_maincpu->state_int(44);
+ offs_t address = (offs_t)fsbase + 0x28;
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address))
{
- debug_console_printf(machine, "Address is unmapped.\n");
+ machine().debugger().console().printf("Address is unmapped.\n");
return;
}
- kthrd = space.read_dword_unaligned(address);
- debug_console_printf(machine, "Current thread is %08X\n", kthrd);
+
+ UINT32 kthrd = space.read_dword_unaligned(address);
+ machine().debugger().console().printf("Current thread is %08X\n", kthrd);
+
address = (offs_t)kthrd + 0x1c;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address))
return;
- topstack = space.read_dword_unaligned(address);
- debug_console_printf(machine, "Current thread stack top is %08X\n", topstack);
+
+ UINT32 topstack = space.read_dword_unaligned(address);
+ machine().debugger().console().printf("Current thread stack top is %08X\n", topstack);
+
address = (offs_t)kthrd + 0x28;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address))
return;
- tlsdata = space.read_dword_unaligned(address);
+
+ UINT32 tlsdata = space.read_dword_unaligned(address);
if (tlsdata == 0)
address = (offs_t)topstack - 0x210 - 8;
else
address = (offs_t)tlsdata - 8;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &address))
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &address))
return;
- debug_console_printf(machine, "Current thread function is %08X\n", space.read_dword_unaligned(address));
+ machine().debugger().console().printf("Current thread function is %08X\n", space.read_dword_unaligned(address));
}
-static void generate_irq_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::generate_irq_command(int ref, int params, const char **param)
{
UINT64 irq;
- xbox_base_state *chst = machine.driver_data<xbox_base_state>();
if (params < 1)
return;
- if (!debug_command_parameter_number(machine, param[0], &irq))
+ if (!machine().debugger().commands().validate_number_parameter(param[0], &irq))
return;
if (irq > 15)
return;
if (irq == 2)
return;
- chst->debug_generate_irq((int)irq, true);
+ debug_generate_irq((int)irq, true);
}
-static void nv2a_combiners_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::nv2a_combiners_command(int ref, int params, const char **param)
{
- int en;
-
- xbox_base_state *chst = machine.driver_data<xbox_base_state>();
- en = chst->nvidia_nv2a->toggle_register_combiners_usage();
+ int en = nvidia_nv2a->toggle_register_combiners_usage();
if (en != 0)
- debug_console_printf(machine, "Register combiners enabled\n");
+ machine().debugger().console().printf("Register combiners enabled\n");
else
- debug_console_printf(machine, "Register combiners disabled\n");
+ machine().debugger().console().printf("Register combiners disabled\n");
}
-static void waitvblank_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::waitvblank_command(int ref, int params, const char **param)
{
- int en;
-
- xbox_base_state *chst = machine.driver_data<xbox_base_state>();
- en = chst->nvidia_nv2a->toggle_wait_vblank_support();
+ int en = nvidia_nv2a->toggle_wait_vblank_support();
if (en != 0)
- debug_console_printf(machine, "Vblank method enabled\n");
+ machine().debugger().console().printf("Vblank method enabled\n");
else
- debug_console_printf(machine, "Vblank method disabled\n");
+ machine().debugger().console().printf("Vblank method disabled\n");
}
-static void grab_texture_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::grab_texture_command(int ref, int params, const char **param)
{
UINT64 type;
- xbox_base_state *chst = machine.driver_data<xbox_base_state>();
if (params < 2)
return;
- if (!debug_command_parameter_number(machine, param[0], &type))
+ if (!machine().debugger().commands().validate_number_parameter(param[0], &type))
return;
if ((param[1][0] == 0) || (strlen(param[1]) > 127))
return;
- chst->nvidia_nv2a->debug_grab_texture((int)type, param[1]);
+ nvidia_nv2a->debug_grab_texture((int)type, param[1]);
}
-static void grab_vprog_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::grab_vprog_command(int ref, int params, const char **param)
{
- xbox_base_state *chst = machine.driver_data<xbox_base_state>();
UINT32 instruction[4];
FILE *fil;
@@ -293,36 +292,40 @@ static void grab_vprog_command(running_machine &machine, int ref, int params, co
if ((fil = fopen(param[0], "wb")) == nullptr)
return;
for (int n = 0; n < 136; n++) {
- chst->nvidia_nv2a->debug_grab_vertex_program_slot(n, instruction);
+ nvidia_nv2a->debug_grab_vertex_program_slot(n, instruction);
fwrite(instruction, sizeof(UINT32), 4, fil);
}
fclose(fil);
}
-static void vprogdis_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::vprogdis_command(int ref, int params, const char **param)
{
- UINT64 address, length, type;
- UINT32 instruction[4];
- offs_t addr;
- vertex_program_disassembler vd;
- char line[64];
- xbox_base_state *chst = machine.driver_data<xbox_base_state>();
- address_space &space = chst->m_maincpu->space();
+ address_space &space = m_maincpu->space();
if (params < 2)
return;
- if (!debug_command_parameter_number(machine, param[0], &address))
+
+ UINT64 address;
+ if (!machine().debugger().commands().validate_number_parameter(param[0], &address))
return;
- if (!debug_command_parameter_number(machine, param[1], &length))
+
+ UINT64 length;
+ if (!machine().debugger().commands().validate_number_parameter(param[1], &length))
return;
- type = 0;
+
+ UINT64 type = 0;
if (params > 2)
- if (!debug_command_parameter_number(machine, param[2], &type))
+ if (!machine().debugger().commands().validate_number_parameter(param[2], &type))
return;
- while (length > 0) {
- if (type == 1) {
- addr = (offs_t)address;
- if (!debug_cpu_translate(space, TRANSLATE_READ_DEBUG, &addr))
+
+ vertex_program_disassembler vd;
+ while (length > 0)
+ {
+ UINT32 instruction[4];
+ if (type == 1)
+ {
+ offs_t addr = (offs_t)address;
+ if (!machine().debugger().cpu().translate(space, TRANSLATE_READ_DEBUG, &addr))
return;
instruction[0] = space.read_dword_unaligned(address);
instruction[1] = space.read_dword_unaligned(address + 4);
@@ -330,65 +333,71 @@ static void vprogdis_command(running_machine &machine, int ref, int params, cons
instruction[3] = space.read_dword_unaligned(address + 12);
}
else
- chst->nvidia_nv2a->debug_grab_vertex_program_slot((int)address, instruction);
+ {
+ nvidia_nv2a->debug_grab_vertex_program_slot((int)address, instruction);
+ }
+
+ char line[64];
while (vd.disassemble(instruction, line) != 0)
- debug_console_printf(machine, "%s\n", line);
+ machine().debugger().console().printf("%s\n", line);
+
if (type == 1)
address = address + 4 * 4;
else
address++;
+
length--;
}
}
-static void help_command(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::help_command(int ref, int params, const char **param)
{
- debug_console_printf(machine, "Available Xbox commands:\n");
- debug_console_printf(machine, " xbox dump_string,<address> -- Dump _STRING object at <address>\n");
- debug_console_printf(machine, " xbox dump_process,<address> -- Dump _PROCESS object at <address>\n");
- debug_console_printf(machine, " xbox dump_list,<address>[,<offset>] -- Dump _LIST_ENTRY chain starting at <address>\n");
- debug_console_printf(machine, " xbox dump_dpc,<address> -- Dump _KDPC object at <address>\n");
- debug_console_printf(machine, " xbox dump_timer,<address> -- Dump _KTIMER object at <address>\n");
- debug_console_printf(machine, " xbox curthread -- Print information about current thread\n");
- debug_console_printf(machine, " xbox irq,<number> -- Generate interrupt with irq number 0-15\n");
- debug_console_printf(machine, " xbox nv2a_combiners -- Toggle use of register combiners\n");
- debug_console_printf(machine, " xbox waitvblank -- Toggle support for wait vblank method\n");
- debug_console_printf(machine, " xbox grab_texture,<type>,<filename> -- Save to <filename> the next used texture of type <type>\n");
- debug_console_printf(machine, " xbox grab_vprog,<filename> -- save current vertex program instruction slots to <filename>\n");
- debug_console_printf(machine, " xbox vprogdis,<address>,<length>[,<type>] -- disassemble <lenght> vertex program instructions at <address> of <type>\n");
- debug_console_printf(machine, " xbox help -- this list\n");
+ machine().debugger().console().printf("Available Xbox commands:\n");
+ machine().debugger().console().printf(" xbox dump_string,<address> -- Dump _STRING object at <address>\n");
+ machine().debugger().console().printf(" xbox dump_process,<address> -- Dump _PROCESS object at <address>\n");
+ machine().debugger().console().printf(" xbox dump_list,<address>[,<offset>] -- Dump _LIST_ENTRY chain starting at <address>\n");
+ machine().debugger().console().printf(" xbox dump_dpc,<address> -- Dump _KDPC object at <address>\n");
+ machine().debugger().console().printf(" xbox dump_timer,<address> -- Dump _KTIMER object at <address>\n");
+ machine().debugger().console().printf(" xbox curthread -- Print information about current thread\n");
+ machine().debugger().console().printf(" xbox irq,<number> -- Generate interrupt with irq number 0-15\n");
+ machine().debugger().console().printf(" xbox nv2a_combiners -- Toggle use of register combiners\n");
+ machine().debugger().console().printf(" xbox waitvblank -- Toggle support for wait vblank method\n");
+ machine().debugger().console().printf(" xbox grab_texture,<type>,<filename> -- Save to <filename> the next used texture of type <type>\n");
+ machine().debugger().console().printf(" xbox grab_vprog,<filename> -- save current vertex program instruction slots to <filename>\n");
+ machine().debugger().console().printf(" xbox vprogdis,<address>,<length>[,<type>] -- disassemble <lenght> vertex program instructions at <address> of <type>\n");
+ machine().debugger().console().printf(" xbox help -- this list\n");
}
-static void xbox_debug_commands(running_machine &machine, int ref, int params, const char **param)
+void xbox_base_state::xbox_debug_commands(int ref, int params, const char **param)
{
if (params < 1)
return;
if (strcmp("dump_string", param[0]) == 0)
- dump_string_command(machine, ref, params - 1, param + 1);
+ dump_string_command(ref, params - 1, param + 1);
else if (strcmp("dump_process", param[0]) == 0)
- dump_process_command(machine, ref, params - 1, param + 1);
+ dump_process_command(ref, params - 1, param + 1);
else if (strcmp("dump_list", param[0]) == 0)
- dump_list_command(machine, ref, params - 1, param + 1);
+ dump_list_command(ref, params - 1, param + 1);
else if (strcmp("dump_dpc", param[0]) == 0)
- dump_dpc_command(machine, ref, params - 1, param + 1);
+ dump_dpc_command(ref, params - 1, param + 1);
else if (strcmp("dump_timer", param[0]) == 0)
- dump_timer_command(machine, ref, params - 1, param + 1);
+ dump_timer_command(ref, params - 1, param + 1);
else if (strcmp("curthread", param[0]) == 0)
- curthread_command(machine, ref, params - 1, param + 1);
+ curthread_command(ref, params - 1, param + 1);
else if (strcmp("irq", param[0]) == 0)
- generate_irq_command(machine, ref, params - 1, param + 1);
+ generate_irq_command(ref, params - 1, param + 1);
else if (strcmp("nv2a_combiners", param[0]) == 0)
- nv2a_combiners_command(machine, ref, params - 1, param + 1);
+ nv2a_combiners_command(ref, params - 1, param + 1);
else if (strcmp("waitvblank", param[0]) == 0)
- waitvblank_command(machine, ref, params - 1, param + 1);
+ waitvblank_command(ref, params - 1, param + 1);
else if (strcmp("grab_texture", param[0]) == 0)
- grab_texture_command(machine, ref, params - 1, param + 1);
+ grab_texture_command(ref, params - 1, param + 1);
else if (strcmp("grab_vprog", param[0]) == 0)
- grab_vprog_command(machine, ref, params - 1, param + 1);
+ grab_vprog_command(ref, params - 1, param + 1);
else if (strcmp("vprogdis", param[0]) == 0)
- vprogdis_command(machine, ref, params - 1, param + 1);
+ vprogdis_command(ref, params - 1, param + 1);
else
- help_command(machine, ref, params - 1, param + 1);
+ help_command(ref, params - 1, param + 1);
}
void xbox_base_state::debug_generate_irq(int irq, bool active)
@@ -2639,7 +2648,10 @@ void xbox_base_state::machine_start()
apust.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(xbox_base_state::audio_apu_timer), this), (void *)"APU Timer");
apust.timer->enable(false);
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
- debug_console_register_command(machine(), "xbox", CMDFLAG_NONE, 0, 1, 4, xbox_debug_commands);
+ {
+ using namespace std::placeholders;
+ machine().debugger().console().register_command("xbox", CMDFLAG_NONE, 0, 1, 4, std::bind(&xbox_base_state::xbox_debug_commands, this, _1, _2, _3));
+ }
// PIC challenge handshake data
pic16lc_buffer[0x1c] = 0x0c;
pic16lc_buffer[0x1d] = 0x0d;
diff --git a/src/mame/video/mbc55x.cpp b/src/mame/video/mbc55x.cpp
index d7fdc80d41c..739bfa3f5ca 100644
--- a/src/mame/video/mbc55x.cpp
+++ b/src/mame/video/mbc55x.cpp
@@ -68,6 +68,8 @@ give the leftmost column of the rectangle, the next four give the next column, a
*************************************************************************************************************/
+#include <functional>
+
#include "includes/mbc55x.h"
#define DEBUG_LINES 1
@@ -75,18 +77,18 @@ give the leftmost column of the rectangle, the next four give the next column, a
#define DEBUG_SET(flags) ((m_debug_video & (flags))==(flags))
-static void video_debug(running_machine &machine, int ref, int params, const char *param[])
+void mbc55x_state::video_debug(int ref, int params, const char *param[])
{
- mbc55x_state *mstate = machine.driver_data<mbc55x_state>();
- if(params>0)
+ if (params > 0)
{
int temp;
- sscanf(param[0],"%d",&temp); mstate->m_debug_video = temp;;
+ sscanf(param[0],"%d",&temp);
+ m_debug_video = temp;
}
else
{
- debug_console_printf(machine,"Error usage : mbc55x_vid_debug <debuglevel>\n");
- debug_console_printf(machine,"Current debuglevel=%02X\n",mstate->m_debug_video);
+ machine().debugger().console().printf("Error usage : mbc55x_vid_debug <debuglevel>\n");
+ machine().debugger().console().printf("Current debuglevel=%02X\n", m_debug_video);
}
}
@@ -168,7 +170,8 @@ void mbc55x_state::video_start()
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
{
- debug_console_register_command(machine(), "mbc55x_vid_debug", CMDFLAG_NONE, 0, 0, 1, video_debug);
+ using namespace std::placeholders;
+ machine().debugger().console().register_command("mbc55x_vid_debug", CMDFLAG_NONE, 0, 0, 1, std::bind(&mbc55x_state::video_debug, this, _1, _2, _3));
}
}
diff --git a/src/mame/video/namcos2.cpp b/src/mame/video/namcos2.cpp
index d45dd94278d..26945737f2e 100644
--- a/src/mame/video/namcos2.cpp
+++ b/src/mame/video/namcos2.cpp
@@ -292,10 +292,10 @@ WRITE16_MEMBER( namcos2_state::rozram_word_w )
{
COMBINE_DATA(&m_rozram[offset]);
m_tilemap_roz->mark_tile_dirty(offset);
-// if( space.machine().input().code_pressed(KEYCODE_Q) )
-// {
-// debugger_break(space.machine());
-// }
+ //if( space.machine().input().code_pressed(KEYCODE_Q) )
+ //{
+ // machine().debugger().debug_break();
+ //}
}
/**************************************************************************/
diff --git a/src/mame/video/powervr2.cpp b/src/mame/video/powervr2.cpp
index 0c31ce84e22..f0d2610945b 100644
--- a/src/mame/video/powervr2.cpp
+++ b/src/mame/video/powervr2.cpp
@@ -1502,13 +1502,13 @@ WRITE32_MEMBER( powervr2_device::ta_yuv_tex_ctrl_w )
/* TODO */
READ32_MEMBER( powervr2_device::ta_yuv_tex_cnt_r )
{
- debugger_break(machine());
+ machine().debugger().debug_break();
return ta_yuv_tex_cnt;
}
WRITE32_MEMBER( powervr2_device::ta_yuv_tex_cnt_w )
{
- debugger_break(machine());
+ machine().debugger().debug_break();
COMBINE_DATA(&ta_yuv_tex_cnt);
}
diff --git a/src/mame/video/rmnimbus.cpp b/src/mame/video/rmnimbus.cpp
index 4ef72cac7c0..654e7f48b96 100644
--- a/src/mame/video/rmnimbus.cpp
+++ b/src/mame/video/rmnimbus.cpp
@@ -23,7 +23,10 @@
code on the real machine.
*/
+#include <functional>
+
#include "emu.h"
+#include "debugger.h"
#include "debug/debugcpu.h"
#include "debug/debugcon.h"
#include "includes/rmnimbus.h"
@@ -45,8 +48,6 @@
#define DEBUG_SET(flags) ((m_debug_video & (flags))==(flags))
-static void video_debug(running_machine &machine, int ref, int params, const char *param[]);
-
READ16_MEMBER(rmnimbus_state::nimbus_video_io_r)
{
UINT16 result = 0;
@@ -470,30 +471,31 @@ void rmnimbus_state::change_palette(UINT8 bank, UINT16 colours)
}
}
-static void video_debug(running_machine &machine, int ref, int params, const char *param[])
+void rmnimbus_state::video_debug(int ref, int params, const char *param[])
{
- rmnimbus_state *state = machine.driver_data<rmnimbus_state>();
- if(params>0)
+ if (params > 0)
{
int temp;
- sscanf(param[0],"%d",&temp); state->m_debug_video = temp;
+ sscanf(param[0],"%d",&temp);
+ m_debug_video = temp;
}
else
{
- debug_console_printf(machine,"Error usage : nimbus_vid_debug <debuglevel>\n");
- debug_console_printf(machine,"Current debuglevel=%02X\n",state->m_debug_video);
+ machine().debugger().console().printf("Error usage : nimbus_vid_debug <debuglevel>\n");
+ machine().debugger().console().printf("Current debuglevel=%02X\n", m_debug_video);
}
}
void rmnimbus_state::video_start()
{
- m_debug_video=0;
+ m_debug_video = 0;
m_screen->register_screen_bitmap(m_video_mem);
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
{
- debug_console_register_command(machine(), "nimbus_vid_debug", CMDFLAG_NONE, 0, 0, 1, video_debug);
+ using namespace std::placeholders;
+ machine().debugger().console().register_command("nimbus_vid_debug", CMDFLAG_NONE, 0, 0, 1, std::bind(&rmnimbus_state::video_debug, this, _1, _2, _3));
}
}
diff --git a/src/osd/modules/debugger/debugimgui.cpp b/src/osd/modules/debugger/debugimgui.cpp
index 25f6938f4fa..504899f560a 100644
--- a/src/osd/modules/debugger/debugimgui.cpp
+++ b/src/osd/modules/debugger/debugimgui.cpp
@@ -316,36 +316,36 @@ void debug_imgui::handle_keys()
else
{
m_machine->schedule_soft_reset();
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
}
}
if(ImGui::IsKeyPressed(ITEM_ID_F5,false))
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
m_running = true;
}
if(ImGui::IsKeyPressed(ITEM_ID_F6,false))
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_next_device();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go_next_device();
m_running = true;
}
if(ImGui::IsKeyPressed(ITEM_ID_F7,false))
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_interrupt();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go_interrupt();
m_running = true;
}
if(ImGui::IsKeyPressed(ITEM_ID_F8,false))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_vblank();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go_vblank();
if(ImGui::IsKeyPressed(ITEM_ID_F9,false))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_out();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step_out();
if(ImGui::IsKeyPressed(ITEM_ID_F10,false))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_over();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step_over();
if(ImGui::IsKeyPressed(ITEM_ID_F11,false))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
if(ImGui::IsKeyPressed(ITEM_ID_F12,false))
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
m_hide = true;
}
@@ -425,11 +425,11 @@ void debug_imgui::handle_console(running_machine* machine)
// if console input is empty, then do a single step
if(strlen(view_main_console->console_input) == 0)
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
view_main_console->exec_cmd = false;
return;
}
- debug_console_execute_command(*m_machine, view_main_console->console_input, 1);
+ m_machine->debugger().console().execute_command(view_main_console->console_input, true);
// check for commands that start execution (so that input fields can be disabled)
if(strcmp(view_main_console->console_input,"g") == 0)
m_running = true;
@@ -501,7 +501,7 @@ void debug_imgui::draw_view(debug_area* view_ptr, bool exp_change)
if(view_ptr->type != DVT_MEMORY) // no scroll bars in memory views
ImGui::SetScrollY(view_ptr->view->visible_position().y * fsize.y);
}
-
+
// update view location, while the cursor is at 0,0.
view_ptr->ofs_x = ImGui::GetCursorScreenPos().x;
view_ptr->ofs_y = ImGui::GetCursorScreenPos().y;
@@ -526,7 +526,7 @@ void debug_imgui::draw_view(debug_area* view_ptr, bool exp_change)
pos.y = ImGui::GetScrollY() / fsize.y;
view_ptr->view->set_visible_position(pos);
}
-
+
viewdata = view_ptr->view->viewdata();
xy1.x = view_ptr->ofs_x;
@@ -866,33 +866,33 @@ void debug_imgui::draw_console()
ImGui::Separator();
if(ImGui::MenuItem("Run", "F5"))
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
m_running = true;
}
if(ImGui::MenuItem("Go to next CPU", "F6"))
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_next_device();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go_next_device();
m_running = true;
}
if(ImGui::MenuItem("Run until next interrupt", "F7"))
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_interrupt();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go_interrupt();
m_running = true;
}
if(ImGui::MenuItem("Run until VBLANK", "F8"))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_vblank();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go_vblank();
if(ImGui::MenuItem("Run and hide debugger", "F12"))
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
m_hide = true;
}
ImGui::Separator();
if(ImGui::MenuItem("Single step", "F11"))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
if(ImGui::MenuItem("Step over", "F10"))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_over();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step_over();
if(ImGui::MenuItem("Step out", "F9"))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_out();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step_out();
ImGui::EndMenu();
}
@@ -1108,7 +1108,7 @@ void debug_imgui::wait_for_debugger(device_t &device, bool firststop)
void debug_imgui::debugger_update()
{
- if ((m_machine != nullptr) && (!debug_cpu_is_stopped(*m_machine)) && (m_machine->phase() == MACHINE_PHASE_RUNNING) && !m_hide)
+ if ((m_machine != nullptr) && (!m_machine->debugger().cpu().is_stopped()) && (m_machine->phase() == MACHINE_PHASE_RUNNING) && !m_hide)
{
UINT32 width = m_machine->render().ui_target().width();
UINT32 height = m_machine->render().ui_target().height();
diff --git a/src/osd/modules/debugger/debugwin.cpp b/src/osd/modules/debugger/debugwin.cpp
index 1f68e6989eb..0fdd86c7e65 100644
--- a/src/osd/modules/debugger/debugwin.cpp
+++ b/src/osd/modules/debugger/debugwin.cpp
@@ -23,6 +23,7 @@
#include "emu.h"
#include "debugger.h"
+#include "debug/debugcpu.h"
#include "window.h"
#include "../input/input_common.h"
@@ -153,14 +154,14 @@ void debugger_windows::wait_for_debugger(device_t &device, bool firststop)
void debugger_windows::debugger_update()
{
// if we're running live, do some checks
- if (!winwindow_has_focus() && m_machine && !debug_cpu_is_stopped(*m_machine) && (m_machine->phase() == MACHINE_PHASE_RUNNING))
+ if (!winwindow_has_focus() && m_machine && !m_machine->debugger().cpu().is_stopped() && (m_machine->phase() == MACHINE_PHASE_RUNNING))
{
// see if the interrupt key is pressed and break if it is
if (seq_pressed())
{
HWND const focuswnd = GetFocus();
- debug_cpu_get_visible_cpu(*m_machine)->debug()->halt_on_next_instruction("User-initiated break\n");
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->halt_on_next_instruction("User-initiated break\n");
// if we were focused on some window's edit box, reset it to default
for (debugwin_info &info : m_window_list)
diff --git a/src/osd/modules/debugger/none.cpp b/src/osd/modules/debugger/none.cpp
index 27157bbee1b..70252a4057c 100644
--- a/src/osd/modules/debugger/none.cpp
+++ b/src/osd/modules/debugger/none.cpp
@@ -10,6 +10,7 @@
#include "modules/osdmodule.h"
#include "debug/debugcpu.h"
+#include "debugger.h"
class debug_none : public osd_module, public debug_module
{
@@ -40,7 +41,7 @@ void debug_none::init_debugger(running_machine &machine)
void debug_none::wait_for_debugger(device_t &device, bool firststop)
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
}
void debug_none::debugger_update()
diff --git a/src/osd/modules/debugger/osx/debugconsole.mm b/src/osd/modules/debugger/osx/debugconsole.mm
index 30ee1e8eab2..35eb2d57c68 100644
--- a/src/osd/modules/debugger/osx/debugconsole.mm
+++ b/src/osd/modules/debugger/osx/debugconsole.mm
@@ -20,6 +20,7 @@
#import "pointsviewer.h"
#import "registersview.h"
+#include "debugger.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
@@ -213,12 +214,12 @@
NSString *command = [sender stringValue];
if ([command length] == 0)
{
- debug_cpu_get_visible_cpu(*machine)->debug()->single_step();
+ machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
[history reset];
}
else
{
- debug_console_execute_command(*machine, [command UTF8String], 1);
+ machine->debugger().console().execute_command([command UTF8String], 1);
[history add:command];
[history edit];
}
@@ -228,7 +229,7 @@
- (IBAction)debugToggleBreakpoint:(id)sender {
device_t &device = *[dasmView source]->device();
- if ([dasmView cursorVisible] && (debug_cpu_get_visible_cpu(*machine) == &device))
+ if ([dasmView cursorVisible] && (machine->debugger().cpu().get_visible_cpu() == &device))
{
offs_t const address = [dasmView selectedAddress];
device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:address
@@ -240,14 +241,14 @@
command = [NSString stringWithFormat:@"bpset 0x%lX", (unsigned long)address];
else
command = [NSString stringWithFormat:@"bpclear 0x%X", (unsigned)bp->index()];
- debug_console_execute_command(*machine, [command UTF8String], 1);
+ machine->debugger().console().execute_command([command UTF8String], 1);
}
}
- (IBAction)debugToggleBreakpointEnable:(id)sender {
device_t &device = *[dasmView source]->device();
- if ([dasmView cursorVisible] && (debug_cpu_get_visible_cpu(*machine) == &device))
+ if ([dasmView cursorVisible] && (machine->debugger().cpu().get_visible_cpu() == &device))
{
device_debug::breakpoint *bp = [[self class] findBreakpointAtAddress:[dasmView selectedAddress]
forDevice:device];
@@ -258,7 +259,7 @@
command = [NSString stringWithFormat:@"bpdisable 0x%X", (unsigned)bp->index()];
else
command = [NSString stringWithFormat:@"bpenable 0x%X", (unsigned)bp->index()];
- debug_console_execute_command(*machine, [command UTF8String], 1);
+ machine->debugger().console().execute_command([command UTF8String], 1);
}
}
}
@@ -266,10 +267,10 @@
- (IBAction)debugRunToCursor:(id)sender {
device_t &device = *[dasmView source]->device();
- if ([dasmView cursorVisible] && (debug_cpu_get_visible_cpu(*machine) == &device))
+ if ([dasmView cursorVisible] && (machine->debugger().cpu().get_visible_cpu() == &device))
{
NSString *command = [NSString stringWithFormat:@"go 0x%lX", (unsigned long)[dasmView selectedAddress]];
- debug_console_execute_command(*machine, [command UTF8String], 1);
+ machine->debugger().console().execute_command([command UTF8String], 1);
}
}
@@ -418,7 +419,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:MAMEHideDebuggerNotification
object:self
userInfo:info];
- debug_cpu_get_visible_cpu(*machine)->debug()->go();
+ machine->debugger().cpu().get_visible_cpu()->debug()->go();
}
}
@@ -481,7 +482,7 @@
SEL const action = [item action];
BOOL const inContextMenu = ([item menu] == [dasmView menu]);
BOOL const haveCursor = [dasmView cursorVisible];
- BOOL const isCurrent = (debug_cpu_get_visible_cpu(*machine) == [dasmView source]->device());
+ BOOL const isCurrent = (machine->debugger().cpu().get_visible_cpu() == [dasmView source]->device());
device_debug::breakpoint *breakpoint = nullptr;
if (haveCursor)
diff --git a/src/osd/modules/debugger/osx/debugview.mm b/src/osd/modules/debugger/osx/debugview.mm
index a32b99794dd..8f0c404cf93 100644
--- a/src/osd/modules/debugger/osx/debugview.mm
+++ b/src/osd/modules/debugger/osx/debugview.mm
@@ -8,6 +8,7 @@
#import "debugview.h"
+#include "debugger.h"
#include "debug/debugcpu.h"
#include "modules/lib/osdobj_common.h"
@@ -810,7 +811,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
- (void)insertNewline:(id)sender {
- debug_cpu_get_visible_cpu(*machine)->debug()->single_step();
+ machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
}
diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.mm b/src/osd/modules/debugger/osx/debugwindowhandler.mm
index 90260914f8e..ceb41e1de79 100644
--- a/src/osd/modules/debugger/osx/debugwindowhandler.mm
+++ b/src/osd/modules/debugger/osx/debugwindowhandler.mm
@@ -12,6 +12,7 @@
#import "debugcommandhistory.h"
#import "debugview.h"
+#include "debugger.h"
//============================================================
// NOTIFICATIONS
@@ -187,12 +188,12 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
- (IBAction)debugBreak:(id)sender {
if (machine->debug_flags & DEBUG_FLAG_ENABLED)
- debug_cpu_get_visible_cpu(*machine)->debug()->halt_on_next_instruction("User-initiated break\n");
+ machine->debugger().cpu().get_visible_cpu()->debug()->halt_on_next_instruction("User-initiated break\n");
}
- (IBAction)debugRun:(id)sender {
- debug_cpu_get_visible_cpu(*machine)->debug()->go();
+ machine->debugger().cpu().get_visible_cpu()->debug()->go();
}
@@ -201,43 +202,43 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
object:self
userInfo:[NSDictionary dictionaryWithObject:[NSValue valueWithPointer:machine]
forKey:@"MAMEDebugMachine"]];
- debug_cpu_get_visible_cpu(*machine)->debug()->go();
+ machine->debugger().cpu().get_visible_cpu()->debug()->go();
}
- (IBAction)debugRunToNextCPU:(id)sender {
- debug_cpu_get_visible_cpu(*machine)->debug()->go_next_device();
+ machine->debugger().cpu().get_visible_cpu()->debug()->go_next_device();
}
- (IBAction)debugRunToNextInterrupt:(id)sender {
- debug_cpu_get_visible_cpu(*machine)->debug()->go_interrupt();
+ machine->debugger().cpu().get_visible_cpu()->debug()->go_interrupt();
}
- (IBAction)debugRunToNextVBLANK:(id)sender {
- debug_cpu_get_visible_cpu(*machine)->debug()->go_vblank();
+ machine->debugger().cpu().get_visible_cpu()->debug()->go_vblank();
}
- (IBAction)debugStepInto:(id)sender {
- debug_cpu_get_visible_cpu(*machine)->debug()->single_step();
+ machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
}
- (IBAction)debugStepOver:(id)sender {
- debug_cpu_get_visible_cpu(*machine)->debug()->single_step_over();
+ machine->debugger().cpu().get_visible_cpu()->debug()->single_step_over();
}
- (IBAction)debugStepOut:(id)sender {
- debug_cpu_get_visible_cpu(*machine)->debug()->single_step_out();
+ machine->debugger().cpu().get_visible_cpu()->debug()->single_step_out();
}
- (IBAction)debugSoftReset:(id)sender {
machine->schedule_soft_reset();
- debug_cpu_get_visible_cpu(*machine)->debug()->go();
+ machine->debugger().cpu().get_visible_cpu()->debug()->go();
}
diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.mm b/src/osd/modules/debugger/osx/disassemblyviewer.mm
index 1254dd8a707..f57d62cfaf4 100644
--- a/src/osd/modules/debugger/osx/disassemblyviewer.mm
+++ b/src/osd/modules/debugger/osx/disassemblyviewer.mm
@@ -105,7 +105,7 @@
[actionButton release];
// set default state
- [dasmView selectSubviewForDevice:debug_cpu_get_visible_cpu(*machine)];
+ [dasmView selectSubviewForDevice:machine->debugger().cpu().get_visible_cpu()];
[dasmView setExpression:@"curpc"];
[expressionField setStringValue:@"curpc"];
[expressionField selectText:self];
@@ -178,13 +178,13 @@
if (bp == nullptr)
{
UINT32 const bpnum = device.debug()->breakpoint_set(address, nullptr, nullptr);
- debug_console_printf(*machine, "Breakpoint %X set\n", bpnum);
+ machine->debugger().console().printf("Breakpoint %X set\n", bpnum);
}
else
{
int const bpnum = bp->index();
device.debug()->breakpoint_clear(bpnum);
- debug_console_printf(*machine, "Breakpoint %X cleared\n", (UINT32)bpnum);
+ machine->debugger().console().printf("Breakpoint %X cleared\n", (UINT32)bpnum);
}
// fail to do this and the display doesn't update
@@ -203,10 +203,9 @@
if (bp != nullptr)
{
device.debug()->breakpoint_enable(bp->index(), !bp->enabled());
- debug_console_printf(*machine,
- "Breakpoint %X %s\n",
- (UINT32)bp->index(),
- bp->enabled() ? "enabled" : "disabled");
+ machine->debugger().console().printf("Breakpoint %X %s\n",
+ (UINT32)bp->index(),
+ bp->enabled() ? "enabled" : "disabled");
machine->debug_view().update_all();
machine->debugger().refresh_display();
}
diff --git a/src/osd/modules/debugger/osx/memoryviewer.mm b/src/osd/modules/debugger/osx/memoryviewer.mm
index dae0c245bfd..9b027e11368 100644
--- a/src/osd/modules/debugger/osx/memoryviewer.mm
+++ b/src/osd/modules/debugger/osx/memoryviewer.mm
@@ -12,6 +12,7 @@
#import "debugview.h"
#import "memoryview.h"
+#include "debugger.h"
#include "debug/debugcpu.h"
#include "debug/dvmemory.h"
@@ -103,7 +104,7 @@
[actionButton release];
// set default state
- [memoryView selectSubviewForDevice:debug_cpu_get_visible_cpu(*machine)];
+ [memoryView selectSubviewForDevice:machine->debugger().cpu().get_visible_cpu()];
[memoryView setExpression:@"0"];
[expressionField setStringValue:@"0"];
[expressionField selectText:self];
diff --git a/src/osd/modules/debugger/osx/registersview.mm b/src/osd/modules/debugger/osx/registersview.mm
index c1e7dc8dce6..0d1e8acd81b 100644
--- a/src/osd/modules/debugger/osx/registersview.mm
+++ b/src/osd/modules/debugger/osx/registersview.mm
@@ -8,6 +8,7 @@
#import "registersview.h"
+#include "debugger.h"
#include "debug/debugcpu.h"
#include "debug/debugvw.h"
@@ -28,7 +29,7 @@
- (NSSize)maximumFrameSize {
debug_view_xy max;
- device_t *curcpu = debug_cpu_get_visible_cpu(*machine);
+ device_t *curcpu = machine->debugger().cpu().get_visible_cpu();
const debug_view_source *source = view->source_for_device(curcpu);
max.x = max.y = 0;
diff --git a/src/osd/modules/debugger/qt/dasmwindow.cpp b/src/osd/modules/debugger/qt/dasmwindow.cpp
index 3cd1dca65ac..7e6b134aef5 100644
--- a/src/osd/modules/debugger/qt/dasmwindow.cpp
+++ b/src/osd/modules/debugger/qt/dasmwindow.cpp
@@ -158,12 +158,12 @@ void DasmWindow::toggleBreakpointAtCursor(bool changedTo)
if (bpindex == -1)
{
bpindex = cpuinfo->breakpoint_set(address, nullptr, nullptr);
- debug_console_printf(*m_machine, "Breakpoint %X set\n", bpindex);
+ m_machine->debugger().console().printf("Breakpoint %X set\n", bpindex);
}
else
{
cpuinfo->breakpoint_clear(bpindex);
- debug_console_printf(*m_machine, "Breakpoint %X cleared\n", bpindex);
+ m_machine->debugger().console().printf("Breakpoint %X cleared\n", bpindex);
}
m_machine->debug_view().update_all();
m_machine->debugger().refresh_display();
@@ -189,7 +189,7 @@ void DasmWindow::enableBreakpointAtCursor(bool changedTo)
if (bp != nullptr)
{
cpuinfo->breakpoint_enable(bp->index(), !bp->enabled());
- debug_console_printf(*m_machine, "Breakpoint %X %s\n", (UINT32)bp->index(), bp->enabled() ? "enabled" : "disabled");
+ m_machine->debugger().console().printf("Breakpoint %X %s\n", (UINT32)bp->index(), bp->enabled() ? "enabled" : "disabled");
m_machine->debug_view().update_all();
m_machine->debugger().refresh_display();
}
diff --git a/src/osd/modules/debugger/qt/mainwindow.cpp b/src/osd/modules/debugger/qt/mainwindow.cpp
index e366ba77247..4020578635d 100644
--- a/src/osd/modules/debugger/qt/mainwindow.cpp
+++ b/src/osd/modules/debugger/qt/mainwindow.cpp
@@ -213,7 +213,7 @@ bool MainWindow::eventFilter(QObject* obj, QEvent* event)
void MainWindow::toggleBreakpointAtCursor(bool changedTo)
{
debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()))
+ if (dasmView->cursor_visible() && (m_machine->debugger().cpu().get_visible_cpu() == dasmView->source()->device()))
{
offs_t const address = downcast<debug_view_disasm *>(dasmView)->selected_address();
device_debug *const cpuinfo = dasmView->source()->device()->debug();
@@ -241,7 +241,7 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
{
command = string_format("bpclear 0x%X", bpindex);
}
- debug_console_execute_command(*m_machine, command.c_str(), 1);
+ m_machine->debugger().console().execute_command(command.c_str(), true);
}
refreshAll();
@@ -251,7 +251,7 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
void MainWindow::enableBreakpointAtCursor(bool changedTo)
{
debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()))
+ if (dasmView->cursor_visible() && (m_machine->debugger().cpu().get_visible_cpu() == dasmView->source()->device()))
{
offs_t const address = dasmView->selected_address();
device_debug *const cpuinfo = dasmView->source()->device()->debug();
@@ -265,7 +265,7 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo)
{
INT32 const bpindex = bp->index();
std::string command = string_format(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex);
- debug_console_execute_command(*m_machine, command.c_str(), 1);
+ m_machine->debugger().console().execute_command(command.c_str(), true);
}
}
@@ -276,11 +276,11 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo)
void MainWindow::runToCursor(bool changedTo)
{
debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()))
+ if (dasmView->cursor_visible() && (m_machine->debugger().cpu().get_visible_cpu() == dasmView->source()->device()))
{
offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address();
std::string command = string_format("go 0x%X", address);
- debug_console_execute_command(*m_machine, command.c_str(), 1);
+ m_machine->debugger().console().execute_command(command.c_str(), true);
}
}
@@ -315,14 +315,12 @@ void MainWindow::executeCommand(bool withClear)
// A blank command is a "silent step"
if (command == "")
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
return;
}
// Send along the command
- debug_console_execute_command(*m_machine,
- command.toLocal8Bit().data(),
- true);
+ m_machine->debugger().console().execute_command(command.toLocal8Bit().data(), true);
// Add history & set the index to be the top of the stack
addToHistory(command);
@@ -348,7 +346,7 @@ void MainWindow::mountImage(bool changedTo)
device_image_interface *img = iter.byindex(imageIndex);
if (img == nullptr)
{
- debug_console_printf(*m_machine, "Something is wrong with the mount menu.\n");
+ m_machine->debugger().console().printf("Something is wrong with the mount menu.\n");
refreshAll();
return;
}
@@ -361,7 +359,7 @@ void MainWindow::mountImage(bool changedTo)
if (img->load(filename.toUtf8().data()) != IMAGE_INIT_PASS)
{
- debug_console_printf(*m_machine, "Image could not be mounted.\n");
+ m_machine->debugger().console().printf("Image could not be mounted.\n");
refreshAll();
return;
}
@@ -377,7 +375,7 @@ void MainWindow::mountImage(bool changedTo)
const QString newTitle = baseString + QString(" : ") + QString(img->filename());
parentMenuItem->setTitle(newTitle);
- debug_console_printf(*m_machine, "Image %s mounted successfully.\n", filename.toUtf8().data());
+ m_machine->debugger().console().printf("Image %s mounted successfully.\n", filename.toUtf8().data());
refreshAll();
}
@@ -401,7 +399,7 @@ void MainWindow::unmountImage(bool changedTo)
const QString newTitle = baseString + QString(" : ") + QString("[empty slot]");
parentMenuItem->setTitle(newTitle);
- debug_console_printf(*m_machine, "Image successfully unmounted.\n");
+ m_machine->debugger().console().printf("Image successfully unmounted.\n");
refreshAll();
}
@@ -409,7 +407,7 @@ void MainWindow::unmountImage(bool changedTo)
void MainWindow::dasmViewUpdated()
{
debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- bool const haveCursor = dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device());
+ bool const haveCursor = dasmView->cursor_visible() && (m_machine->debugger().cpu().get_visible_cpu() == dasmView->source()->device());
bool haveBreakpoint = false;
bool breakpointEnabled = false;
if (haveCursor)
diff --git a/src/osd/modules/debugger/qt/memorywindow.cpp b/src/osd/modules/debugger/qt/memorywindow.cpp
index 9d10dbb5024..8709c8d5aa2 100644
--- a/src/osd/modules/debugger/qt/memorywindow.cpp
+++ b/src/osd/modules/debugger/qt/memorywindow.cpp
@@ -291,7 +291,7 @@ void MemoryWindow::populateComboBox()
void MemoryWindow::setToCurrentCpu()
{
- device_t* curCpu = debug_cpu_get_visible_cpu(*m_machine);
+ device_t* curCpu = m_machine->debugger().cpu().get_visible_cpu();
const debug_view_source *source = m_memTable->view()->source_for_device(curCpu);
const int listIndex = m_memTable->view()->source_list().indexof(*source);
m_memoryComboBox->setCurrentIndex(listIndex);
@@ -346,7 +346,7 @@ void DebuggerMemView::mousePressEvent(QMouseEvent* event)
const debug_view_memory_source* source = downcast<const debug_view_memory_source*>(memView->source());
address_space* addressSpace = source->space();
const int nativeDataWidth = addressSpace->data_width() / 8;
- const UINT64 memValue = debug_read_memory(*addressSpace,
+ const UINT64 memValue = source->device()->machine().debugger().cpu().read_memory(*addressSpace,
addressSpace->address_to_byte(address),
nativeDataWidth,
true);
diff --git a/src/osd/modules/debugger/qt/windowqt.cpp b/src/osd/modules/debugger/qt/windowqt.cpp
index a18fd9885b6..b29633fbf82 100644
--- a/src/osd/modules/debugger/qt/windowqt.cpp
+++ b/src/osd/modules/debugger/qt/windowqt.cpp
@@ -10,6 +10,8 @@
#include "breakpointswindow.h"
#include "deviceswindow.h"
+#include "debug/debugcpu.h"
+
bool WindowQt::s_refreshAll = false;
bool WindowQt::s_hideAll = false;
@@ -176,49 +178,49 @@ void WindowQt::debugActOpenDevices()
void WindowQt::debugActRun()
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
}
void WindowQt::debugActRunAndHide()
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go();
hideAll();
}
void WindowQt::debugActRunToNextCpu()
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_next_device();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go_next_device();
}
void WindowQt::debugActRunNextInt()
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_interrupt();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go_interrupt();
}
void WindowQt::debugActRunNextVBlank()
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_vblank();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->go_vblank();
}
void WindowQt::debugActStepInto()
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
}
void WindowQt::debugActStepOver()
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_over();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step_over();
}
void WindowQt::debugActStepOut()
{
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_out();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step_out();
}
void WindowQt::debugActSoftReset()
{
m_machine->schedule_soft_reset();
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step();
+ m_machine->debugger().cpu().get_visible_cpu()->debug()->single_step();
}
void WindowQt::debugActHardReset()
diff --git a/src/osd/modules/debugger/win/consolewininfo.cpp b/src/osd/modules/debugger/win/consolewininfo.cpp
index 89c3061c688..5e77a28a6e3 100644
--- a/src/osd/modules/debugger/win/consolewininfo.cpp
+++ b/src/osd/modules/debugger/win/consolewininfo.cpp
@@ -11,6 +11,7 @@
#include "debugviewinfo.h"
#include "uimetrics.h"
+#include "debugger.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
#include "imagedev/cassette.h"
@@ -77,7 +78,7 @@ consolewin_info::consolewin_info(debugger_windows_interface &debugger) :
}
// recompute the children
- set_cpu(*debug_cpu_get_visible_cpu(machine()));
+ set_cpu(*machine().debugger().cpu().get_visible_cpu());
// mark the edit box as the default focus and set it
editwin_info::set_default_focus();
@@ -298,9 +299,9 @@ bool consolewin_info::handle_command(WPARAM wparam, LPARAM lparam)
void consolewin_info::process_string(char const *string)
{
if (string[0] == 0) // an empty string is a single step
- debug_cpu_get_visible_cpu(machine())->debug()->single_step();
+ machine().debugger().cpu().get_visible_cpu()->debug()->single_step();
else // otherwise, just process the command
- debug_console_execute_command(machine(), string, 1);
+ machine().debugger().console().execute_command(string, true);
// clear the edit text box
set_editwnd_text("");
diff --git a/src/osd/modules/debugger/win/debugviewinfo.cpp b/src/osd/modules/debugger/win/debugviewinfo.cpp
index 01a300f0733..c2d4bdb85ca 100644
--- a/src/osd/modules/debugger/win/debugviewinfo.cpp
+++ b/src/osd/modules/debugger/win/debugviewinfo.cpp
@@ -206,7 +206,7 @@ bool debugview_info::source_is_visible_cpu() const
if (m_view != nullptr)
{
const debug_view_source *const source = m_view->source();
- return (source != nullptr) && (debug_cpu_get_visible_cpu(machine()) == source->device());
+ return (source != nullptr) && (machine().debugger().cpu().get_visible_cpu() == source->device());
}
return false;
}
@@ -244,7 +244,7 @@ bool debugview_info::set_source_for_device(device_t &device)
bool debugview_info::set_source_for_visible_cpu()
{
- device_t *const curcpu = debug_cpu_get_visible_cpu(machine());
+ device_t *const curcpu = machine().debugger().cpu().get_visible_cpu();
if (curcpu != nullptr)
return set_source_for_device(*curcpu);
else
diff --git a/src/osd/modules/debugger/win/debugwininfo.cpp b/src/osd/modules/debugger/win/debugwininfo.cpp
index d46b5a1d79c..f46c3332bfb 100644
--- a/src/osd/modules/debugger/win/debugwininfo.cpp
+++ b/src/osd/modules/debugger/win/debugwininfo.cpp
@@ -10,6 +10,7 @@
#include "debugviewinfo.h"
+#include "debugger.h"
#include "debug/debugcpu.h"
#include "window.h"
#include "winutf8.h"
@@ -296,31 +297,31 @@ bool debugwin_info::handle_command(WPARAM wparam, LPARAM lparam)
case ID_RUN_AND_HIDE:
debugger().hide_all();
case ID_RUN:
- debug_cpu_get_visible_cpu(machine())->debug()->go();
+ machine().debugger().cpu().get_visible_cpu()->debug()->go();
return true;
case ID_NEXT_CPU:
- debug_cpu_get_visible_cpu(machine())->debug()->go_next_device();
+ machine().debugger().cpu().get_visible_cpu()->debug()->go_next_device();
return true;
case ID_RUN_VBLANK:
- debug_cpu_get_visible_cpu(machine())->debug()->go_vblank();
+ machine().debugger().cpu().get_visible_cpu()->debug()->go_vblank();
return true;
case ID_RUN_IRQ:
- debug_cpu_get_visible_cpu(machine())->debug()->go_interrupt();
+ machine().debugger().cpu().get_visible_cpu()->debug()->go_interrupt();
return true;
case ID_STEP:
- debug_cpu_get_visible_cpu(machine())->debug()->single_step();
+ machine().debugger().cpu().get_visible_cpu()->debug()->single_step();
return true;
case ID_STEP_OVER:
- debug_cpu_get_visible_cpu(machine())->debug()->single_step_over();
+ machine().debugger().cpu().get_visible_cpu()->debug()->single_step_over();
return true;
case ID_STEP_OUT:
- debug_cpu_get_visible_cpu(machine())->debug()->single_step_out();
+ machine().debugger().cpu().get_visible_cpu()->debug()->single_step_out();
return true;
case ID_HARD_RESET:
@@ -329,7 +330,7 @@ bool debugwin_info::handle_command(WPARAM wparam, LPARAM lparam)
case ID_SOFT_RESET:
machine().schedule_soft_reset();
- debug_cpu_get_visible_cpu(machine())->debug()->go();
+ machine().debugger().cpu().get_visible_cpu()->debug()->go();
return true;
case ID_EXIT:
@@ -488,7 +489,7 @@ LRESULT debugwin_info::window_proc(UINT message, WPARAM wparam, LPARAM lparam)
if (m_is_main_console)
{
debugger().hide_all();
- debug_cpu_get_visible_cpu(machine())->debug()->go();
+ machine().debugger().cpu().get_visible_cpu()->debug()->go();
}
else
{
diff --git a/src/osd/modules/debugger/win/disasmbasewininfo.cpp b/src/osd/modules/debugger/win/disasmbasewininfo.cpp
index 597e6b54b75..b8f65aa925d 100644
--- a/src/osd/modules/debugger/win/disasmbasewininfo.cpp
+++ b/src/osd/modules/debugger/win/disasmbasewininfo.cpp
@@ -183,12 +183,12 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam)
if (bpindex == -1)
{
bpindex = debug->breakpoint_set(address, nullptr, nullptr);
- debug_console_printf(machine(), "Breakpoint %X set\n", bpindex);
+ machine().debugger().console().printf("Breakpoint %X set\n", bpindex);
}
else
{
debug->breakpoint_clear(bpindex);
- debug_console_printf(machine(), "Breakpoint %X cleared\n", bpindex);
+ machine().debugger().console().printf("Breakpoint %X cleared\n", bpindex);
}
machine().debug_view().update_all();
machine().debugger().refresh_display();
@@ -200,7 +200,7 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam)
command = string_format("bpset 0x%X", address);
else
command = string_format("bpclear 0x%X", bpindex);
- debug_console_execute_command(machine(), command.c_str(), 1);
+ machine().debugger().console().execute_command(command.c_str(), true);
}
}
return true;
@@ -222,7 +222,7 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam)
if (!is_main_console())
{
debug->breakpoint_enable(bp->index(), !bp->enabled());
- debug_console_printf(machine(), "Breakpoint %X %s\n", (UINT32)bp->index(), bp->enabled() ? "enabled" : "disabled");
+ machine().debugger().console().printf("Breakpoint %X %s\n", (UINT32)bp->index(), bp->enabled() ? "enabled" : "disabled");
machine().debug_view().update_all();
machine().debugger().refresh_display();
}
@@ -230,7 +230,7 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam)
{
std::string command;
command = string_format(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", (UINT32)bp->index());
- debug_console_execute_command(machine(), command.c_str(), 1);
+ machine().debugger().console().execute_command(command.c_str(), true);
}
}
}
@@ -244,7 +244,7 @@ bool disasmbasewin_info::handle_command(WPARAM wparam, LPARAM lparam)
{
std::string command;
command = string_format("go 0x%X", address);
- debug_console_execute_command(machine(), command.c_str(), 1);
+ machine().debugger().console().execute_command(command.c_str(), true);
}
else
{
diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h
index 46a1faa606b..4a320319f44 100644
--- a/src/osd/sdl/osdsdl.h
+++ b/src/osd/sdl/osdsdl.h
@@ -150,6 +150,7 @@ private:
virtual void osd_exit() override;
void extract_video_config();
+ void output_oslog(const char *buffer);
sdl_options &m_options;
};
diff --git a/src/osd/sdl/sdlmain.cpp b/src/osd/sdl/sdlmain.cpp
index df99b1938a7..c518191d1a7 100644
--- a/src/osd/sdl/sdlmain.cpp
+++ b/src/osd/sdl/sdlmain.cpp
@@ -8,6 +8,8 @@
//
//============================================================
+// only for oslog callback
+#include <functional>
#ifdef SDLMAME_UNIX
#if (!defined(SDLMAME_MACOSX)) && (!defined(SDLMAME_EMSCRIPTEN)) && (!defined(SDLMAME_ANDROID))
@@ -224,19 +226,6 @@ int main(int argc, char *argv[])
exit(res);
}
-
-
-//============================================================
-// output_oslog
-//============================================================
-
-static void output_oslog(const running_machine &machine, const char *buffer)
-{
- fputs(buffer, stderr);
-}
-
-
-
//============================================================
// constructor
//============================================================
@@ -390,10 +379,20 @@ void sdl_osd_interface::video_register()
//video_options_add("auto", nullptr); // making d3d video default one
}
+
//============================================================
-// init
+// output_oslog
//============================================================
+void sdl_osd_interface::output_oslog(const char *buffer)
+{
+ fputs(buffer, stderr);
+}
+
+
+//============================================================
+// init
+//============================================================
void sdl_osd_interface::init(running_machine &machine)
{
@@ -491,7 +490,10 @@ void sdl_osd_interface::init(running_machine &machine)
osd_common_t::init_subsystems();
if (options().oslog())
- machine.add_logerror_callback(output_oslog);
+ {
+ using namespace std::placeholders;
+ machine.add_logerror_callback(std::bind(&sdl_osd_interface::output_oslog, this, _1));
+ }
diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp
index 1dcb10e2e37..4a4cd95defa 100644
--- a/src/osd/windows/winmain.cpp
+++ b/src/osd/windows/winmain.cpp
@@ -6,6 +6,9 @@
//
//============================================================
+// only for oslog callback
+#include <functional>
+
// standard windows headers
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -418,7 +421,7 @@ windows_options::windows_options()
// output_oslog
//============================================================
-static void output_oslog(const running_machine &machine, const char *buffer)
+void windows_osd_interface::output_oslog(const char *buffer)
{
if (IsDebuggerPresent())
win_output_debug_string_utf8(buffer);
@@ -523,7 +526,10 @@ void windows_osd_interface::init(running_machine &machine)
// hook up the debugger log
if (options.oslog())
- machine.add_logerror_callback(output_oslog);
+ {
+ using namespace std::placeholders;
+ machine.add_logerror_callback(std::bind(&windows_osd_interface::output_oslog, this, _1));
+ }
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// crank up the multimedia timer resolution to its max
diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h
index f7774922223..0abc85b674a 100644
--- a/src/osd/windows/winmain.h
+++ b/src/osd/windows/winmain.h
@@ -303,6 +303,7 @@ protected:
private:
virtual void osd_exit() override;
+ void output_oslog(const char *buffer);
windows_options & m_options;