From nobody Fri Jul 28 09:10:48 2023 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 4RC2152FFQz4pcN6; Fri, 28 Jul 2023 09:10:49 +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 4RC2151bckz3mrW; Fri, 28 Jul 2023 09:10:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690535449; 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=JdJqXALNKuwhTSjXmGcORWidFV3qVk5dhWv6V5QhrTg=; b=JeIK347BzHkRNU7s4Xwx5F33/TTns1liiAN+N+nhBWNy7Jrcua4Ep3fg5iRd64DueeMX55 vFXQA1/BagaIw+q4oA5Jn5zWfndNvmkaeNwz/yqVA3O7CJYfz77OWt7ynXKjikqJD97/P7 TExrdsyDoHoO/FJ/UiFhlJ52QCvmlDBcPCgtyWXd4aa9oTLA93nPlSoEFJddECav917nYU X74liqDFAMTtDEvOciuxAIcLxppyL8JCzP+LrUeegpD0vOvZwVTf3W8HIvbBdwxZKLrTTm /Axt32B7gnKUK6E0TRvwSUOGJbDnyYcnGBrkxyZd4dIdMo4pSoWHU20EfNdMgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690535449; 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=JdJqXALNKuwhTSjXmGcORWidFV3qVk5dhWv6V5QhrTg=; b=o+lk60myJ3lvFUQLBAAUfzS0ysjsmQExkVD93NbBR8vzXx73862V7fS0p9T/QScW0h7atk IS7rC3sQzdfW78hDwz0U2YY/6UtUdwdKVyXl19vD8V4TUX2bUIJKtXXOCbzsMjTCkAgNl5 +5tfqrNBxLAzKa2XCEISpVoUDyvE09qvuxBiWaSsajimvdD7sdOSV9NgxHngwYX/5O+Jhr 44TNJyUdYOGTBL/QUx3Rkd0jTQMw2qASa8aCgV7JeDbwbBe4BKjOJsYOppnVELKGnPBlzC bnT616vhJSS75LxAry8mb5uOhjaeKP82mhVoPWuGiOhLYdSou+CuyOVcDMFyzQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690535449; a=rsa-sha256; cv=none; b=pzQVZ4JAWjbjRHKrNCuC0q/D0i4d6m7m3BkMyyus3aVJ+IQu122YDemsdyxWokawgIt0xA xSDFmKUV0TpbXibUhSVUcMFyl6uNct1eiDyY0l4+SFV3yO4gUnijpM+5OUYPv7WMYXlliz ElkXMssvwr+/H70N3N2mTbuN03teS2obb/MKquPBP+BLDpAA0vSi8/KHHEVgDD8OYuqTza PPzhjOIhP+9nDZganOpfOjCSAhxyvHiCoUecmQ25GPPllHv1vlaU14y02bUC9bbHnps1jO TSPp/ykGSEGnwujSvbfdqLvOC3VYSbHzAWo082vQNK2UJHJ+U/uPbY9g+3ICUA== 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 4RC2150ZcNzlNs; Fri, 28 Jul 2023 09:10:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36S9Am92073019; Fri, 28 Jul 2023 09:10:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36S9Am5C073018; Fri, 28 Jul 2023 09:10:48 GMT (envelope-from git) Date: Fri, 28 Jul 2023 09:10:48 GMT Message-Id: <202307280910.36S9Am5C073018@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: df1ea5887326 - main - tests: Test libexecinfo backtrace call througth signal trampoline 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: df1ea5887326103f0cc1445ab42fce528b474030 Auto-Submitted: auto-generated The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=df1ea5887326103f0cc1445ab42fce528b474030 commit df1ea5887326103f0cc1445ab42fce528b474030 Author: Dmitry Chagin AuthorDate: 2023-07-28 09:10:27 +0000 Commit: Dmitry Chagin CommitDate: 2023-07-28 09:10:27 +0000 tests: Test libexecinfo backtrace call througth signal trampoline It should fails on Aarch64 until https://reviews.llvm.org/D155066 is not merged. Reviewed by: Differential Revision: https://reviews.freebsd.org/D41129 --- lib/libexecinfo/tests/Makefile | 3 ++ lib/libexecinfo/tests/sigtramp_test.c | 75 +++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/lib/libexecinfo/tests/Makefile b/lib/libexecinfo/tests/Makefile index da34964c5005..7b90029fe354 100644 --- a/lib/libexecinfo/tests/Makefile +++ b/lib/libexecinfo/tests/Makefile @@ -14,7 +14,10 @@ STRIP= # so that doesn't seem useful. NETBSD_ATF_TESTS_C+= backtrace_test +ATF_TESTS_C+= sigtramp_test + LIBADD.backtrace_test+= execinfo +LIBADD.sigtramp_test+= execinfo .include diff --git a/lib/libexecinfo/tests/sigtramp_test.c b/lib/libexecinfo/tests/sigtramp_test.c new file mode 100644 index 000000000000..cd3b3cc418de --- /dev/null +++ b/lib/libexecinfo/tests/sigtramp_test.c @@ -0,0 +1,75 @@ +/*- + * Copyright (c) 2023 Dmitry Chagin + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include +#include +#include +#include + +#include + +#define BT_FUNCTIONS 10 + +void handler(int); + +__noinline void +handler(int signum __unused) +{ + void *addresses[BT_FUNCTIONS]; + char **symbols; + size_t n, i, match; + + n = backtrace(addresses, nitems(addresses)); + ATF_REQUIRE(n > 1); + symbols = backtrace_symbols(addresses, n); + ATF_REQUIRE(symbols != NULL); + + match = -1; + for (i = 0; i < n; i++) { + printf("%zu: %p, %s\n", i, addresses[i], symbols[i]); + if (strstr(symbols[i], " 0); + printf("match at %zu, symbols %zu\n", match, n); + +} + +ATF_TC_WITHOUT_HEAD(test_backtrace_sigtramp); +ATF_TC_BODY(test_backtrace_sigtramp, tc) +{ + struct sigaction act; + pid_t child; + int status; + + memset(&act, 0, sizeof(act)); + act.sa_handler = handler; + sigemptyset(&act.sa_mask); + sigaction(SIGUSR1, &act, NULL); + + child = fork(); + ATF_REQUIRE(child != -1); + + if (child == 0) { + kill(getppid(), SIGUSR1); + _exit(0); + } else + wait(&status); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, test_backtrace_sigtramp); + + return (atf_no_error()); +}