Re: [PATCH v6 2/5] perf: util: use capstone disasm engine to show assembly instructions

From: Changbin Du
Date: Tue Feb 06 2024 - 06:20:27 EST


On Tue, Feb 06, 2024 at 01:17:05PM +0200, Adrian Hunter wrote:
> On 6/02/24 13:11, Changbin Du wrote:
> > On Tue, Feb 06, 2024 at 12:33:10PM +0200, Adrian Hunter wrote:
> >> On 6/02/24 04:14, Changbin Du wrote:
> >>> +size_t sample__fprintf_insn(struct perf_sample *sample, struct thread *thread __maybe_unused,
> >>> + struct machine *machine __maybe_unused, FILE *fp)
> >>> +{
> >>> + pr_warning_once("perf needs to be built with libcapstone support to disassemble instructions\n");
> >>> + return sample__fprintf_insn_raw(sample, fp);
> >>
> >> The validation stops this being called so could just leave
> >> out the 2 lines above, and add __maybe_unused as necessary.
> >>
> > I expect this being a generic api and could be invoked by other functions which
> > may not require the validation (raw code is acceptable).
>
> kernel-style is not to add code if it isn't being used,
> but it seems likely another user of the API would probably
> need to check for libcapstone first, just like perf script,
> so the code would still not be used.
>
okay, so let me just return 0 since nothing printed.

--
Cheers,
Changbin Du