From patchwork Tue Oct 15 15:25:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serhei Makarov X-Patchwork-Id: 98959 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C812B3858023 for ; Tue, 15 Oct 2024 15:28:12 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) by sourceware.org (Postfix) with ESMTPS id 32CA03857C6A for ; Tue, 15 Oct 2024 15:27:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 32CA03857C6A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=serhei.io Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=serhei.io ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 32CA03857C6A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729006081; cv=none; b=IvlAaoMzF1LZeny0u1BP46X1MkrY/CMf6mUPu1xLu0eFpfowV7K/kyFPQN9Qf+5kvGLbg+0EB2ZvsHc229Z0N/WAlUbtdX+row3+7TpkgSz7jUTiI21JXyi3ypZ7UpLfcGfPmPwMfjxLMHafebIlu2FBm+iDE5L0OBO8b718wss= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729006081; c=relaxed/simple; bh=+oVASFsBKcT5miduCsVs5fZtp9e049STo3VftFMR8yg=; h=DKIM-Signature:DKIM-Signature:MIME-Version:Date:From:To: Message-Id:Subject; b=MVG5m1URyjoldUY84Tk86XNuPNOIOOSNJAwFs/M3PswdwSGNJ/NRNKNKiOFl84gD7DWxdOpu4qbG7h+h/m71KPlOhGo1xt2XUVVItPu9enNTOyvZiYu3GSbBWKMO/ljmWWyMFWXFdLpoT8ew2RwqOu4OKMgqiN9+FT0nHHxZ+V0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfout.phl.internal (Postfix) with ESMTP id 07D871380225 for ; Tue, 15 Oct 2024 11:27:56 -0400 (EDT) Received: from phl-imap-10 ([10.202.2.85]) by phl-compute-07.internal (MEProxy); Tue, 15 Oct 2024 11:27:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=serhei.io; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm2; t=1729006076; x=1729092476; bh=kCICL1PMAB X+NKJk3hpIRwFbfBFwPOBvmAITNTZlIOY=; b=HaFcw6EE6T/zKZ1EOmimED6eE2 MtmyU0E5KWpmtXnIusqn4LhDQ0y3tGf2fDjTmNqFOYi/hIiMl5hpxXrhgbht58dB FYp6IkEbsJOWOAlUXox5lLXm+CE/7NZDqOe5XXE5R3FTNHLnR5WPDzNbtxEUe0Hm c94PQfqUdIEouF1jIk6n5SqQYhcJfEAF0OKuPijRidtWKnRQ7sXyBwJCuzWI4f1M 4mYAREECFe+QtWMksE3cIn39YzDtq5XLkAvAD+hYZL0o3SAw++j3JrXWyDx2Dxf/ +Ct6RE9kdKiK7sy0IggAomZrpLrzicxzh5uqzyJXEkDuJ8xMoRv3sVRN1REA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1729006076; x=1729092476; bh=kCICL1PMABX+NKJk3hpIRwFbfBFw POBvmAITNTZlIOY=; b=ZlVIYJ0SQujNthwZMrL8w7sHNax+zASZ5TsARYRoyz01 ct/zXc2lLKtK7ET9wkmCvTLZ/COhmLQE15o+e9ZlIrVCwbTYQkaQgIAE/u5BAp1N KGrOISAQ+nI4k2OPtb37/NhMXDD1QASMv+UmYnoXUkDV84950ckewUwnPfNSIuqi /fngsoREXxOSaZ0XL1REtzMTq3lUnpomFOfLruMbxnOVyeeNtsJbrKC4K6XbTwfc hTtotCEuipKbMThb4dDdANP1cEXyEiHD1VKV89tv1ZFT5IlrK5y1eartqV1bRm2a 7+ytvUTtCb9i9v3UJBHJwe80h5g4ZgJTvr8Qdh9E+Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdegjedgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefoggffhf fvkffutgfgsehtjeertdertddtnecuhfhrohhmpedfufgvrhhhvghiucforghkrghrohhv fdcuoehsvghrhhgvihesshgvrhhhvghirdhioheqnecuggftrfgrthhtvghrnhepgeevve ehudeuudetleeuudefteekleefhedvjeefkeevtddvueeugeegvdevudeinecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgvrhhhvghisehsvg hrhhgvihdrihhopdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgt phhtthhopegvlhhfuhhtihhlshdquggvvhgvlhesshhouhhrtggvfigrrhgvrdhorhhg X-ME-Proxy: Feedback-ID: i572946fc:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id BCE9C3C0068; Tue, 15 Oct 2024 11:27:55 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 Date: Tue, 15 Oct 2024 11:25:04 -0400 From: "Serhei Makarov" To: elfutils-devel@sourceware.org Message-Id: <8db81b6e-f3ed-49c2-9302-421247bec92c@app.fastmail.com> Subject: [PATCH 2/4] eu-stacktrace: configury for initial version (x86/sysprof only) X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org Due to the x86-specific code in the initial version the configury has significant restrictions. If --enable-stacktrace is not explicitly provided, then eu-stacktrace will be disabled by default when x86 architecture or sysprof headers are absent. The way we test for x86 is a bit unusual. What we actually care about is that the register file provided by perf_events on the system is an x86 register file; this is done by checking that is Linux kernel arch/x86/include/uapi/asm/perf_regs.h. Once eu-stacktrace is properly portable across architectures, these grody checks can be simplified. * configure.ac: Add configure checks and conditionals for stacktrace tool. * src/Makefile.am: Add stacktrace tool conditional on ENABLE_STACKTRACE. Signed-off-by: Serhei Makarov --- configure.ac | 66 ++++++++++++++++++++++++++++++++++++++++++++++++- src/Makefile.am | 9 ++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 8f5901a2..1af1c708 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. dnl Configure input file for elfutils. -*-autoconf-*- dnl -dnl Copyright (C) 1996-2019 Red Hat, Inc. +dnl Copyright (C) 1996-2019, 2024 Red Hat, Inc. dnl Copyright (C) 2022, 2023 Mark J. Wielaard dnl dnl This file is part of elfutils. @@ -918,6 +918,69 @@ AC_ARG_ENABLE(debuginfod-ima-cert-path, AC_SUBST(DEBUGINFOD_IMA_CERT_PATH, $default_debuginfod_ima_cert_path) AC_CONFIG_FILES([config/profile.sh config/profile.csh config/profile.fish]) +# XXX Currently, eu-stacktrace can only work with sysprof/x86, hence: +AC_ARG_ENABLE([stacktrace],AS_HELP_STRING([--enable-stacktrace], [Enable eu-stacktrace]), + stacktrace_option_given=yes, + stacktrace_option_given=no) +# check for x86, or more precisely _ASM_X86_PERF_REGS_H +AS_IF([test "x$enable_stacktrace" != "xno"], [ + enable_stacktrace=no + AC_LANG([C]) + AC_CACHE_CHECK([for _ASM_X86_PERF_REGS_H], ac_cv_has_asm_x86_perf_regs_h, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +#include +#ifndef _ASM_X86_PERF_REGS_H +#error "_ASM_X86_PERF_REGS_H not found" +#endif +])], ac_cv_has_asm_x86_perf_regs_h=yes, ac_cv_has_asm_x86_perf_regs_h=no)]) + AS_IF([test "x$ac_cv_has_asm_x86_perf_regs_h" = xyes], [ + enable_stacktrace=yes + ]) + if test "x$enable_stacktrace" = "xno"; then + if test "x$stacktrace_option_given" = "xyes"; then + AC_MSG_ERROR([${program_prefix}stacktrace currently only supports x86, use --disable-stacktrace to disable.]) + else + AC_MSG_WARN([${program_prefix}stacktrace currently only supports x86, disabling by default on other architectures.]) + fi + fi +]) +# check for sysprof headers: +AS_IF([test "x$enable_stacktrace" != "xno"], [ + enable_stacktrace=no + AC_CACHE_CHECK([for sysprof-6/sysprof-capture-types.h], ac_cv_has_sysprof_6_headers, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include ]])], + ac_cv_has_sysprof_6_headers=yes, ac_cv_has_sysprof_6_headers=no)]) + AS_IF([test "x$ac_cv_has_sysprof_6_headers" = xyes], [ + AC_DEFINE(HAVE_SYSPROF_6_HEADERS) + enable_stacktrace=yes + ]) + AH_TEMPLATE([HAVE_SYSPROF_6_HEADERS], [Define to 1 if `sysprof-6/sysprof-capture-types.h` + is provided by the system, 0 otherwise.]) + AC_CACHE_CHECK([for sysprof-4/sysprof-capture-types.h], ac_cv_has_sysprof_4_headers, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include ]])], + ac_cv_has_sysprof_4_headers=yes, ac_cv_has_sysprof_4_headers=no)]) + AS_IF([test "x$ac_cv_has_sysprof_4_headers" = xyes], [ + AC_DEFINE(HAVE_SYSPROF_4_HEADERS) + enable_stacktrace=yes + ]) + AH_TEMPLATE([HAVE_SYSPROF_4_HEADERS], [Define to 1 if `sysprof-4/sysprof-capture-types.h` + is provided by the system, 0 otherwise.]) + if test "x$enable_stacktrace" = "xno"; then + if test "x$stacktrace_option_given" = "xyes"; then + AC_MSG_ERROR([sysprof headers for ${program_prefix}stacktrace not found, use --disable-stacktrace to disable.]) + else + AC_MSG_WARN([sysprof headers for ${program_prefix}stacktrace not found, disabling by default.]) + fi + fi +],[ +# If eu-stacktrace is disabled, also disable the automake conditionals: +ac_cv_has_sysprof_6_headers=no +ac_cv_has_sysprof_4_headers=no +]) +AM_CONDITIONAL([HAVE_SYSPROF_6_HEADERS],[test "x$ac_cv_has_sysprof_6_headers" = xyes]) +AM_CONDITIONAL([HAVE_SYSPROF_4_HEADERS],[test "x$ac_cv_has_sysprof_4_headers" = xyes]) +AM_CONDITIONAL([ENABLE_STACKTRACE],[test "x$enable_stacktrace" = "xyes"]) + AC_OUTPUT AC_MSG_NOTICE([ @@ -957,6 +1020,7 @@ AC_MSG_NOTICE([ Default DEBUGINFOD_URLS : ${default_debuginfod_urls} Debuginfod RPM sig checking : ${enable_debuginfod_ima_verification} Default DEBUGINFOD_IMA_CERT_PATH : ${default_debuginfod_ima_cert_path} + ${program_prefix}stacktrace support : ${enable_stacktrace} EXTRA TEST FEATURES (used with make check) have bunzip2 installed (required) : ${HAVE_BUNZIP2} diff --git a/src/Makefile.am b/src/Makefile.am index e0267d96..6bdf2dfb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to create Makefile.in ## -## Copyright (C) 1996-2014, 2016 Red Hat, Inc. +## Copyright (C) 1996-2014, 2016, 2024 Red Hat, Inc. ## This file is part of elfutils. ## ## This file is free software; you can redistribute it and/or modify @@ -31,6 +31,10 @@ bin_PROGRAMS = readelf nm size strip elflint findtextrel addr2line \ elfcmp objdump ranlib strings ar unstrip stack elfcompress \ elfclassify srcfiles +if ENABLE_STACKTRACE +bin_PROGRAMS += stacktrace +endif + noinst_LIBRARIES = libar.a libar_a_SOURCES = arlib.c arlib2.c arlib-argp.c @@ -94,6 +98,9 @@ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD) ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib) +if ENABLE_STACKTRACE +stacktrace_LDADD = $(libelf) $(libdw) $(libeu) $(argp_LDADD) +endif elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) elfclassify_LDADD = $(libelf) $(libdw) $(libeu) $(argp_LDADD) srcfiles_SOURCES = srcfiles.cxx