Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp995830lqo; Thu, 9 May 2024 01:18:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJAy9W+xv4btswBIccAvYrzCiOoULHS9OkgxUHtCTOLVNBumOhfWn99/xBKYnY3AiPbaA5YsB382bkw+cjHSKfExMG9uxsBbBWfphlZA== X-Google-Smtp-Source: AGHT+IG8mGdqc1gnFeqxU9MTOiDS7ev9rHDbuJESswTvtzjuqCB9VWhonrDwFg897//qPudJPrnT X-Received: by 2002:a05:620a:2990:b0:78d:5e64:4d5a with SMTP id af79cd13be357-792b26f3f44mr676953085a.38.1715242725826; Thu, 09 May 2024 01:18:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715242725; cv=pass; d=google.com; s=arc-20160816; b=TUWsNxz75oX57sMDDghqvBMcAkSLk8L62k+FdG/AeO9QZ7lTjFVjwup5nzCm+zhqsY Mxy8mP+HQzEhFfpQoqX2ZAZxTdTcXPbRlxYBid4ATT2YMftz6ZKYDlGM+ZFcgWehzkb8 VG/r8oIF7Ax/VniYtsAPCWlJBV22fzu1AXVkD8t4daRPZZB1D6uEY1PouzanBAr8myBQ TqUYVPKAssId97Ph8FNvxaHBVWMEpR3rRXD317XRpEBZJJpYj3EuZroj6gwXcnSqU+3o mV7BDdFqwBxu5E4xITJwxOreeaPH/+SyUZGMTOvJxsTV7g1y8weUinyrGQioC7ucuhRT aqoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=yU2z5WhSAQTqB93fjY3ukGXftN14kQ1DQjtcB3aeejE=; fh=jDum8ZwHU+yAQ4h3ArT2RpVKeuYcgphvmwl2A+O0iGI=; b=VFbiRhzSvG9NdEjmKAMZu6hR+bVsnI0++ajkUWINmQXyrIHAOpQBmRN8Ugb+HZY+l8 Xc1GeipCNaEf8R/1AT/6n0tQoXZLXZghCWBYjG3+11DnLe/ZJ0G1OrabBGQ+IUwBZvY8 YW9kdUHOYcYnC5W1zprTI0Lk4yQXX3lASHmVzHVbANt3B+ucL2bQds70t9TMT43yPU/t WXP3XphJWaGMW8E8CbvFasg2FC6d9AYts+MECTQ3gF3j2d1W3jabeM5AnweszggV+N2C ARVgT2H7Nc7adNA040QIEda/RWBoapoWb8AstWmZ+zjMb1DjxC50Jd3ydMUr6XlFktxq TJUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=e9lVmzlg; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-174276-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf38d113si77796185a.719.2024.05.09.01.18.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 01:18:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174276-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=e9lVmzlg; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-174276-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174276-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8BA681C21669 for ; Thu, 9 May 2024 08:18:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE0F814A622; Thu, 9 May 2024 08:18:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="e9lVmzlg" Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 701EF149E18 for ; Thu, 9 May 2024 08:18:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715242703; cv=none; b=o9WXVXzC5vEoyPqVUteoIWGwRsN39UV0gqXFuS2Rc9mK6g2k8sXF3JDzNswZUv5XCWsLx6mDZAEw1tS2suekLf7vRPNto3esHOB7O2Liij0sHcxRII1MKFkKk4YIARcT5rs9tknwY7vGy/0Zm+x3QGMOILQ+ss4He5TnVAsUHGY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715242703; c=relaxed/simple; bh=YWhSEjEbsm7333DuMdJ8QQbDQ8u2mmDpgmnCidre4OM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=nn1rkqrkLBaG1RWBGVZEQ5v8QgNlfgnHjAA5Vednwh+e5OgRKL9MahcX0RukpDAoEtkCPGlAHY3ihbs//FeJ9HF5B7tM2JPXspn30sAajZJ14j88O6+y+Xwvw1B7Le0v6gScfQiJ+cKvq2yxAemR0qdrKBQVuPgJsLgW1hRpnCk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=e9lVmzlg; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 59E95FF806; Thu, 9 May 2024 08:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1715242680; 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: in-reply-to:in-reply-to:references:references; bh=yU2z5WhSAQTqB93fjY3ukGXftN14kQ1DQjtcB3aeejE=; b=e9lVmzlgiGpIHxll1amJDGhf3cX7f9PaBNhtrjSNqgPDDiJuvQHgGEX4lJd8jWYBPnfPA8 uE7NNSoe0worlgTH3NhfRUBjcYBgbLFAJ7KjKJTCmxJvMUB4Dvpv+r+tE4w0vsysCX3IMd MRC6BxEpgVpZ+rF1j8ti1RrMJ23Xwd27oVJOIye6l0LX4iDfmyu4Wp4DTp9rCzduE99KSG AF00dSgs0r1qH19G7nhW2laO4jlv8a0QXu7zTqZxpNTshvKQDuUAwN8Pb4qnhfnAQaYpIC 1BPg030SV4fPPwyB5rQ+9vzkukcFWo3rbq5+7TLnDkcKBonSVBDseLn+Koj9Dg== From: Luca Ceresoli Date: Thu, 09 May 2024 10:17:21 +0200 Subject: [PATCH v2 1/3] scripts/decode_stacktrace.sh: remove find_module recursion and improve error reporting Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240509-decode_stacktrace-find_module-improvements-v2-1-887fb6d5acb9@bootlin.com> References: <20240509-decode_stacktrace-find_module-improvements-v2-0-887fb6d5acb9@bootlin.com> In-Reply-To: <20240509-decode_stacktrace-find_module-improvements-v2-0-887fb6d5acb9@bootlin.com> To: Konstantin Khlebnikov , Stephen Boyd , Sasha Levin , =?utf-8?q?Alexis_Lothor=C3=A9?= , Thomas Petazzoni , linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.13.0 X-GND-Sasl: luca.ceresoli@bootlin.com The find_module() function can fail for two reasons: * the module was not found * the module was found but without debugging info In both cases the user is reported the same error: WARNING! Modules path isn't set, but is needed to parse this symbol This is misleading in case the modules path is set correctly. find_module() is currently implemented as a recursive function based on global variables in order to check up to 4 different paths. This is not straightforward to read and even less to modify. Besides, the debuginfod code at the beginning of find_module() is executed identically every time the function is entered, i.e. up to 4 times per each module search due to recursion. To be able to improve error reporting, first rewrite the find_module() function to remove recursion. The new version of the function iterates over all the same (up to 4) paths as before and for each of them does the same checks as before. At the end of the iteration it is now able to print an appropriate error message, so that has been moved from the caller into find_module(). Finally, when the module is found but without debugging info, mention the two Kconfig variables one needs to set in order to have the needed debugging symbols. Reviewed-by: Stephen Boyd Signed-off-by: Luca Ceresoli --- scripts/decode_stacktrace.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index fa5be6f57b00..7f3fb5e82707 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -88,31 +88,32 @@ find_module() { fi fi - if [[ "$modpath" != "" ]] ; then - for fn in $(find "$modpath" -name "${module//_/[-_]}.ko*") ; do - if ${READELF} -WS "$fn" | grep -qwF .debug_line ; then - echo $fn - return - fi - done - return 1 - fi - - modpath=$(dirname "$vmlinux") - find_module && return - - if [[ $release == "" ]] ; then + if [ -z $release ] ; then release=$(gdb -ex 'print init_uts_ns.name.release' -ex 'quit' -quiet -batch "$vmlinux" 2>/dev/null | sed -n 's/\$1 = "\(.*\)".*/\1/p') fi + if [ -n "${release}" ] ; then + release_dirs="/usr/lib/debug/lib/modules/$release /lib/modules/$release" + fi - for dn in {/usr/lib/debug,}/lib/modules/$release ; do - if [ -e "$dn" ] ; then - modpath="$dn" - find_module && return + found_without_debug_info=false + for dir in "$modpath" "$(dirname "$vmlinux")" ${release_dirs}; do + if [ -n "${dir}" ] && [ -e "${dir}" ]; then + for fn in $(find "$dir" -name "${module//_/[-_]}.ko*") ; do + if ${READELF} -WS "$fn" | grep -qwF .debug_line ; then + echo $fn + return + fi + found_without_debug_info=true + done fi done - modpath="" + if [[ ${found_without_debug_info} == true ]]; then + echo "WARNING! No debugging info in module ${module}, rebuild with DEBUG_KERNEL and DEBUG_INFO" >&2 + else + echo "WARNING! Cannot find .ko for module ${module}, please pass a valid module path" >&2 + fi + return 1 } @@ -130,7 +131,6 @@ parse_symbol() { else local objfile=$(find_module) if [[ $objfile == "" ]] ; then - echo "WARNING! Modules path isn't set, but is needed to parse this symbol" >&2 return fi if [[ $aarray_support == true ]]; then -- 2.34.1