Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp788094lqd; Wed, 24 Apr 2024 17:53:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVaatGPSgrWO9674VIhwqzIkhvWrkh17vHwOmmIaIS7dJZPT3602eKHlLrkaQa8W1hLz1Vq3ZBfMiOb7/Gl46vf3uvymBCWKN1SiiZHcQ== X-Google-Smtp-Source: AGHT+IGoIRIitQyXDutUi418Qd9Ypy0iBJ3s+gxOci5GbSM2faKVi4bVx5ksIvuqxtr1HXQB/hvY X-Received: by 2002:a05:690c:6a09:b0:618:7f3c:cbac with SMTP id ih9-20020a05690c6a0900b006187f3ccbacmr4575663ywb.31.1714006386269; Wed, 24 Apr 2024 17:53:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714006386; cv=pass; d=google.com; s=arc-20160816; b=ZwStxgsp/VL1/VGL20RPqv7l8tT80Tx13fCCob1DfPFyjhN9dHzrX9Ox25FA/foirM yLB+tSMcciNqQY54r7gRoGu9q87Pqbgv6Xs4MsmSLp4PENfmlp2QqwoRJrT9HxP3QCeT ZGqV4EWW2mKk1Ot4S7FQFn5/eWLCIC7niJmtAcLCt5S3Y3PAsZtV5Loj6xTkBq7e2BRf vSCmTDeDLWM5k5oMNX2DI3pOVLMoEjiAQum+6hMpVpYCCCEjyTJ3hpknpiMjIf9z1+Sx WwbQN+rzzyztLX0gkdZoF5s851hIv1WZkNvfRLp9+hA6UgeZx4JyFYvrkwFQVbBcP4Cj 7Nnw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=XBHQr92VI7IsH28YbrMdXThy18DQoRTz7jLtPXOTkPU=; fh=fHhbvXgCev/wpffLVpfaAi8pPyv7hrTyhVPgsZ7HNrs=; b=K8d8Q4elQCdU8oWhi/Q7BlHQURt67zW6+BpA+AnIbcMFuIDCHpnkuZB1adjLpGdYp3 P3db3fdou8q6Axko4LKlF1ITfWd7GrCueAB5d1MTXGoHvoA+d8rdb0Qie8VLd7UAfbdY sEUN/8fp9jWK6mm2hEn+8XmTcZvlWqRr6QJZtDljoZunXNPUg1NLE/VLLsQ8zGPJ6upd FK3tqSr824p5eF/hF56H/ClCw9J9my0BIqPr9Co/EsDiMCRhLkeGcS2g5lf7TC/cVC6b ayhIIPId1Qn09M2znwSKrioLRsQRWbsdQ32NpOjvz1XToeso3wU+Eh8OKa1/9ZWHvISJ k0Ww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CN6cE9Vb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-157890-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157890-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w10-20020a05622a134a00b0043a471224a7si381027qtk.335.2024.04.24.17.53.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 17:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157890-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=@kernel.org header.s=k20201202 header.b=CN6cE9Vb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-157890-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157890-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 2FB921C2407C for ; Thu, 25 Apr 2024 00:52:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F8C5AD31; Thu, 25 Apr 2024 00:51:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CN6cE9Vb" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 91FEF4C62; Thu, 25 Apr 2024 00:51:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714006318; cv=none; b=rcpbfcKRYtHss2qArYVwUesdPAlSTqopo3ZKTEoDNb0cME8zUgTdckBgC59XirpVilgKbhCQYYr2+i/LH4UakERAR1efvAyBSClM4bC1reBWJiVn2WtRJWJj79Xg/OFZQqrzMNTaTW9UGTRyrxLKae6Oxsqh86ZQVQCzm+SoIpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714006318; c=relaxed/simple; bh=xJPhb8n2lxP5Gp+Xbv+wgx1zDYnLgjcoI1fT4bMeiVs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dF799HsfMnyaqLfyuj3HV8xIaleS/mx5o4h4/8pPT8eKoT51EdQn5MvTFlJ2yJvG7tqUeyoJhP1UhNGgLvyDyThjw6UZty+DguNuuvsBbBrm5o1tIRenViIv/ysrL8PB+hGQHl1A83uZx0IFDXsO8jxqc5il+55DMuB0/x5NBlo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CN6cE9Vb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBB92C113CD; Thu, 25 Apr 2024 00:51:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714006318; bh=xJPhb8n2lxP5Gp+Xbv+wgx1zDYnLgjcoI1fT4bMeiVs=; h=From:To:Cc:Subject:Date:From; b=CN6cE9VbyUTmz/cAIB0/kIIyHc6+ZoUEUD1yt1rDUGoGMjkOhKNjwhiCZ+WrIczQG A8Ss175z44DAuj+v6x/UWpzDsVvcKNb1JLiMy5kfN6Nn9o1o3PZIXbPiKsivApaEb6 8ivAFVViuo5nCS1MkTHOO84LoCZgcA/k/r1BGUz/khlrD72AO84zeXqzK126dmGDTr uc9PFVAoKasvn/5xlfamSIjG/WoR13C462n1uMQThJYYGTf0O8DxfmpMO29OR/jP9B Sowx1TU1N2jJrMBW031N04/w84RW73qwjEaBR0w6kD0TiTPJZrytnlcv+T+RX38mI2 kn7Jf0GPMQmeg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: [PATCH 1/2] perf annotate: Fallback to objdump when capstone fails Date: Wed, 24 Apr 2024 17:51:56 -0700 Message-ID: <20240425005157.1104789-1-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.769.g3c40516874-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit I found some cases that capstone failed to disassemble. Probably my capstone is an old version but anyway there's a chance it can fail. And then it silently stopped in the middle. In my case, it didn't understand "RDPKRU" instruction. Let's check if the capstone disassemble reached to the end of the function. And fallback to objdump if not. Signed-off-by: Namhyung Kim --- tools/perf/util/disasm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c index 92937809be85..412101f2cf2a 100644 --- a/tools/perf/util/disasm.c +++ b/tools/perf/util/disasm.c @@ -1542,6 +1542,20 @@ static int symbol__disassemble_capstone(char *filename, struct symbol *sym, offset += insn[i].size; } + /* It failed in the middle: probably due to unknown instructions */ + if (offset != len) { + struct list_head *list = ¬es->src->source; + + /* Discard all lines and fallback to objdump */ + while (!list_empty(list)) { + dl = list_first_entry(list, struct disasm_line, al.node); + + list_del_init(&dl->al.node); + disasm_line__free(dl); + } + count = -1; + } + out: if (needs_cs_close) cs_close(&handle); -- 2.44.0.769.g3c40516874-goog