linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Ian Rogers <irogers@google.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/2] perf annotate: Fallback to objdump when capstone fails
Date: Thu, 25 Apr 2024 11:02:06 -0300	[thread overview]
Message-ID: <ZipiXhB21fgPM_xl@x1> (raw)
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 <namhyung@kernel.org>
> ---
>  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 = &notes->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

  parent reply	other threads:[~2024-04-25 14:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25  0:51 [PATCH 1/2] perf annotate: Fallback to objdump when capstone fails Namhyung Kim
2024-04-25  0:51 ` [PATCH 2/2] perf annotate: Update dso binary type when try build-id Namhyung Kim
2024-04-25 14:12   ` Arnaldo Carvalho de Melo
2024-04-25 14:49     ` Arnaldo Carvalho de Melo
2024-04-27  1:09       ` Arnaldo Carvalho de Melo
2024-04-25 14:50     ` Ian Rogers
2024-04-25 14:02 ` Arnaldo Carvalho de Melo [this message]
2024-04-25 14:02 ` [PATCH 1/2] perf annotate: Fallback to objdump when capstone fails Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZipiXhB21fgPM_xl@x1 \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).