Subject: port-alpha/32502: profiling (ticks) is broken on alpha
To: None <port-alpha-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: Anders Hjalmarsson <hjalmar@hjalmar.to>
List: netbsd-bugs
Date: 01/11/2006 22:55:00
>Number:         32502
>Category:       port-alpha
>Synopsis:       profiling (ticks) is broken on alpha
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-alpha-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 11 22:55:00 +0000 2006
>Originator:     Anders Hjalmarsson
>Release:        NetBSD 3.99.15
>Organization:
	unorganized
>Environment:
System: NetBSD as2.hjalmar.to 3.99.15 NetBSD 3.99.15 (BIGBOX-$Revision: 1.10 $) #8: Mon Jan 9 22:06:48 CET 2006 hjalmar@as2.hjalmar.to:/var/obj/alpha/compile/BIGBOX alpha
Architecture: alpha
Machine: alpha
>Description:
	Profiling does not work on alpha, no time is accumulated.

	This is because kern/subr_prof.c:addupc_task is never called.
	need_proftick correctly sets P_OWEUPC in p_flag, but
	trap checks for P_OWEUPC in l_flag instead.

>How-To-Repeat:
	Compile and link a program with -pg, run it, check gprof output

>Fix:

Index: sys/arch/alpha/alpha/trap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/alpha/trap.c,v
retrieving revision 1.102
diff -u -r1.102 trap.c
--- sys/arch/alpha/alpha/trap.c	11 Dec 2005 12:16:10 -0000	1.102
+++ sys/arch/alpha/alpha/trap.c	11 Jan 2006 22:44:54 -0000
@@ -689,8 +689,8 @@
 	uvmexp.softs++;
 	l->l_md.md_tf = framep;
 
-	if (l->l_flag & P_OWEUPC) {
-		l->l_flag &= ~P_OWEUPC;
+	if (l->l_proc->p_flag & P_OWEUPC) {
+		l->l_proc->p_flag &= ~P_OWEUPC;
 		ADDUPROF(l->l_proc);
 	}