Commit Graph

79 Commits

Author SHA1 Message Date
Maxim Poliakovski
f1e56cd353 Make the debugger a global object. 2024-11-30 12:12:32 +01:00
Mihai Parparita
bf92b04d6c debugger: Use a named constant when we don't have a current instruction 2024-11-29 18:33:22 +01:00
Mihai Parparita
564c43c907 Remove ppc_cur_instruction global variable
Replace it wth an explicit opcode parameter that is passed around. That
is both slightly easier to reason about (to trace where it comes from)
and slightly faster, since it can be read from a register.

On my machine takes booting to "Welcome to Macintosh" being output in
a verbose boot of Mac OS X 10.2.8 from 31.8s to 30.6s (average of 5
runs, measured using deterministic mode and looking at when execution
reaches PC 0x90004a88).
2024-11-28 23:41:38 +01:00
joevt
27d389c36a debugger: Erase prompt when repeating command.
Enterring a blank command continues the disassembly or stepping for one instruction. Erasing the prompt saves one line in the console so the disassembly doesn't appear double spaced. I don't know if the terminal control sequence works in Windows.
2024-11-09 06:48:22 -07:00
joevt
f09710a5f7 viacuda: Do shutdown.
Shutdown will enter the debugger or quit depending on the execution mode.
Quit is different from shutdown since it is triggered outside the guest by using the host Quit menu item.
2024-08-31 18:09:12 -07:00
dingusdev
606c9dd9a8 More compiler warning fixes 2024-06-24 19:40:20 -07:00
dingusdev
c0e28b81a8 Gracefully exit upon EOF
Taken from #94 - Originally fixed by dressupgeekout  and refined by joevt
2024-06-16 07:28:40 -07:00
joevt
7866675a55 debugger: Auto increment after disassemble.
Pressing return after disassembling some instructions should cause the next instruction to disassemble.
2024-03-11 07:13:40 -07:00
joevt
619579bee3 debugger: Add instruction bytes to disassembly.
8 characters for address, 8 characters for instruction hex, followed by instruction.
2024-03-11 07:13:07 -07:00
joevt
b5dbaff748 debugger: Don't echo auto-repeated commands. 2024-03-11 07:12:57 -07:00
Mihai Parparita
57e6e90002 Add support for the CUDA_RESTART_SYSTEM command
There are cases where when it's necessary (e.g. given uninitialized NVRAM,
the Beige G3 with the 10.2 install CD inserted will update the boot
device and restart to boot from it).

Restart support was done by wrapping the ppc_exec function in a loop and
checking for a restart power off reason. We also need to disconnect all
event listeners, since they will be recreated when the machine is
re-initialized.
2024-03-07 23:32:23 -08:00
joevt
ebb51addd7 debugger: Allow interrupt of disassembly.
Part of the "debugger: Fix interrupt signal." commit.
2024-03-03 14:36:24 -07:00
joevt
177098c957 debugger: Fix interrupt signal.
Typing Control-C in Terminal app causes an interrupt signal that should enter the DPPC debugger but this only worked once since the signal handler never returned. Even if the signal handler reenabled the signal somehow, it calls enter_debugger recursively which is strange since the earlier calls to enter_debugger would never return.

Now the signal handler just sets a flag (power_on) which can be used to exit any loop (emulator loops, stepping loops, disassembly loops, dumping loops).

Main always calls enter_debugger now which calls the ppc_exec loop. The power_on flag will exit the ppc_exec loop to return to the debugger. Recursion of enter_debugger is eliminated except for calls to loguru's ABORT_F.

An enum power_off_reason is used to indicate why the power_on flag is set to false and to determine what happens next.
2024-03-02 12:57:02 -07:00
joevt
6a51e8a1c9 debugger: regs command needs to reset setfill.
So printenv will fill with spaces after regs.
2024-03-01 07:28:58 -07:00
joevt
006a90f681 debugger: Some commands should not repeat.
Entering a blank command causes the last command to repeat. This doesn't make sense for the following commands:
help, quit, regs, context, printenv, setenv, nvedit, amicint, viaint.
2024-03-01 07:26:34 -07:00
joevt
17983e7fad debugger: Fix setenv command to allow spaces.
To allow setting boot-command to "0 bootr -v debug=0x144" for example.
2024-03-01 07:13:41 -07:00
joevt
a15b1805fb debugger: Fix handling of empty commands.
An empty command should not be reported as an unknown command.
An empty command should not repeat an unknown command.
2024-03-01 07:08:12 -07:00
joevt
11e0bd79b0 debugger: Work around Xcode Terminal.app issue.
If debugging with Xcode using Terminal.app for the console, Terminal.app may send empty lines to the dingusppc debugger while resizing the Terminal.app window and it will do this forever.
As a workaround, use std::cin.clear() to clear the input buffer before getline and loop until the terminal window size is not changing or the input line is not empty.
2024-03-01 06:56:20 -07:00
dingusdev
229509a067 Add help for mregs 2024-02-29 21:48:04 -07:00
joevt
ff5c43e6cb debugger: Add mregs command.
To dump more registers.
2024-02-29 21:46:44 -07:00
Maxim Poliakovski
c188d0251a ofnvram: support CHRP style OF config partition. 2023-02-25 18:14:42 +01:00
joevt
64fec88436 Fix compiler warnings: cast loses precision.
Use explicit cast when converting large integer types to smaller integer types when it is known that the most significant bytes are not required.
For pcidevice, check the ROM file size before casting to int. We'll allow expansion ROM sizes up to 4MB but usually they are 64K, sometimes 128K, rarely 256K.
for machinefactory, change the type to size_t so that it can correctly get the size of files that are larger than 4GB; it already checks the file size is 4MB before we need to cast to uint32_t.
For floppyimg, check the image size before casting to int. For raw images, only allow files up to 2MB. For DiskCopy42 images, it already checks the file size, so do the cast after that.
2023-01-11 01:17:12 -08:00
Maxim Poliakovski
5b08f283e5 Hacks for debugging HW interrupts. 2022-08-27 17:38:53 +02:00
Maxim Poliakovski
50053a52dc debugger: disable nvedit command on Windows hosts. 2022-08-26 11:13:33 +02:00
joevt
1c1300ce5a Add nvedit
setenv doesn't allow entering strings that include multiple lines which is useful for nvramrc.

