From nobody Thu Jun 30 17:06:35 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BC9678AD2A2; Thu, 30 Jun 2022 17:06:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LYl9R3k6Bz3sxR; Thu, 30 Jun 2022 17:06:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656608795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WZISySdFsKiv7NtmAwjcGlKk+DDeTo0EgigOuRW5gVk=; b=uasAg4YRsVGuLaUnratvoEIMdXCmtKfLPJyW6oLe/ugHhKDzxAw6nfxAA/gkjrCELbTOgk 6nmeXPk45VHKqdBUj/kf/OYqwkBaDfcpc6eq70XVdX03W9B6fh8EGrVaF8LsB5fUrozFs0 5NE+q7v2t95ZA3DuWRxmeqzRMZcMiWocorfgh0a85hmkmqKl00PZ4UAYAGS/V9VWPlE5Mv lAU2DqMTg9NVWiPDktjxswrYDFBvCywU4Fq5sVfGfA6FHctgoHgMnksYJufWCVKbS2/U0f eCWbixNOTZuVVut0UoZWu5GKIhxgVnEEGtd4Vu7CXsW5QQKfVTXGBWTHyKWitA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3336021DE; Thu, 30 Jun 2022 17:06:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25UH6ZFh083566; Thu, 30 Jun 2022 17:06:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25UH6ZAu083565; Thu, 30 Jun 2022 17:06:35 GMT (envelope-from git) Date: Thu, 30 Jun 2022 17:06:35 GMT Message-Id: <202206301706.25UH6ZAu083565@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: d95657a1a758 - main - gcore: Use PT_GETREGSET for NT_THRMISC and NT_PTLWPINFO. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d95657a1a758e8d993a0eb92259f8c860a309207 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656608795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WZISySdFsKiv7NtmAwjcGlKk+DDeTo0EgigOuRW5gVk=; b=STyhB1f/qonZ9VjZLj2AGTqJP106h5lTCg10P9KsVI3SHwbgOyMwBQwLC6wYkNXYvQfVkk dPwLqBVZHqbuyrHBO4WywlOzq/K+cP0rPzlKVFNjkMW1o4fEIX5T1/joB8q/cK4h2MP/7D 7za5Wx5CHBJJrB2q7jP+dwpwstarAKHH6RR4Y8KWO/fUH1j9yHVVxvtYbzL4xd3sNBH/Sk LdE4ge3nnpqEPnPUBLRlcmFDd/39/bi8T/jcRyg5AoRv9XA67tbvT+yIyBlxBPdKh/gAvF t9Au6QAZhbTjfv3ICZqPqbBziACDN5rmdrMtEQpDckA6mc0S4L3pR+MxdiRd6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656608795; a=rsa-sha256; cv=none; b=EPgy48uKGGEh7jr+6nBJEvs6SQsDuoWNvIGJ0jgFoBn26n00CiuWDgzfHD6tdQipt7dBC0 OTMYXwWsyvYvCyQ3FisLbljD7Kf4JmSa5Hc5S79ZXOelZKVlHHnd/3Qn1VEXsBGPHc7beB egP83hqodR5uuJmEvpoMh/CC2JulrcpW6oK1D1wW09Tkowc/v8cx9BPjdJCXLSLmo7BLDz GYWcz50nHb//TjgJMeZxFoNvD7WxPjJiUdCUfZm2HbEW0+eGqhPMlS1ON9hIpFEOr6ndEq IRSTmT9Jf1QEtenGPrr8KppjZnzj1ehG8Kfn+RoGn9lJMqx3F1qe1OVK29eKQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d95657a1a758e8d993a0eb92259f8c860a309207 commit d95657a1a758e8d993a0eb92259f8c860a309207 Author: John Baldwin AuthorDate: 2022-06-30 17:04:19 +0000 Commit: John Baldwin CommitDate: 2022-06-30 17:05: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 --- 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)