XRoar, GDB

A place to discuss everything Dragon related that doesn't fall into the other categories.
sixxie
Posts: 1346
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

XRoar, GDB

Post by sixxie »

(Reposting here what I just sent to the coco list).

http://www.6809.org.uk/tmp/xroar/debugging.png

If you're interested in what's behind it, the current XRoar public git has a branch called "gdb":

Code: Select all

git clone -b gdb http://www.6809.org.uk/repos/xroar.git
Still breakpoints/watchpoints to add, once done this will actually be of some use...

BTW, I've been patching GDB myself to support 6809, but this must surely be an existing project somewhere. Damned if I can find one with google though; anyone got some pointers? In case not, here's my patch against GDB's git copy as of this morning:

http://www.6809.org.uk/tmp/xroar/gdb-m6809.diff

..ciaran

Update: hbreak now supported, and a copy of the GDB git copy with my branch in it made, clone with:

Code: Select all

git clone -b m6809 http://www.6809.org.uk/repos/gdb.git
Further update: watchpoints now supported! Write (watch), read (rwatch) and access (awatch) should all do the right thing.

Snapshots of XRoar in the usual place, though if you want a 6809-patched GDB, that's still DIY...
sixxie
Posts: 1346
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: XRoar, GDB

Post by sixxie »

I'm not sure it works properly - it seems to hang as soon as you type anything when running under Wine - but in case it's fine on a real machine, I've pushed a windows32 build of my patched GDB out too, in case anyone wants to experiment: m6809-gdb.exe
Alastair
Posts: 669
Joined: Fri Jul 18, 2008 11:33 pm

Re: XRoar, GDB

Post by Alastair »

sixxie wrote:I'm not sure it works properly - it seems to hang as soon as you type anything when running under Wine - but in case it's fine on a real machine, I've pushed a windows32 build of my patched GDB out too, in case anyone wants to experiment.
'Help' and 'Quit' work! Could you suggest a few commands to put it through its paces?
sixxie
Posts: 1346
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: XRoar, GDB

Post by sixxie »

Alastair wrote:'Help' and 'Quit' work! Could you suggest a few commands to put it through its paces?
Well that's better than I get under Wine - cool (Linux & Mac builds are how I've tested).

So first off, run a recent XRoar snapshot - in its logging (stderr.txt maybe), it should say "gdb: stub listening on localhost:65520".

Run gdb, and type "target remote localhost:65520". XRoar should stop, and you should get a prompt showing the address it stopped at (address of next instruction to be executed).

Try "x/10i $pc" - examine 10 instructions (so, disassemble) from the current program counter. "stepi" executes one instruction (short: "si"). "continue" starts it running again (short: "c") until you press Control+C to interrupt it. Just pressing enter repeats the last command (useful for single stepping).

Set a breakpoint with something like "hbreak *0xbbcc", then continue - it should stop when it gets to that address (which is just after a delay loop).

Type "delete" to delete that breakpoint, then set a watchpoint, something like "watch *(short *)0x0088" and continue. That should let it run until anything tries to write to the 16-bit value at 0x0088 - which is where BASIC stores its cursor position, so try focussing the emulator and pressing a key...

So all that's nice, but the best mode is if you start gdb with the "-tui" (text user interface) option, or press Control+'x' followed by 'a' (toggles the mode). You should see a little text window, if that works on the Windows build. Type "layout asm", and try single stepping...

There's more... "info registers" dumps the current registers (it will probably complain about 6309 ones it didn't get a value for). "info breakpoints" lists all the breakpoints you set. gdb is pretty powerful...
Alastair
Posts: 669
Joined: Fri Jul 18, 2008 11:33 pm

Re: XRoar, GDB

Post by Alastair »

Thanks Ciaran, I've tried all of the above and everything works except TUI mode. "Ctrl+x, a" does not produce anything and starting gdb with the "-tui" switch gives the message "m6809-gdb: TUI mode is not supported". Is the following screen output of any use?

Code: Select all

GNU gdb (GDB) 7.6.50.20130426-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=m6809".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) show configuration
This GDB was configured as follows:
   configure --host=i686-w64-mingw32 --target=m6809
             --with-auto-load-dir=$debugdir:$datadir/auto-load
             --with-auto-load-safe-path=$debugdir:$datadir/auto-load
             --without-expat
             --with-gdb-datadir=/usr/local/share/gdb (relocatable)
             --with-jit-reader-dir=/usr/local/lib/gdb (relocatable)
             --without-libunwind-ia64
             --without-lzma
             --with-separate-debug-dir=/usr/local/lib/debug (relocatable)
             --without-zlib
             --without-babeltrace
(gdb)
Also, I cannot get xroar-snap-20130428-w32 to close cleanly - either by clicking on the close button or pressing Ctrl+c - instead I have to end the program via the "Program is not responding" box.
sixxie
Posts: 1346
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: XRoar, GDB

Post by sixxie »

Alastair wrote:Thanks Ciaran, I've tried all of the above and everything works except TUI mode.
Ah, I think a lack of curses may have been to blame here - I've built it again, linked against ncurses. Hopefully you'll get to see the fancy-pants interface now.
Also, I cannot get xroar-snap-20130428-w32 to close cleanly - either by clicking on the close button or pressing Ctrl+c - instead I have to end the program via the "Program is not responding" box.
Oh, erk. I'm guessing the GDB stub thread isn't being killed off properly then. I'll look into that.
Alastair
Posts: 669
Joined: Fri Jul 18, 2008 11:33 pm

Re: XRoar, GDB

Post by Alastair »

sixxie wrote:Ah, I think a lack of curses may have been to blame here - I've built it again, linked against ncurses. Hopefully you'll get to see the fancy-pants interface now.
Starting the newest (1st May 2013 [07:26]) version with -tui does produce a text window which seems to function properly. Unfortunately I can no longer run the program without the text user interface as whenever I try this the program quits as soon as I press any key.
sixxie
Posts: 1346
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: XRoar, GDB

Post by sixxie »

I've applied one of the patches from the comments of this page that claims to allow it to work in either mode (does some initialisation for getch(), which I guess it ends up using when built with ncurses). See if that's any better?
Alastair
Posts: 669
Joined: Fri Jul 18, 2008 11:33 pm

Re: XRoar, GDB

Post by Alastair »

The 2nd May version seems to work in both modes but there is now a problem with the cursor control and delete keys. The cursor control keys problem is partially mentioned (left and right don't do anything either) in the comments on the page that you linked to. The delete key problem occurs in non-tui mode only, in this case characters are deleted from the program's buffer but the screen is not updated to reflect this, instead the cursor moves right as if the space-bar has been pressed.
sixxie
Posts: 1346
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: XRoar, GDB

Post by sixxie »

Well, patched with the other suggestion in the thread then.
Post Reply