From nobody Wed Jun 22 11:40:58 2022 X-Original-To: dev-commits-src-all@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 2BE0887152B; Wed, 22 Jun 2022 11:40:59 +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 4LShKQ6DCdz4sMW; Wed, 22 Jun 2022 11:40:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655898059; 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=l0SrJHS76EijzWqxfNz1XEz+1mKFv191jZt/bCiUMoE=; b=yWW5RtMsx/G3VKeRGoecn3+fMovZPsHb075v9kJBUfeIrzV73kcsw20ksWx7SEIMyKVLQ9 0IcNgc7QJrnoGkZAab4xMN731J/seWfa6y60QQAtOGpqVZLd+qexaBC/kDAzbo/jYVXqVx lxBsszW4PYyp6ed4IkuQFm+6FCT4vNqBtKpYgyyfv5jVno67XdVZ2aukkVfUzMI9ShIX0j 04DbGLe4sKMX23R93KP9mnC2J9IMfb4plKezgUFUTaGUN7g4HIEdsY0u5t3uRo2wPZHN+F 6nVDjT3VtN5q1kIfW70W1fMZiq5wyzz0k57LcC48O7AgpvpeiraBT9v3efYmJQ== 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 A8CF32578C; Wed, 22 Jun 2022 11:40:58 +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 25MBewpH023634; Wed, 22 Jun 2022 11:40:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25MBewhn023633; Wed, 22 Jun 2022 11:40:58 GMT (envelope-from git) Date: Wed, 22 Jun 2022 11:40:58 GMT Message-Id: <202206221140.25MBewhn023633@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: f85848fc6175 - main - libsysdecode: Add method for decoding Linux signal names List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: f85848fc61752c3823825cdee34104a640d7f6e0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655898059; 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=l0SrJHS76EijzWqxfNz1XEz+1mKFv191jZt/bCiUMoE=; b=sHM93U1Be6i7R9gWqOwjYAAQWe5OLxrqxGKBzKHnqiXAIp9NS1zn4Z4nx1XBWmFqrrLsgM t3C3nrnEI1HOTCi1z8+8Xbosx0O1WVDCMMamh0NBKE2Bxkf1zenhBunzI6b6HQeiRx/WNo 4+mcdo2ecCRmIQ6tFrGuFhXW6MrjT2VjWjUeNgJGmKcwBMCXTSgz3c3bVoi8Ngy7GCndU1 vqox6JQgN+5UJTrwCLCTMMgkZ84lzwOMDjW3lSgWTaTJyjLzcjWh4qjzz+xcdeT41H4dCw OzSI5k6nyMQE/L+035YqeQ2Fl6VWVcR7z8B2r+5k1mP6Br3oo/T7CvXSACOr7A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655898059; a=rsa-sha256; cv=none; b=DTJJhv4r6m8wI9sxLfB6kYFc0Sfin4VHnolsvb8FKR0CX5yvkGgb2qXdKXq3/H/1FH0Bq1 LUunO14LDnLO/ArgJi0FYS6ELf+jb0HNSTNRwwOFCVxF40OvY2zlyXDy0DwFMNkb0x2iU7 aTLVIp6Zm5XzdZPeu1HHiG2xp/jNvxR+AmZBU4+yDHn5kHfFs8cNWNT/N6xO87Zqumq0u1 itpxhISqzRrw4kAayINVufS7ml7H//0O0mHWW19SJXmje9+3Q2lFJV5j4Yjz9MZUxPDkVN LaFrC+jq3PnZ0q8TNfufvgyO5Q8eKhLXQj5crrGeCa1gC3TRg5XPH0qUVgq+Lg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=f85848fc61752c3823825cdee34104a640d7f6e0 commit f85848fc61752c3823825cdee34104a640d7f6e0 Author: Dmitry Chagin AuthorDate: 2022-06-22 11:00:05 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-22 11:00:05 +0000 libsysdecode: Add method for decoding Linux signal names Reviewed by: jhb Differential revision: https://reviews.freebsd.org/D35215 MFC after: 2 weeks --- 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 683d344ac0ca..e386ae0466a9 100644 --- a/lib/libsysdecode/sysdecode.h +++ b/lib/libsysdecode/sysdecode.h @@ -139,6 +139,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__ */