(cherry picked from commit b569c60961472ced29b1832b535fb38ddb4f3805)
This commit is contained in:
shafeipaozi 2024-06-30 02:45:38 +08:00 committed by openeuler-sync-bot
parent 092c9691dc
commit c04303ea16
15 changed files with 123 additions and 338 deletions

28
0001-python313.patch Normal file
View File

@ -0,0 +1,28 @@
From 2ba15130fae66e19d4d75ab28ef448b0206235c4 Mon Sep 17 00:00:00 2001
From: Yaakov Selkowitz <yselkowi@redhat.com>
Date: Sun, 23 Jun 2024 13:04:28 -0400
Subject: [PATCH] trace-cmd library: fix compatibility with Python 3.13
PyEval_CallObject was deprecated in Python 3.9 and removed from 3.13.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
---
python/ctracecmd.i | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python/ctracecmd.i b/python/ctracecmd.i
index 6d0179e3..8757cbe4 100644
--- a/python/ctracecmd.i
+++ b/python/ctracecmd.i
@@ -214,7 +214,7 @@ static int python_callback(struct trace_seq *s,
SWIG_NewPointerObj(SWIG_as_voidptr(event),
SWIGTYPE_p_tep_event, 0));
- result = PyEval_CallObject(context, arglist);
+ result = PyObject_CallObject(context, arglist);
Py_XDECREF(arglist);
if (result && result != Py_None) {
if (!PyInt_Check(result)) {
--
2.45.2

1
98-trace-cmd.rules Normal file
View File

@ -0,0 +1 @@
SUBSYSTEM=="module", ACTION=="add", PROGRAM="/usr/bin/systemctl is-active trace-cmd.service", PROGRAM="/usr/bin/systemctl reload trace-cmd.service"

View File

@ -1,33 +0,0 @@
From 67b2de06ccd249f2b0dcc9b3e196e4fbcb943066 Mon Sep 17 00:00:00 2001
From: Peter Bergin <peter@berginkonsult.se>
Date: Fri, 30 Apr 2021 17:24:30 +0200
Subject: [PATCH] trace-cmd: Changing default install path of plugins
README file states that default install path for plugins
is '/usr/local/lib/trace-cmd/plugins' but Makefile did
specify other location.
Link: https://lore.kernel.org/linux-trace-devel/20210430152430.1958285-1-peter@berginkonsult.se
Signed-off-by: Peter Bergin <peter@berginkonsult.se>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index ec73b5c6..0d8fea0d 100644
--- a/Makefile
+++ b/Makefile
@@ -94,7 +94,7 @@ plugin_tracecmd_dir = $(libdir)/trace-cmd/plugins
python_dir ?= $(libdir)/traceevent/python
var_dir = $(HOME)/.trace-cmd/
else
-plugin_traceevent_dir = $(libdir)/traceevent/plugins
+plugin_traceevent_dir = $(libdir)/trace-cmd/plugins
python_dir ?= $(libdir)/trace-cmd/python
PLUGIN_DIR_TRACEEVENT = -DPLUGIN_TRACEEVENT_DIR="$(plugin_traceevent_dir)"
PLUGIN_DIR_TRACECMD = -DPLUGIN_TRACECMD_DIR="$(plugin_tracecmd_dir)"
--
2.33.0

View File

@ -1,35 +0,0 @@
From 7e12e8ba4001f51869f28770246f0ac3dbfb9999 Mon Sep 17 00:00:00 2001
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Date: Fri, 14 May 2021 10:52:41 +0300
Subject: [PATCH] trace-cmd: Fix broken profile command
Recent changes in creating trace.dat files broke the streams, used
internaly by the trace-cmd profile command.
Link: https://lore.kernel.org/linux-trace-devel/20210514075241.65418-1-tz.stoyanov@gmail.com
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=213045
Reported-by: Jerome Marchand <jmarchan@redhat.com>
Fixes: 1762536da ("trace-cmd: Have tracecmd_read_headers() specify the state to read up to")
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
tracecmd/trace-stream.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tracecmd/trace-stream.c b/tracecmd/trace-stream.c
index f503bf77..b47b208c 100644
--- a/tracecmd/trace-stream.c
+++ b/tracecmd/trace-stream.c
@@ -59,7 +59,7 @@ trace_stream_init(struct buffer_instance *instance, int cpu, int fd, int cpus,
goto fail;
}
- if (tracecmd_read_headers(trace_input, 0) < 0)
+ if (tracecmd_read_headers(trace_input, TRACECMD_FILE_PRINTK) < 0)
goto fail_free_input;
if (handle_init)
--
2.33.0

View File

@ -1,38 +0,0 @@
From 43fa39ef1717e98ffe71ab0b53fefdfe1f02be3d Mon Sep 17 00:00:00 2001
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Date: Thu, 25 Mar 2021 08:40:44 +0200
Subject: [PATCH] trace-cmd: Remove unneeded multiply in events timestamp
reading
When the event timestamp is converted to seconds, the local variable
that holds this timestamp is converted to seconds also. As this
variable is not used in the function later, this conversion in not
needed.
Link: https://lore.kernel.org/linux-trace-devel/20210325064055.539554-13-tz.stoyanov@gmail.com
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-input.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index c1ea07fd..c4fb9639 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -1932,10 +1932,8 @@ read_again:
handle->cpu_data[cpu].timestamp = timestamp_correct(ts, handle);
- if (handle->ts2secs) {
+ if (handle->ts2secs)
handle->cpu_data[cpu].timestamp *= handle->ts2secs;
- ts *= handle->ts2secs;
- }
index = kbuffer_curr_offset(kbuf);
--
2.33.0

View File

@ -1,39 +0,0 @@
From c5d548379b25705c2061b8c010f78fd242212f65 Mon Sep 17 00:00:00 2001
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Date: Tue, 14 Sep 2021 16:12:14 +0300
Subject: [PATCH] trace-cmd library: Fix version string memory leak
The version string is allocated when a VERSION option is processed, but
is never freed. Free it on input handler close.
Link: https://lore.kernel.org/linux-trace-devel/20210914131232.3964615-4-tz.stoyanov@gmail.com
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-input.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 0dbcdbdc..9253bc37 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -3518,6 +3518,7 @@ void tracecmd_close(struct tracecmd_input *handle)
free(handle->cpu_data);
free(handle->uname);
free(handle->trace_clock);
+ free(handle->version);
close(handle->fd);
tracecmd_free_hooks(handle->hooks);
@@ -3959,6 +3960,7 @@ tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx)
new_handle->cpu_data = NULL;
new_handle->nr_buffers = 0;
new_handle->buffers = NULL;
+ new_handle->version = NULL;
new_handle->ref = 1;
if (handle->trace_clock) {
new_handle->trace_clock = strdup(handle->trace_clock);
--
2.33.0

View File

@ -1,43 +0,0 @@
From 402be29ae6fa1e29c963c71be2713687a4a71686 Mon Sep 17 00:00:00 2001
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Date: Tue, 14 Sep 2021 16:12:15 +0300
Subject: [PATCH] trace-cmd library: Fixed a memory leak on input handler close
When an input handler to a trace file is closed with tracecmd_close(),
the list with buffers is not freed. This leads to a memory leak. Added
logic to free that list.
Link: https://lore.kernel.org/linux-trace-devel/20210914131232.3964615-5-tz.stoyanov@gmail.com
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-input.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 9253bc37..ffe87e8a 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -3484,6 +3484,7 @@ void tracecmd_ref(struct tracecmd_input *handle)
void tracecmd_close(struct tracecmd_input *handle)
{
int cpu;
+ int i;
if (!handle)
return;
@@ -3521,6 +3522,10 @@ void tracecmd_close(struct tracecmd_input *handle)
free(handle->version);
close(handle->fd);
+ for (i = 0; i < handle->nr_buffers; i++)
+ free(handle->buffers[i].name);
+ free(handle->buffers);
+
tracecmd_free_hooks(handle->hooks);
handle->hooks = NULL;
--
2.33.0

View File

@ -1,32 +0,0 @@
From be207b060775c9841d7e3c1c240e74de63df3040 Mon Sep 17 00:00:00 2001
From: wangmeiyang <wangmeiyang@xfusion.com>
Date: Tue, 26 Dec 2023 11:15:29 +0800
Subject: [PATCH 2/2] trace-cmd record: Set sleep_time to zero at end of
recording
When the recording (of trace-cmd record) or streaming (of trace-cmd stream)
is finished, set sleep_time to zero. This will cause various calls to read
the buffer to not block, as the sleep_time is used in some instances to
determine how long to wait if there's no data.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tracecmd/trace-record.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 826d1e7..9a7cba2 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -3066,6 +3066,8 @@ static void expand_event_list(void)
static void finish(int sig)
{
+ sleep_time = 0;
+
/* all done */
if (recorder)
tracecmd_stop_recording(recorder);
--
2.37.0.windows.1

View File

@ -1,41 +0,0 @@
From 9fd5f8ecd0bb98b6fdcfe75118b535f613226b9f Mon Sep 17 00:00:00 2001
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Date: Tue, 14 Sep 2021 16:12:13 +0300
Subject: [PATCH] trace-cmd report: Fix typos in error messages
Fixed typos in "trace-cmd report" messages that report reading and
parsing errors.
Link: https://lore.kernel.org/linux-trace-devel/20210914131232.3964615-3-tz.stoyanov@gmail.com
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
tracecmd/trace-read.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index 6f43c1d2..31724b09 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -1290,7 +1290,7 @@ static void read_data_info(struct list_head *handle_list, enum output_type otype
die("error in reading buffer instance");
new_handle = tracecmd_buffer_instance_handle(handles->handle, i);
if (!new_handle) {
- warning("could not retreive handle %s", name);
+ warning("could not retrieve handle %s", name);
continue;
}
add_handle(new_handle, name);
@@ -1324,7 +1324,7 @@ static void read_data_info(struct list_head *handle_list, enum output_type otype
if (last_record) {
int cpu = last_record->cpu;
if (cpu >= last_handle->cpus)
- die("cpu %d creater than %d\n", cpu, last_handle->cpus);
+ die("cpu %d greater than %d\n", cpu, last_handle->cpus);
if (tscheck &&
last_handle->last_timestamp[cpu] > last_record->ts) {
errno = 0;
--
2.33.0

View File

@ -1,31 +0,0 @@
From 57e830f5078314a114a34c6512629ff66b9ee590 Mon Sep 17 00:00:00 2001
From: wangmeiyang <wangmeiyang@xfusion.com>
Date: Tue, 26 Dec 2023 11:01:29 +0800
Subject: [PATCH 1/2] trace-cmd stream: Set default sleep time to half a second
When in streaming mode, set the default to half a second instead of 1
millisecond (which should be changed for record as well).
Link:https://lore.kernel.org/linux-trace-devel/20230106183930.12565-8-rostedt@goodmis.org/
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tracecmd/trace-record.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 89a3e76..826d1e7 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -6533,6 +6533,9 @@ void trace_stream(int argc, char **argv)
{
struct common_record_context ctx;
+ /* Default sleep time is half a second for streaming */
+ sleep_time = 500000;
+
parse_record_options(argc, argv, CMD_stream, &ctx);
record_trace(argc, argv, &ctx);
exit(0);
--
2.37.0.windows.1

Binary file not shown.

BIN
trace-cmd-v3.2.tar.gz Normal file

Binary file not shown.

4
trace-cmd.conf Normal file
View File

@ -0,0 +1,4 @@
# ftrace based flightrecorder configuration file.
# trace-cmd options
OPTS="-b 2048 -i -e block -e irq -e mce -e module -e power -e sched -e signal -e timer -e workqueue -e kvm -e net"

15
trace-cmd.service Normal file
View File

@ -0,0 +1,15 @@
[Unit]
Description=trace-cmd Flightrecorder
DefaultDependencies=no
Before=sysinit.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/sysconfig/trace-cmd.conf
ExecStart=/usr/bin/trace-cmd start $OPTS
ExecStop=/usr/bin/trace-cmd reset
ExecReload=/usr/bin/trace-cmd start $OPTS
[Install]
WantedBy=multi-user.target

View File

@ -1,79 +1,108 @@
Name: trace-cmd
Version: 2.9.2
Release: 12
Version: 3.2
Release: 1
Summary: A front-end for Ftrace
License: GPLv2 and LGPLv2
URL: http://git.kernel.org/?p=linux/kernel/git/rostedt/trace-cmd.git;a=summary
Source0: https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git/snapshot/%{name}-v%{version}.tar.gz
Source1: kernelshark.desktop
# If upstream does not provide tarballs, to generate:
# git clone https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git
# cd trace-cmd
# git archive --prefix=trace-cmd-%%{version}/ -o trace-cmd-v%%{version}.tar.gz %%{git_commit}
Source0: https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/snapshot/trace-cmd-v%{version}.tar.gz
Source1: trace-cmd.conf
Source2: trace-cmd.service
Source3: 98-trace-cmd.rules
Patch0: 0001-python313.patch
Patch0001: backport-trace-cmd-report-Fix-typos-in-error-messages.patch
Patch0002: backport-trace-cmd-library-Fix-version-string-memory-leak.patch
Patch0003: backport-trace-cmd-library-Fixed-a-memory-leak-on-input-handl.patch
Patch0004: backport-Remove-unneeded-multiply-in-events-timesta.patch
Patch0005: backport-Changing-default-install-path-of-plugins.patch
Patch0006: backport-Fix-broken-profile-command.patch
Patch0007: backport-trace-cmd-stream-Set-default-sleep-time-to-half-a-se.patch
Patch0008: backport-trace-cmd-record-Set-sleep_time-to-zero-at-end-of-re.patch
BuildRequires: make
BuildRequires: gcc
BuildRequires: xmlto
BuildRequires: asciidoc
BuildRequires: graphviz doxygen
BuildRequires: gcc-c++
BuildRequires: cmake
BuildRequires: libtraceevent-devel >= 1.8.0
BuildRequires: libtracefs-devel >= 1.8.0
BuildRequires: audit-libs-devel
BuildRequires: chrpath
BuildRequires: swig
#BuildRequires: libtracecmd-devel
BuildRequires: libzstd-devel
BuildRequires: python3-devel
BuildRequires: gcc xmlto asciidoc mlocate libxml2-devel chrpath
BuildRequires: gtk2-devel glib2-devel desktop-file-utils libtraceevent-devel
Provides: kernelshark
Obsoletes: kernelshark
%description
This package is a user-space front-end command-line tool for Ftrace.
%package_help
%package python3
Summary: Python plugin support for trace-cmd
Requires: trace-cmd = %{version}-%{release}
%description python3
Python plugin support for trace-cmd
%prep
%autosetup -n %{name}-v%{version} -p1
cp %{SOURCE1} .
cp %{SOURCE2} .
cp %{SOURCE3} .
%build
MANPAGE_DOCBOOK_XSL=`rpm -ql docbook-style-xsl | grep manpages/docbook.xsl`
make V=1 MANPAGE_DOCBOOK_XSL=$MANPAGE_DOCBOOK_XSL prefix=%{_prefix} all doc
CFLAGS="%{optflags} -D_GNU_SOURCE" LDFLAGS="%{build_ldflags}" BUILD_TYPE=Release \
make V=9999999999 MANPAGE_DOCBOOK_XSL=$MANPAGE_DOCBOOK_XSL \
prefix=%{_prefix} libdir=%{_libdir} \
PYTHON_VERS=python3 all_cmd doc
for i in python/*.py ; do
sed -i 's/env python2/python3/g' $i
done
chrpath --delete tracecmd/trace-cmd
%install
make V=1 DESTDIR=$RPM_BUILD_ROOT/ prefix=%{_prefix} install install_doc
find $RPM_BUILD_ROOT%{_mandir} -type f | xargs chmod u-x,g-x,o-x
find $RPM_BUILD_ROOT%{_datadir} -type f | xargs chmod u-x,g-x,o-x
install -d -m 755 $RPM_BUILD_ROOT/%{_datadir}/applications
install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT/%{_datadir}/applications/kernelshark.desktop
desktop-file-validate $RPM_BUILD_ROOT/%{_datadir}/applications/kernelshark.desktop
chrpath -d $RPM_BUILD_ROOT%{_bindir}/trace-cmd
mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d
echo "%{_bindir}/%{name}" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf
%pre
make libdir=%{_libdir} prefix=%{_prefix} V=1 DESTDIR=%{buildroot}/ CFLAGS="%{optflags} -D_GNU_SOURCE" LDFLAGS="%{build_ldflags} -z muldefs " BUILD_TYPE=Release install install_doc install_python
mkdir -p %{buildroot}/%{_libdir}/trace-cmd/python
find %{buildroot}%{_mandir} -type f | xargs chmod u-x,g-x,o-x
find %{buildroot}%{_datadir} -type f | xargs chmod u-x,g-x,o-x
mkdir -p %{buildroot}/%{_libdir}
find %{buildroot}%{_libdir} -type f -name "*.so" -print0 | xargs -0 -r chmod 0755
chmod -R 0755 %{buildroot}/%{_libdir}/trace-cmd/python
mkdir -p -m755 %{buildroot}/%{_sysconfdir}/sysconfig/
mkdir -p -m755 %{buildroot}/%{_unitdir}/
mkdir -p -m755 %{buildroot}/%{_udevrulesdir}/
install -p -m 644 trace-cmd.conf %{buildroot}/%{_sysconfdir}/sysconfig/
install -p -m 644 trace-cmd.service %{buildroot}/%{_unitdir}/
install -p -m 644 98-trace-cmd.rules %{buildroot}/%{_udevrulesdir}/
rm -rf %{buildroot}/%{_docdir}/libtracecmd-doc
rm -rf %{buildroot}/%{_mandir}/man3/*
%preun
%post
/sbin/ldconfig
%postun
/sbin/ldconfig
%systemd_preun %{name}.service
%files
%defattr(-,root,root)
%license COPYING COPYING.LIB
%doc README
%doc COPYING COPYING.LIB README
%{_bindir}/trace-cmd
%{_datadir}/applications/kernelshark.desktop
%{_mandir}/man1/%{name}*
%{_mandir}/man5/%{name}*
%{_docdir}/trace-cmd/trace-cmd*.html
%{_sysconfdir}/bash_completion.d/trace-cmd.bash
%{_docdir}/libtracecmd-doc/libtracecmd-files.html
%{_docdir}/libtracecmd-doc/libtracecmd-instances.html
%{_docdir}/libtracecmd-doc/libtracecmd-peer.html
%{_docdir}/libtracecmd-doc/libtracecmd-record.html
%{_docdir}/libtracecmd-doc/libtracecmd.html
%config(noreplace) /etc/ld.so.conf.d/*
%files help
%{_mandir}/man1/*
%{_mandir}/man3/*
%{_mandir}/man5/*
%{_sysconfdir}/sysconfig/trace-cmd.conf
%{_unitdir}/trace-cmd.service
%{_udevrulesdir}/98-trace-cmd.rules
%files python3
%doc Documentation/README.PythonPlugin
%{_libdir}/%{name}/python/
%changelog
* Tue Oct 22 2024 shafeipaozi <sunbo.oerv@isrc.iscas.ac.cn> - 3.2-1
- update to 3.2
* Tue Dec 26 2023 meiyang666 <wangmeiyang@xfusion.com> - 2.9.2-12
- Fix spec file