Subject: debugging early startup code (was: [PATCH] Fixup for Amigas with memory at 0x200000)
To: Ilpo Ruotsalainen <lonewolf@iki.fi>
From: Aymeric Vincent <Aymeric.Vincent@labri.fr>
List: port-amiga
Date: 01/10/2003 20:35:54
Ilpo Ruotsalainen <lonewolf@iki.fi> writes:

> Any tips on how to debug the early startup code on amiga? I'm quite new
> to NetBSD (and non-AmigaOS stuff on amiga in general) and I have
> absolutely no ideas how to debug this.
> 
> (Perhaps I could write AGA registers to change the screen color, hmm
> that might work...)

You can define DEBUG_KERNEL_START to show some nice colors at each
important step of the process, but it has never proved very useful in
my experience.

Here is how I do (with two machines, to be able to lookup things
concurrently):

- boot a kernel that fails
- reboot and "Boot With No Startup Sequence"
- launch a memory monitor (I use AsmOne with the "h" command)

- on the other machine (or before) lookup the address of "tmpstk",
  adjust it to get its physical address. On my machine which has a
  chunk of memory at 0x200000, it's 0x200000 + tmpstk
- move up the stack, write down the addresses which appear in it, look
  them up on the other machine with nm, objdump -d, or whatever.
- guess what was going on when the kernel crashed by iterating the
  previous point.

If the kernel goes far enough, it switches stack to
*proc0paddr + USPACE, so you have to look backtraces from here.

That's a lot of fun. This is how I found the uninitialized bug in
amiga_config_found(). :-/

Have fun! ;)
 Aymeric