diff --git a/0001-python313.patch b/0001-python313.patch new file mode 100644 index 0000000000000000000000000000000000000000..42bf62a7e01dccf27affb873460df3211c41ac84 --- /dev/null +++ b/0001-python313.patch @@ -0,0 +1,28 @@ +From 2ba15130fae66e19d4d75ab28ef448b0206235c4 Mon Sep 17 00:00:00 2001 +From: Yaakov Selkowitz +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 +--- + 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 + diff --git a/98-trace-cmd.rules b/98-trace-cmd.rules new file mode 100644 index 0000000000000000000000000000000000000000..9575bd819a8e7f804e1a6ea91aa5511b1a920fb1 --- /dev/null +++ b/98-trace-cmd.rules @@ -0,0 +1 @@ +SUBSYSTEM=="module", ACTION=="add", PROGRAM="/usr/bin/systemctl is-active trace-cmd.service", PROGRAM="/usr/bin/systemctl reload trace-cmd.service" diff --git a/backport-Changing-default-install-path-of-plugins.patch b/backport-Changing-default-install-path-of-plugins.patch deleted file mode 100644 index 31ddfd368688cf270d9156d12d89bd3507fc0297..0000000000000000000000000000000000000000 --- a/backport-Changing-default-install-path-of-plugins.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 67b2de06ccd249f2b0dcc9b3e196e4fbcb943066 Mon Sep 17 00:00:00 2001 -From: Peter Bergin -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 -Signed-off-by: Steven Rostedt (VMware) ---- - 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 - diff --git a/backport-Fix-broken-profile-command.patch b/backport-Fix-broken-profile-command.patch deleted file mode 100644 index fd4f62dc9cb7df3d05095bae8278492c2bd2878d..0000000000000000000000000000000000000000 --- a/backport-Fix-broken-profile-command.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 7e12e8ba4001f51869f28770246f0ac3dbfb9999 Mon Sep 17 00:00:00 2001 -From: "Tzvetomir Stoyanov (VMware)" -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 -Fixes: 1762536da ("trace-cmd: Have tracecmd_read_headers() specify the state to read up to") -Signed-off-by: Tzvetomir Stoyanov (VMware) -Signed-off-by: Steven Rostedt (VMware) ---- - 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 - diff --git a/backport-Remove-unneeded-multiply-in-events-timesta.patch b/backport-Remove-unneeded-multiply-in-events-timesta.patch deleted file mode 100644 index 017e992660e45fbfb1ca0a74bbfc5363773d6e54..0000000000000000000000000000000000000000 --- a/backport-Remove-unneeded-multiply-in-events-timesta.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 43fa39ef1717e98ffe71ab0b53fefdfe1f02be3d Mon Sep 17 00:00:00 2001 -From: "Tzvetomir Stoyanov (VMware)" -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) -Signed-off-by: Steven Rostedt (VMware) ---- - 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 - diff --git a/backport-trace-cmd-library-Fix-version-string-memory-leak.patch b/backport-trace-cmd-library-Fix-version-string-memory-leak.patch deleted file mode 100644 index 1405ff5d331ca4702a92ff687f877baf1441a51c..0000000000000000000000000000000000000000 --- a/backport-trace-cmd-library-Fix-version-string-memory-leak.patch +++ /dev/null @@ -1,39 +0,0 @@ -From c5d548379b25705c2061b8c010f78fd242212f65 Mon Sep 17 00:00:00 2001 -From: "Tzvetomir Stoyanov (VMware)" -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) -Signed-off-by: Steven Rostedt (VMware) ---- - 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 - diff --git a/backport-trace-cmd-library-Fixed-a-memory-leak-on-input-handl.patch b/backport-trace-cmd-library-Fixed-a-memory-leak-on-input-handl.patch deleted file mode 100644 index e2465a71607df9b56fc99e0c6279b1315a0a42bd..0000000000000000000000000000000000000000 --- a/backport-trace-cmd-library-Fixed-a-memory-leak-on-input-handl.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 402be29ae6fa1e29c963c71be2713687a4a71686 Mon Sep 17 00:00:00 2001 -From: "Tzvetomir Stoyanov (VMware)" -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) -Signed-off-by: Steven Rostedt (VMware) ---- - 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 - diff --git a/backport-trace-cmd-report-Fix-typos-in-error-messages.patch b/backport-trace-cmd-report-Fix-typos-in-error-messages.patch deleted file mode 100644 index 0ddd8fb13764215ecb224cc5161d6850416b51ed..0000000000000000000000000000000000000000 --- a/backport-trace-cmd-report-Fix-typos-in-error-messages.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 9fd5f8ecd0bb98b6fdcfe75118b535f613226b9f Mon Sep 17 00:00:00 2001 -From: "Tzvetomir Stoyanov (VMware)" -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) -Signed-off-by: Steven Rostedt (VMware) ---- - 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 - diff --git a/trace-cmd-v2.9.2.tar.gz b/trace-cmd-v2.9.2.tar.gz deleted file mode 100644 index d93f882876287ff6958f524ed042f88fa345d8a2..0000000000000000000000000000000000000000 Binary files a/trace-cmd-v2.9.2.tar.gz and /dev/null differ diff --git a/trace-cmd-v3.2.tar.gz b/trace-cmd-v3.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..8c42b86391a9a5b25640dd6074ea96ab4b842530 Binary files /dev/null and b/trace-cmd-v3.2.tar.gz differ diff --git a/trace-cmd.conf b/trace-cmd.conf new file mode 100644 index 0000000000000000000000000000000000000000..85c4fbee3c1aeba1fa05f0996f6f428a8a58187b --- /dev/null +++ b/trace-cmd.conf @@ -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" diff --git a/trace-cmd.service b/trace-cmd.service new file mode 100644 index 0000000000000000000000000000000000000000..27b07f5e4f886b0da2ac17cea12d80248625d808 --- /dev/null +++ b/trace-cmd.service @@ -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 diff --git a/trace-cmd.spec b/trace-cmd.spec index a961f52b37545ebbebe84b4936b5aac8ef21584f..e31b7d1059b8bb2458653875b122689971467065 100644 --- a/trace-cmd.spec +++ b/trace-cmd.spec @@ -1,77 +1,121 @@ Name: trace-cmd -Version: 2.9.2 -Release: 9 +Version: 3.2 +Release: 2 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 - -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 - -BuildRequires: gcc xmlto asciidoc mlocate libxml2-devel chrpath -BuildRequires: gtk2-devel glib2-devel desktop-file-utils libtraceevent-devel -Provides: kernelshark -Obsoletes: kernelshark + +# 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 + +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 +Requires: libtraceevent + %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/* +%{_sysconfdir}/sysconfig/trace-cmd.conf +%{_unitdir}/trace-cmd.service +%{_udevrulesdir}/98-trace-cmd.rules %files help %{_mandir}/man1/* -%{_mandir}/man3/* %{_mandir}/man5/* + +%files python3 +%doc Documentation/README.PythonPlugin +%{_libdir}/%{name}/python/ %changelog +* Fri Nov 08 2024 wangkai <13474090681@163.com> - 3.2-2 +- Fix uninstall trace-cmd error and service start fail + +* Tue Oct 22 2024 shafeipaozi - 3.2-1 +- update to 3.2 + +* Tue Dec 26 2023 meiyang666 - 2.9.2-12 +- Fix spec file + +* Tue Dec 26 2023 meiyang666 - 2.9.2-11 +- trace-cmd record: Set sleep_time to zero at end of recording + +* Tue Dec 26 2023 meiyang666 - 2.9.2-10 +- trace-cmd stream: Set default sleep time to half a second + * Mon Jan 09 2023 Bolehu - 2.9.2-9 - Fix broken profile command