Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1142965lqd; Thu, 25 Apr 2024 07:12:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVgNsdMToVtZwzlYgrDXCZHa2hrb7wp+0iXvoWs24YiqVfUTfHfq/9reYQlknLuEo3b3JY8CBxnTpzrVZrgixnJrjxcKpb1jvyDFiMYkQ== X-Google-Smtp-Source: AGHT+IFV5vV1S1Id84/vJKFe7IkuH/Lub73T2lqN2h7fqs4VA2YCcihgjODo3lZo9oH6gF9SSEx2 X-Received: by 2002:a50:bb07:0:b0:568:7c01:a4a2 with SMTP id y7-20020a50bb07000000b005687c01a4a2mr3878057ede.13.1714054358741; Thu, 25 Apr 2024 07:12:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714054358; cv=pass; d=google.com; s=arc-20160816; b=N9eIbtWwGF0y/zzyPLz+UZM8GrrHRR9cMVYJWFUBw+XEEspJpknN7aZ/rJphFBNMjo YoiSWtJMgxNZgh58rcF+6gMRCorAMITir8JqKKPWEZS0hYyqRt18GO0A/IXW33ytLe+K WZ1Nb5WCbyVqxKGbClk7IztHLJ9liaI7qj1UKijps63Mjj+f6ytqd7vAeILnZ6tyMgSZ rwsG6aGQ80YDMcTQVq3yM210JZXg+r6wZ9afjpGyvb2ZCHl6CPBa8SUF2SMIzekhsyWX Z14NsbbhGQjEyLlnf+T+48dp1RkeWEmBpX5d+CCQ4mZ1ENabT2iNyrgeS9O3CbYbzat/ iBUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eq+KdJ3U18xGkIbsB+OXMs3Tc9k6c+xyPTCj/cotSqI=; fh=49GrrO/H3LiGmymuFnNd59pBYHHWBS2xk/6Ejg0rn8E=; b=scVIJlso3ZmtOQ6o+8rN5dppiyfm6ty0KY1LY131J9dkBqZR/quDcL4SnyNi03pi3a QcvlWrsVmn5yEIgC92EnYF8KHtvcZNPTlT02uZIxENjPk65u1Wvqg2hf76cllCyGAP0L gZ5KRDohgbmFDIyp+ETMeM9Kb4mnOa/iOFQTbSiHDtEUaERNKn29HCMizkM4pShfupVK svA7jJTam7bxKS7zEchfV/gOki3N0djGaW2DetpUkdpgBqnFfWG41z2Wi7tzXr6dptKp gPri19bL7etkDwpOyCzeqfqGG2q+XTTHpYMKMnosejxEz49kvgGBMeZ3mm4bEa08XMXb GoVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MUmKFK5+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-158650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r6-20020a50d686000000b0056df9749489si9455929edi.651.2024.04.25.07.12.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 07:12:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MUmKFK5+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-158650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158650-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 106871F22D61 for ; Thu, 25 Apr 2024 14:03:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 926B814A099; Thu, 25 Apr 2024 14:03:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MUmKFK5+" 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 B9492149E18; Thu, 25 Apr 2024 14:03:01 +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=1714053781; cv=none; b=JeIwYjVFXA7TxUHKJIb6Vcc+W8/8nX/kHvwbKprSd4nq0+0mrywg1/8BgHNXRvM8emefpgHvp2PaRve5wwArWWbDfhxQ5FxXdS5wT/6NBGnQddnj3JMTYxt9s9i9FPCk3lJ9Bq/WarY/c496vjJ7yBzROILwuR3CRtzkFUJyaIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714053781; c=relaxed/simple; bh=ILvhGO1VsJHi02UTnDRo93FjUfCcr+5j1zrCi7PVrnU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hbj3uAOJzvIwGtNSx40hl8zsvwsOSNeFiMxCBEUNiKwqwBHK1VdFi/tDsRnEeWODeG+KoNlPYY1UeBUWVxS8opfVpxP6jAHytC1U+rhUwoMNCHONekJE5TLiK9V2r5n4rRlUJJLTzaVafgpS4zf0r5Tcu3ZW5fbZlcNXUVhuv+U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MUmKFK5+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73CA5C3277B; Thu, 25 Apr 2024 14:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714053781; bh=ILvhGO1VsJHi02UTnDRo93FjUfCcr+5j1zrCi7PVrnU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MUmKFK5+D30BpDLy4QRzJT0M9fOo5C3u+1sA80IKgp3O+MwEZMamX+35MloptqbZP Musz3DGloPC7J1/oQ9yI/1mU9/gQtt45J2/tn6r6D8hknvP2Z938RKkqZhZg0w0QK6 YxOgzgNoHHlKUrQGs416+ddv3evyhIHmbr3QDHq2U/vUL2Z23J+X4C7pfmBdXAY1C2 uHjs+EpZT9sGHVxWSM0XoGiLf/U4+VpmMrnYgMO64X8n52MXotZyrXc7cmFpf7UAPe 9pbu4kYcn40VRL8Dmic4YsnpjfMsKPANiUwUPm96APeYtgK5HQOUhe5iy7NMwvgIhc AUe4mkBnfLp8g== Date: Thu, 25 Apr 2024 11:02:57 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ian Rogers , Kan Liang , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org Subject: Re: [PATCH 1/2] perf annotate: Fallback to objdump when capstone fails Message-ID: References: <20240425005157.1104789-1-namhyung@kernel.org> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240425005157.1104789-1-namhyung@kernel.org> On Wed, Apr 24, 2024 at 05:51:56PM -0700, Namhyung Kim wrote: > 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. Humm: ⬢[acme@toolbox perf-tools-next]$ git am ./20240424_namhyung_perf_annotate_fallback_to_objdump_when_capstone_fails.mbx Applying: perf annotate: Fallback to objdump when capstone fails Applying: perf annotate: Update dso binary type when try build-id error: patch failed: tools/perf/util/disasm.c:1156 error: tools/perf/util/disasm.c: patch does not apply Patch failed at 0002 perf annotate: Update dso binary type when try build-id hint: Use 'git am --show-current-patch=diff' to see the failed patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". ⬢[acme@toolbox perf-tools-next]$ git am --abort ⬢[acme@toolbox perf-tools-next]$ checking... - Arnado > 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