From nobody Tue Feb 10 23:01:56 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 56C8B3382E0 for ; Mon, 9 Feb 2026 20:22:14 +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=1770668535; cv=none; b=f7uWAxDhJPytlujHI6h2Xt0iW1HP8Aa+f+Oh8iBsTXqrKlERsNWYSAtPWFBtUW9AWa61xbZyS5MBJ/kLythdu2tfJUdUfs4QRe9gaN9NOJRHPy6HZSS9rcjO7cZifisX+fXVwDBpNlvM3qKRBuqgUeNXPVrz+zb6ISHzq3GjXlk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770668535; c=relaxed/simple; bh=Ui/SugiVmcRAov8tt7/adCmjGYW1ScNgh0Y3uPIDkF4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=ZRbgfGtixIY3Hia9+oouDplrV3Mf6W7IqMlN2u8DkYwMSpI1sKNAgudfyYhkLKIDSZRruyziNxvyzh8kaa4flXzzcNqquiJWwOTg85pYCE8NIaD4W6VUnhe3agDBKS6Mkw02E/uqBEsGX9DNugfyhM+9h2k5Fj6ps61cqvlnS2o= 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=RIHqp01x; 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="RIHqp01x" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-126e8ee6227so83395c88.0 for ; Mon, 09 Feb 2026 12:22:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770668533; x=1771273333; 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=K0daziDUtL2ibgI5WtkZQDKzcSzE6a5XxpXzSEtLh90=; b=RIHqp01xMw0CKXnUwhwekkv+fvTer6yLvlaE91cU+3sMApi2wa8oKtZAN4RI7DhAZy sv+Myh8ZEA5s1DuoSHXK1SPG8drknmHizTCIA96pjXm+Ht4/Jbo+fclvGKJBwPp1Phr4 X6bkgHmW+NKZyapK6ohbY06YmpeF1l/8rGAhfa4GDnBwBUSfx0hO8S8hdkfYGLuNt+xt 5h0iLwDLnx1IRNIf/nT3kjIcwXYBQexZ95WbXcXIL2aa9zUIKiHn3diaYUKm+fOzaO4H K4YXRB66rIjzO61bSmf2xwiW624+xlkB70iuCpTLp1lFN/k1/ggp/FBiEDQPy9cs05tm BU5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770668533; x=1771273333; 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=K0daziDUtL2ibgI5WtkZQDKzcSzE6a5XxpXzSEtLh90=; b=c2EZNYe3tDekrOH1+L22xZ4IwloXBwc33eAg/I7Op/e2Hr77L4u/8/OjZXYvIQGiCu B2nJr1KR+vswQJRAUc9CDaypeFEG1QLy1JI8OIKfQuB04MLWGQFYhOGvl9GcXxbMn7KJ TKv0LMFNCfmg6Yt0HjHMMD0MnwSqHB09f2xtkRbbP8rOde18VhexJOh+LbA/rga1oKDa gATokwknldsqeSinoO0AMauJwU1hk3KVhDz8XJ7uvfkZSzp0h2E0oMtlOH45zQGnWIGH KImRomJGpS1QuFjqVPu9wSvva/RFzlIORohqXbnylN6D3j6tffgM59scjA49EXL5Y1FJ WPfg== X-Forwarded-Encrypted: i=1; AJvYcCUWASRFstsnqaovXEddp/qo0F5JQjBGqUFJ/IEcyxXgYTBHdzqdfz8m7iM0rZFuhJqea01ZdM7T7zKyGgs=@vger.kernel.org X-Gm-Message-State: AOJu0Yxh4Yp6z6YZJVhWPxQm/fZVFwo++fPTu6IJaF/6wxLgOKdR4+Jh AYLJsEXPYyjC2R0rIETNFsf4J9U942hNeQYMWbslKgK5Uo2EuWS6cuJe1RLtzG36k9jKZDXqN6K s6+/VAYBjaQ== X-Received: from dll39.prod.google.com ([2002:a05:7022:227:b0:123:2708:9404]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:e22:b0:11b:8b4b:bff7 with SMTP id a92af1059eb24-1270409535emr5362949c88.39.1770668533318; Mon, 09 Feb 2026 12:22:13 -0800 (PST) Date: Mon, 9 Feb 2026 12:22:06 -0800 In-Reply-To: <20260209202208.2027001-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: <20260209202208.2027001-1-irogers@google.com> X-Mailer: git-send-email 2.53.0.rc2.204.g2597b5adb4-goog Message-ID: <20260209202208.2027001-2-irogers@google.com> Subject: [PATCH v1 1/3] perf script: Allow the generated script to be a path From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Sandipan Das , Leo Yan , Yujie Liu , 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 script generated by "perf script -g " to be a file path and the language determined by the file extension. This is useful in testing so that the generated script file can be written to a test directory. Signed-off-by: Ian Rogers --- tools/perf/Documentation/perf-script.txt | 6 ++++-- tools/perf/builtin-script.c | 24 ++++++++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Document= ation/perf-script.txt index 03d112960632..ddf92f9c7821 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt @@ -98,8 +98,10 @@ OPTIONS =20 -g:: --gen-script=3D:: - Generate perf-script.[ext] starter script for given language, - using current perf.data. + Generate a starter script. If a language is given then the + script is named perf-script.[ext] according to the + language. If a file path is given then python is used for + files ending '.py' and perl used for files ending '.pl'. =20 --dlfilter=3D:: Filter sample events using the given shared object file. diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 14c6f6c3c4f2..7c743a303507 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -4489,6 +4489,7 @@ int cmd_script(int argc, const char **argv) if (generate_script_lang) { struct stat perf_stat; int input; + char *filename =3D strdup("perf-script"); =20 if (output_set_by_user()) { fprintf(stderr, @@ -4516,17 +4517,32 @@ int cmd_script(int argc, const char **argv) } =20 scripting_ops =3D script_spec__lookup(generate_script_lang); + if (!scripting_ops && ends_with(generate_script_lang, ".py")) { + scripting_ops =3D script_spec__lookup("python"); + free(filename); + filename =3D strdup(generate_script_lang); + filename[strlen(filename) - 3] =3D '\0'; + } else if (!scripting_ops && ends_with(generate_script_lang, ".pl")) { + scripting_ops =3D script_spec__lookup("perl"); + free(filename); + filename =3D strdup(generate_script_lang); + filename[strlen(filename) - 3] =3D '\0'; + } if (!scripting_ops) { - fprintf(stderr, "invalid language specifier"); + fprintf(stderr, "invalid language specifier '%s'\n", generate_script_la= ng); err =3D -ENOENT; goto out_delete; } + if (!filename) { + err =3D -ENOMEM; + goto out_delete; + } #ifdef HAVE_LIBTRACEEVENT - err =3D scripting_ops->generate_script(session->tevent.pevent, - "perf-script"); + err =3D scripting_ops->generate_script(session->tevent.pevent, filename); #else - err =3D scripting_ops->generate_script(NULL, "perf-script"); + err =3D scripting_ops->generate_script(NULL, filename); #endif + free(filename); goto out_delete; } =20 --=20 2.53.0.rc2.204.g2597b5adb4-goog