• Hello MLAers! We've re-enabled auto-approval for accounts. If you are still waiting on account approval, please check this thread for more information.

Debugging via QEMU

Thank you @joevt, I appreciate it. I could not get MacsBug to work in QEMU - I press a key to type something and it just ends up filling the full line with that letter. And apart from that it just seems like one more great tool and convenient to run on my main desktop - although I think you are right that for what I wanted to do, MacsBug would be better.

I don't find CFLOpenContainer in the Mac OS header support files in CW Pro 7.1, I tried declaring it external to see if the linker would find it but it seems not - but I have not checked all the libs yet.

As for Ghidra, I really don't know. But thanks for sharing that mpw line, I will use that from now on!
I might be barking up the wrong tree, it is quite possible CFLOpenContainer is not invoked at all when launching a PPC application. In particular, I want to find the code that parses the PEF prior to launching the app.

Thanks again for the pointers!
 
I could not get MacsBug to work in QEMU - I press a key to type something and it just ends up filling the full line with that letter.
I have this problem on my Power Mac 8600 with G4 upgrade but not on my Power Mac B&W G3 with G4 upgrade. I don't know why.
I tested the B&W G3 and Power Mac 8600 just now.

For my Power Mac 8600, I can get into MacsBug using Command-Reset on the ADB keyboard. Pressing a key fills the line. I can use the ADB mouse to select commands from the menu. I'm using MacsBug 6.6.3. I can click on words from the MacsBug help to enter them into the command line. I can click on a space character to insert a space in the command line. In this way I can use the MacsBug Help menu to get help on MacsBug commands, and enter "help flow" by clicking on "help", " " (space character), and "flow". This help shows the "go" command. I can click on "go" and press return to leave Macs Bug.

Here's a thread that also discusses this problem:
https://tinkerdifferent.com/threads/emulator-for-macos-8-9-macsbug.2707/
Here's a small mention:
https://www.emaculation.com/forum/viewtopic.php?p=74582#p74582
There's an interesting note at:
https://www.emaculation.com/forum/viewtopic.php?p=68004&sid=b3d2461d5b066bfd84e7381addf5e3fc#p68004
Maybe just need to change the TimeDBRA low memory global?

Code:
TimeDBRA  		EQU 		$0D00 					; (word) number of iterations of DBRA per millisecond

; Mouse/Keyboard
KeyLast   		EQU 		$184  					; ASCII for last valid keycode [word]
KeyTime   		EQU 		$186  					; tickcount when KEYLAST was rec'd [long]
KeyRepTime		EQU 		$18A  					; tickcount when key was last repeated [long]

; Unpacked, user versions of parameter ram
KeyThresh 		EQU 		$18E  					; threshold for key repeat [word]
KeyRepThresh  	EQU 		$190  					; key repeat speed [word]

; Parameter Ram
SPKbd 			EQU 		$206  					; kbd repeat thresh in 4/60ths [2 4-bit]

Maybe TimeDBRA wrapped around from 65535? But wouldn't both my Power Macs have the same problem? Maybe both of them wrapped around but the B&W landed on a value that is ok and the Power Mac 8600 did not.
I need to compare them.
 
I don't find CFLOpenContainer in the Mac OS header support files in CW Pro 7.1, I tried declaring it external to see if the linker would find it but it seems not - but I have not checked all the libs yet.
The stub libraries do not have all the exports of the real library:
Code:
cd "/Volumes/Devs/Metrowerks CodeWarrior 8.0/Metrowerks CodeWarrior/MacOS Support/Universal/Libraries/StubLibraries"
mpw DumpPEF CFragManager
DeRez CFragManager

This is the list of symbols in the stub library:
Code:
CountSymbols
GetMemFragment
CloseConnection
FindSymbol
GetDiskFragment
GetIndSymbol
GetSharedLibrary

You can try linking the library that is extracted from the ROM resources. You may need to add a cfrg resource.
 
Whilst working on the q800 series for QEMU, I wrote a utility called list2elf that takes the symbols from the MPW ROM map files and uses them to generate a stub ELF file so that you can also have access to the ROM symbols in gdb i.e.

You can find out more information and download the stub ELF file from https://github.com/mcayland/qemu-m68k-macos-utils/tree/main/list2elf.
This is great! I was giving this a try today and newer gdb doesn't seem to like it...am I just doing it wrong?
Code:
The target architecture is set to "m68k".
⚠️ warning: BFD: warning: Quadra800ROM.elf has a section extending past end of file
Reading symbols from Quadra800ROM.elf...
⚠️ warning: Discarding section .text which has an invalid size (100000) [in module Quadra800ROM.elf](No debugging symbols found in
Quadra800ROM.elf)
Remote debugging using localhost:1234
0x4080002a in ?? ()
(gdb) b STARTBOOT
Breakpoint 1 at 0x8100008c
Despite the warnings the function definitions do load but the offsets are all wrong, at 0x81000000 instead of 0x40800000. The file itself is right:
Code:
$ nm Quadra800ROM.elf | grep STARTBOOT
4080008c T STARTBOOT
So it seems like gdb is confused somehow, it's like it's shifting the upper bits to the left by one for some reason? I'm using 17.1
 
It seems like it's offsetting to 0x40800000 twice, even when I tell it to load at 0x0 manually. Loading it at 0x100000000 (overflowing it back to zero) works though, amusingly. add-symbol-file Quadra800ROM.elf 0x100000000
 
Back
Top