From owner-svn-src-all@freebsd.org Mon Jul 18 15:14:25 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 39D74B9D7D9; Mon, 18 Jul 2016 15:14:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 157B61489; Mon, 18 Jul 2016 15:14:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6IFEOcl093032; Mon, 18 Jul 2016 15:14:24 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6IFEOFp093029; Mon, 18 Jul 2016 15:14:24 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201607181514.u6IFEOFp093029@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 18 Jul 2016 15:14:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303002 - in head: sys/kern sys/sys usr.bin/gcore X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Mon, 18 Jul 2016 15:14:25 -0000 Author: jhb Date: Mon Jul 18 15:14:23 2016 New Revision: 303002 URL: https://svnweb.freebsd.org/changeset/base/303002 Log: Include process IDs in core dumps. When threads were added to the kernel, the pr_pid member of the NT_PRSTATUS note was repurposed to store LWP IDs instead of process IDs. However, the process ID was no longer recorded in core dumps. This change adds a pr_pid field to prpsinfo (NT_PRSINFO). Rather than bumping the prpsinfo version number, note parsers can use the note's payload size to determine if pr_pid is present. Reviewed by: kib, emaste (older version) MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D7117 Modified: head/sys/kern/imgact_elf.c head/sys/sys/procfs.h head/usr.bin/gcore/elfcore.c Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Mon Jul 18 14:53:55 2016 (r303001) +++ head/sys/kern/imgact_elf.c Mon Jul 18 15:14:23 2016 (r303002) @@ -1874,6 +1874,7 @@ __elfN(note_prpsinfo)(void *arg, struct *cp = ' '; } } + psinfo->pr_pid = p->p_pid; sbuf_bcat(sb, psinfo, sizeof(*psinfo)); free(psinfo, M_TEMP); } Modified: head/sys/sys/procfs.h ============================================================================== --- head/sys/sys/procfs.h Mon Jul 18 14:53:55 2016 (r303001) +++ head/sys/sys/procfs.h Mon Jul 18 15:14:23 2016 (r303002) @@ -49,7 +49,10 @@ typedef struct fpreg fpregset_t; /* * The parenthsized numbers like (1) indicate the minimum version number - * for which each element exists in the structure. + * for which each element exists in the structure. The version number is + * not bumped when adding new fields to the end, only if the meaning of + * an existing field changes. Additional fields are annotated as (1a), + * (1b), etc. to indicate the groupings of additions. */ #define PRSTATUS_VERSION 1 /* Current version of prstatus_t */ @@ -61,7 +64,7 @@ typedef struct prstatus { size_t pr_fpregsetsz; /* sizeof(fpregset_t) (1) */ int pr_osreldate; /* Kernel version (1) */ int pr_cursig; /* Current signal (1) */ - pid_t pr_pid; /* Process ID (1) */ + pid_t pr_pid; /* LWP (Thread) ID (1) */ gregset_t pr_reg; /* General purpose registers (1) */ } prstatus_t; @@ -78,6 +81,7 @@ typedef struct prpsinfo { size_t pr_psinfosz; /* sizeof(prpsinfo_t) (1) */ char pr_fname[PRFNAMESZ+1]; /* Command name, null terminated (1) */ char pr_psargs[PRARGSZ+1]; /* Arguments, null terminated (1) */ + pid_t pr_pid; /* Process ID (1a) */ } prpsinfo_t; typedef struct thrmisc { @@ -104,6 +108,7 @@ typedef struct prpsinfo32 { uint32_t pr_psinfosz; char pr_fname[PRFNAMESZ+1]; char pr_psargs[PRARGSZ+1]; + int32_t pr_pid; } prpsinfo32_t; struct thrmisc32 { Modified: head/usr.bin/gcore/elfcore.c ============================================================================== --- head/usr.bin/gcore/elfcore.c Mon Jul 18 14:53:55 2016 (r303001) +++ head/usr.bin/gcore/elfcore.c Mon Jul 18 15:14:23 2016 (r303002) @@ -586,6 +586,7 @@ elf_note_prpsinfo(void *arg, size_t *siz } else strlcpy(psinfo->pr_psargs, kip.ki_comm, sizeof(psinfo->pr_psargs)); + psinfo->pr_pid = pid; *sizep = sizeof(*psinfo); return (psinfo);