diff options
author | jhb <jhb@FreeBSD.org> | 2016-10-06 21:17:18 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2016-10-06 21:17:18 +0000 |
commit | db8336b3b5dc7d45eade8e5b892602873e104a69 (patch) | |
tree | e76287760ee0e51cdcfc5cec24ab7fdff59167c7 /usr.bin/gcore | |
parent | a59a05611ac01b8ce4be7b584a6df90b50179c27 (diff) | |
download | FreeBSD-src-db8336b3b5dc7d45eade8e5b892602873e104a69.zip FreeBSD-src-db8336b3b5dc7d45eade8e5b892602873e104a69.tar.gz |
MFC 302859: Include command line arguments in core dump process info.
Fill in pr_psargs in the NT_PRSINFO ELF core dump note with command
line arguments.
Diffstat (limited to 'usr.bin/gcore')
-rw-r--r-- | usr.bin/gcore/elfcore.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c index 98c9024..6493688 100644 --- a/usr.bin/gcore/elfcore.c +++ b/usr.bin/gcore/elfcore.c @@ -548,6 +548,7 @@ readmap(pid_t pid) static void * elf_note_prpsinfo(void *arg, size_t *sizep) { + char *cp, *end; pid_t pid; elfcore_prpsinfo_t *psinfo; struct kinfo_proc kip; @@ -571,7 +572,20 @@ elf_note_prpsinfo(void *arg, size_t *sizep) if (kip.ki_pid != pid) err(1, "kern.proc.pid.%u", pid); strlcpy(psinfo->pr_fname, kip.ki_comm, sizeof(psinfo->pr_fname)); - strlcpy(psinfo->pr_psargs, psinfo->pr_fname, sizeof(psinfo->pr_psargs)); + name[2] = KERN_PROC_ARGS; + len = sizeof(psinfo->pr_psargs) - 1; + if (sysctl(name, 4, psinfo->pr_psargs, &len, NULL, 0) == 0 && len > 0) { + cp = psinfo->pr_psargs; + end = cp + len - 1; + for (;;) { + cp = memchr(cp, '\0', end - cp); + if (cp == NULL) + break; + *cp = ' '; + } + } else + strlcpy(psinfo->pr_psargs, kip.ki_comm, + sizeof(psinfo->pr_psargs)); *sizep = sizeof(*psinfo); return (psinfo); |