From owner-svn-src-all@FreeBSD.ORG Fri Oct 8 00:44:53 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BBEB210656B6; Fri, 8 Oct 2010 00:44:53 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8E75B8FC1E; Fri, 8 Oct 2010 00:44:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o980iraD072761; Fri, 8 Oct 2010 00:44:53 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o980irC5072756; Fri, 8 Oct 2010 00:44:53 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201010080044.o980irC5072756@svn.freebsd.org> From: Ed Maste Date: Fri, 8 Oct 2010 00:44:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213536 - in head: bin/ps sys/kern sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 00:44:53 -0000 Author: emaste Date: Fri Oct 8 00:44:53 2010 New Revision: 213536 URL: http://svn.freebsd.org/changeset/base/213536 Log: Make a thread's address available via the kern proc sysctl, just like the process address. Add "tdaddr" keyword to ps(1) to display this thread address. Distilled from Sandvine's patch set by Mark Johnston. Modified: head/bin/ps/keyword.c head/bin/ps/ps.1 head/sys/kern/kern_proc.c head/sys/sys/user.h Modified: head/bin/ps/keyword.c ============================================================================== --- head/bin/ps/keyword.c Thu Oct 7 21:56:10 2010 (r213535) +++ head/bin/ps/keyword.c Fri Oct 8 00:44:53 2010 (r213536) @@ -187,6 +187,8 @@ static VAR var[] = { UINT, UIDFMT, 0}, {"svuid", "SVUID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_svuid), UINT, UIDFMT, 0}, + {"tdaddr", "TDADDR", NULL, 0, kvar, NULL, sizeof(void *) * 2, + KOFF(ki_tdaddr), KPTR, "lx", 0}, {"tdev", "TDEV", NULL, 0, tdev, NULL, 5, 0, CHAR, NULL, 0}, {"tdnam", "TDNAM", NULL, LJUST, tdnam, NULL, COMMLEN, 0, CHAR, NULL, 0}, {"time", "TIME", NULL, USER, cputime, NULL, 9, 0, CHAR, NULL, 0}, Modified: head/bin/ps/ps.1 ============================================================================== --- head/bin/ps/ps.1 Thu Oct 7 21:56:10 2010 (r213535) +++ head/bin/ps/ps.1 Fri Oct 8 00:44:53 2010 (r213536) @@ -591,6 +591,8 @@ symbolic process state (alias saved gid from a setgid executable .It Cm svuid saved UID from a setuid executable +.It Cm tdaddr +thread address .It Cm tdev control terminal device number .It Cm time Modified: head/sys/kern/kern_proc.c ============================================================================== --- head/sys/kern/kern_proc.c Thu Oct 7 21:56:10 2010 (r213535) +++ head/sys/kern/kern_proc.c Fri Oct 8 00:44:53 2010 (r213536) @@ -842,6 +842,7 @@ fill_kinfo_thread(struct thread *td, str struct proc *p; p = td->td_proc; + kp->ki_tdaddr = td; PROC_LOCK_ASSERT(p, MA_OWNED); thread_lock(td); Modified: head/sys/sys/user.h ============================================================================== --- head/sys/sys/user.h Thu Oct 7 21:56:10 2010 (r213535) +++ head/sys/sys/user.h Fri Oct 8 00:44:53 2010 (r213536) @@ -85,7 +85,7 @@ */ #define KI_NSPARE_INT 9 #define KI_NSPARE_LONG 12 -#define KI_NSPARE_PTR 7 +#define KI_NSPARE_PTR 6 #ifndef _KERNEL #ifndef KINFO_PROC_SIZE @@ -188,6 +188,7 @@ struct kinfo_proc { struct pcb *ki_pcb; /* kernel virtual addr of pcb */ void *ki_kstack; /* kernel virtual addr of stack */ void *ki_udata; /* User convenience pointer */ + struct thread *ki_tdaddr; /* address of thread */ /* * When adding new variables, take space for pointers from the * front of ki_spareptrs, and longs from the end of ki_sparelongs.