MacsBug on QEMU

About QEMU, a PPC Mac emulator for Windows, macOS and Linux that can run Mac OS 9.0 up to Mac OS X 10.5

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
dadreamer
Inquisitive Elf
Posts: 34
Joined: Sun Jan 08, 2017 4:31 pm
Location: Russia

MacsBug on QEMU

Post by dadreamer »

I'm trying to invoke MacsBug on QEMU, but cannot succeed. Well, I've got it successfully installed according to the manual - I see "Debugger installed" message during the system boot. But how can I launch MacsBug window? Everything I found is this:
GSOC qemu Boot Mac OS >= 8.5 on PowerPC system wrote:Defining an 'FKEY' Resource to Invoke MacsBug 2
Another way to invoke MacsBug is to define an 'FKEY' resource using ResEdit or MPWS. Once you have defined this resource, you can use a Shift-Command-key combination to invoke MacsBug.
To define an 'FKEY' resource using ResEdit 2.1, follow these steps:
1. Launch ResEdit.
2. Open the 'FKEY' resource in the System File.
3. Choose “Create New Resource” from the Resource menu to create a new 'FKEY' resource.
4. Type the following numbers into the new resource exactly as shown:
A9FF 4E75
A9FF is machine code for the _Debugger trap; 4E75 is machine code for the RTS instruction.
Figure 2-6 shows what the resource looks like after you’ve entered the instruction.
Figure 2-6 Defining an 'FKEY' resource to invoke MacsBug
5. Choose Get Resource Info from the Resource menu and set its ID number to a number greater than 4 and less than or equal to 9. Please remember to use a number that is not already in use. The numbers 1, 2, 3, and 4 are reserved for system functions.
6. Close and save the System file.
7. To invoke MacsBug, press Command-Shift and the ID number you have assigned the resource. For example, if you’ve assigned the resource ID 7, press Command-Shift-7 to invoke MacsBug.
This method of invoking MacsBug will only work when the application is calling GetNextEvent or WaitNextEvent regularly, which it might not do if it’s hung or frozen.
That's the same instructions as in the MacsBug's official manual - MacsBug Reference and Debugging Guide.
But when I press Command+Shift+7 (I set FKEY ID to 7), nothing happens. My host OS is Windows 10 x64 1803, guest OS is Mac OS 9.2.2. With trial and error method I discovered that the Command/Clover key is Windows+Alt on my keyboard. Any standard hotkeys with Command key work just fine.

Any advices to try?
User avatar
Cat_7
Expert User
Posts: 5100
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: MacsBug on QEMU

Post by Cat_7 »

Hi

You can at least get to the nanokernel log in this way (from qemu wiki):

In the command line set auto-boot? to false
Add this
-prom-env "aapl,debug=2000000"

In OpenBIOS type:
dev /
2000000 encode-int
“ AAPL,debug” property

Then, to boot from a hard drive image:
boot hd:,\\:tbxi

A forum search tells me pressing the Ctrl key before the splash screen appears might get you into macsbug when installed.
I don't know whether that will work.

Best,
Cat_7
dadreamer
Inquisitive Elf
Posts: 34
Joined: Sun Jan 08, 2017 4:31 pm
Location: Russia

Re: MacsBug on QEMU

Post by dadreamer »

Thanks for the reply, Cat_7.

I tried this NanoKernel Log already and tried again with your advice, but it seems to be of no use for me, because it views QEMU's internal info and I need Mac OS internal info (even not all of it). I'm trying to debug old software and I need to get to its disassembly to step/trace, view stack/registers etc. Pretty the same thing as IDA does.
That's the log I get:
Image
What could I do with it?
Cat_7 wrote:A forum search tells me pressing the Ctrl key before the splash screen appears might get you into macsbug when installed.
I don't know whether that will work.
It doesn't work as it should. Tried several times, but I get just this black window with the log text on the background:
Image
Nothing happens after this state, the system doesn't react to any keys. :sad:

As I see in the manual, there exists a way to view MacsBug with calling a Debugger trap like this:

Code: Select all

Begin
thisnumber := $666;
Debugger;
newnumber := thisnumber
End
I wonder whether this solution works on QEMU. Could someone check this out?
mcayland
Granny Smith
Posts: 111
Joined: Sun Nov 01, 2015 10:33 pm

Re: MacsBug on QEMU

Post by mcayland »

If you're using the newest builds (pre-3.0) with PMU support then you can break into MacsBug via the programmer switch. From the command line make sure that you enable both PMU and stdio monitor like this:

Code: Select all

$ ./qemu-system-ppc -M mac99,via=pmu -monitor stdio ....
Then once you want to break in, simply issue "nmi" on the monitor which triggers the virtual programmer switch:

Code: Select all

$ ./qemu-system-ppc -monitor stdio -M mac99,via=pmu -cdrom MacOS921-macsbug.iso -boot d
QEMU 2.12.90 monitor - type 'help' for more information
(qemu) nmi
A quick test here shows that it causes OS 9 to enter MacsBug without any issues.
User avatar
Cat_7
Expert User
Posts: 5100
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: MacsBug on QEMU

Post by Cat_7 »

Thanks MCayland,

The monitor displays "nmi" as: (qemu) n[K[Dnm[K[D[Dnmi[K
but it still works.

For windows this also works: Just start qemu. At splash (or any moment required) press Ctrl-Alt-2 and enter "nmi".
Press Ctrl-Alt-2 again to get back into the graphical window.
At least you can see what you type ;-)

Best,
Cat_7
dadreamer
Inquisitive Elf
Posts: 34
Joined: Sun Jan 08, 2017 4:31 pm
Location: Russia

Re: MacsBug on QEMU

Post by dadreamer »

Thanks a lot, mcayland and Cat_7!
With the recent QEMU 3.0.0-rc0 it works as a charm! Even pressing Ctrl key on the splash screen works also. Command+Shift+[Some number] still doesn't want to work, but it doesn't matter now.

By the way, I even don't need to invoke the monitor (serial0 console). As I run QEMU through a batch file, I just write "nmi" there and press Enter. It also works in PowerShell/cmd the same way.
dadreamer
Inquisitive Elf
Posts: 34
Joined: Sun Jan 08, 2017 4:31 pm
Location: Russia

Re: MacsBug on QEMU

Post by dadreamer »

dadreamer wrote:As I see in the manual, there exists a way to view MacsBug with calling a Debugger trap like this:

Code: Select all

Begin
thisnumber := $666;
Debugger;
newnumber := thisnumber
End
I wonder whether this solution works on QEMU. Could someone check this out?
I checked this. Seems to work fine in MetroWerks CodeWarrior Pro 4 Pascal with both Debugger and DebugStr calls. But in LabVIEW it appears to hang the system completely if called from InterfaceLib.
Post Reply