View Single Post
Old 28 March 2016, 12:18   #1
Registered User

Join Date: Mar 2016
Location: Australia
Posts: 878
Hacking the fs-uae console debugger

Being a noob I need a debugger. I think the UAE console debugger is pretty cool.

So today I hacked some stuff into it that I was used to coming from GDB. I thought I'd share this here in case anyone else finds it useful.

Firstly I added gnu readline support. The main advantage this gives me is "up arrow" history. The history is saved to disk so each time I run FS-UAE, my commands from the previous run are there. You pretty much get all the features of the bash command editor (search, cut paste etc). I also made another small change so that hitting "enter" without a command runs the previous command, so if you're stepping through a bunch of code you can go "t" or "z", then just keep hitting enter.

Next I wanted symbols. I only debug bootblock run programs, so there are no symbols on the adf, so I added an option to tell fs-uae to load the symbols from a file. The file is just is list of names and addresses, that I generate with vlink or objdump.

So now, any command in the debugger that takes an address will optionally take a symbol:

>f Entry
Breakpoint added
00004008 (Entry) 
>f Entry
Breakpoint removed

>d MainLoop
00004078 4eb9 0000 4314           JSR $00004314 (WaitVerticalBlank)
0000407E 6100 0124                BSR.W #$0124 == $000041a4 (InstallPalette)
00004082 207a 0244                MOVEA.L (PC,$0244) == $000042c8 (offscreen),A0
00004086 7003                     MOVE.L #$00000003,D0
00004088 323c 000a                MOVE.W #$000a,D1
0000408C 243a 00a6                MOVE.L (PC,$00a6) == $00004134 (ypos),D2
00004090 4eb9 0001 8594           JSR $00018594 (BlitFillColor)
Whenever an address matches a symbol during disasm the symbol name (should) be shown.

The last thing I added was tab completion for symbol names. So if you type a command then the start of a symbol you can hit TAB and it will complete it, or show you a list of matches:

>d doy<TAB>
doy_full_000015  doy_lcopy_near   doy_literal      doy_mcopy        doy_mgetlen      doy_mrefill      doynaxdepack
doy_full_000018  doy_lendlen      doy_lsingle      doy_mendlen1     doy_mhalf        doy_return       
doy_lcopy        doy_lgetlen      doy_match        doy_mendlen2     doy_mprefix      doy_table
So far I am finding the hacks really useful. There might be some issues as I haven't exhaustively tested it yet, but the changes were all pretty simple.

Anyone have any other ideas for debugger hacks ?

Source is on my fork of FS-UAE:
alpine9000 is offline  
Page generated in 0.04965 seconds with 11 queries