11 July 2013, 18:23 | #1 |
Registered User
Join Date: Nov 2012
Location: GB
Posts: 32
|
Basics of debugging ASM in WinUAE?
Hi,
Debugging ASM code in WinUAE, how is it done? For someone new to Amiga ASM, this is quite confusing. I understand the basics of high level language debugging on the PC and from what I can imagine the ideas are similar for ASM debugging: set a point in your code where you want a break(point), and then manually step through each command/function while watching variables, status regs, etc to identify incorrect input/output of various functions. Since beginning to learn ASM on Amiga, I'm seeing that some proper debugging skills might be useful. Just being able to look at a data reg befor the code explodes could answer some questions and help track down the problem. So how do I do it using the WinUAE and its debugger? For example, I have some buggy code and a rough idea where the problems in the code begin and I want to set a "breakpoint" at the point just before the code crashes and bring up the monitor/debugger so that I can watch certain registers, or values of memory addresses. What do I do in my code to trigger this break point? How do I mark a variable/memory address so that I can "watch" it in the debugger? How do I get symbols out to the debugger to make code easier to read in the debugger? Also any other useful information? Is there a manual for the debugger somewhere that I've missed, a good tutorial? anything? Last edited by bodhi; 11 July 2013 at 18:29. |
11 July 2013, 21:02 | #2 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
I don't know about the WinUAE debugger and haven't ever really used it but... I have debugged lots of asm code.
I've always just used the debugger (MonAm) that is available with the assembler I use (GenAm) that are both bundled together as Devpac. You can think of MonAm as analagous to a modern IDE debugger in that it allows all the things that you describe - you can load in your code, set breakpoints, single step, watch registers etc. etc. There is a .pdf manual available for Devpac that contains instructions for how to use MonAm too. I've mentioned the tools available in Devpac as that's what I've used but there are a few other assemblers worth using (AsmOne anyone...? Sting...? ) that also have their own debuggers that might be more to your taste that you could try too. |
11 July 2013, 21:16 | #3 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
here's the debugger help (type h lol)
Code:
HELP for UAE Debugger ----------------------- g [<address>] Start execution at the current address or <address>. c Dump state of the CIA, disk drives and custom registers. r Dump state of the CPU. r <reg> <value> Modify CPU registers (Dx,Ax,USP,ISP,VBR,...). m <address> [<lines>] Memory dump starting at <address>. d <address> [<lines>] Disassembly starting at <address>. t [instructions] Step one or more instructions. z Step through one instruction - useful for JSR, DBRA etc. f Step forward until PC in RAM ("boot block finder"). f <address> Add/remove breakpoint. fa <address> [<start>] [<end>] Find effective address <address>. fi Step forward until PC points to RTS, RTD or RTE. fi <opcode> Step forward until PC points to <opcode>. fp "<name>"/<addr> Step forward until process <name> or <addr> is active. fl List breakpoints. fd Remove all breakpoints. fs <val> <mask> Break when (SR & mask) = val. f <addr1> <addr2> Step forward until <addr1> <= PC <= <addr2>. e Dump contents of all custom registers, ea = AGA colors. i [<addr>] Dump contents of interrupt and trap vectors. il [<mask>] Exception breakpoint. o <0-2|addr> [<lines>]View memory as Copper instructions. od Enable/disable Copper vpos/hpos tracing. ot Copper single step trace. ob <addr> Copper breakpoint. H[H] <cnt> Show PC history (HH=full CPU info) <cnt> instructions. C <value> Search for values like energy or lifes in games. Cl List currently found trainer addresses. D[idxzs <[max diff]>] Deep trainer. i=new value must be larger, d=smaller, x = must be same, z = must be different, s = restart. W <address> <values[.x] separated by space> Write into Amiga memory. W <address> 'string' Write into Amiga memory. w <num> <address> <length> <R/W/I/F/C> [<value>[.x]] (read/write/opcode/freeze/mustchange). Add/remove memory watchpoints. wd [<0-1>] Enable illegal access logger. 1 = enable break. S <file> <addr> <n> Save a block of Amiga memory. s "<string>"/<values> [<addr>] [<length>] Search for string/bytes. T or Tt Show exec tasks and their PCs. Td,Tl,Tr,Ts,Ti,TO Show devices, libraries, resources, residents, interrupts, doslist. b Step to previous state capture position. M<a/b/s> <val> Enable or disable audio channels, bitplanes or sprites. sp <addr> [<addr2][<size>] Dump sprite information. di <mode> [<track>] Break on disk access. R=DMA read,W=write,RW=both,P=PIO. Also enables level 1 disk logging. did <log level> Enable disk logging. dj [<level bitmask>] Enable joystick/mouse input debugging. smc [<0-1>] Enable self-modifying code detector. 1 = enable break. dm Dump current address space map. v <vpos> [<hpos>] Show DMA data (accurate only in cycle-exact mode). v [-1 to -4] = enable visual DMA debugger. ?<value> Hex ($ and 0x)/Bin (%)/Dec (!) converter. x Close debugger. xx Switch between console and GUI debugger. mg <address> Memory dump starting at <address> in GUI. dg <address> Disassembly starting at <address> in GUI. q Quit the emulator. You don't want to use this command. |
11 July 2013, 21:27 | #4 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,573
|
UAE debugger is designed (if you can call it being "designed"..) for debugging programs that take over the system and it is not meant to be user friendly
f, w and t are the most important break point commands. |
12 July 2013, 12:37 | #5 |
Registered User
Join Date: Sep 2008
Location: Germany
Age: 49
Posts: 138
|
Have been working with the UAE debugger and I'm getting used to it. Here are my steps trying to solve serious problems (code which took over the system)
1. put a loop waiting for the left mousebutton right after the start of the code 2. put a string (dc.b. "[whatever]") near the location where I presume the faulty code 3. start the program, program stays in wait-loop 4. enter Shift-F12 starting the uae debugger 5. search for the string > s "[whatever] < in memory, at least one address should be found 6. disassembling the memory at given address, > d $xxxxxx < 7. searching for the spot where I want to have the breakpoint, setting the bp with > f $xxxxxx < 8. quit the uae debugger and continuing the emulation 9. hit the left mousebutton 10. when the program stops at the breakpoint I follow the program with > t < or > z < (tip, within a dbxx loop >z< completely handles the loop) 11. anything after this is more or less related to the error, usually I seach for wrong pointers or condition codes (a wrong test or branch maybe?) |
12 July 2013, 12:49 | #6 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,573
|
Much faster method to "find" your code is to have instruction like clr.w $100 before the code you need to debug and use memwatch point to break when $100 is accessed (for example "w 0 100 2")
|
13 July 2013, 00:04 | #7 |
Registered User
Join Date: Nov 2012
Location: GB
Posts: 32
|
pmc: I would prefer to use UAE's debugger as it'd be better for my Windows-based crossdev Notpad++/VASM way of doing things but MonAm is definitely an alternative option. Devpac is a really nice Amiga asm IDE. I used it for a bit before I decided on crossdev. Didn't use MonAm at the time but I had a little play around with it lastnight and, like you say, it works well when I give it a GenAm compiled binary.
Haven't tried it with one of my regular VASM compiled binaries yet, so I don't know if MonAm will have difficulty with VASM symbols, hunks, line numbers (for source level debugging), etc. I'm not sure if all that stuff (debug hunks,etc) is standard on Amiga - but VASM also has some Devpac compatibility options. I'll have play around with that a bit more and see if they work well together. I also had a quick look at BDebug (by Ralph Schmidt), which looks great. Can't say how well it works in use yet but it has a really nice Intuition interface (I noticed I could set BPs, etc. by clicking on mem addresses/labels, nice!) bippym: I needed the h++++ option that displays Apollo's post. Couldn't find it! Anyways, you're right, seems the help list really is all there is to it Appolo: That's great, Just what I needed to get me going. Thank you very much. I followed your steps for a simple program and they work well. From what Toni says, UAE's debbugger was never designed for "friendly" debugging - I thought maybe there was a bunch of functionality just not officially documented. But your steps may be all I ever need to debug my simple code anyway, so I think it could still be useful. Toni: You're right. w 0 100 2 removes the need for at least 3 of Appolo's steps. Nice tip, cheers! Last edited by bodhi; 13 July 2013 at 00:27. |
13 July 2013, 22:26 | #8 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
|
18 November 2017, 19:14 | #9 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
Is there any absolute address that you can use for this purpose, without risk?
|
18 November 2017, 20:48 | #10 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,374
|
$60 is the spurious interrupt vector. Never saw that activated... also if you don't have MMU a lot of zero page addresses are unused.
Oh and you can still write 0 in 0. |
18 November 2017, 21:05 | #11 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,437
|
If you feel uneasy writing to system vectors or memory addresses you haven't allocated, you could also include a word of allocated space in your program and write to that. Then, after the program starts, use the debugger to locate the address you use to write.
That should be safe in all cases. However, the examples above will also work so you could just use them. |
19 November 2017, 11:29 | #12 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
|
02 December 2017, 11:48 | #13 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,847
|
|
02 December 2017, 12:29 | #14 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,355
|
|
05 December 2017, 06:50 | #15 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,847
|
|
06 September 2020, 15:21 | #16 | ||
OctaMED Music Composer
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 672
|
Quote:
Quote:
It keeps freezing at every frame Thanks! Last edited by KONEY; 06 September 2020 at 16:31. |
||
06 September 2020, 16:39 | #17 |
Registered User
Join Date: Jan 2011
Location: -
Posts: 728
|
w 0 100 2 - Add to watchpoint #0
w 0 - Remove watchpoint #0 w 1 100 2 - Add to watchpoint #1 w 1 - Remove watchpoint #1 etc |
06 September 2020, 18:09 | #18 |
OctaMED Music Composer
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 672
|
perfect, thanks!
|
06 September 2020, 18:22 | #19 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,546
|
fi <opcode>is usually the best method to set a breakpoint for UAE in your code, if you select an opcode which appears nowhere else, like exg a7,a7= fi cf4f. This code would also have no effect on your program. |
06 September 2020, 20:10 | #20 |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
The watch points are better to use in my opinion because you can filter on the types of operation and the source of it (CPU, BLIITER channel, COPPER etc).
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Debugging my dodgy asm! | hypnoshock | Coders. Asm / Hardware | 5 | 01 May 2012 01:55 |
[REQ:ASM] Sprite collisions basics | jman | Coders. Tutorials | 5 | 03 September 2011 00:07 |
Amiga basics? | stefcep2 | support.Apps | 7 | 08 September 2010 04:02 |
some basics | diamond | request.UAE Wishlist | 1 | 26 March 2005 03:03 |
|
|