Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1134373lqd; Thu, 25 Apr 2024 07:02:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXqcMkiGXmO56QofDYUkvBYyIKcNpi8AhKNGUdSuDFsqks11Wkb8SldcnaVoxD+O1gwjgPMKnU5SVi6Y+02cw0rEtvRVBTgYlB4tgyaGQ== X-Google-Smtp-Source: AGHT+IEUgJo4yXyNBKWMO1tzQz1SkVflNgNV9dlMQw8l+GwUJBFt5w+eoICG5bDLAjApnXt63bm9 X-Received: by 2002:a50:9e64:0:b0:566:2f24:b063 with SMTP id z91-20020a509e64000000b005662f24b063mr4058243ede.23.1714053768907; Thu, 25 Apr 2024 07:02:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714053768; cv=pass; d=google.com; s=arc-20160816; b=YjzTvtZnXNxYAa9V1MVPLCxwyAfw7DuHAHTqwLqrt2WCtx2DwG2c79kQOa3dI+GXbU qUB0mqHW94tVP4zmHwa8SI0SQpVq0u93goM5Jl4aSUvEIGPq1WHQu1e0VoCnruxZ6jGI XJAdQRt087eAZ9hRzbf7NTU6mSj9gqQfktf2Dj8t5zr7jZ6UnkfTBP505bUsJOineUP2 qeY8v6ik58sbkYCQmqyVLjW6elbG/CEqzsY3tuCIhG/zLLCZVeqg9wcVtAa1R5YSYwnF gQVYGosu5wEdgNUzevcWKQr8g9xkXT3fMXcXUhqGKk8QT+mrNaKCgEPGcV7rivcO9bd3 LlMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WjG5IUh85nt42pjeu+qpTxWsW2SAHinJZBGnvyBAsbs=; fh=49GrrO/H3LiGmymuFnNd59pBYHHWBS2xk/6Ejg0rn8E=; b=atELEkyUeqFPDnKQGSnAH/unA5wCx8LiwMefsF60diV6uX34NwvLrRaEOQ7Stzj1E0 sKSB3sqpgSkzRlV0/HNL1ha/P9unQAaYCKR3qVVyYHopoD2qfk7F77sUo+CD8T297A+F dh3P9YSVrf9YoLVKa52svp5ATT4+0Pbd0LLn+MHr77RPN3jRQNXDumbINA82l2ANUia7 2CaupoB+4/rKETiiwlBMbC0JbJix5MkEQDvNl/Yox50J/W+EeHIFjGLKjnVJrPg6ALTY wrTfdMVsP4eD+iS/oF1MFnUupm7Z6YV9Km5pGe5PTvdTvHYyJ3xMigv2syhB3Psw1Arl wFFA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UGsqkNso; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-158648-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158648-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 dh3-20020a0564021d2300b0056e6a049cdasi9466544edb.176.2024.04.25.07.02.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 07:02:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158648-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=UGsqkNso; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-158648-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158648-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 681411F23AE3 for ; Thu, 25 Apr 2024 14:02:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5052149E08; Thu, 25 Apr 2024 14:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UGsqkNso" 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 09A1A149C67; Thu, 25 Apr 2024 14:02:11 +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=1714053732; cv=none; b=qGeu4grdno7bpFTNcJvoXzmv+3d2udmJFsT1YWAVsNV2Lfgxi9VbZ0vQPNEgvHH8iG8mSNEGjbyvzvrLXGowoNbVvIfUdVqSGcu0B60T8n6HbHHkGLaMaMPs9hLP9sMXEo8FY1P64kUVzXTOOdwgssNxvx6yFnL1b7kEwezVa1s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714053732; c=relaxed/simple; bh=DqKDPDUySoPXORwAqXe1B4HQ1YXnLVQ0qpjZYrw3o/Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eiITfrH2uThuc0HjOKnrsMmjIna5HGiJew2W3TGo+joCmPMO14UhHhkCg453ukAAq57Ar6oMjP9XydFtuVW+YyTPXM1Y3WcD8/qWe44qc/oFtM/DaaclrL4K6TMhW1QPxsp0mC+ctd2BGNYGVTszejStsQxKzQ++g3qukczT8Fs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UGsqkNso; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3504C113CC; Thu, 25 Apr 2024 14:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714053731; bh=DqKDPDUySoPXORwAqXe1B4HQ1YXnLVQ0qpjZYrw3o/Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UGsqkNsokOe2xC6Fyqe0dMBHKMyWAXt6nvmoVnUSUIAcbn0o0scNqoVJXGQvp9+kl /IyN+IMZ52aCbpjmYubh915efG8Gigbx0F1xJx+nnEWBLUvUgLOxLyGMUUmUWoZOxY LTSko+R85DzFxx91a4WVKuuILPxZqG6wXXyHIEPYpYVW6c6ai+f6F7GSG1petyjnyu bOlGMaVqirH9NYB7qRu3364NRAhkv5pnoemq1KWQqYLP5gHzOH8IdG7CefKsxcJtN4 +FsBeU/uyZNgc4Fs7mz4P9ryJ61h/ODCTMvZsSaXUIo+IEECydN36FygplyihMqhoS y8kaj9XaFhUAA== Date: Thu, 25 Apr 2024 11:02:06 -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=us-ascii Content-Disposition: inline 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. Thanks, applied to perf-tools-next, - Arnaldo > 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