D-Bug & Automation Forum
D-Bug & Automation Forum >> Coding >> Bugaboo usage
http://d-bug.mooo.com/dbugforums/cgi-bin/yabb2/YaBB.pl?num=1179828064

Message started by ggn on 22.05.07 at 10:01:03

Title: Re: Bugaboo usage
Post by ggn on 22.05.07 at 10:41:03
Preliminaries


Even when starting Bugaboo there is some sort of flexibility! Well, not built in really, but using an external program provided in the Turbo Assembler package (L_XXXXXX.PRG), you can load Bugaboo to any possible address from start of program area up to the Physical screen. This is very handy especially when you have lots of memory because you can load it high enough so it won't interfere with a code you're trying to trace through and it has to load at a specific address.

Bugaboo is a very special debugger in my opinion, as you can use it using shortcut keys AND/OR CLI commands. When you load it you can see the top 2 lines containing 20 useful functions. These can be invoked using F-keys (top line) and Shift-F-Keys (second line). Let me cover briefly the most important of those functions.

  • Trace (F1): Well, it traces thru a single command. Enters bsr/jsr subroutines too.
  • Do PC (F2): Executes the code until the next command relative to the current is reached. So you can pass a dbra loop without having to trace each step. Useful!
  • Tracrts (F3): Traces until an RTS instruction is reached. So you can quickly pass by a subroutine. CAUTION! You should use this BEFORE the stack is tampered by the subroutine!!! So if a subroutine immediately saves registers to the stack you must press F3 before this happens, or else you'll most probably bomb out!
  • Ttraps (F4): Identical to Trace, but lets you enter a trap vector and trace it. Useful for tracing through O/S or a custom trap.
  • Skip PC (F5): Just skips to the next instruction.
  • Source (F6): If you assemble a source from Turbo Assembler to Bugaboo then you can see the source this way.
  • Hexdump (F7): Produces a hex dump of the memory at PC. Also you can use the 'm' command on the CLI. Just type

    Code (]m <address> [#no_of_lines_to_display):
    [/code]
    So typing
    [code]m $200000

    will produce a memory dump of $200000 onwards. However if you only need to display 3 lines (this is mosty because you don't want to overwrite other information being displayed) you can use

    Code (]m $200000#3[/code):

  • Disassm (F8): Produces a diassembly of the memory at PC. Like F7 there is a CLI equivalent:
    [code]d <address> [#no_of_lines_to_display]

  • List (F9): Produces a re-assembly of the memory at PC. Like F7 and F8 we have:

    Code (]l <address> [#no_of_lines_to_display):
    [/code]

    Now, when you press F7, F8 or F9 you will see a listing that resembles these:

    F7:
    [code]$200000>,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00


    F8:

    Code (]$200000>/0000,0000                ; ori.b #0,d0[/code):


    F9:
    [code]$200000>!                 ori.b #0,d0


    What Bugaboo does here is to provide the listing in CLI style. This is default and I don't think it can be changed. What most people don't realise here is that what is printed there can be changed at will. In fact you don't need to type any command to change any memory place, if you know the syntax. Let's break the lines down a bit. (taking F8 as an example)


    Code (]$200000>[/code):

    This is of course the memory address. The '>' is essential for Bugaboo to parse the command properly. When you see a '>>' character it means that the PC is in that address.

    [code]/0000,0000

    This is the disassembled opcode actually.


    Code (]; ori.b #0,d0[/code):

    This is actually a comment just to help you. Bugaboo stops parsing a line when it encounters the 1st ';'. In this case it shows you the instruction at that address.

    So, let's say you want to change $200000 to have a nice nop instruction instead! What you can do is go to a clean line in the CLI (navigate using the cursor keys) and write the following:

    [code]$200000>/4e71;

    (the ';' is essential if the line is not 100% and contains some other characters after our opcode) Press Return and voila! Instruction changed! If you don't remember the hex value of the opcode you can of course use:


    Code (]$200000>!nop;[/code):

    If you want to see the changed listing just type:

    [code]l $200000;

    It is a personal preference of mine to end the commands I enter using a ';' because this way I don't have to worry about finding an empty line or cleaning it up.

  • Switch (F10): Switches between Bugaboo's screen and the user screen.

    Let's take a small break here and discuss some stuff. Bugaboo is a highly crash-proof debugger. It manages that by hooking to every vector possible (just about) and using its own custom interface, keyboard interrupt, mouse driver, palette, etc. So games that disable vectors don't actually do anything to Bugaboo, as it switches between states (debugger mode, user mode) every time that is needed (i.e. when you trace an instruction). Also, any interrupts that the program sets don't affect Bugaboo at all since too are saved and restored when it's needed. It's also reset proof.

  • Tractre (Shift-F3): Like F3, but for RTEs. Careful with this!
  • Go (Shift-F4): Runs the program until it exits or an exception is reached or a breakpoint.
  • Marker (Shift-F6): Lists all defined markers (more on this later)
  • Breakp (Shift-F7): Lists all defined breakpoints (later as well)
  • Quit (Shift-F10): Exits to the O/S (if you haven't trashed all memory that is ;))


D-Bug & Automation Forum » Powered by YaBB 2.6.0!
YaBB Forum Software © 2000-2024. All Rights Reserved.