From nobody Sun Feb 8 12:36:51 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F7A648167E for ; Thu, 22 Jan 2026 07:31:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769067108; cv=none; b=ELO3uOEPBIJZFSpJBOpb08SLyIqir16ekfrPTZYrXEtpD0bQD+cTqdxEY6hJcGmFpqD987fYUJ5zkyMX1VnnIym6GK2UO+ls9QGNXH3KuL4EEzSK6UeH/Qar9/5qUbNt7z/5tr9bT1tLMdstCcxiOY5+EL7GkfdiHZb+Ph38KU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769067108; c=relaxed/simple; bh=Z2Z1CNYL+JGQpEAglddwhhjQLplFdYsGvVBBauh3Bto=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=Qm9oteA/3bulvvZ9tMl+6lCkStxULB5hToltYtxPDp8E2IVq7kBvl4WBkkjIucAFmHwQ9sjpR2KGqe7+Xe8sQcGT8bx59uftgkKy0XP7wjP2XnNeo+y6g826M/sKOifcqZ/gbOW+/oGLGPmTLb3PVNLloZSWi/k297hsO37aoI4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=mmYt/0ty; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mmYt/0ty" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-124743cf760so4725291c88.1 for ; Wed, 21 Jan 2026 23:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769067096; x=1769671896; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=JZ50YiJoEVxCgYjte6CjV+ls97az2nN7mWUZv3Wr1mA=; b=mmYt/0tyeETjxqJVC3Rv/Bcu/5XryV+pJ8ktPapvzqp8EJHaqFQpqTxY1/DwQ8wnma 7fLcD20bRvG9UsKcayKXTRzTdi1PVN4W6JPfLQQRBBsAgT/0Tthk1EVksf341asTT7vM 8wJXqyVanqejESqkf74iQ7RvWQw6Z7kvlt9Xto2S3YeFnweWsvS2jkoCdQB3J3mei2JA SNkP98AKD/wPbr8ps/in/O8qOyKrX2y/hZLyapB1aXYKpFVeg+RYCmflYuu/oIKSnLo2 XfrzcBo/HTGE/wP7/vOpvA+6rjJuZCm+2qZIFU7SzmDyonWk++2PgDIAV/WfRc03svyr pWjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769067096; x=1769671896; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JZ50YiJoEVxCgYjte6CjV+ls97az2nN7mWUZv3Wr1mA=; b=iI+sx2X3WoAOIF6m1mfZ5ab6LbKMBkEtG1HWcyc9tK2R+LjvJAE6b9blkwLix42AW+ hP8nEM/GBEtOryjXPrV1ADo2i9Yh1XXRB5XgMDYVg7Uam/c5rILTHsUD4+Vmx+ZZww/i toEco+pNzgTVuNy1kZcwk0JMiG+J3UrcjaIH3DlfzusYuBIUskKoYROSsMXbneKGsnaM YPIJLQkl30fkWMLTfCMDQutA7wNYGN1WnbdB+hbsOcsN4jPcOUcbV95Y0D7KJ3zfSzIj MbKPlG8oSjT9t6Z7Gi2E2TA1atUZpC5zmyeCPlw/8r+7VFGI99VzXWaSP6lcikEuuMYm YwfQ== X-Forwarded-Encrypted: i=1; AJvYcCUfYI0/oxexzpPpbuHPGAqQ/jJFgzQQVvvsWMTgR+ewgiezeWJ1v6JWADZB9DFWwNyCQwHMcXgZ08EOn6w=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1EloLSUl4eZ1KAY3eRk2dFxtT3OmnSfbRXBuucqBO29fvdp55 JQgYAtbQj2arIwe1p69E5ghVBsOYpNOWjloKGAoeyVuxXTaFq87bL9QBl2SXQZMu7CgPfcaOMVp 5XwW6rPPKcg== X-Received: from dll12.prod.google.com ([2002:a05:7022:20c:b0:123:17b9:69c2]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:f86:b0:11c:b397:2657 with SMTP id a92af1059eb24-1246aa90798mr5597076c88.22.1769067095464; Wed, 21 Jan 2026 23:31:35 -0800 (PST) Date: Wed, 21 Jan 2026 23:31:19 -0800 In-Reply-To: <20260122073127.375139-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260122073127.375139-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260122073127.375139-4-irogers@google.com> Subject: [PATCH v1 03/11] perf disasm: Constify use of struct arch From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , Will Deacon , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Zecheng Li , Tianyou Li , Thomas Falcon , Julia Lawall , Suchit Karunakaran , Athira Rajeev , Aditya Bodkhe , Howard Chu , "=?UTF-8?q?Krzysztof=20=C5=81opatowski?=" , "Dr. David Alan Gilbert" , Shimin Guo , Sergei Trofimovich , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The struct arch holds variables that are read but not written, except during some initialization. Change most uses to be for a "const struct arch *" version to capture this immutability. Signed-off-by: Ian Rogers --- tools/perf/arch/arm64/annotate/instructions.c | 2 +- .../arch/loongarch/annotate/instructions.c | 12 ++++-- tools/perf/arch/s390/annotate/instructions.c | 7 ++-- tools/perf/arch/x86/annotate/instructions.c | 4 +- tools/perf/ui/browsers/annotate.c | 2 +- tools/perf/util/annotate-data.c | 2 +- tools/perf/util/annotate-data.h | 2 +- tools/perf/util/annotate.c | 28 ++++++------- tools/perf/util/annotate.h | 10 ++--- tools/perf/util/disasm.c | 42 ++++++++++--------- tools/perf/util/disasm.h | 14 +++---- 11 files changed, 67 insertions(+), 58 deletions(-) diff --git a/tools/perf/arch/arm64/annotate/instructions.c b/tools/perf/arc= h/arm64/annotate/instructions.c index 16cb62d40bd9..5099fa36180d 100644 --- a/tools/perf/arch/arm64/annotate/instructions.c +++ b/tools/perf/arch/arm64/annotate/instructions.c @@ -10,7 +10,7 @@ struct arm64_annotate { jump_insn; }; =20 -static int arm64_mov__parse(struct arch *arch __maybe_unused, +static int arm64_mov__parse(const struct arch *arch __maybe_unused, struct ins_operands *ops, struct map_symbol *ms __maybe_unused, struct disasm_line *dl __maybe_unused) diff --git a/tools/perf/arch/loongarch/annotate/instructions.c b/tools/perf= /arch/loongarch/annotate/instructions.c index 70262d5f1444..4ca4fb6bbcf9 100644 --- a/tools/perf/arch/loongarch/annotate/instructions.c +++ b/tools/perf/arch/loongarch/annotate/instructions.c @@ -5,8 +5,10 @@ * Copyright (C) 2020-2023 Loongson Technology Corporation Limited */ =20 -static int loongarch_call__parse(struct arch *arch, struct ins_operands *o= ps, struct map_symbol *ms, - struct disasm_line *dl __maybe_unused) +static int loongarch_call__parse(const struct arch *arch, struct ins_opera= nds *ops, + struct map_symbol *ms, + struct disasm_line *dl __maybe_unused) + { char *c, *endptr, *tok, *name; struct map *map =3D ms->map; @@ -52,8 +54,10 @@ static struct ins_ops loongarch_call_ops =3D { .scnprintf =3D call__scnprintf, }; =20 -static int loongarch_jump__parse(struct arch *arch, struct ins_operands *o= ps, struct map_symbol *ms, - struct disasm_line *dl __maybe_unused) +static int loongarch_jump__parse(const struct arch *arch, struct ins_opera= nds *ops, + struct map_symbol *ms, + struct disasm_line *dl __maybe_unused) + { struct map *map =3D ms->map; struct symbol *sym =3D ms->sym; diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch= /s390/annotate/instructions.c index c61193f1e096..8d66c0ea3810 100644 --- a/tools/perf/arch/s390/annotate/instructions.c +++ b/tools/perf/arch/s390/annotate/instructions.c @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include =20 -static int s390_call__parse(struct arch *arch, struct ins_operands *ops, - struct map_symbol *ms, struct disasm_line *dl __maybe_unused) +static int s390_call__parse(const struct arch *arch, struct ins_operands *= ops, + struct map_symbol *ms, + struct disasm_line *dl __maybe_unused) { char *endptr, *tok, *name; struct map *map =3D ms->map; @@ -50,7 +51,7 @@ static struct ins_ops s390_call_ops =3D { .scnprintf =3D call__scnprintf, }; =20 -static int s390_mov__parse(struct arch *arch __maybe_unused, +static int s390_mov__parse(const struct arch *arch __maybe_unused, struct ins_operands *ops, struct map_symbol *ms __maybe_unused, struct disasm_line *dl __maybe_unused) diff --git a/tools/perf/arch/x86/annotate/instructions.c b/tools/perf/arch/= x86/annotate/instructions.c index 803f9351a3fb..24b388bacdae 100644 --- a/tools/perf/arch/x86/annotate/instructions.c +++ b/tools/perf/arch/x86/annotate/instructions.c @@ -119,7 +119,7 @@ static struct ins x86__instructions[] =3D { { .name =3D "xorps", .ops =3D &mov_ops, }, }; =20 -static bool amd__ins_is_fused(struct arch *arch, const char *ins1, +static bool amd__ins_is_fused(const struct arch *arch, const char *ins1, const char *ins2) { if (strstr(ins2, "jmp")) @@ -142,7 +142,7 @@ static bool amd__ins_is_fused(struct arch *arch, const = char *ins1, return false; } =20 -static bool intel__ins_is_fused(struct arch *arch, const char *ins1, +static bool intel__ins_is_fused(const struct arch *arch, const char *ins1, const char *ins2) { if (arch->family !=3D 6 || arch->model < 0x1e || strstr(ins2, "jmp")) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/ann= otate.c index 36aca8d6d003..3df61cd46652 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -30,7 +30,7 @@ struct annotate_browser { struct rb_root entries; struct rb_node *curr_hot; struct annotation_line *selection; - struct arch *arch; + const struct arch *arch; /* * perf top can delete hist_entry anytime. Callers should make sure * its lifetime. diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-dat= a.c index 07cf9c334be0..edfcd6e9df9c 100644 --- a/tools/perf/util/annotate-data.c +++ b/tools/perf/util/annotate-data.c @@ -160,7 +160,7 @@ bool has_reg_type(struct type_state *state, int reg) return (unsigned)reg < ARRAY_SIZE(state->regs); } =20 -static void init_type_state(struct type_state *state, struct arch *arch) +static void init_type_state(struct type_state *state, const struct arch *a= rch) { memset(state, 0, sizeof(*state)); INIT_LIST_HEAD(&state->stack_vars); diff --git a/tools/perf/util/annotate-data.h b/tools/perf/util/annotate-dat= a.h index 869307c7f130..9b222869e42d 100644 --- a/tools/perf/util/annotate-data.h +++ b/tools/perf/util/annotate-data.h @@ -117,7 +117,7 @@ extern struct annotated_data_type canary_type; */ struct data_loc_info { /* These are input field, should be filled by caller */ - struct arch *arch; + const struct arch *arch; struct thread *thread; struct map_symbol *ms; u64 ip; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 791d60f97c23..132af2556aec 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -761,7 +761,7 @@ static int disasm_line__print(struct disasm_line *dl, u= 64 start, int addr_fmt_wi } =20 static struct annotated_data_type * -__hist_entry__get_data_type(struct hist_entry *he, struct arch *arch, +__hist_entry__get_data_type(struct hist_entry *he, const struct arch *arch, struct debuginfo *dbg, struct disasm_line *dl, int *type_offset); =20 @@ -980,11 +980,11 @@ void symbol__calc_percent(struct symbol *sym, struct = evsel *evsel) annotation__calc_percent(notes, evsel, symbol__size(sym)); } =20 -int evsel__get_arch(struct evsel *evsel, struct arch **parch) +int evsel__get_arch(struct evsel *evsel, const struct arch **parch) { struct perf_env *env =3D evsel__env(evsel); const char *arch_name =3D perf_env__arch(env); - struct arch *arch; + const struct arch *arch; int err; =20 if (!arch_name) { @@ -999,7 +999,7 @@ int evsel__get_arch(struct evsel *evsel, struct arch **= parch) } =20 if (arch->init) { - err =3D arch->init(arch, env ? env->cpuid : NULL); + err =3D arch->init((struct arch *)arch, env ? env->cpuid : NULL); if (err) { pr_err("%s: failed to initialize %s arch priv area\n", __func__, arch->name); @@ -1010,14 +1010,14 @@ int evsel__get_arch(struct evsel *evsel, struct arc= h **parch) } =20 int symbol__annotate(struct map_symbol *ms, struct evsel *evsel, - struct arch **parch) + const struct arch **parch) { struct symbol *sym =3D ms->sym; struct annotation *notes =3D symbol__annotation(sym); struct annotate_args args =3D { .options =3D &annotate_opts, }; - struct arch *arch =3D NULL; + const struct arch *arch =3D NULL; int err, nr; =20 err =3D evsel__get_arch(evsel, &arch); @@ -2204,7 +2204,7 @@ void annotation_line__write(struct annotation_line *a= l, struct annotation *notes } =20 int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel, - struct arch **parch) + const struct arch **parch) { struct symbol *sym =3D ms->sym; struct annotation *notes =3D symbol__annotation(sym); @@ -2457,7 +2457,7 @@ int annotate_check_args(void) * to revisit the format when it handles different architecture. * Fills @reg and @offset when return 0. */ -static int extract_reg_offset(struct arch *arch, const char *str, +static int extract_reg_offset(const struct arch *arch, const char *str, struct annotated_op_loc *op_loc) { char *p; @@ -2538,7 +2538,7 @@ static int extract_reg_offset(struct arch *arch, cons= t char *str, * # dst_reg1 =3D rbx, dst_reg2 =3D rcx, dst_= mem =3D 1 * # dst_multi_regs =3D 1, dst_offset =3D 8 */ -int annotate_get_insn_location(struct arch *arch, struct disasm_line *dl, +int annotate_get_insn_location(const struct arch *arch, struct disasm_line= *dl, struct annotated_insn_loc *loc) { struct ins_operands *ops; @@ -2673,7 +2673,7 @@ static struct annotated_item_stat *annotate_data_stat= (struct list_head *head, return istat; } =20 -static bool is_stack_operation(struct arch *arch, struct disasm_line *dl) +static bool is_stack_operation(const struct arch *arch, struct disasm_line= *dl) { if (arch__is(arch, "x86")) { if (!strncmp(dl->ins.name, "push", 4) || @@ -2686,7 +2686,7 @@ static bool is_stack_operation(struct arch *arch, str= uct disasm_line *dl) return false; } =20 -static bool is_stack_canary(struct arch *arch, struct annotated_op_loc *lo= c) +static bool is_stack_canary(const struct arch *arch, struct annotated_op_l= oc *loc) { /* On x86_64, %gs:40 is used for stack canary */ if (arch__is(arch, "x86")) { @@ -2702,7 +2702,7 @@ static bool is_stack_canary(struct arch *arch, struct= annotated_op_loc *loc) * Returns true if the instruction has a memory operand without * performing a load/store */ -static bool is_address_gen_insn(struct arch *arch, struct disasm_line *dl) +static bool is_address_gen_insn(const struct arch *arch, struct disasm_lin= e *dl) { if (arch__is(arch, "x86")) { if (!strncmp(dl->ins.name, "lea", 3)) @@ -2791,7 +2791,7 @@ void debuginfo_cache__delete(void) } =20 static struct annotated_data_type * -__hist_entry__get_data_type(struct hist_entry *he, struct arch *arch, +__hist_entry__get_data_type(struct hist_entry *he, const struct arch *arch, struct debuginfo *dbg, struct disasm_line *dl, int *type_offset) { @@ -2895,7 +2895,7 @@ struct annotated_data_type *hist_entry__get_data_type= (struct hist_entry *he) { struct map_symbol *ms =3D &he->ms; struct evsel *evsel =3D hists_to_evsel(he->hists); - struct arch *arch; + const struct arch *arch; struct disasm_line *dl; struct annotated_data_type *mem_type; struct annotated_item_stat *istat; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index d4990bff29a7..58eaf4b2fa65 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -202,7 +202,7 @@ struct annotation_write_ops { struct annotation_print_data { struct hist_entry *he; struct evsel *evsel; - struct arch *arch; + const struct arch *arch; struct debuginfo *dbg; /* save data type info keyed by al->offset */ struct hashmap *type_hash; @@ -441,10 +441,10 @@ void symbol__annotate_zero_histograms(struct symbol *= sym); =20 int symbol__annotate(struct map_symbol *ms, struct evsel *evsel, - struct arch **parch); + const struct arch **parch); int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel, - struct arch **parch); + const struct arch **parch); =20 enum symbol_disassemble_errno { SYMBOL_ANNOTATE_ERRNO__SUCCESS =3D 0, @@ -546,7 +546,7 @@ struct annotated_insn_loc { i++, op_loc++) =20 /* Get detailed location info in the instruction */ -int annotate_get_insn_location(struct arch *arch, struct disasm_line *dl, +int annotate_get_insn_location(const struct arch *arch, struct disasm_line= *dl, struct annotated_insn_loc *loc); =20 /* Returns a data type from the sample instruction (if any) */ @@ -586,5 +586,5 @@ int annotation_br_cntr_entry(char **str, int br_cntr_nr= , u64 *br_cntr, int num_aggr, struct evsel *evsel); int annotation_br_cntr_abbr_list(char **str, struct evsel *evsel, bool hea= der); =20 -int evsel__get_arch(struct evsel *evsel, struct arch **parch); +int evsel__get_arch(struct evsel *evsel, const struct arch **parch); #endif /* __PERF_ANNOTATE_H */ diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c index 96c78b01e17a..d41a0f96a6f6 100644 --- a/tools/perf/util/disasm.c +++ b/tools/perf/util/disasm.c @@ -213,7 +213,7 @@ static void arch__sort(void) qsort(architectures, nmemb, sizeof(struct arch), arch__cmp); } =20 -struct arch *arch__find(const char *name) +const struct arch *arch__find(const char *name) { const int nmemb =3D ARRAY_SIZE(architectures); static bool sorted; @@ -226,7 +226,7 @@ struct arch *arch__find(const char *name) return bsearch(name, architectures, nmemb, sizeof(struct arch), arch__key= _cmp); } =20 -bool arch__is(struct arch *arch, const char *name) +bool arch__is(const struct arch *arch, const char *name) { return !strcmp(arch->name, name); } @@ -256,7 +256,7 @@ static int ins__scnprintf(struct ins *ins, char *bf, si= ze_t size, return ins__raw_scnprintf(ins, bf, size, ops, max_ins_name); } =20 -bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2) +bool ins__is_fused(const struct arch *arch, const char *ins1, const char *= ins2) { if (!arch || !arch->ins_is_fused) return false; @@ -264,7 +264,7 @@ bool ins__is_fused(struct arch *arch, const char *ins1,= const char *ins2) return arch->ins_is_fused(arch, ins1, ins2); } =20 -static int call__parse(struct arch *arch, struct ins_operands *ops, struct= map_symbol *ms, +static int call__parse(const struct arch *arch, struct ins_operands *ops, = struct map_symbol *ms, struct disasm_line *dl __maybe_unused) { char *endptr, *tok, *name; @@ -362,7 +362,7 @@ static inline const char *validate_comma(const char *c,= struct ins_operands *ops return c; } =20 -static int jump__parse(struct arch *arch, struct ins_operands *ops, struct= map_symbol *ms, +static int jump__parse(const struct arch *arch, struct ins_operands *ops, = struct map_symbol *ms, struct disasm_line *dl __maybe_unused) { struct map *map =3D ms->map; @@ -525,7 +525,7 @@ static int comment__symbol(char *raw, char *comment, u6= 4 *addrp, char **namep) return 0; } =20 -static int lock__parse(struct arch *arch, struct ins_operands *ops, struct= map_symbol *ms, +static int lock__parse(const struct arch *arch, struct ins_operands *ops, = struct map_symbol *ms, struct disasm_line *dl __maybe_unused) { ops->locked.ops =3D zalloc(sizeof(*ops->locked.ops)); @@ -592,7 +592,7 @@ static struct ins_ops lock_ops =3D { * But it doesn't care segment selectors like %gs:0x5678(%rcx), so just ch= eck * the input string after 'memory_ref_char' if exists. */ -static bool check_multi_regs(struct arch *arch, const char *op) +static bool check_multi_regs(const struct arch *arch, const char *op) { int count =3D 0; =20 @@ -613,8 +613,9 @@ static bool check_multi_regs(struct arch *arch, const c= har *op) return count > 1; } =20 -static int mov__parse(struct arch *arch, struct ins_operands *ops, struct = map_symbol *ms __maybe_unused, - struct disasm_line *dl __maybe_unused) +static int mov__parse(const struct arch *arch, struct ins_operands *ops, + struct map_symbol *ms __maybe_unused, + struct disasm_line *dl __maybe_unused) { char *s =3D strchr(ops->raw, ','), *target, *comment, prev; =20 @@ -719,7 +720,7 @@ static int arithmetic__scnprintf(struct ins *ins, char = *bf, size_t size, * - Add to Zero Extended XO-form ( Ex: addze, addzeo ) * - Subtract From Zero Extended XO-form ( Ex: subfze ) */ -static int arithmetic__parse(struct arch *arch __maybe_unused, struct ins_= operands *ops, +static int arithmetic__parse(const struct arch *arch __maybe_unused, struc= t ins_operands *ops, struct map_symbol *ms __maybe_unused, struct disasm_line *dl) { int opcode =3D PPC_OP(dl->raw.raw_insn); @@ -756,7 +757,7 @@ static int load_store__scnprintf(struct ins *ins, char = *bf, size_t size, * used by powerpc and since binary instruction code is used to * extract opcode, regs and offset, no other parsing is needed here */ -static int load_store__parse(struct arch *arch __maybe_unused, struct ins_= operands *ops, +static int load_store__parse(const struct arch *arch __maybe_unused, struc= t ins_operands *ops, struct map_symbol *ms __maybe_unused, struct disasm_line *dl __maybe_unu= sed) { ops->source.mem_ref =3D true; @@ -776,8 +777,9 @@ static struct ins_ops load_store_ops =3D { .scnprintf =3D load_store__scnprintf, }; =20 -static int dec__parse(struct arch *arch __maybe_unused, struct ins_operand= s *ops, struct map_symbol *ms __maybe_unused, - struct disasm_line *dl __maybe_unused) +static int dec__parse(const struct arch *arch __maybe_unused, struct ins_o= perands *ops, + struct map_symbol *ms __maybe_unused, + struct disasm_line *dl __maybe_unused) { char *target, *comment, *s, prev; =20 @@ -867,7 +869,8 @@ static void ins__sort(struct arch *arch) qsort(arch->instructions, nmemb, sizeof(struct ins), ins__cmp); } =20 -static struct ins_ops *__ins__find(struct arch *arch, const char *name, st= ruct disasm_line *dl) +static struct ins_ops *__ins__find(const struct arch *arch, const char *na= me, + struct disasm_line *dl) { struct ins *ins; const int nmemb =3D arch->nr_instructions; @@ -885,8 +888,8 @@ static struct ins_ops *__ins__find(struct arch *arch, c= onst char *name, struct d } =20 if (!arch->sorted_instructions) { - ins__sort(arch); - arch->sorted_instructions =3D true; + ins__sort((struct arch *)arch); + ((struct arch *)arch)->sorted_instructions =3D true; } =20 ins =3D bsearch(name, arch->instructions, nmemb, sizeof(struct ins), ins_= _key_cmp); @@ -913,17 +916,18 @@ static struct ins_ops *__ins__find(struct arch *arch,= const char *name, struct d return ins ? ins->ops : NULL; } =20 -struct ins_ops *ins__find(struct arch *arch, const char *name, struct disa= sm_line *dl) +struct ins_ops *ins__find(const struct arch *arch, const char *name, struc= t disasm_line *dl) { struct ins_ops *ops =3D __ins__find(arch, name, dl); =20 if (!ops && arch->associate_instruction_ops) - ops =3D arch->associate_instruction_ops(arch, name); + ops =3D arch->associate_instruction_ops((struct arch *)arch, name); =20 return ops; } =20 -static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arc= h, struct map_symbol *ms) +static void disasm_line__init_ins(struct disasm_line *dl, const struct arc= h *arch, + struct map_symbol *ms) { dl->ins.ops =3D ins__find(arch, dl->ins.name, dl); =20 diff --git a/tools/perf/util/disasm.h b/tools/perf/util/disasm.h index a3ea9d676281..273a9c906514 100644 --- a/tools/perf/util/disasm.h +++ b/tools/perf/util/disasm.h @@ -30,7 +30,7 @@ struct arch { unsigned int model; unsigned int family; int (*init)(struct arch *arch, char *cpuid); - bool (*ins_is_fused)(struct arch *arch, const char *ins1, + bool (*ins_is_fused)(const struct arch *arch, const char *ins1, const char *ins2); struct { char comment_char; @@ -89,14 +89,14 @@ struct ins_operands { =20 struct ins_ops { void (*free)(struct ins_operands *ops); - int (*parse)(struct arch *arch, struct ins_operands *ops, struct map_symb= ol *ms, + int (*parse)(const struct arch *arch, struct ins_operands *ops, struct ma= p_symbol *ms, struct disasm_line *dl); int (*scnprintf)(struct ins *ins, char *bf, size_t size, struct ins_operands *ops, int max_ins_name); }; =20 struct annotate_args { - struct arch *arch; + const struct arch *arch; struct map_symbol *ms; struct annotation_options *options; s64 offset; @@ -105,14 +105,14 @@ struct annotate_args { char *fileloc; }; =20 -struct arch *arch__find(const char *name); -bool arch__is(struct arch *arch, const char *name); +const struct arch *arch__find(const char *name); +bool arch__is(const struct arch *arch, const char *name); =20 -struct ins_ops *ins__find(struct arch *arch, const char *name, struct disa= sm_line *dl); +struct ins_ops *ins__find(const struct arch *arch, const char *name, struc= t disasm_line *dl); =20 bool ins__is_call(const struct ins *ins); bool ins__is_jump(const struct ins *ins); -bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2); +bool ins__is_fused(const struct arch *arch, const char *ins1, const char *= ins2); bool ins__is_ret(const struct ins *ins); bool ins__is_lock(const struct ins *ins); =20 --=20 2.52.0.457.g6b5491de43-goog