Date: Wed, 13 Jul 2022 16:47:49 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 6ab064ac064f - stable/13 - gcore: Use PT_GETREGSET for NT_THRMISC and NT_PTLWPINFO. Message-ID: <202207131647.26DGln0k052454@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=6ab064ac064f7b8efcfccba656c56438ac7fcb96 commit 6ab064ac064f7b8efcfccba656c56438ac7fcb96 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2022-06-30 17:04:19 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2022-07-13 16:25:02 +0000 gcore: Use PT_GETREGSET for NT_THRMISC and NT_PTLWPINFO. This avoids the need for dealing with converting lwpinfo for alternate ABIs in gcore itself. Reviewed by: markj MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D35667 (cherry picked from commit d95657a1a758e8d993a0eb92259f8c860a309207) --- usr.bin/gcore/elf32core.c | 38 ---------------------------------- usr.bin/gcore/elfcore.c | 52 ++--------------------------------------------- 2 files changed, 2 insertions(+), 88 deletions(-) diff --git a/usr.bin/gcore/elf32core.c b/usr.bin/gcore/elf32core.c index 98e2408c4aa9..29fb7d3608b4 100644 --- a/usr.bin/gcore/elf32core.c +++ b/usr.bin/gcore/elf32core.c @@ -12,41 +12,3 @@ #define ELFCORE_COMPAT_32 1 #include "elfcore.c" -static void -elf_convert_siginfo(struct siginfo32 *sid, siginfo_t *sis) -{ - - bzero(sid, sizeof(*sid)); - sid->si_signo = sis->si_signo; - sid->si_errno = sis->si_errno; - sid->si_code = sis->si_code; - sid->si_pid = sis->si_pid; - sid->si_uid = sis->si_uid; - sid->si_status = sis->si_status; - sid->si_addr = (uintptr_t)sis->si_addr; -#if _BYTE_ORDER == _BIG_ENDIAN - if (sis->si_value.sival_int == 0) - sid->si_value.sival_ptr = (uintptr_t)sis->si_value.sival_ptr; - else -#endif - sid->si_value.sival_int = sis->si_value.sival_int; - sid->si_timerid = sis->si_timerid; - sid->si_overrun = sis->si_overrun; -} - -static void -elf_convert_lwpinfo(struct ptrace_lwpinfo32 *pld, struct ptrace_lwpinfo *pls) -{ - - pld->pl_lwpid = pls->pl_lwpid; - pld->pl_event = pls->pl_event; - pld->pl_flags = pls->pl_flags; - pld->pl_sigmask = pls->pl_sigmask; - pld->pl_siglist = pls->pl_siglist; - elf_convert_siginfo(&pld->pl_siginfo, &pls->pl_siginfo); - memcpy(pld->pl_tdname, pls->pl_tdname, sizeof(pld->pl_tdname)); - pld->pl_child_pid = pls->pl_child_pid; - pld->pl_syscall_code = pls->pl_syscall_code; - pld->pl_syscall_narg = pls->pl_syscall_narg; -} - diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c index 8a6fdb642aeb..b01adb9a73b4 100644 --- a/usr.bin/gcore/elfcore.c +++ b/usr.bin/gcore/elfcore.c @@ -85,13 +85,8 @@ struct sseg_closure { #ifdef ELFCORE_COMPAT_32 typedef struct prpsinfo32 elfcore_prpsinfo_t; -typedef struct ptrace_lwpinfo32 elfcore_lwpinfo_t; -static void elf_convert_lwpinfo(struct ptrace_lwpinfo32 *pld, - struct ptrace_lwpinfo *pls); #else typedef prpsinfo_t elfcore_prpsinfo_t; -typedef struct ptrace_lwpinfo elfcore_lwpinfo_t; -#define elf_convert_lwpinfo(d,s) *d = *s #endif typedef void* (*notefunc_t)(void *, size_t *); @@ -102,8 +97,6 @@ static void each_dumpable_segment(struct map_entry *, segment_callback, void *closure); static void elf_detach(void); /* atexit() handler. */ static void *elf_note_prpsinfo(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 @@ -366,8 +359,8 @@ elf_putnotes(pid_t pid, struct sbuf *sb, size_t *sizep) for (i = 0; i < threads; ++i) { elf_putregnote(NT_PRSTATUS, tids[i], sb); elf_putregnote(NT_FPREGSET, tids[i], sb); - elf_putnote(NT_THRMISC, elf_note_thrmisc, tids + i, sb); - elf_putnote(NT_PTLWPINFO, elf_note_ptlwpinfo, tids + i, sb); + elf_putregnote(NT_THRMISC, tids[i], sb); + elf_putregnote(NT_PTLWPINFO, tids[i], sb); #if defined(__aarch64__) || defined(__arm__) elf_putregnote(NT_ARM_TLS, tids[i], sb); #endif @@ -682,47 +675,6 @@ elf_note_prpsinfo(void *arg, size_t *sizep) return (psinfo); } -static void * -elf_note_thrmisc(void *arg, size_t *sizep) -{ - lwpid_t tid; - struct ptrace_lwpinfo lwpinfo; - thrmisc_t *thrmisc; - - tid = *(lwpid_t *)arg; - thrmisc = calloc(1, sizeof(*thrmisc)); - if (thrmisc == NULL) - errx(1, "out of memory"); - ptrace(PT_LWPINFO, tid, (void *)&lwpinfo, - sizeof(lwpinfo)); - memset(&thrmisc->_pad, 0, sizeof(thrmisc->_pad)); - strcpy(thrmisc->pr_tname, lwpinfo.pl_tdname); - - *sizep = sizeof(*thrmisc); - return (thrmisc); -} - -static void * -elf_note_ptlwpinfo(void *arg, size_t *sizep) -{ - lwpid_t tid; - elfcore_lwpinfo_t *elf_info; - struct ptrace_lwpinfo lwpinfo; - void *p; - - tid = *(lwpid_t *)arg; - p = calloc(1, sizeof(int) + sizeof(elfcore_lwpinfo_t)); - if (p == NULL) - errx(1, "out of memory"); - *(int *)p = sizeof(elfcore_lwpinfo_t); - elf_info = (void *)((int *)p + 1); - ptrace(PT_LWPINFO, tid, (void *)&lwpinfo, sizeof(lwpinfo)); - elf_convert_lwpinfo(elf_info, &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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207131647.26DGln0k052454>