linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Cort Dougan <cort@fsmlabs.com>
To: linuxppc-dev@lists.linuxppc.org
Subject: [PATCH] vs. latest linuxppc_2_4_devel and linuxppc_2_4 for xmon
Date: Wed, 12 Feb 2003 13:31:20 -0700	[thread overview]
Message-ID: <20030212203120.GC12358@host109.fsmlabs.com> (raw)


Allows printing of pgtables in xmon.  Mighty useful in both trees.

diff -Nru a/arch/ppc/xmon/xmon.c b/arch/ppc/xmon/xmon.c
--- a/arch/ppc/xmon/xmon.c	Wed Feb 12 13:28:51 2003
+++ b/arch/ppc/xmon/xmon.c	Wed Feb 12 13:28:51 2003
@@ -138,6 +138,7 @@
   ms	set a block of memory\n\
   md	compare two blocks of memory\n\
   M	print System.map\n\
+  p	print page tables for current\n\
   r	print registers\n\
   S	print special registers\n\
   t	print backtrace\n\
@@ -432,6 +433,9 @@
 		case 'M':
 			print_sysmap();
 			break;
+		case 'p':
+			print_pgtables();
+			break;
 		case 'S':
 			super_regs();
 			break;
@@ -689,6 +693,78 @@
 	}
 }

+
+/*
+ * Lookup page mappings for the current task and for the
+ * kernel and print them all.  -- Cort <cort@fsmlabs.com>
+ */
+static void
+print_pgtables(void)
+{
+	int i = 0;/* j = 0;*/
+	pgd_t *pgd;
+	pmd_t *pmd;
+	/*pte_t *pte;*/
+	struct mm_struct *mm = current->mm;
+
+	if (!mm) {
+		printf("!current->mm, using init_task\n");
+		mm = &init_mm;
+	}
+
+	printf("current %08x %s/%d\n", current, current->comm,
+	       current->pid);
+
+	printf("User mappings: ");
+again:
+	printf("->mm %08x ->context %08x\n",
+	       (ulong)mm, (ulong)mm->context);
+
+	if ( !mm->pgd ) {
+		printf("!mm->pgd\n");
+		return;
+	}
+
+	pgd = mm->pgd;
+
+	printf("PGD/PMD table spans %08x -> %08x\n",
+	       (ulong)mm->pgd,
+	       (ulong)mm->pgd+(PTRS_PER_PGD*sizeof(pgd_t)));
+
+
+	for ( i = 0 ; i < PTRS_PER_PGD; i++, pgd++ ) {
+		/* pmd is the same as the PGD on PPC -- Cort */
+		pmd = pmd_offset(pgd,0);
+
+		/* if there is a valid PMD (table of 1024 PTE's) */
+		if ( !pmd_none(*pmd) ) {
+			printf(" PMD %08x maps %08x,%08x (pmd_val %08x)\n",
+			       pgd, i*PGDIR_SIZE,
+			       (i*PGDIR_SIZE)+(PGDIR_SIZE-1),
+			       pmd_val(*pmd));
+#if 0
+			pte = (pte_t *)pmd_page(*pmd);
+
+			for ( j = 0; j < PTRS_PER_PTE; j++,pte++ )
+			{
+				if ( !pte || !pte_none(*pte) )
+					continue;
+				printf("   PTE %08x maps %08x,%08x\n",
+				       pte, (i*PGDIR_SIZE) + (j*PAGE_SIZE),
+				       (i*PGDIR_SIZE) + (j*PAGE_SIZE) + (PAGE_SIZE-1));
+			}
+#endif
+		}
+	}
+
+	/* do the swapper_pg_dir */
+	if ( mm != &init_mm ) {
+		printf("Kernel mappings: ");
+		mm = &init_mm;
+		goto again;
+	}
+}
+
 static void
 backtrace(struct pt_regs *excp)
 {

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

             reply	other threads:[~2003-02-12 20:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-12 20:31 Cort Dougan [this message]
2003-02-13  0:03 ` [PATCH] vs. latest linuxppc_2_4_devel and linuxppc_2_4 for xmon Paul Mackerras

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=20030212203120.GC12358@host109.fsmlabs.com \
    --to=cort@fsmlabs.com \
    --cc=linuxppc-dev@lists.linuxppc.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).