Date: Fri, 28 Oct 2016 03:54:20 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r308009 - in stable: 10/sys/kern 10/sys/sys 10/usr.bin/gcore 11/sys/kern 11/sys/sys 11/usr.bin/gcore Message-ID: <201610280354.u9S3sKwC028308@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Fri Oct 28 03:54:19 2016 New Revision: 308009 URL: https://svnweb.freebsd.org/changeset/base/308009 Log: MFC 303002: 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. Modified: stable/10/sys/kern/imgact_elf.c stable/10/sys/sys/procfs.h stable/10/usr.bin/gcore/elfcore.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/kern/imgact_elf.c stable/11/sys/sys/procfs.h stable/11/usr.bin/gcore/elfcore.c Directory Properties: stable/11/ (props changed) Modified: stable/10/sys/kern/imgact_elf.c ============================================================================== --- stable/10/sys/kern/imgact_elf.c Fri Oct 28 02:10:07 2016 (r308008) +++ stable/10/sys/kern/imgact_elf.c Fri Oct 28 03:54:19 2016 (r308009) @@ -1835,6 +1835,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: stable/10/sys/sys/procfs.h ============================================================================== --- stable/10/sys/sys/procfs.h Fri Oct 28 02:10:07 2016 (r308008) +++ stable/10/sys/sys/procfs.h Fri Oct 28 03:54:19 2016 (r308009) @@ -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: stable/10/usr.bin/gcore/elfcore.c ============================================================================== --- stable/10/usr.bin/gcore/elfcore.c Fri Oct 28 02:10:07 2016 (r308008) +++ stable/10/usr.bin/gcore/elfcore.c Fri Oct 28 03:54:19 2016 (r308009) @@ -580,6 +580,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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610280354.u9S3sKwC028308>