From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1DldvA-0004uC-Ep for mharc-grub-devel@gnu.org; Thu, 23 Jun 2005 22:27:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Dldun-0004gs-PR for grub-devel@gnu.org; Thu, 23 Jun 2005 22:27:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DlduV-0004Om-RZ for grub-devel@gnu.org; Thu, 23 Jun 2005 22:27:32 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DlduV-00045d-CH for grub-devel@gnu.org; Thu, 23 Jun 2005 22:27:15 -0400 Received: from [207.69.195.66] (helo=pop-canoe.atl.sa.earthlink.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DldsD-0004Vh-Gf for grub-devel@gnu.org; Thu, 23 Jun 2005 22:24:55 -0400 Received: from user-0vvde2g.cable.mindspring.com ([63.246.184.80] helo=miracle) by pop-canoe.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) id 1Dldoi-0005Ms-00 for grub-devel@gnu.org; Thu, 23 Jun 2005 22:21:16 -0400 Received: from hollis by miracle with local (Exim 3.36 #1 (Debian)) id 1DldgF-0008O7-00 for ; Thu, 23 Jun 2005 21:12:31 -0500 Date: Thu, 23 Jun 2005 21:12:30 -0500 To: grub-devel@gnu.org Message-ID: <20050624021230.GA32209@miracle> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040907i From: Hollis Blanchard Subject: [patch] some debug statements X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2005 02:27:36 -0000 This patch adds some useful debug statements I've been accumulating. It uses the following debug categories: disk, mem, loader. I've already found the dprintf infrastructure to be quite useful, albeit a little hard to read with all the file paths and line numbers being output... ;) I hope that as other people successfully debug other areas (like "partition"), they will add more dprintf statements to facilitate future remote debugging, because you know we're going to have a lot of it. :) If this is acceptable I will check it in. -Hollis 2005-06-23 Hollis Blanchard * disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_open): dprintf the device path and resulting ihandle. (grub_ofdisk_close): dprintf the ihandle being closed. (grub_ofdisk_read): dprintf function parameters. * kern/mm.c (grub_mm_init_region): Likewise. * loader/powerpc/ieee1275/linux.c (grub_linux_boot): dprintf the Linux entry point, initrd address and size, and boot arguments. (grub_rescue_cmd_linux): dprintf each ELF segment's address and size before loading into memory. (grub_rescue_cmd_initrd): dprintf the initrd's address and size before loading into memory. Index: disk/powerpc/ieee1275/ofdisk.c =================================================================== RCS file: /cvsroot/grub/grub2/disk/powerpc/ieee1275/ofdisk.c,v retrieving revision 1.9 diff -u -p -w -r1.9 ofdisk.c --- disk/powerpc/ieee1275/ofdisk.c 1 May 2005 03:45:35 -0000 1.9 +++ disk/powerpc/ieee1275/ofdisk.c 24 Jun 2005 01:54:31 -0000 @@ -63,6 +63,8 @@ grub_ofdisk_open (const char *name, grub if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0)) grub_strcat (devpath, ":0"); + grub_dprintf ("disk", "Opening `%s'.\n", devpath); + grub_ieee1275_open (devpath, &dev_ihandle); if (! dev_ihandle) { @@ -70,6 +72,8 @@ grub_ofdisk_open (const char *name, grub goto fail; } + grub_dprintf ("disk", "Opened `%s' as handle 0x%x.\n", devpath, dev_ihandle); + if (grub_ieee1275_finddevice (devpath, &dev)) { grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Can't read device properties"); @@ -112,6 +116,8 @@ grub_ofdisk_open (const char *name, grub static void grub_ofdisk_close (grub_disk_t disk) { + grub_dprintf ("disk", "Closing handle 0x%x.\n", + (grub_ieee1275_ihandle_t) disk->data); grub_ieee1275_close ((grub_ieee1275_ihandle_t) disk->data); } @@ -123,6 +129,10 @@ grub_ofdisk_read (grub_disk_t disk, unsi int actual; unsigned long long pos; + grub_dprintf ("disk", + "Reading handle 0x%x: sector 0x%lx, size 0x%lx, buf %p.\n", + (grub_ieee1275_ihandle_t) disk->data, sector, size, buf); + pos = (unsigned long long) sector * 512UL; grub_ieee1275_seek ((grub_ieee1275_ihandle_t) disk->data, (int) (pos >> 32), Index: kern/mm.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/mm.c,v retrieving revision 1.10 diff -u -p -w -r1.10 mm.c --- kern/mm.c 23 Jun 2005 08:12:19 -0000 1.10 +++ kern/mm.c 24 Jun 2005 01:54:31 -0000 @@ -96,9 +96,7 @@ grub_mm_init_region (void *addr, grub_si grub_mm_header_t h; grub_mm_region_t r, *p, q; -#if 0 - grub_printf ("%s:%d: addr=%p, size=%u\n", __FILE__, __LINE__, addr, size); -#endif + grub_dprintf ("mem", "addr=%p, size=%u\n", addr, size); /* If this region is too small, ignore it. */ if (size < GRUB_MM_ALIGN * 2) Index: loader/powerpc/ieee1275/linux.c =================================================================== RCS file: /cvsroot/grub/grub2/loader/powerpc/ieee1275/linux.c,v retrieving revision 1.7 diff -u -p -w -r1.7 linux.c --- loader/powerpc/ieee1275/linux.c 21 Jun 2005 02:33:51 -0000 1.7 +++ loader/powerpc/ieee1275/linux.c 24 Jun 2005 01:54:31 -0000 @@ -53,6 +53,12 @@ grub_linux_boot (void) grub_ieee1275_set_property (grub_ieee1275_chosen, "bootargs", linux_args, grub_strlen (linux_args) + 1, &actual); + grub_dprintf ("loader", "entry point: 0x%x\n", linux_addr); + grub_dprintf ("loader", "initrd at: 0x%x, size 0x%x\n", initrd_addr, + initrd_size); + grub_dprintf ("loader", "/chosen/bootargs: %s\n", linux_args); + grub_dprintf ("loader", "jumping to Linux...\n"); + /* Boot the kernel. */ linuxmain = (kernel_entry_t) linux_addr; linuxmain ((void *) initrd_addr, initrd_size, grub_ieee1275_entry_fn, 0, 0); @@ -185,13 +191,18 @@ grub_rescue_cmd_linux (int argc, char *a if (phdr->p_type == PT_LOAD) { + void *segment_addr = ((char *) entry) + offset; + if (grub_file_seek (file, phdr->p_offset) == -1) { grub_error (GRUB_ERR_BAD_OS, "Invalid offset in program header"); goto fail; } - if (grub_file_read (file, (void *) (((char *) entry) + offset) , phdr->p_filesz) + grub_dprintf ("loader", "Loading segment %d at %p, size 0x%x\n", i, + segment_addr, phdr->p_filesz); + + if (grub_file_read (file, segment_addr, phdr->p_filesz) != (grub_ssize_t) phdr->p_filesz) goto fail; @@ -272,6 +283,8 @@ grub_rescue_cmd_initrd (int argc, char * goto fail; } + grub_dprintf ("loader", "Loading initrd at 0x%x, size 0x%x\n", addr, size); + if (grub_file_read (file, (void *) addr, size) != size) { grub_ieee1275_release (addr, size);