From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7E88EA0C4D; Mon, 6 Sep 2021 06:20:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F7AE410F0; Mon, 6 Sep 2021 06:19:58 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 6EA9E410EA for ; Mon, 6 Sep 2021 06:19:57 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 185Le8nD010416; Sun, 5 Sep 2021 21:19:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=M+pMJhlvapl4RbnlYzIvjj/zHga3oTOjf0jjUl+f0yg=; b=c5zzPJa0LECX6kGzM5JfDQYsXOwK2uGaHpKUchoZuZrtS9aba8HUM3O3c74skf2jWd7v Av0KDToWqn9ZtJbOn9gcP9c6/I1qOBbx4Nrk0iCwEY2dtQo/gj/jxvYXAQi3jKP49sr1 xO1SemLixYx1oaRHkhMqWCI+HrAhsM6DzzqlpbzA4uWWLFyPz43LlOI0H91l6/o/Oasm aYfkRzUlfoZAGf6ECQR8Jd3Y7715H6sdVueP9e5XNRIh5GApnFKjFTNVMLFGvNQhJHaS Ia1OHjPPt5kbnHYPtK1SQLOEDgsFIBi3w0fQ2aujwhlVx71fAtznxpRl4f876emtgQM6 QQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3aw2sp140a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 05 Sep 2021 21:19:53 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 5 Sep 2021 21:19:51 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Sun, 5 Sep 2021 21:19:51 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 80F8A3F7065; Sun, 5 Sep 2021 21:19:47 -0700 (PDT) From: To: , Aaron Conole , Michael Santana , Bruce Richardson CC: , , , , , , , , , , Jerin Jacob Date: Mon, 6 Sep 2021 09:47:29 +0530 Message-ID: <20210906041732.1019743-4-jerinj@marvell.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210906041732.1019743-1-jerinj@marvell.com> References: <20210817032723.3997054-1-jerinj@marvell.com> <20210906041732.1019743-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 5-6DAQYvl4nHP_DQ-Yuyvv005aEEx69y X-Proofpoint-ORIG-GUID: 5-6DAQYvl4nHP_DQ-Yuyvv005aEEx69y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-06_01,2021-09-03_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH v3 3/6] eal: support libunwind based backtrace X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jerin Jacob adding optional libwind library dependency to DPDK for enhanced backtrace based on ucontext. Signed-off-by: Jerin Jacob --- .github/workflows/build.yml | 2 +- .travis.yml | 2 +- config/meson.build | 8 +++++++ lib/eal/unix/eal_oops.c | 45 +++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 151641e6fa..de985776ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -93,7 +93,7 @@ jobs: run: sudo apt install -y ccache libnuma-dev python3-setuptools python3-wheel python3-pip python3-pyelftools ninja-build libbsd-dev libpcap-dev libibverbs-dev libcrypto++-dev libfdt-dev libjansson-dev - libarchive-dev + libarchive-dev libunwind-dev - name: Install libabigail build dependencies if no cache is available if: env.ABI_CHECKS == 'true' && steps.libabigail-cache.outputs.cache-hit != 'true' run: sudo apt install -y autoconf automake libtool pkg-config libxml2-dev diff --git a/.travis.yml b/.travis.yml index 4bb5bf629e..cfb8931d3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ addons: packages: &required_packages - [libnuma-dev, python3-setuptools, python3-wheel, python3-pip, python3-pyelftools, ninja-build] - [libbsd-dev, libpcap-dev, libibverbs-dev, libcrypto++-dev, libfdt-dev, libjansson-dev] - - [libarchive-dev] + - [libarchive-dev, libunwind-dev] _aarch64_packages: &aarch64_packages - *required_packages diff --git a/config/meson.build b/config/meson.build index 3b5966ec2f..7f4dd52bc5 100644 --- a/config/meson.build +++ b/config/meson.build @@ -237,6 +237,14 @@ if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false dpdk_extra_ldflags += '-latomic' endif +# check for libunwind +unwind_dep = dependency('libunwind', required: false, method: 'pkg-config') +if unwind_dep.found() and cc.has_header('libunwind.h', dependencies: unwind_dep) + dpdk_conf.set('RTE_USE_LIBUNWIND', 1) + add_project_link_arguments('-lunwind', language: 'c') + dpdk_extra_ldflags += '-lunwind' +endif + # add -include rte_config to cflags add_project_arguments('-include', 'rte_config.h', language: 'c') diff --git a/lib/eal/unix/eal_oops.c b/lib/eal/unix/eal_oops.c index a480437f23..9c2d9d99d9 100644 --- a/lib/eal/unix/eal_oops.c +++ b/lib/eal/unix/eal_oops.c @@ -28,11 +28,56 @@ struct oops_signal { static struct oops_signal signals_db[RTE_DIM(oops_signals)]; +#if defined(RTE_USE_LIBUNWIND) + +#define BACKTRACE_DEPTH 256 +#define UNW_LOCAL_ONLY +#include + +static void +back_trace_dump(ucontext_t *context) +{ + unw_cursor_t cursor; + unw_word_t ip, off; + int rc, level = 0; + char name[256]; + + if (context == NULL) + return; + + rc = unw_init_local(&cursor, (unw_context_t *)context); + if (rc < 0) + goto fail; + + for (;;) { + rc = unw_get_reg(&cursor, UNW_REG_IP, &ip); + if (rc < 0) + goto fail; + rc = unw_get_proc_name(&cursor, name, sizeof(name), &off); + if (rc == 0) + oops_print("[%16p]: %s()+0x%" PRIx64 "\n", (void *)ip, + name, (uint64_t)off); + else + oops_print("[%16p]: \n", (void *)ip); + rc = unw_step(&cursor); + if (rc <= 0 || ++level >= BACKTRACE_DEPTH) + break; + } + return; +fail: + oops_print("libunwind call failed %s\n", unw_strerror(rc)); +} + +#else + static void back_trace_dump(ucontext_t *context) { RTE_SET_USED(context); } + +#endif + static void siginfo_dump(int sig, siginfo_t *info) { -- 2.33.0