nvedit uses CTRL-C to end editing, like Open Firmware. It does not support deleting characters from a line or editing previous lines or any other special keys. It doesn't have nvstore or nvquit or nvrecover commands. Basically, you should edit your nvramrc in a text editor, then copy and paste into the debugger.
2022-08-22 17:21:58 -07:00
Maxim Poliakovski
b8915f11a2 debugger: fix ofnvram commands for Nubus machines. 2022-07-18 20:27:34 +02:00
Maxim Poliakovski
898c677ffb debugger: add printenv and setenv commands. 2022-05-21 14:51:27 +02:00
Maxim Poliakovski
932a6ae01e debugger: GO command. 2022-02-26 12:47:51 +01:00
Maxim Poliakovski
f1ed56ae9a debugger: a couple of cosmetic improvements. 2022-02-26 10:57:13 +01:00
Maxim Poliakovski
c0cd6eb38f Add missing licence headers, update license date. 2021-10-23 21:00:31 +02:00
Maxim Poliakovski
e66979d30f debugger: improve disassembling of 68k F-Traps. 2021-10-13 09:04:52 +02:00
Maxim Poliakovski
e9fcc51b93 Debugger fixes for PDM. 2021-09-26 14:21:31 +02:00
Maxim Poliakovski
e052eb4a87 Merge branch 'atirage-hacks'. 2021-09-25 23:16:38 +02:00
Maxim Poliakovski
212cd58f40 ppcmmu: refactor and clean up. 2021-09-25 19:13:40 +02:00
Maxim Poliakovski
84e111290f Fix includes for loguru and SDL. 2021-09-16 00:46:38 +02:00
Maxim Poliakovski
6f9ee10de5 Rework PPC CPU profiler. 2021-04-29 02:26:17 +02:00
Maxim Poliakovski
ed6c316c82 profiler: add reset command. 2021-04-14 17:04:14 +02:00
Maxim Poliakovski
31b5290ac9 New profiler API. 2021-04-14 01:27:07 +02:00
Maxim Poliakovski
d8f7588693 debugger: some fixes and improvements. 2021-01-12 15:17:51 +01:00
Maxim Poliakovski
180cb0d25f Make 68k debugger optional and disabled by default. 2020-12-03 02:18:13 +01:00
Maxim Poliakovski
f0315e98ee Add Capstone submodule. 2020-12-03 00:53:28 +01:00
Maxim Poliakovski
2be8e7b542 Set minimum Capstone version to 4.0.2
This version has fixed a bug with Capstone's main header.
2020-11-28 02:23:47 +01:00
Maxim Poliakovski
353035e9ca Prevent clobbering during debugging. 2020-07-20 23:02:07 +02:00
Maxim Poliakovski
660d227ac7 debugger: fix string formatting. 2020-07-20 18:00:04 +02:00
Maxim Poliakovski
b9dcfef551 debugger: debugging commands for 68k code. 2020-07-16 14:26:34 +02:00
Maxim Poliakovski
6b74e358dc WIP: basic 68k debugging environment. 2020-07-15 02:19:05 +02:00
Waqar Ahmed
0ab9380be3 clang-format everything 2020-05-12 23:55:45 +05:00
Maxim Poliakovski
7154e51d86 Make debugger standalone component. 2020-04-20 20:32:09 +02:00
dingusdev
60ffa5bfac Initial attempt at fixing SDL2 building for Windows 2020-03-22 20:15:12 -07:00
Maxim Poliakovski
cea840fc09 debugger: add command to control log level. 2020-03-02 23:48:02 +01:00