Page 1 of 1

Xroar + GDB

Posted: Thu Jul 13, 2017 4:08 pm
by prime
Hi all,

Is there a noddy guide to using gdb with xroar? I can get them to connect but need to know how to do things like disassemble from current PC, single step etc.

Cheers.

Phill.

Re: Xroar + GDB

Posted: Thu Jul 13, 2017 4:41 pm
by pser1
Hi Phill,
I do use XRoar+GDB regularly despite XRoar still refuses to connect to GDB from time to time (more often than I would like :( )
First of all, I am using Windows 7, not Mac nor Linux, so my explanations will be from this side of the world.
I start them issuing this bat file:

Code: Select all

cd..
copy ..\XRoar\DOS-ROMs\dplus50.rom ddos40.rom
copy ..\XRoar\ROMs\d64rom1V31.rom d64_1.rom
copy ..\XRoar\ROMs\d64rom2V31.rom d64_2.rom
start xroar -gdb -machine dragon64 -machine-cpu 6309 -extbas d64_1.rom -altbas d64_2.rom -machine-cart dragondos -cart-rom ddos40.rom -force-crc-match -disk-write-back -joy-left 0,0:1:0 -kbd-translate -lp-file ..\XRoar\sortida.txt 
pause "press a key when XRoar has started"
m6809-gdb -ex "layout asm" -ex "layout regs" --eval-command="target remote localhost:65520"
del *.rom 
This opens three windows on GDB, see image
GDB.jpg
GDB.jpg (87.05 KiB) Viewed 6146 times
Using the manual that comes with GDB I have 'noted' some useful commands, to change registers, memory
and see contents of any place in memory too ...
cheers
pere

Ps. By the way, once you see the disassembled window, command 'SI' steps program line by line

Re: Xroar + GDB

Posted: Tue Sep 25, 2018 7:38 pm
by robcfg
Sorry for resurrecting an old thread, but I finally managed to get m6809-gdb running with XRoar 0.35 on my mac and I don't know how to make it run.

I'm stuck at the following screen:
m6809-gdb.png
m6809-gdb.png (16.28 KiB) Viewed 5938 times
While the emulator is frozen.

How should I proceed?

Re: Xroar + GDB

Posted: Wed Sep 26, 2018 12:11 pm
by pser1
Hi Roberto Carlos,
not sure if this could work for you. This is the bat file I do execute to start XRoar with GDB

Code: Select all

cd..
copy ..\XRoar\DOS-ROMs\dplus50.rom ddos40.rom
copy ..\XRoar\ROMs\d64rom1V31.rom d64_1.rom
copy ..\XRoar\ROMs\d64rom2V31.rom d64_2.rom
start xroar -gdb -machine dragon64 -machine-cpu 6309 -extbas d64_1.rom -altbas d64_2.rom -machine-cart dragondos -cart-rom ddos40.rom -force-crc-match -disk-write-back -joy-left 0,0:1:0 -kbd-translate -lp-file ..\XRoar\sortida.txt 
pause "press a key when XRoar is running"
m6809-gdb -ex "layout asm" -ex "layout regs" --eval-command="target remote localhost:65520"
del *.rom
I execute the bat from a subfolder outside the main XRoar one, but the important here is that you just have to copy the ROMs you'd need and then call XRoar with a start command and with -gdb as the first parameter, so that you can then call m6809-gdb and execute a few commands to set up the layout of the windows and connect to XRoar
I hope the localhost will work for you, too!
cheers
pere

Re: Xroar + GDB

Posted: Wed Sep 26, 2018 12:13 pm
by pser1
I forgot to say that once you do this, you gain control over the GDB and the XRoar stays frozen untill you issue a command
"cont" in the GDB window.
Usually you will have set one breakpoint or a watchpoint before 'cont' is issued
The GDB manual is not very user friendly but can be of help ...
cheers
pere

Re: Xroar + GDB

Posted: Wed Sep 26, 2018 12:18 pm
by pser1
Another important point ...
IIRC you need to use a 6309 emulation or you will have problems with the '9' register
It looks like GDB 'needs' to get access to all of the registers of the 6309 CPU, so you cannot
debug a 6809 emulation or at least I am not aware of how could this be done :-(
cheers

Re: Xroar + GDB

Posted: Wed Sep 26, 2018 2:46 pm
by sixxie
I have a very vague recollection that when I started that patch, the "missing" registers didn't cause any issues, but later they did.

I'd say I need to distinguish between 6809 and 6309 targets, but to do the same patch against modern GDB now would mean starting from scratch anyway, and there might be a much better way...

..ciaran

Re: Xroar + GDB

Posted: Wed Sep 26, 2018 6:14 pm
by pser1
sixxie wrote:I have a very vague recollection that when I started that patch, the "missing" registers didn't cause any issues, but later they did.
I'd say I need to distinguish between 6809 and 6309 targets, but to do the same patch against modern GDB now would mean starting from scratch anyway, and there might be a much better way...
..ciaran
Hello Ciaran,
My laptop crashed severely and my new one wears Windows10, but ... fortunately I have discovered that when I trace/debug
one of my programs that use graphics, the screen doesn't go nuts as happenend witn Windows7, instead I can see the changes / evolution
on screen, and this increases greatly the value of the XRoar-GDB combo!
I could even say that now GDB does 'always' start well instead of hanging as happened many times with W7 ...
I hope that someday you will surprise all of us with a new XRoar version even more powerful.
Please, keep on creating so wonderful tools for the 6809
cheers
pere

Re: Xroar + GDB

Posted: Wed Sep 26, 2018 8:43 pm
by robcfg
Thanks for your tips and patience!

I finally managed to get it working :mrgreen:
m6809-gdb_working.png
m6809-gdb_working.png (25.19 KiB) Viewed 5915 times

Re: Xroar + GDB

Posted: Wed Sep 26, 2018 10:38 pm
by pser1
cheers!
hope you enjoy the nice task of debugging ;-)
pere