summaryrefslogtreecommitdiff
path: root/usr.bin/gcore
diff options
context:
space:
mode:
authorTycho Nightingale <tychon@FreeBSD.org>2017-03-30 18:21:36 +0000
committerTycho Nightingale <tychon@FreeBSD.org>2017-03-30 18:21:36 +0000
commit86be94fca32cba783d836da0200837f914d56cac (patch)
tree1a2ed8405fd580e6f366465bdd678a59a2155940 /usr.bin/gcore
parent1fb4382cb22e201435107888c19bb7fd1daa13e3 (diff)
downloadsrc-test2-86be94fca32cba783d836da0200837f914d56cac.tar.gz
src-test2-86be94fca32cba783d836da0200837f914d56cac.zip
Add support for capturing 'struct ptrace_lwpinfo' for signals
resulting in a process dumping core in the corefile. Also extend procstat to view select members of 'struct ptrace_lwpinfo' from the contents of the note. Sponsored by: Dell EMC Isilon
Notes
Notes: svn path=/head/; revision=316286
Diffstat (limited to 'usr.bin/gcore')
-rw-r--r--usr.bin/gcore/elfcore.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c
index 2a5a328d41ce..f32ff4270406 100644
--- a/usr.bin/gcore/elfcore.c
+++ b/usr.bin/gcore/elfcore.c
@@ -1,4 +1,5 @@
/*-
+ * Copyright (c) 2017 Dell EMC
* Copyright (c) 2007 Sandvine Incorporated
* Copyright (c) 1998 John D. Polstra
* All rights reserved.
@@ -102,6 +103,7 @@ static void *elf_note_fpregset(void *, size_t *);
static void *elf_note_prpsinfo(void *, size_t *);
static void *elf_note_prstatus(void *, size_t *);
static void *elf_note_thrmisc(void *, size_t *);
+static void *elf_note_ptlwpinfo(void *, size_t *);
#if defined(__i386__) || defined(__amd64__)
static void *elf_note_x86_xstate(void *, size_t *);
#endif
@@ -360,6 +362,7 @@ elf_putnotes(pid_t pid, struct sbuf *sb, size_t *sizep)
elf_putnote(NT_PRSTATUS, elf_note_prstatus, tids + i, sb);
elf_putnote(NT_FPREGSET, elf_note_fpregset, tids + i, sb);
elf_putnote(NT_THRMISC, elf_note_thrmisc, tids + i, sb);
+ elf_putnote(NT_PTLWPINFO, elf_note_ptlwpinfo, tids + i, sb);
#if defined(__i386__) || defined(__amd64__)
elf_putnote(NT_X86_XSTATE, elf_note_x86_xstate, tids + i, sb);
#endif
@@ -689,6 +692,24 @@ elf_note_thrmisc(void *arg, size_t *sizep)
return (thrmisc);
}
+static void *
+elf_note_ptlwpinfo(void *arg, size_t *sizep)
+{
+ lwpid_t tid;
+ void *p;
+
+ tid = *(lwpid_t *)arg;
+ p = calloc(1, sizeof(int) + sizeof(struct ptrace_lwpinfo));
+ if (p == NULL)
+ errx(1, "out of memory");
+ *(int *)p = sizeof(struct ptrace_lwpinfo);
+ ptrace(PT_LWPINFO, tid,
+ (char *)p + sizeof (int), sizeof(struct ptrace_lwpinfo));
+
+ *sizep = sizeof(int) + sizeof(struct ptrace_lwpinfo);
+ return (p);
+}
+
#if defined(__i386__) || defined(__amd64__)
static void *
elf_note_x86_xstate(void *arg, size_t *sizep)