All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hollis Blanchard <hollis@penguinppc.org>
To: grub-devel@gnu.org
Subject: [patch] some debug statements
Date: Thu, 23 Jun 2005 21:12:30 -0500	[thread overview]
Message-ID: <20050624021230.GA32209@miracle> (raw)

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  <hollis@penguinppc.org>

	* 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);



                 reply	other threads:[~2005-06-24  2:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050624021230.GA32209@miracle \
    --to=hollis@penguinppc.org \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.