From nobody Sat Feb 7 22:54:48 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 9220B2DAFA8 for ; Sat, 10 Jan 2026 08:27:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033628; cv=none; b=AdU1+AkqAfZvsHOSORg8LAkV8i8JI2lDfljl2Hn82zzZOVCT6/VyPomRwBgOS7EDzCrb32FeIZnL0UHMAAJgwGgRP/1RYDoRP+gJPQA5GLbDXQBPoRTslphDf6Qs1/96fwpHAkC9l8YiCnyZKaH1Y5orXvYl/ouh78wywmkxEus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033628; c=relaxed/simple; bh=lAOpRrZBAzndekAzUtilJeJJaQXcn5zTLkfR0cHcBPk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=DsScx/AFogipXuK0hG85PMsVv9NwyIcgTa+p1i84piOu4SYEsBH4nCk2cxlJShUzvrbVkbL5AIBJ4hOABiuUL1OErHmOGhfqfvCYepAS46CxAtMzli6+zoeyIA5WdsiFS9gS9vfE2QrI1TGDp52i0x+6DP6liYO8YIIh17pP5sQ= 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=IMM4Y3Rb; arc=none smtp.client-ip=74.125.82.202 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="IMM4Y3Rb" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2b0751d8de7so6545944eec.1 for ; Sat, 10 Jan 2026 00:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768033625; x=1768638425; 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=u/ZvUUCfGJNtWXGkKfwls+jhSECP7zD4/7BhG/Dc49c=; b=IMM4Y3Rbi62FJ6Rb14JSLaLszSZ6okFuuXd+82Un1r1DRLrWmcrRdYlXfX17ktx6AR Tq2ow3rZZhecTdoHvBuIrwECY9SeGJZt9VOgZacVpyUnt8gs+g+e9amHKy4Mpf7R70Yg bDGZXi0edzETjeWqmQ10oimykjcE3cILFTVuMLny9d0GxAm0agXgC0uSIGq6vaXYvccN FsoVP+VXllloZJXN3+4CvQ3G0BNlNj5dBLMMehSXI8K+Hs0/Nrz8RF8k/MzLuGBXmpph 9aORzrL5BW5xxC1N9oYAc0OPgYL3ScY6b/EFYWSJ8Nh+30/aSeuG3fBv0yB2tm53rge3 Q0mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768033625; x=1768638425; 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=u/ZvUUCfGJNtWXGkKfwls+jhSECP7zD4/7BhG/Dc49c=; b=WBOfG5qQiuPBtgGZvKO+pxZ3ZeDabUbVhhBpNIdWUXqWvOj/xjnX2Lvepbi5o0mOmi mYFbwNhUDvher73aKA4oS7jPuhUh/Jo0UEMrJRmbd0rISkh5Br/yne/mgeX+L/OPURK/ E3lJDWBleBegdaE5xJ5g0NS+RgszJ3kAGw/LiSLeZC0R7/EtdMzcvKZqAZimAx2fDNGS EMP9Pxdf0YVUs9ho6r0Eg9ZN8M6lQ+RmbCWRD6VoxFDb/pNM8XIKBogcJbLqt0PAvh83 JSH6OrW2P6gQQ0nVf8g7coC86P92P8QMIKF72jRy04cLq1hvT07e6aKTiSRwV1E3DVL0 W/lg== X-Forwarded-Encrypted: i=1; AJvYcCU3LP0nl8v2iqDC56pJgQ4h+Eie77bbu+ABEAJeIYDnPvz62Dm0M51dwdgSiY71xA29nmtf2H7gzq1RICo=@vger.kernel.org X-Gm-Message-State: AOJu0YzcrB2Cvy/wIi2FcTjkCki/PQKaEw3rpOh0y8N1u415azcUcn59 HUzsnkwojZT8g0ezb4iBgIn+Pi+yQc8k7KmGc3fq9F4YsdF0aUpQq+3p9nhT63Khep1QP/3rKok z3iAVr72cKw== X-Google-Smtp-Source: AGHT+IFjtbNFi9aDz6yRBicVvWV5oEMS6tbW3iBo61dhD6tGrmBdl8dVtqSUPB9qhDM2ZGRIRKxjr8Ru5+58 X-Received: from dlii15.prod.google.com ([2002:a05:7022:418f:b0:11b:a892:80ac]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:609a:b0:11b:923d:7735 with SMTP id a92af1059eb24-121f8af867cmr11373773c88.1.1768033624590; Sat, 10 Jan 2026 00:27:04 -0800 (PST) Date: Sat, 10 Jan 2026 00:26:42 -0800 In-Reply-To: <20260110082647.1487574-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: <20260110082647.1487574-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260110082647.1487574-2-irogers@google.com> Subject: [PATCH v2 1/6] perf addr2line: Add a libdw implementation From: Ian Rogers To: Tony Jones , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Howard Chu , Stephen Brennan , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add an implementation of addr2line that uses libdw. Other addr2line implementations are slow, particularly in the case of forking addr2line. Add an implementation that caches the libdw information in the dso and uses it to find the file and line number information. Inline information is supported but because cu_walk_functions_at visits the leaf function last add a inline_list__append_tail to reverse the lists order. Signed-off-by: Ian Rogers --- tools/perf/util/Build | 1 + tools/perf/util/dso.c | 2 + tools/perf/util/dso.h | 11 +++ tools/perf/util/libdw.c | 148 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/libdw.h | 60 ++++++++++++++++ tools/perf/util/srcline.c | 24 +++++++ tools/perf/util/srcline.h | 1 + 7 files changed, 247 insertions(+) create mode 100644 tools/perf/util/libdw.c create mode 100644 tools/perf/util/libdw.h diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 1c2a43e1dc68..2bed6274e248 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -224,6 +224,7 @@ perf-util-$(CONFIG_LIBDW) +=3D dwarf-regs-powerpc.o perf-util-$(CONFIG_LIBDW) +=3D dwarf-regs-x86.o perf-util-$(CONFIG_LIBDW) +=3D debuginfo.o perf-util-$(CONFIG_LIBDW) +=3D annotate-data.o +perf-util-$(CONFIG_LIBDW) +=3D libdw.o =20 perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) +=3D unwind-libdw.o perf-util-$(CONFIG_LOCAL_LIBUNWIND) +=3D unwind-libunwind-local.o diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 344e689567ee..06980844c014 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -32,6 +32,7 @@ #include "string2.h" #include "vdso.h" #include "annotate-data.h" +#include "libdw.h" =20 static const char * const debuglink_paths[] =3D { "%.0s%s", @@ -1605,6 +1606,7 @@ void dso__delete(struct dso *dso) auxtrace_cache__free(RC_CHK_ACCESS(dso)->auxtrace_cache); dso_cache__free(dso); dso__free_a2l(dso); + dso__free_a2l_libdw(dso); dso__free_symsrc_filename(dso); nsinfo__zput(RC_CHK_ACCESS(dso)->nsinfo); mutex_destroy(dso__lock(dso)); diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index f8ccb9816b89..4aee23775054 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -268,6 +268,7 @@ DECLARE_RC_STRUCT(dso) { const char *short_name; const char *long_name; void *a2l; + void *a2l_libdw; char *symsrc_filename; #if defined(__powerpc__) void *dwfl; /* DWARF debug info */ @@ -334,6 +335,16 @@ static inline void dso__set_a2l(struct dso *dso, void = *val) RC_CHK_ACCESS(dso)->a2l =3D val; } =20 +static inline void *dso__a2l_libdw(const struct dso *dso) +{ + return RC_CHK_ACCESS(dso)->a2l_libdw; +} + +static inline void dso__set_a2l_libdw(struct dso *dso, void *val) +{ + RC_CHK_ACCESS(dso)->a2l_libdw =3D val; +} + static inline unsigned int dso__a2l_fails(const struct dso *dso) { return RC_CHK_ACCESS(dso)->a2l_fails; diff --git a/tools/perf/util/libdw.c b/tools/perf/util/libdw.c new file mode 100644 index 000000000000..91e8c161a437 --- /dev/null +++ b/tools/perf/util/libdw.c @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "dso.h" +#include "libdw.h" +#include "srcline.h" +#include "symbol.h" +#include "dwarf-aux.h" +#include +#include +#include + +void dso__free_a2l_libdw(struct dso *dso) +{ + Dwfl *dwfl =3D dso__a2l_libdw(dso); + + if (dwfl) { + dwfl_end(dwfl); + dso__set_a2l_libdw(dso, NULL); + } +} + +struct libdw_a2l_cb_args { + struct dso *dso; + struct symbol *sym; + struct inline_node *node; +}; + +static int libdw_a2l_cb(Dwarf_Die *die, void *_args) +{ + struct libdw_a2l_cb_args *args =3D _args; + struct symbol *inline_sym =3D new_inline_sym(args->dso, args->sym, dwarf_= diename(die)); + char *srcline =3D NULL; + const char *fname =3D die_get_decl_file(die); + + if (fname) { + int lineno; + + dwarf_decl_line(die, &lineno); + srcline =3D srcline_from_fileline(fname, lineno); + } + inline_list__append_tail(inline_sym, srcline, args->node); + return 0; +} + +int libdw__addr2line(const char *dso_name, u64 addr, + char **file, unsigned int *line_nr, + struct dso *dso, bool unwind_inlines, + struct inline_node *node, struct symbol *sym) +{ + static const Dwfl_Callbacks offline_callbacks =3D { + .find_debuginfo =3D dwfl_standard_find_debuginfo, + .section_address =3D dwfl_offline_section_address, + .find_elf =3D dwfl_build_id_find_elf, + }; + Dwfl *dwfl =3D dso__a2l_libdw(dso); + Dwfl_Module *mod; + Dwfl_Line *dwline; + Dwarf_Addr bias; + const char *src; + int lineno; + + if (!dwfl) { + /* + * Initialize Dwfl session. + * We need to open the DSO file to report it to libdw. + */ + int fd; + + fd =3D open(dso_name, O_RDONLY); + if (fd < 0) + return 0; + + dwfl =3D dwfl_begin(&offline_callbacks); + if (!dwfl) { + close(fd); + return 0; + } + + /* + * If the report is successful, the file descriptor fd is consumed + * and closed by the Dwfl. If not, it is not closed. + */ + mod =3D dwfl_report_offline(dwfl, dso_name, dso_name, fd); + if (!mod) { + dwfl_end(dwfl); + close(fd); + return 0; + } + + dwfl_report_end(dwfl, /*removed=3D*/NULL, /*arg=3D*/NULL); + dso__set_a2l_libdw(dso, dwfl); + } else { + /* Dwfl session already initialized, get module for address. */ + mod =3D dwfl_addrmodule(dwfl, addr); + } + + if (!mod) + return 0; + + /* + * Get/ignore the dwarf information. Determine the bias, difference + * between the regular ELF addr2line addresses and those to use with + * libdw. + */ + if (!dwfl_module_getdwarf(mod, &bias)) + return 0; + + /* Find source line information for the address. */ + dwline =3D dwfl_module_getsrc(mod, addr + bias); + if (!dwline) + return 0; + + /* Get line information. */ + src =3D dwfl_lineinfo(dwline, /*addr=3D*/NULL, &lineno, /*col=3D*/NULL, /= *mtime=3D*/NULL, + /*length=3D*/NULL); + + if (file) + *file =3D src ? strdup(src) : NULL; + if (line_nr) + *line_nr =3D lineno; + + /* Optionally unwind inline function call chain. */ + if (unwind_inlines && node) { + Dwarf_Addr unused_bias; + Dwarf_Die *cudie =3D dwfl_module_addrdie(mod, addr + bias, &unused_bias); + struct libdw_a2l_cb_args args =3D { + .dso =3D dso, + .sym =3D sym, + .node =3D node, + }; + + /* Walk from the parent down to the leaf. */ + cu_walk_functions_at(cudie, addr, libdw_a2l_cb, &args); + /* + * The srcline information is for die, fix up the leaf one to be + * that of the particular addr. + */ + if (src) { + struct inline_list *ilist; + + list_for_each_entry(ilist, &node->val, list) { + free(ilist->srcline); + ilist->srcline =3D srcline_from_fileline(src, lineno); + break; + } + } + } + return 1; +} diff --git a/tools/perf/util/libdw.h b/tools/perf/util/libdw.h new file mode 100644 index 000000000000..0f8d7b4a11a5 --- /dev/null +++ b/tools/perf/util/libdw.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef PERF_LIBDW_H +#define PERF_LIBDW_H + +#include + +struct dso; +struct inline_node; +struct symbol; + +#ifdef HAVE_LIBDW_SUPPORT +/* + * libdw__addr2line - Convert address to source location using libdw + * @dso_name: Name of the DSO + * @addr: Address to resolve + * @file: Pointer to return filename (caller must free) + * @line_nr: Pointer to return line number + * @dso: The dso struct + * @unwind_inlines: Whether to unwind inline function calls + * @node: Inline node list to append to + * @sym: The symbol associated with the address + * + * This function initializes a Dwfl context for the DSO if not already pre= sent, + * finds the source line information for the given address, and optionally + * resolves inline function call chains. + * + * Returns 1 on success (found), 0 on failure (not found). + */ +int libdw__addr2line(const char *dso_name, u64 addr, char **file, + unsigned int *line_nr, struct dso *dso, + bool unwind_inlines, struct inline_node *node, + struct symbol *sym); + +/* + * dso__free_a2l_libdw - Free libdw resources associated with the DSO + * @dso: The dso to free resources for + * + * This function cleans up the Dwfl context used for addr2line lookups. + */ +void dso__free_a2l_libdw(struct dso *dso); + +#else /* HAVE_LIBDW_SUPPORT */ + +static inline int libdw__addr2line(const char *dso_name __maybe_unused, + u64 addr __maybe_unused, char **file __maybe_unused, + unsigned int *line_nr __maybe_unused, + struct dso *dso __maybe_unused, + bool unwind_inlines __maybe_unused, + struct inline_node *node __maybe_unused, + struct symbol *sym __maybe_unused) +{ + return 0; +} + +static inline void dso__free_a2l_libdw(struct dso *dso __maybe_unused) +{ +} +#endif /* HAVE_LIBDW_SUPPORT */ + +#endif /* PERF_LIBDW_H */ diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index 27c0966611ab..e2d280678b02 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -6,6 +6,7 @@ #include "libbfd.h" #include "llvm.h" #include "symbol.h" +#include "libdw.h" =20 #include #include @@ -51,6 +52,25 @@ int inline_list__append(struct symbol *symbol, char *src= line, struct inline_node return 0; } =20 +int inline_list__append_tail(struct symbol *symbol, char *srcline, struct = inline_node *node) +{ + struct inline_list *ilist; + + ilist =3D zalloc(sizeof(*ilist)); + if (ilist =3D=3D NULL) + return -1; + + ilist->symbol =3D symbol; + ilist->srcline =3D srcline; + + if (callchain_param.order =3D=3D ORDER_CALLEE) + list_add(&ilist->list, &node->val); + else + list_add_tail(&ilist->list, &node->val); + + return 0; +} + /* basename version that takes a const input string */ static const char *gnu_basename(const char *path) { @@ -120,6 +140,10 @@ static int addr2line(const char *dso_name, u64 addr, c= har **file, unsigned int * { int ret; =20 + ret =3D libdw__addr2line(dso_name, addr, file, line_nr, dso, unwind_inlin= es, node, sym); + if (ret > 0) + return ret; + ret =3D llvm__addr2line(dso_name, addr, file, line_nr, dso, unwind_inline= s, node, sym); if (ret > 0) return ret; diff --git a/tools/perf/util/srcline.h b/tools/perf/util/srcline.h index c36f573cd339..be9f002bf234 100644 --- a/tools/perf/util/srcline.h +++ b/tools/perf/util/srcline.h @@ -57,6 +57,7 @@ struct inline_node *inlines__tree_find(struct rb_root_cac= hed *tree, u64 addr); void inlines__tree_delete(struct rb_root_cached *tree); =20 int inline_list__append(struct symbol *symbol, char *srcline, struct inlin= e_node *node); +int inline_list__append_tail(struct symbol *symbol, char *srcline, struct = inline_node *node); char *srcline_from_fileline(const char *file, unsigned int line); struct symbol *new_inline_sym(struct dso *dso, struct symbol *base_sym, --=20 2.52.0.457.g6b5491de43-goog From nobody Sat Feb 7 22:54:48 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 3D0FB2E6CB2 for ; Sat, 10 Jan 2026 08:27:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033629; cv=none; b=scnLxw8uup8XvqmXctrgiAkI/XaqXviqwlStJtcOr8C3MroX+ShqJn9rD648Q+dIQQPdfCoSmqDzhlc/QG0ocBpTKBwAfNhgUIcppC/ij+sfckVkEVIco3QZyssU+Qroj16ysjwmmphLJYWcxKkPIyEiqf690d8EIZzimwan1ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033629; c=relaxed/simple; bh=X1MjIcGZucyzCm2r2IlBzTymaxjsdQoFFc+rtk3RK20=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=s0tVU8xv3r/2+NTOf5/xqx4xeDlx0cXRNO/bT7EGTplnPIXWBAVm808ZXBh5xDJv03uPQoNgFBLBHFz3g/Q+qg51SHjNICxC4SBhpXyGcnOQpR3xvxJSvvdmPGvrcGGqM9smj+sz32Bvp4011hSWmUIGuYpb7SuZPDzzRtqlJGM= 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=vUb8wGM+; arc=none smtp.client-ip=74.125.82.202 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="vUb8wGM+" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2ae56205588so5909465eec.1 for ; Sat, 10 Jan 2026 00:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768033626; x=1768638426; 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=GeyCcyFu8+y/NnCQ7WsdxHS48sCTNn9MjknKssLg0z0=; b=vUb8wGM+CFbmthM8TckKZ9PYJN50ecvwCP9JOUOInjrK5PbVLd2MfhwPFdqZOs/0d5 NeufndcmZwZopgEV6CWd+bmfUWiV8SBag/F+INL4GXoxHWWVPnKFUi3W1qUcoVNNIzoK VXcvrKSYsncBf2aa2FDcEfN63i14zsaNUWz5iCvVS+z3HZoGvSnMe2XB3xosoX6dzqgP BI4Qwgq7iIOf2oN8XKC121X3QEv9FdvIESwb5sDWW5b/blGNhjS/WfHT0HwULQLX2fTk QQPUThGScLQvZEE2E9tveBXk5Qi1+h/n4oqTXAEaOjaeKPNVOpz4yV31XrWvJ6ozISJF gvfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768033626; x=1768638426; 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=GeyCcyFu8+y/NnCQ7WsdxHS48sCTNn9MjknKssLg0z0=; b=XJ8XZG0O2imwQE+d8LRaden26oT9q+Yy1Lpq9QDQIU4S9DQo39j5iOr4LHr81wMckR AmmkLyEiWCF54ue9IJLT69n7qn6Sk80JK/0IjpDQbs5nQDE8vjjOAXHsnz9YNs0akR27 fP5gynPMYpRI24PqtydlDHgvTRQx0o8Je5qIunlcrq0dDppieOEdZFxvQrED+ZBsxYEt +a6Ae83eF0B8WEraUpz5EMyo5bzSrftuWpI+R7pPRm5D96UAwWgjmA2Gs2I6rvWr7Fcj riQkjnyTgahK4c4czauj2nYk3XzMplOw5J5PsbA+AIU6zOJa3UO7OysS9Iovc+tsRmyZ bTLw== X-Forwarded-Encrypted: i=1; AJvYcCXKVhnJp7ZdA2f2MIa7kFlxYHUQyLI9DvQgkiighvcXupdRSveOn91U5ZkialRMf0IMOJUjtAg+7yCx1DM=@vger.kernel.org X-Gm-Message-State: AOJu0YziZkm+DcgOzPlXCIMRTqxfp70faTZlP+9kc7b/c0K5iT2HoYZR rkCYzbSoJMxC8i7/UiFAgwi5mFYG5EuZMwFOQ8WdTAp5VuPU2nrQiFM8iwCGkpaJBEqtI9fTgmY UlNL+qLM+GA== X-Google-Smtp-Source: AGHT+IFiNbZL8zBQ61wqoykyJMyxlzCNV4Dnpo+uPuFeWFdkSSYtZrTbTPhfi56pcUDS5JqF9yr4caC+R4C5 X-Received: from dyek19.prod.google.com ([2002:a05:7300:6413:b0:2b0:5041:8a8b]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:8290:b0:2ae:598e:abe5 with SMTP id 5a478bee46e88-2b17d321a6dmr6978326eec.35.1768033626253; Sat, 10 Jan 2026 00:27:06 -0800 (PST) Date: Sat, 10 Jan 2026 00:26:43 -0800 In-Reply-To: <20260110082647.1487574-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: <20260110082647.1487574-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260110082647.1487574-3-irogers@google.com> Subject: [PATCH v2 2/6] perf addr2line.c: Rename a2l_style to cmd_a2l_style From: Ian Rogers To: Tony Jones , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Howard Chu , Stephen Brennan , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The a2l_style is only relevant to the command line version, so rename to make this clearer. Signed-off-by: Ian Rogers --- tools/perf/util/addr2line.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/addr2line.c b/tools/perf/util/addr2line.c index f2d94a3272d7..0f1499350d47 100644 --- a/tools/perf/util/addr2line.c +++ b/tools/perf/util/addr2line.c @@ -90,16 +90,16 @@ static struct child_process *addr2line_subprocess_init(= const char *addr2line_pat return a2l; } =20 -enum a2l_style { +enum cmd_a2l_style { BROKEN, GNU_BINUTILS, LLVM, }; =20 -static enum a2l_style addr2line_configure(struct child_process *a2l, const= char *dso_name) +static enum cmd_a2l_style cmd_addr2line_configure(struct child_process *a2= l, const char *dso_name) { static bool cached; - static enum a2l_style style; + static enum cmd_a2l_style style; =20 if (!cached) { char buf[128]; @@ -149,7 +149,7 @@ static enum a2l_style addr2line_configure(struct child_= process *a2l, const char } =20 static int read_addr2line_record(struct io *io, - enum a2l_style style, + enum cmd_a2l_style style, const char *dso_name, u64 addr, bool first, @@ -298,7 +298,7 @@ int cmd__addr2line(const char *dso_name, u64 addr, char buf[128]; ssize_t written; struct io io =3D { .eof =3D false }; - enum a2l_style a2l_style; + enum cmd_a2l_style cmd_a2l_style; =20 if (!a2l) { if (!filename__has_section(dso_name, ".debug_line")) @@ -314,8 +314,8 @@ int cmd__addr2line(const char *dso_name, u64 addr, pr_warning("%s %s: addr2line_subprocess_init failed\n", __func__, dso_n= ame); goto out; } - a2l_style =3D addr2line_configure(a2l, dso_name); - if (a2l_style =3D=3D BROKEN) + cmd_a2l_style =3D cmd_addr2line_configure(a2l, dso_name); + if (cmd_a2l_style =3D=3D BROKEN) goto out; =20 /* @@ -336,7 +336,7 @@ int cmd__addr2line(const char *dso_name, u64 addr, } io__init(&io, a2l->out, buf, sizeof(buf)); io.timeout_ms =3D addr2line_timeout_ms; - switch (read_addr2line_record(&io, a2l_style, dso_name, addr, /*first=3D*= /true, + switch (read_addr2line_record(&io, cmd_a2l_style, dso_name, addr, /*first= =3D*/true, &record_function, &record_filename, &record_line_nr)) { case -1: if (!symbol_conf.disable_add2line_warn) @@ -351,7 +351,7 @@ int cmd__addr2line(const char *dso_name, u64 addr, * binutils, also force a non-zero address as we're no longer * reading that record. */ - switch (read_addr2line_record(&io, a2l_style, dso_name, + switch (read_addr2line_record(&io, cmd_a2l_style, dso_name, /*addr=3D*/1, /*first=3D*/true, NULL, NULL, NULL)) { case -1: @@ -397,7 +397,7 @@ int cmd__addr2line(const char *dso_name, u64 addr, * as we're reading records beyond the first. */ while ((record_status =3D read_addr2line_record(&io, - a2l_style, + cmd_a2l_style, dso_name, /*addr=3D*/1, /*first=3D*/false, --=20 2.52.0.457.g6b5491de43-goog From nobody Sat Feb 7 22:54:48 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 033282D0C9D for ; Sat, 10 Jan 2026 08:27:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033632; cv=none; b=V9G1uxi2USECrlSsLIFJzaKVcKE/QsOep8gTWrYARNQXlf8C+evXUCoKDP5Jf7ypqJcqDjbBV0KLtlEuzRWB9ir8rAdjmYwakkMP4SXbIYcuTcKy8ifDeLKmyMxGhgSsVK+syQrETLNUqzAjUIs4uGSH0icfFvO2kqSPlQP2Ios= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033632; c=relaxed/simple; bh=pnkoaS3BDyegUiypzuayNhPPwN3jB4XGtFWuYD1ZLdE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=ituH9Fn2WLEa6Zql1nYAd8eOI+g84ajaIoE++tgu7R4aClKIHKVYK6Zyk53AvYWxDLiu7Kx4/2GJHdF3ruoEUJb32w/zsnx/0vzqtKxAGjnJOyTrDMiVCNY04ZKq8ov/LBaLYTH7tGybpBXqePyjOXrEk94vWmRsaLxyO6sa1uo= 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=Yd0ebnaQ; arc=none smtp.client-ip=74.125.82.202 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="Yd0ebnaQ" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2b0751d8de7so6545988eec.1 for ; Sat, 10 Jan 2026 00:27:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768033628; x=1768638428; 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=79Lm5r+aff6tOMggRex7lERHHcu3vz/+dw8OY+TEe/4=; b=Yd0ebnaQSX+GYtdVOfJkteUHQNK6P/KHpYrnTzgwmWvMi4F17cAtrh9/t1vrFGErgW clID8T+Za5Nj6FX91zhbRR1aV94emW995LEL2eqweP0dqLUvHB/UAebYIzYvgEzQfaVz 8Bv5Kag9zZ5r058xuouZfpk55NBYddJ7jFkdMaNL1Gha9zvnMa4gKB1rJ92K1ed0Yz8V DyE+4Mv2Z7Ea7drEpg9ATz8Tnm6H7QVVofqWYN3jmkaOGTwyLU84468+WPAlFQPgoZd8 fiAY+m7Ym42o5VkZqp2p7Z/yRV2Fgh6i1N74gggiX92aD0yivQjWYJfBjg2BWA4a84e9 O3dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768033628; x=1768638428; 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=79Lm5r+aff6tOMggRex7lERHHcu3vz/+dw8OY+TEe/4=; b=GKFdKu1iNOwssDisskk8zGRpMLpQkNE40Sve//H6tV1kh3bnNJ5cSeTqiReaErm78o XKwh4d203OyMxa2reOZNZ/Jf2jz3oYujHuw8MiVEvTy47dp1oetz2L2VUYZgd7knpFQP WHeDVc9eSgIGDE5UcmTrnfST4YQH8pxUdEKVrdhQcccUXZLUDBfIl44N/l7xzHBsXIcL vEtx04od68D4R8k57a+V1kdpYYixYa9F5V3MlqqoLyoh2fA06K6D2nDcEiPNxB01E0J8 br6VMgcxrjyiOBnLXqPv8B+Hs+71erjYzeCRxGEnf0G+g2XLwxmb5YdYptYB9hqj0Cj1 EQGQ== X-Forwarded-Encrypted: i=1; AJvYcCW3aw7Sk7rffycTKAfZPt/3O9kg1z16oueYjUx6xl1/fVrDd/KQaxzR5xLL4fVhHAW/X8+IipOyt1nE8bI=@vger.kernel.org X-Gm-Message-State: AOJu0YyiKJy0DfGcnxsAiGV7GJyOEqCW8O3N4dPIsuPJgcDMuDLSyKjb AlPg11HhMY479399ofF92HwVrYhlTyjov76uPHU9Z6NVjuQfHLygM9hJ8f8may76xEFDybiXbTR PsX2JYkwb6A== X-Google-Smtp-Source: AGHT+IGm21jOzlz78+2UjMxDPLK8wEehACK+/yY7QPmjN+KJZhLWyZGzOZVqvJ/Fkf4vb/EEKX5U3Wycb+pP X-Received: from dlbtk10.prod.google.com ([2002:a05:7022:fb0a:b0:11f:4501:52c4]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:e07:b0:119:e56b:98b9 with SMTP id a92af1059eb24-121f8b78f17mr13167388c88.32.1768033627888; Sat, 10 Jan 2026 00:27:07 -0800 (PST) Date: Sat, 10 Jan 2026 00:26:44 -0800 In-Reply-To: <20260110082647.1487574-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: <20260110082647.1487574-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260110082647.1487574-4-irogers@google.com> Subject: [PATCH v2 3/6] perf srcline: Add configuration support for the addr2line style From: Ian Rogers To: Tony Jones , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Howard Chu , Stephen Brennan , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow the addr2line style to be specified on the `perf report` command line or in the .perfconfig file. Signed-off-by: Ian Rogers --- tools/perf/builtin-report.c | 10 ++++ tools/perf/util/config.c | 4 ++ tools/perf/util/srcline.c | 98 +++++++++++++++++++++++++++++++---- tools/perf/util/srcline.h | 2 + tools/perf/util/symbol_conf.h | 10 ++++ 5 files changed, 113 insertions(+), 11 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 6c2b4f93ec78..2e936928e8c0 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1271,6 +1271,13 @@ parse_percent_limit(const struct option *opt, const = char *str, return 0; } =20 +static int +report_parse_addr2line_config(const struct option *opt __maybe_unused, + const char *arg, int unset __maybe_unused) +{ + return addr2line_configure("addr2line.style", arg, NULL); +} + static int process_attr(const struct perf_tool *tool __maybe_unused, union perf_event *event, struct evlist **pevlist) @@ -1447,6 +1454,9 @@ int cmd_report(int argc, const char **argv) "objdump binary to use for disassembly and annotations"), OPT_STRING(0, "addr2line", &addr2line_path, "path", "addr2line binary to use for line numbers"), + OPT_CALLBACK(0, "addr2line-style", NULL, "addr2line style", + "addr2line styles (libdw,llvm,libbfd,addr2line)", + report_parse_addr2line_config), OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle, "Symbol demangling. Enabled by default, use --no-demangle to disable= ."), OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel, diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index e0219bc6330a..0452fbc6c085 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -20,6 +20,7 @@ #include "util/stat.h" /* perf_stat__set_big_num */ #include "util/evsel.h" /* evsel__hw_names, evsel__use_bpf_counters */ #include "util/addr2line.h" /* addr2line_timeout_ms */ +#include "srcline.h" #include "build-id.h" #include "debug.h" #include "config.h" @@ -519,6 +520,9 @@ int perf_default_config(const char *var, const char *va= lue, if (strstarts(var, "stat.")) return perf_stat_config(var, value); =20 + if (strstarts(var, "addr2line.")) + return addr2line_configure(var, value, dummy); + /* Add other config variables here. */ return 0; } diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index e2d280678b02..28fa1abd1fd3 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -7,9 +7,11 @@ #include "llvm.h" #include "symbol.h" #include "libdw.h" +#include "debug.h" =20 #include #include +#include =20 bool srcline_full_filename; =20 @@ -138,21 +140,95 @@ static int addr2line(const char *dso_name, u64 addr, = char **file, unsigned int * struct dso *dso, bool unwind_inlines, struct inline_node *node, struct symbol *sym) { - int ret; + int ret =3D 0; + + if (symbol_conf.addr2line_style[0] =3D=3D A2L_STYLE_UNKNOWN) { + int i =3D 0; + + /* Default addr2line fallback order. */ +#ifdef HAVE_LIBDW_SUPPORT + symbol_conf.addr2line_style[i++] =3D A2L_STYLE_LIBDW; +#endif +#ifdef HAVE_LIBLLVM_SUPPORT + symbol_conf.addr2line_style[i++] =3D A2L_STYLE_LLVM; +#endif +#ifdef HAVE_LIBBFD_SUPPORT + symbol_conf.addr2line_style[i++] =3D A2L_STYLE_LIBBFD; +#endif + symbol_conf.addr2line_style[i++] =3D A2L_STYLE_CMD; + } + + for (size_t i =3D 0; i < ARRAY_SIZE(symbol_conf.addr2line_style); i++) { + switch (symbol_conf.addr2line_style[i]) { + case A2L_STYLE_LIBDW: + ret =3D libdw__addr2line(dso_name, addr, file, line_nr, dso, unwind_inl= ines, + node, sym); + break; + case A2L_STYLE_LLVM: + ret =3D llvm__addr2line(dso_name, addr, file, line_nr, dso, unwind_inli= nes, + node, sym); + break; + case A2L_STYLE_LIBBFD: + ret =3D libbfd__addr2line(dso_name, addr, file, line_nr, dso, unwind_in= lines, + node, sym); + break; + case A2L_STYLE_CMD: + ret =3D cmd__addr2line(dso_name, addr, file, line_nr, dso, unwind_inlin= es, + node, sym); + break; + case A2L_STYLE_UNKNOWN: + default: + break; + } + if (ret > 0) + return ret; + } + + return 0; +} + +int addr2line_configure(const char *var, const char *value, void *cb __may= be_unused) +{ + static const char * const a2l_style_names[] =3D { + [A2L_STYLE_LIBDW] =3D "libdw", + [A2L_STYLE_LLVM] =3D "llvm", + [A2L_STYLE_LIBBFD] =3D "libbfd", + [A2L_STYLE_CMD] =3D "addr2line", + NULL + }; + + char *s, *p, *saveptr; + size_t i =3D 0; =20 - ret =3D libdw__addr2line(dso_name, addr, file, line_nr, dso, unwind_inlin= es, node, sym); - if (ret > 0) - return ret; + if (strcmp(var, "addr2line.style")) + return 0; + + if (!value) + return -1; =20 - ret =3D llvm__addr2line(dso_name, addr, file, line_nr, dso, unwind_inline= s, node, sym); - if (ret > 0) - return ret; + s =3D strdup(value); + if (!s) + return -1; =20 - ret =3D libbfd__addr2line(dso_name, addr, file, line_nr, dso, unwind_inli= nes, node, sym); - if (ret > 0) - return ret; + p =3D strtok_r(s, ",", &saveptr); + while (p && i < ARRAY_SIZE(symbol_conf.addr2line_style)) { + bool found =3D false; + char *q =3D strim(p); + + for (size_t j =3D A2L_STYLE_LIBDW; j < MAX_A2L_STYLE; j++) { + if (!strcasecmp(q, a2l_style_names[j])) { + symbol_conf.addr2line_style[i++] =3D j; + found =3D true; + break; + } + } + if (!found) + pr_warning("Unknown addr2line style: %s\n", q); + p =3D strtok_r(NULL, ",", &saveptr); + } =20 - return cmd__addr2line(dso_name, addr, file, line_nr, dso, unwind_inlines,= node, sym); + free(s); + return 0; } =20 static struct inline_node *addr2inlines(const char *dso_name, u64 addr, diff --git a/tools/perf/util/srcline.h b/tools/perf/util/srcline.h index be9f002bf234..7c37b3bf9ce7 100644 --- a/tools/perf/util/srcline.h +++ b/tools/perf/util/srcline.h @@ -63,4 +63,6 @@ struct symbol *new_inline_sym(struct dso *dso, struct symbol *base_sym, const char *funcname); =20 +int addr2line_configure(const char *var, const char *value, void *cb); + #endif /* PERF_SRCLINE_H */ diff --git a/tools/perf/util/symbol_conf.h b/tools/perf/util/symbol_conf.h index 7a80d2c14d9b..71bb17372a6c 100644 --- a/tools/perf/util/symbol_conf.h +++ b/tools/perf/util/symbol_conf.h @@ -9,6 +9,15 @@ struct strlist; struct intlist; =20 +enum a2l_style { + A2L_STYLE_UNKNOWN =3D 0, + A2L_STYLE_LIBDW, + A2L_STYLE_LLVM, + A2L_STYLE_LIBBFD, + A2L_STYLE_CMD, +}; +#define MAX_A2L_STYLE (A2L_STYLE_CMD + 1) + struct symbol_conf { bool nanosecs; unsigned short priv_size; @@ -70,6 +79,7 @@ struct symbol_conf { *col_width_list_str, *bt_stop_list_str; const char *addr2line_path; + enum a2l_style addr2line_style[MAX_A2L_STYLE]; unsigned long time_quantum; struct strlist *dso_list, *comm_list, --=20 2.52.0.457.g6b5491de43-goog From nobody Sat Feb 7 22:54:48 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 A0FB42DAFA8 for ; Sat, 10 Jan 2026 08:27:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033636; cv=none; b=mv7wIe9Ohy4Re44B3Mz6Of9vhIqtADs45fenSp7HPshQyXtgik+ueGC/CohkB9lJcFpNxgMUZchG5sY6wq0mQCGQJbcI3W5Y2RbEzBxK+S1BOi1kir/9NtqTpSJ4nL6SDo+zRVsjop05mSsLwVB5WDxbpXajrGpHt3lmXQLvzw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033636; c=relaxed/simple; bh=maJyLYZB2FWx2e0vl8zLnRWKAaYapuD0B5sWshQY2lA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=XJe097aUblNgDMTpu+q+Sbe2KKp+lkIYT+UpffCcaGQ355QUEO8mu6a0/HqglLzk0McwXWg1ixJNsB8qkv4c9o1uR7jjLA7eCvOKV7XGZgUHQ40VM4hg8JcQn1VH6pHKE1N3iiieR5tF+IoTca/a9Sg8SbISt9oteOEKCzagExU= 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=r4vlv/72; arc=none smtp.client-ip=74.125.82.202 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="r4vlv/72" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2ae51ce0642so4274243eec.0 for ; Sat, 10 Jan 2026 00:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768033630; x=1768638430; 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=wBuF0YhhsuNCPdotB4FjlRI1J5nXeTBdLsus5/rNBYw=; b=r4vlv/72J7RCGTsh3SwLtP8gs847NvBPSeyF+ZvXGlTx7GtomouBAln/0b+BTJFUkZ egUD0tJ0PsJmCMAp8Dpd477l1sszdPmHABRWygwihJ0OM7fRDZWFcl2DFl31Z1AheRb9 W/+SB0+ADRvRl71IyScq6mDw3xkZu7T/xJ7mq0OIAK8RcRoJcIjcsEDyOYy09h9Ks0h6 3TCrHEhZwBoPbwCmwrE4VnThg/OvJYkNAYft1QiHbZWQlR2R7+lY5U81Q16g+mowTDA9 stg/8zAYUeNmBtfb99i71PGRFYmXafKB45GyTgmxG8MWzqs/xxuN/zhGk1cUFXzrmYVn ZNSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768033630; x=1768638430; 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=wBuF0YhhsuNCPdotB4FjlRI1J5nXeTBdLsus5/rNBYw=; b=fkAp3MH/D2BaYNq7+y83ANkoCuQY9AX7g2D1EVeS0tUgEor+rI7x5o7H6cbgpD1EOT 4FglYgpOjjMNBQG7xtfCtwyzo4EoqLjSyBgOaG1OmWCLXWud2NtKLjtaJenj5eJRLyAg fRXW6HbRthjFD9UI+RSx7rzIfviGvnGPSmXONkhlaBW52jcbmIYzCcrwX9wUKKuivpf/ aYqohgCGdeE/wj8ZsqiVUwtU7gD7DYbYX6IPBYGqD0WY+68a+7sdwkNkI/VgNV+BE3pp MOFge10gNA1dEowmB4bMgaYD74wfCIMvR7gjdxMxWe8krPdtWgCBx4vf89MUvnsGyrGR lWag== X-Forwarded-Encrypted: i=1; AJvYcCVeLJzffL+vKmiTYL1zVHYpiV/a4tDPmuPOM7veNCrWYdJIjct+ymvXra9dusU+zioRhN/AtPQrPNE0vPA=@vger.kernel.org X-Gm-Message-State: AOJu0YynJNzEkRZMJfGmo50+WKJ4EMkBn7FBnIyy5Q/EBE3xDvdbLCKl CqPugrV7xlboEkR3jOw0J92o6cZJobwBYO2hEU6ayrWxxZtlRXFtL0U+rswpRIOvPZpo5UrGxFg eXMhaHbsghQ== X-Google-Smtp-Source: AGHT+IGYojtwJBo4BOFYANV+ARAGrhYAgkvu3KCkGq68x1ht0dKFHVggr0YcEyQRIZ7/cPkkOkikzpTGiGl1 X-Received: from dlbqi1.prod.google.com ([2002:a05:7022:ebc1:b0:11b:8174:bf47]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:24a3:b0:119:e56b:91f6 with SMTP id a92af1059eb24-121f8b656c7mr11354434c88.39.1768033629805; Sat, 10 Jan 2026 00:27:09 -0800 (PST) Date: Sat, 10 Jan 2026 00:26:45 -0800 In-Reply-To: <20260110082647.1487574-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: <20260110082647.1487574-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260110082647.1487574-5-irogers@google.com> Subject: [PATCH v2 4/6] perf callchain: Fix srcline printing with inlines From: Ian Rogers To: Tony Jones , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Howard Chu , Stephen Brennan , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" sample__fprintf_callchain was using map__fprintf_srcline which won't report inline line numbers. Fix by using the srcline from the callchain and falling back to the map variant. Signed-off-by: Ian Rogers --- tools/perf/util/evsel_fprintf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprint= f.c index 10f1a03c2860..5521d00bff2c 100644 --- a/tools/perf/util/evsel_fprintf.c +++ b/tools/perf/util/evsel_fprintf.c @@ -185,8 +185,12 @@ int sample__fprintf_callchain(struct perf_sample *samp= le, int left_alignment, if (print_dso && (!sym || !sym->inlined)) printed +=3D map__fprintf_dsoname_dsoff(map, print_dsoff, addr, fp); =20 - if (print_srcline) - printed +=3D map__fprintf_srcline(map, addr, "\n ", fp); + if (print_srcline) { + if (node->srcline) + printed +=3D fprintf(fp, "\n %s", node->srcline); + else + printed +=3D map__fprintf_srcline(map, addr, "\n ", fp); + } =20 if (sym && sym->inlined) printed +=3D fprintf(fp, " (inlined)"); --=20 2.52.0.457.g6b5491de43-goog From nobody Sat Feb 7 22:54:48 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (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 AA8BA2E62A9 for ; Sat, 10 Jan 2026 08:27:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033636; cv=none; b=ePMZKZxQSColomNVR5d8/BINFd+AaocFZWdNrAxWYsnQpKn8uZb8nRxNwAvW/3NvHtPFTXCmA9G4tsbCCy8+EiQS3oj84PHY/pRYE8JcqZw4PmNV92ZY7FDRFUVcjxD2r8DcWzE06t4bZ/oWC+/PTcVe7f2kKdeyT5WUuFCsv10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033636; c=relaxed/simple; bh=uzEtsFy0IeVG96C7cTzkE8RkZxzyVZ3pUWgMlhMyoDA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=cAsjA1AIs3gvQGgjY84uli7XddNPwRYw8OdAuSUuy9vYT31Ph266+fro5ow8TPWfIK2gprnLWweUGGE3xhTdo36uD6PJUV5BSp6qeErYJcJRULyjEK29CoqCdfVMY374fKOnuLg8/1ul7bbxZ5OFuYMxq5iVdFK/745HFcdjqrg= 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=VT6mYFS+; arc=none smtp.client-ip=74.125.82.201 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="VT6mYFS+" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2ac39bd5501so4067006eec.0 for ; Sat, 10 Jan 2026 00:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768033632; x=1768638432; 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=ocxcW+CrbKRyA7dscXnknw+e+BoFyfbyTfcxor6PA9I=; b=VT6mYFS+VkI9t3NeXIAtZqs1P6oOZDla7AqVGhUnXhTjeUPuI94SfqIWFaUJr7qnf9 mtqeYAMHPonTNPa0KJx2dmsL+Jxkv8iIZfCi0i8NFLRGt36Ax4KQ8mhEhde6K7V0fN3s xPSUke9+2A7v8cCRFuiZ3ni+TuG8CHB6igoDa/WFnBBS4DeHsDg1rKY2CKodelg5on/s Rpf8lPr9U3UemNo5tFifrCCFakOMe+DoW6o5jqSsqsHjczaRPODXb7KWnAK3AQ6fkPR0 N77Ial3do99UPH0clggfacUvEp7MQCa88UBovteoG5yWX3opRYCvha98fH02OD3GUgG3 Psbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768033632; x=1768638432; 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=ocxcW+CrbKRyA7dscXnknw+e+BoFyfbyTfcxor6PA9I=; b=ON2RYurouJoNCjyszRaBRjcOX06gXeA4J9WKDfracOeN623VsRwhw4cOqku4bJ3l1v 0ZAqO+9PnuW0iPLxEFVWixmPib3eEAhJUchoJaZRLF57ESRBJWQ3pEbSjH6M0pAR1oS5 Oq9N7qhs91BFD4yPsAUop/Ay36e6BVDmlu6GQYBmOOhcAbVC86US6SjXwQIw17NB6LGF RE+mHgXpgvEHN2Rtp1IpKlgi5X9ZgmpALzBvUvja4P7LnfH5ZY0rylFr1HP7GXXAeGI6 qil9s4OBPEZ91RLOC1RWiMggloUdzntV+f2QHUIM1xfSUqVqqWFVqBl24l0m/rFEhtGa oWtw== X-Forwarded-Encrypted: i=1; AJvYcCVYFC0gqOY4NdSou//vhPdFWWxMPfmkBDoAYRhn2ymYeJ6/XHHnwDIJbBVNif51Wozbum4mZeBTcmB1qA4=@vger.kernel.org X-Gm-Message-State: AOJu0YysL4gmlFDE/qQE7w3l8fm8peQ+8ldsdaPY1GmhOOWgUMJqgknn 1rZVqQ1UyVRpdDiy8bCocenn7am1E9owZUtuA9Zo9JsYVSoh/v488LGdKA+YtguZqOBzNI8T1aP iGcXkJsQFNQ== X-Google-Smtp-Source: AGHT+IF/uSZnbAdG0hb8q5tKkUv66JlQFX3QvHJ00VWJpoNrjcX+WjJPQg1r+i/rrgsWoKQm2wMVsQqMfIVg X-Received: from dlbur8-n1.prod.google.com ([2002:a05:7022:ea48:10b0:121:766b:11e4]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:4590:b0:11b:a36d:a7f7 with SMTP id a92af1059eb24-121f8b15e40mr10204622c88.16.1768033631646; Sat, 10 Jan 2026 00:27:11 -0800 (PST) Date: Sat, 10 Jan 2026 00:26:46 -0800 In-Reply-To: <20260110082647.1487574-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: <20260110082647.1487574-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260110082647.1487574-6-irogers@google.com> Subject: [PATCH v2 5/6] perf test workload: Add inlineloop test workload From: Ian Rogers To: Tony Jones , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Howard Chu , Stephen Brennan , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The purpose of this workload is to gather samples in an inlined function. This can be used to test whether inlined addr2line works correctly. Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/tests.h | 1 + tools/perf/tests/workloads/Build | 2 + tools/perf/tests/workloads/inlineloop.c | 52 +++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 tools/perf/tests/workloads/inlineloop.c diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index bd6ffa8e4578..e2490652f030 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -153,6 +153,7 @@ static struct test_workload *workloads[] =3D { &workload__datasym, &workload__landlock, &workload__traploop, + &workload__inlineloop, }; =20 #define workloads__for_each(workload) \ diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index cb67ddbd0375..1f0f8b267fb1 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -240,6 +240,7 @@ DECLARE_WORKLOAD(brstack); DECLARE_WORKLOAD(datasym); DECLARE_WORKLOAD(landlock); DECLARE_WORKLOAD(traploop); +DECLARE_WORKLOAD(inlineloop); =20 extern const char *dso_to_test; extern const char *test_objdump_path; diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/= Build index fb1012cc4fc3..866a00bd14a0 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -8,9 +8,11 @@ perf-test-y +=3D brstack.o perf-test-y +=3D datasym.o perf-test-y +=3D landlock.o perf-test-y +=3D traploop.o +perf-test-y +=3D inlineloop.o =20 CFLAGS_sqrtloop.o =3D -g -O0 -fno-inline -U_FORTIFY_SOURCE CFLAGS_leafloop.o =3D -g -O0 -fno-inline -fno-omit-frame-pointer -= U_FORTIFY_SOURCE CFLAGS_brstack.o =3D -g -O0 -fno-inline -U_FORTIFY_SOURCE CFLAGS_datasym.o =3D -g -O0 -fno-inline -U_FORTIFY_SOURCE CFLAGS_traploop.o =3D -g -O0 -fno-inline -U_FORTIFY_SOURCE +CFLAGS_inlineloop.o =3D -g -O2 diff --git a/tools/perf/tests/workloads/inlineloop.c b/tools/perf/tests/wor= kloads/inlineloop.c new file mode 100644 index 000000000000..bc82dfc7c410 --- /dev/null +++ b/tools/perf/tests/workloads/inlineloop.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include +#include "../tests.h" + +static volatile int a; +static volatile sig_atomic_t done; + +static void sighandler(int sig __maybe_unused) +{ + done =3D 1; +} + +static inline void __attribute__((always_inline)) leaf(int b) +{ +again: + a +=3D b; + if (!done) + goto again; +} + +static inline void __attribute__((always_inline)) middle(int b) +{ + leaf(b); +} + +static noinline void parent(int b) +{ + middle(b); +} + +static int inlineloop(int argc, const char **argv) +{ + int sec =3D 1; + + pthread_setname_np(pthread_self(), "perf-inlineloop"); + if (argc > 0) + sec =3D atoi(argv[0]); + + signal(SIGINT, sighandler); + signal(SIGALRM, sighandler); + alarm(sec); + + parent(sec); + + return 0; +} + +DEFINE_WORKLOAD(inlineloop); --=20 2.52.0.457.g6b5491de43-goog From nobody Sat Feb 7 22:54:48 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 A1B612E7631 for ; Sat, 10 Jan 2026 08:27:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033638; cv=none; b=l9zE+5nl0Y0vcJWl9R+64iuqAYMKP0WZbHKoGn8nWJTJNkFeGc1AfBao4xAojyYs+KVxrO1yb1OlzNg1wmu6Nh4d4RDjkUyFxIvGrTnk2TU08CdfxMvaHYElIvuyg49/fT+vfM6QEXJ7S9rwu+T037BlNhe/JlmA0JlCqiS5VLU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033638; c=relaxed/simple; bh=p9yZjdPOVlIsrzsRvdNrHY7nRPFeaZefQijhYmOqz0Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=ZZb+9SbfHPI5l8cOoUrOlXacgAsP6C2udX6BXrAV66dmywFT2pnCgS2N23Uamoouy0MVt6hZkxW+TUjJL/EXYnF6Ea2E/3mZWfjAEwkVU4au2dstTj4OsyympxJJ/GIrRRx4/9aKVcw+BnO6lmUg0nDZN+D2p+EJqUvXQmexYrI= 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=G2F1m2gQ; arc=none smtp.client-ip=74.125.82.202 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="G2F1m2gQ" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2ae29a21e7eso2625841eec.0 for ; Sat, 10 Jan 2026 00:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768033634; x=1768638434; 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=Y1L+OOdkfbYNneXDpVeIu9zEur50u8G+yPfcpgNFE0M=; b=G2F1m2gQ5llrW6r8Ck9XryuzdA9HXVhxJovvxbXwkTN5EMct+l8C82baYDB30YiBku mmv69tSJfTf0gonbWAD+nyBMAbykNOD7SdE/yUJe7ko4pP2gXYtE+X3xnUkd5bXUqjhA d0K+oAS4rL7UQ/gj8Elj5MK2b01VOdPN9/9fH6xKh6I3kYjPI0yken8pNbzFiam8OtK0 dqHCnh3uIwbgz47CCzBYT8EOu24uNEGqHCEapAIdFD6gNoz4JNTDqwujlojqUuPAlmCp 9Wm90NluZ+mnQX15WjIiI/0aW8HTTm2H+87tGP45z8Cf19xUTyYOMKV2DsElqGM/gyoY FNbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768033634; x=1768638434; 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=Y1L+OOdkfbYNneXDpVeIu9zEur50u8G+yPfcpgNFE0M=; b=CuBMW0cotXPNUa8sVpIPIZ2CDveuICVdvCSN02xiav3J1ylVNjHWTwZmOeoyU6rI2F mV+fTrirrQVV4gsoV4pv2n+ukkEkx7OCxoUZUbt9Tq0+CkGrUqXS7x+Ik5QCVAJ3hO+L AlO8FmL/0+ezMCWpCiukHDfI8FQfk8FuOC/NekIcJAEbDFB8u0/dDtNCB92ESf6qnUZq aXi9Oc6UEyzK5CHqJLBwUzCAyAmo3QpOjdYduacWC00zqgigwWeVLsYlJWV0NUi9yh1g voZsNyTDceplOlHLz988wAe7uiRNBUQkzkZtEYZJ74XWXx/Uo5UXuKr5sS5rS5EjONJQ rB2Q== X-Forwarded-Encrypted: i=1; AJvYcCVZm+2FletRJVNwacy7ysLrFKig5ewBd17VZ8U7uO/AyyGWDaqKiW8UJglbQJeJGSvRt6K2vumZFWUaDac=@vger.kernel.org X-Gm-Message-State: AOJu0YzLMyzuy4+K3eCJ3JtzI9kOaj4RUGXwjwv6AxqETvoWxeKpk/kP Xj/cxahzLZZvd1yrx5igumT51wYE7Nzwenq/WlRDVvQCABV4FgrR01BDmPGkbvrfu6F1bHdZP08 CfDYX8z9l8g== X-Google-Smtp-Source: AGHT+IEQpnrv5YMXhTRF34W6qbcoh5juNyS5pLjmdu4Lo09vc0suzL8frFCFCE9E1+rfz8s+Egg3NdjQpUBL X-Received: from dlii15.prod.google.com ([2002:a05:7022:418f:b0:11b:a892:80ac]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:11c:b0:11d:fcc9:f225 with SMTP id a92af1059eb24-121f8653d54mr12079194c88.14.1768033633833; Sat, 10 Jan 2026 00:27:13 -0800 (PST) Date: Sat, 10 Jan 2026 00:26:47 -0800 In-Reply-To: <20260110082647.1487574-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: <20260110082647.1487574-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260110082647.1487574-7-irogers@google.com> Subject: [PATCH v2 6/6] perf test: Test addr2line unwinding works with inline functions From: Ian Rogers To: Tony Jones , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Howard Chu , Stephen Brennan , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a test that seeks to see inline functions correctly displayed in perf script from the inlineloop workload. Signed-off-by: Ian Rogers --- tools/perf/tests/shell/addr2line_inlines.sh | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 tools/perf/tests/shell/addr2line_inlines.sh diff --git a/tools/perf/tests/shell/addr2line_inlines.sh b/tools/perf/tests= /shell/addr2line_inlines.sh new file mode 100755 index 000000000000..4a5b6f5be23d --- /dev/null +++ b/tools/perf/tests/shell/addr2line_inlines.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# test addr2line inline unwinding +# SPDX-License-Identifier: GPL-2.0 + +set -e + +err=3D0 +test_dir=3D$(mktemp -d /tmp/perf-test-inline-addr2line.XXXXXXXXXX) +perf_data=3D"${test_dir}/perf.data" +perf_script_txt=3D"${test_dir}/perf_script.txt" + +cleanup() { + rm -rf "${test_dir}" + trap - EXIT TERM INT +} + +trap_cleanup() { + echo "Unexpected signal in ${FUNCNAME[1]}" + cleanup + exit 1 +} +trap trap_cleanup EXIT TERM INT + +test_inlinedloop() { + echo "Inline unwinding verification test" + # Record data. Currently only dwarf callchains support inlined functio= ns. + perf record --call-graph dwarf -e task-clock:u -o "${perf_data}" -- pe= rf test -w inlineloop 1 + + # Check output with inline (default) and srcline + perf script -i "${perf_data}" --fields +srcline > "${perf_script_txt}" + + # Expect the leaf and middle functions to occur on lines in the 20s, w= ith + # the non-inlined parent function on a line in the 30s. + if grep -q "inlineloop.c:2. (inlined)" "${perf_script_txt}" && + grep -q "inlineloop.c:3.$" "${perf_script_txt}" + then + echo "Inline unwinding verification test [Success]" + else + echo "Inline unwinding verification test [Failed missing inlined f= unctions]" + err=3D1 + fi +} + +test_inlinedloop + +cleanup +exit $err --=20 2.52.0.457.g6b5491de43-goog