From nobody Wed Jul 06 11:03:59 2022 X-Original-To: dev-commits-src-branches@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 8186E1D009C8; Wed, 6 Jul 2022 11:04:00 +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 4LdGrH70DKz3NMD; Wed, 6 Jul 2022 11:03:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657105440; 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=+W7vYncHgQ09Ab0J9VTMlca2L3vjIZOAVwia6otVF9Q=; b=XBJVvBc85vm1XD0n6n8b9PKGxEyNWAmOyzvPNy9m34a9q4raJG8BU2l0MvHC1hWkB+friY xCTKkb7I8h5BEhWJYDrlsvpHddBF/9gNekn6K+x0a5/L7YzhBrNCXhqhI4T53oY74NUgcd jsxYqS1K4fUyeeaX7gCvA7IsenRaBzakGsiDhwHqcj7ghGEb7Im6Wk8UoxbQiI7wAfo3u0 J2J7bMo9QAB7Uu5ALHJT4eZFJG0HdsShtxwKFQ8FHKrvntw3VPAVvaLskxKTQQSIfYhdhx CN2dhJW3fCmz9nGGF9W7EWfzcWiPA941n6zxAuq+Z298WPhg+iDgyHrgyDFnxw== 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 9A985192C6; Wed, 6 Jul 2022 11:03:59 +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 266B3xTa096399; Wed, 6 Jul 2022 11:03:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 266B3xkI096398; Wed, 6 Jul 2022 11:03:59 GMT (envelope-from git) Date: Wed, 6 Jul 2022 11:03:59 GMT Message-Id: <202207061103.266B3xkI096398@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 1705937d854b - stable/13 - libsysdecode: Add method for decoding Linux signal names List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1705937d854bb71c58c2bd8777bd4a042726ccf3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657105440; 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=+W7vYncHgQ09Ab0J9VTMlca2L3vjIZOAVwia6otVF9Q=; b=UaUDClUtn7sMDlsN28u1l+QJD7fJQQuXWF4/ixKvgVEg8YxuhY+El6frl/dTPtJceazaIS wFX4jvoOIGiI+UjClaM5pZVOI6kbTSZ7wTKxAg+yOsJzASqkD0Itmuz5/WsqCIzIRQNnf4 XHEIGuwtnbgRewf+WdqxEmwplMw4CKpYG/esn2PVr9l5sD1b/3uu1PMsC/oC84KU0BmKR4 uzvKbR1up9kwcGaVtYdaHwzED6uh0d0Wkex4qtZfCGJz5WX1Y5xrof4/WN0+GHRNerEhYx Bua5FKZ4v06UOMmIsW7OoyPpxWFixYWIVhkV8JT3Mz8/u3IY9W8gvFpCdwlgTg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657105440; a=rsa-sha256; cv=none; b=VEntmjqox4kp2JbMF1o1grfLWZ01ziQeSyXFbeWRHTPnUn9DLABrg3DCs367eprWEuem98 SttzC4TqjRvjX8tAo2PB8lH//WF05U3cWCwJFtkdui4Cc6Sx+B3zJeZ+/q/79qnE9SradP 9srRm7uTGmDCWNlyWvYi27IF+XDaDDvwn6xPiUlmUjFVmpsR5/ov8l1ndNlXE7VxYqQW06 uW7lRFXLY88fbNWl1NvmGU/GaMm0jZY2du3u6ltV5euedfpkiA1hz89bnmUTTYrWl6weB5 ZQbS+H3KqaDsciNwsQz8a4gHoCHRHzh3FQiTReaMbVduHR2jjkhOFmqend6MkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=1705937d854bb71c58c2bd8777bd4a042726ccf3 commit 1705937d854bb71c58c2bd8777bd4a042726ccf3 Author: Dmitry Chagin AuthorDate: 2022-06-22 11:00:05 +0000 Commit: Dmitry Chagin CommitDate: 2022-07-06 11:02:12 +0000 libsysdecode: Add method for decoding Linux signal names Reviewed by: jhb Differential revision: https://reviews.freebsd.org/D35215 MFC after: 2 weeks (cherry picked from commit f85848fc61752c3823825cdee34104a640d7f6e0) --- lib/libsysdecode/linux.c | 79 ++++++++++++++++++++++++++++++++++++++++++++ lib/libsysdecode/sysdecode.h | 1 + 2 files changed, 80 insertions(+) diff --git a/lib/libsysdecode/linux.c b/lib/libsysdecode/linux.c index 68b6c3fa9472..6a8d30207835 100644 --- a/lib/libsysdecode/linux.c +++ b/lib/libsysdecode/linux.c @@ -66,6 +66,76 @@ __FBSDID("$FreeBSD$"); #undef TABLE_ENTRY #undef TABLE_END +static const char *linux_signames[] = { + [LINUX_SIGHUP] = "SIGHUP", + [LINUX_SIGINT] = "SIGINT", + [LINUX_SIGQUIT] = "SIGQUIT", + [LINUX_SIGILL] = "SIGILL", + [LINUX_SIGTRAP] = "SIGTRAP", + [LINUX_SIGABRT] = "SIGABRT", + [LINUX_SIGBUS] = "SIGBUS", + [LINUX_SIGFPE] = "SIGFPE", + [LINUX_SIGKILL] = "SIGKILL", + [LINUX_SIGUSR1] = "SIGUSR1", + [LINUX_SIGSEGV] = "SIGSEGV", + [LINUX_SIGUSR2] = "SIGUSR2", + [LINUX_SIGPIPE] = "SIGPIPE", + [LINUX_SIGALRM] = "SIGALRM", + [LINUX_SIGTERM] = "SIGTERM", + [LINUX_SIGSTKFLT] = "SIGSTKFLT", + [LINUX_SIGCHLD] = "SIGCHLD", + [LINUX_SIGCONT] = "SIGCONT", + [LINUX_SIGSTOP] = "SIGSTOP", + [LINUX_SIGTSTP] = "SIGTSTP", + [LINUX_SIGTTIN] = "SIGTTIN", + [LINUX_SIGTTOU] = "SIGTTOU", + [LINUX_SIGURG] = "SIGURG", + [LINUX_SIGXCPU] = "SIGXCPU", + [LINUX_SIGXFSZ] = "SIGXFSZ", + [LINUX_SIGVTALRM] = "SIGVTALRM", + [LINUX_SIGPROF] = "SIGPROF", + [LINUX_SIGWINCH] = "SIGWINCH", + [LINUX_SIGIO] = "SIGIO", + [LINUX_SIGPWR] = "SIGPWR", + [LINUX_SIGSYS] = "SIGSYS", + + [LINUX_SIGRTMIN] = "SIGCANCEL", + [LINUX_SIGRTMIN + 1] = "SIGSETXID", + [LINUX_SIGRTMIN + 2] = "SIGRT2", + [LINUX_SIGRTMIN + 3] = "SIGRT3", + [LINUX_SIGRTMIN + 4] = "SIGRT4", + [LINUX_SIGRTMIN + 5] = "SIGRT5", + [LINUX_SIGRTMIN + 6] = "SIGRT6", + [LINUX_SIGRTMIN + 7] = "SIGRT7", + [LINUX_SIGRTMIN + 8] = "SIGRT8", + [LINUX_SIGRTMIN + 9] = "SIGRT9", + [LINUX_SIGRTMIN + 10] = "SIGRT10", + [LINUX_SIGRTMIN + 11] = "SIGRT11", + [LINUX_SIGRTMIN + 12] = "SIGRT12", + [LINUX_SIGRTMIN + 13] = "SIGRT13", + [LINUX_SIGRTMIN + 14] = "SIGRT14", + [LINUX_SIGRTMIN + 15] = "SIGRT15", + [LINUX_SIGRTMIN + 16] = "SIGRT16", + [LINUX_SIGRTMIN + 17] = "SIGRT17", + [LINUX_SIGRTMIN + 18] = "SIGRT18", + [LINUX_SIGRTMIN + 19] = "SIGRT19", + [LINUX_SIGRTMIN + 20] = "SIGRT20", + [LINUX_SIGRTMIN + 21] = "SIGRT21", + [LINUX_SIGRTMIN + 22] = "SIGRT22", + [LINUX_SIGRTMIN + 23] = "SIGRT23", + [LINUX_SIGRTMIN + 24] = "SIGRT24", + [LINUX_SIGRTMIN + 25] = "SIGRT25", + [LINUX_SIGRTMIN + 26] = "SIGRT26", + [LINUX_SIGRTMIN + 27] = "SIGRT27", + [LINUX_SIGRTMIN + 28] = "SIGRT28", + [LINUX_SIGRTMIN + 29] = "SIGRT29", + [LINUX_SIGRTMIN + 30] = "SIGRT30", + [LINUX_SIGRTMIN + 31] = "SIGRT31", + [LINUX_SIGRTMIN + 32] = "SIGRTMAX", +}; +_Static_assert(nitems(linux_signames) == LINUX_SIGRTMAX + 1, + "invalid entries count in linux_signames"); + void sysdecode_linux_clockid(FILE *fp, clockid_t which) { @@ -104,3 +174,12 @@ pidp: pid = LINUX_CPUCLOCK_ID(which); fprintf(fp, "(%d)", pid); } + +const char * +sysdecode_linux_signal(int sig) +{ + + if ((unsigned)sig < nitems(linux_signames)) + return (linux_signames[sig]); + return (NULL); +} diff --git a/lib/libsysdecode/sysdecode.h b/lib/libsysdecode/sysdecode.h index b1e7d1fb526c..6c1b0bd2d226 100644 --- a/lib/libsysdecode/sysdecode.h +++ b/lib/libsysdecode/sysdecode.h @@ -141,6 +141,7 @@ bool sysdecode_shmflags(FILE *_fp, int _flags, int *_rem); #define SYSDECODE_HAVE_LINUX void sysdecode_linux_clockid(FILE *_fp, clockid_t _which); +const char *sysdecode_linux_signal(int _sig); #endif /* __i386__ || __amd64__ || __aarch64__ */