shithub: riscv

Download patch

ref: 6cb7ba7ed5e515a7ae4a286c25f8adf13b01349a
parent: c9f5d14ea6948355e760bb55b281640a3ebbca55
author: cinap_lenrek <[email protected]>
date: Mon Feb 13 01:06:13 EST 2012

libmach: use correct kernel base, kprof: use kernel base from libmach (from applied/kprof patch)

--- a/sys/src/cmd/kprof.c
+++ b/sys/src/cmd/kprof.c
@@ -94,19 +94,25 @@
 		exits(0);
 	if (!textsym(&s, 0))
 		error(0, "no text symbols");
-	tbase = s.value & ~(mach->pgsize-1);	/* align down to page */
-	print("KTZERO %.8llux\n", tbase);
+
+	tbase = mach->kbase;
+	if(tbase != s.value & ~0xFFF)
+		print("warning: kbase %.8llux != tbase %.8llux\n",
+			tbase, s.value&~0xFFF);
+	print("KTZERO %.8llux PGSIZE %dKb\n", tbase, mach->pgsize/1024);
 	/*
 	 * Accumulate counts for each function
 	 */
 	cp = 0;
 	k = 0;
-	for (i = 0, j = (s.value-tbase)/PCRES+2; j < n; i++) {
+	for (i = 0, j = 2; j < n; i++) {
 		name = s.name;		/* save name */
 		if (!textsym(&s, i))	/* get next symbol */
 			break;
+		s.value -= tbase;
+		s.value /= PCRES;
 		sum = 0;
-		while (j < n && j*PCRES < s.value-tbase)
+		while (j < n && j < s.value)
 			sum += data[j++];
 		if (sum) {
 			cp = realloc(cp, (k+1)*sizeof(struct COUNTER));
--- a/sys/src/libmach/8.c
+++ b/sys/src/libmach/8.c
@@ -68,7 +68,7 @@
 	"setSB",	/* static base register name (bogus anyways) */
 	0,		/* static base register value */
 	0x1000,		/* page size */
-	0x80100000ULL,	/* kernel base */
+	0xF0100000ULL,	/* kernel base */
 	0xF0000000ULL,	/* kernel text mask */
 	0x7FFFFFFFULL,	/* user stack top */
 	1,		/* quantization of pc */