Compare commits

..

No commits in common. "c8" and "c10s" have entirely different histories.
c8 ... c10s

33 changed files with 945 additions and 1130 deletions

17
.gitignore vendored
View File

@ -1 +1,16 @@
SOURCES/trace-cmd-v2.7.tar.gz
/trace-cmd-1.2.20120606git8266dff.tar.gz
/trace-cmd-2.1.0.tar.gz
/trace-cmd-2.2.1.tar.gz
/trace-cmd-2.6.tar.gz
/trace-cmd-2.6.1.tar.gz
/trace-cmd-v2.6.2.tar.gz
/trace-cmd-v2.7.tar.gz
/trace-cmd-v2.8.3.tar.gz
/trace-cmd-v2.9.1.tar.gz
/trace-cmd-v2.9.2.tar.gz
/trace-cmd-v2.9.7.tar.gz
/trace-cmd-v3.0.3.tar.gz
/trace-cmd-v3.1.4.tar.gz
/trace-cmd-v3.1.6.tar.gz
/trace-cmd-v3.2.tar.gz
/trace-cmd-v3.3.1.tar.gz

View File

@ -1 +0,0 @@
f95c34b6d9090b81f5c91e97ef71e6b6d835147b SOURCES/trace-cmd-v2.7.tar.gz

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 7e8a6e3d03c0a6a7a5014ce488be1e16f99db006 Mon Sep 17 00:00:00 2001
From: Zamir SUN <sztsian@gmail.com>
Date: Sat, 11 Nov 2017 10:28:32 +0800
Subject: [PATCH] trace-cmd: Figure out the arch and install library to the
right place
Signed-off-by: Zamir SUN <sztsian@gmail.com>
---
Makefile | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 5c35143..d10e547 100644
--- a/Makefile
+++ b/Makefile
@@ -47,7 +47,13 @@ html_install = $(prefix)/share/kernelshark/html
html_install_SQ = '$(subst ','\'',$(html_install))'
img_install = $(prefix)/share/kernelshark/html/images
img_install_SQ = '$(subst ','\'',$(img_install))'
-libdir ?= $(prefix)/lib
+
+# figure out what arch we are on and install to the right place
+ARCH = $(shell getconf LONG_BIT)
+LIBDIR_32 = /lib
+LIBDIR_64 = /lib64
+
+libdir ?= $(prefix)/$(LIBDIR_$(ARCH))
libdir_SQ = '$(subst ','\'',$(libdir))'
includedir = $(prefix)/include/trace-cmd
includedir_SQ = '$(subst ','\'',$(includedir))'
--
2.13.4

View File

@ -1,53 +0,0 @@
From a57b906f58c8d293a1a353dbc5dabea237875759 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Thu, 4 Jun 2015 21:02:13 +0200
Subject: [PATCH] Add trace-cmd flightrecorder service
Make it possible to start and stop trace-cmd commands at start-up time.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
98-trace-cmd.rules | 1 +
trace-cmd.conf | 4 ++++
trace-cmd.service | 10 ++++++++++
3 files changed, 15 insertions(+)
create mode 100644 98-trace-cmd.rules
create mode 100644 trace-cmd.conf
create mode 100644 trace-cmd.service
diff --git a/98-trace-cmd.rules b/98-trace-cmd.rules
new file mode 100644
index 000000000000..7c073692a0ab
--- /dev/null
+++ b/98-trace-cmd.rules
@@ -0,0 +1 @@
+SUBSYSTEM=="module", ACTION=="add", PROGRAM="/usr/bin/systemctl try-restart trace-cmd.service"
diff --git a/trace-cmd.conf b/trace-cmd.conf
new file mode 100644
index 000000000000..22896d961d64
--- /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 sys_enter -e sys_exit -e timer -e workqueue -e kvm -e net"
diff --git a/trace-cmd.service b/trace-cmd.service
new file mode 100644
index 000000000000..6439b490f8f4
--- /dev/null
+++ b/trace-cmd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=trace-cmd Flightrecorder
+
+[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 reset; /usr/bin/trace-cmd start $OPTS
--
1.8.3.1

View File

@ -1,170 +0,0 @@
From 1132270594314acb2eed250f1690d5b10d0fb47c Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Tue, 30 Jun 2015 14:30:47 +0200
Subject: [PATCH] Various fixes for trace-cmd flightrecorder - systemd files
1) Allow systemctl enable trace-cmd.service to start trace-cmd.service automatically at system boot
2) Don't stop trace-cmd.service at system shutdown
3) Don't stop trace-cmd.service at each kernel module loading
4) Start trace-cmd.service before any normal services
1) Allow systemctl enable trace-cmd.service to start trace-cmd.service automatically at system boot
I added [Install] section in trace-cmd.service. This is necessary to
make trace-cmd.service automatically get started at system
boot. Without the [Install] section, systemctl enable
trace-cmd.service fails as below:
~]# systemctl enable trace-cmd.service
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
WantedBy=multi-user.target in trace-cmd.service means that
trace-cmd.service is started if multi-user.target, traditional
runlevel 3, is active.
2) Don't stop trace-cmd.service at system shutdown
In the current configuration, trace-cmd reset is executed when
trace-cmd.service is stopped at system shutdown. Then, trace buffer is
cleared. This could become a problem if system crash happens at system
shutdown. Even if we get a crash dump at the crash during system
shutdown, the crash dump doesn't contain useful trace data.
To fix the issue, it's necessary to make trace-cmd.service not stop at
system shutdown.
To achieve this, I added DefaultDependencies=no into trace-cmd.service.
To understand this, first you need to understand how systemd achieves
system shutdown. Look at the description of shutdown.target in man 7
systemd.special.
shutdown.target
A special target unit that terminates the services on
system shutdown.
Services that shall be terminated on system shutdown
shall add Conflicts= dependencies to this unit for their
service unit, which is implicitly done when
DefaultDependencies=yes is set (the default).
As this explains, systemd adds Conflicts=shutdown.target dependency to
all the unit files by default. By this, if we shutdown system for
example by systemctl poweroff, then all the currently active services
with the default dependency get stopped when shutdown.target is pulled
in.
Thus, in order not to stop trace-cmd.service at system shutdown, it's
necessary to remove the default Conflicts=shutdown.target
dependency. This is achieved by DefaultDependencies=no.
Also, we need to consider a default dependency around basic.target
that is explained in man 7 systemd.special as follows:
basic.target
A special target unit covering basic boot-up.
systemd automatically adds dependencies of the types
Requires= and After= for this target unit to all
services (except for those with DefaultDependencies=no).
Usually this should pull-in all mount points, swap
devices, sockets, timers, and path units and other basic
initialization necessary for general purpose daemons.
As this explains, Requires=basic.target is assigned to each service by
default.
Requires=basic.target means that the service tries to pull in the
basic.target when it's pulled in and gets stopped if the basic.target
gets stopped.
This means that trace-cmd.service gets stopped at system shutdown via
Requires=basic.target when basic.target is stopped.
Thus, not to stop trace-cmd.service at system shutdown, it's necessary
to remove the default Requires=basic.target dependency. This is again
achieved by DefaultDependencies=no.
3) Don't stop trace-cmd.service at each kernel module loading
We have now udev configuration that restarts trace-cmd.service each
time some kernel module is loaded. However, systemctl restart
trace-cmd.service means that systemctl stop trace-cmd.service and then
systemctl start trace-cmd.service. trace data gets lost when the
systemctl stop trace-cmd.service is executed as I explained above.
To fix the issue, we remove trace-cmd reset from ExecReload= in
trace-cmd.service and use systemctl reload trace-cmd.service in the
udev script instead of systemctl try-restart trace-cmd.service.
Note that it's enough to trace-cmd start to enable trace events of
newly loaded kernel modules.
Also note that systemctl is-active trace-cmd.service in the udev
script is needed to avoid executing systemctl reload trace-cmd.service
when trace-cmd.service is inactive. Without systemctl is-active
trace-cmd.service, systemctl reload trace-cmd.service is executed even
when trace-cmd.service is inactive and then logs the following
message:
Jun 12 20:24:25 localhost systemd: Unit trace-cmd.service cannot be reloaded because it is inactive.
4) Start trace-cmd.service before any normal services
trace-cmd.service needs to start early enough to collect useful kernel
event information. It's too late if any of the normal services has
started.
To achieve this, DefaultDependencies=no is again needed to remove
After=basic.target dependency assigned by default that is explained in
man 7 systemd.special.
Also, we need Before=basic.target to start trace-cmd.service *before*
any normal services, i.e. any services with the default
After=basic.target dependency.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
98-trace-cmd.rules | 2 +-
trace-cmd.service | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/98-trace-cmd.rules b/98-trace-cmd.rules
index 7c073692a0ab..9575bd819a8e 100644
--- a/98-trace-cmd.rules
+++ b/98-trace-cmd.rules
@@ -1 +1 @@
-SUBSYSTEM=="module", ACTION=="add", PROGRAM="/usr/bin/systemctl try-restart trace-cmd.service"
+SUBSYSTEM=="module", ACTION=="add", PROGRAM="/usr/bin/systemctl is-active trace-cmd.service", PROGRAM="/usr/bin/systemctl reload trace-cmd.service"
diff --git a/trace-cmd.service b/trace-cmd.service
index 6439b490f8f4..a5cdd046ca0c 100644
--- a/trace-cmd.service
+++ b/trace-cmd.service
@@ -1,5 +1,7 @@
[Unit]
Description=trace-cmd Flightrecorder
+DefaultDependencies=no
+Before=basic.target
[Service]
Type=oneshot
@@ -7,4 +9,7 @@ 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 reset; /usr/bin/trace-cmd start $OPTS
+ExecReload=/usr/bin/trace-cmd start $OPTS
+
+[Install]
+WantedBy=multi-user.target
--
1.8.3.1

View File

@ -1,7 +0,0 @@
[Desktop Entry]
Name=Kernelshark
Comment=Analyze data output by trace-cmd
Exec=kernelshark
Type=Application
Categories=Development;Profiling;
Icon=applications-development

View File

@ -1,65 +0,0 @@
From 8e8f12df7500f501447a2926a9e1db9ff42d882c Mon Sep 17 00:00:00 2001
From: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Date: Fri, 12 Apr 2019 11:22:49 -0300
Subject: [PATCH] tools lib traceevent: Fix missing equality check for strcmp
There was a missing comparison with 0 when checking if type is "s64" or
"u64". Therefore, the body of the if-statement was entered if "type" was
"u64" or not "s64", which made the first strcmp() redundant since if
type is "u64", it's not "s64".
If type is "s64", the body of the if-statement is not entered but since
the remainder of the function consists of if-statements which will not
be entered if type is "s64", we will just return "val", which is
correct, albeit at the cost of a few more calls to strcmp(), i.e., it
will behave just as if the if-statement was entered.
If type is neither "s64" or "u64", the body of the if-statement will be
entered incorrectly and "val" returned. This means that any type that is
checked after "s64" and "u64" is handled the same way as "s64" and
"u64", i.e., the limiting of "val" to fit in for example "s8" is never
reached.
This was introduced in the kernel tree when the sources were copied from
trace-cmd in commit f7d82350e597 ("tools/events: Add files to create
libtraceevent.a"), and in the trace-cmd repo in 1cdbae6035cei
("Implement typecasting in parser") when the function was introduced,
i.e., it has always behaved the wrong way.
Detected by cppcheck.
Link: http://lkml.kernel.org/r/20190412142250.20595-7-acme@kernel.org
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Clark Williams <williams@redhat.com>
Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Fixes: f7d82350e597 ("tools/events: Add files to create libtraceevent.a")
Link: http://lkml.kernel.org/r/20190409091529.2686-1-rikard.falkeborn@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
event-parse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/event-parse.c b/event-parse.c
index e5f2acbb70cc..7dba02bd19fe 100644
--- a/event-parse.c
+++ b/event-parse.c
@@ -2206,7 +2206,7 @@ eval_type_str(unsigned long long val, const char *type, int pointer)
return val & 0xffffffff;
if (strcmp(type, "u64") == 0 ||
- strcmp(type, "s64"))
+ strcmp(type, "s64") == 0)
return val;
if (strcmp(type, "s8") == 0)
--
2.20.1

View File

@ -1,105 +0,0 @@
From c4936880059251b28b7049f01bbfddb1882bda0e Mon Sep 17 00:00:00 2001
From: Slavomir Kaslev <kaslevs@vmware.com>
Date: Wed, 17 Apr 2019 21:31:57 +0300
Subject: [PATCH 2/2] trace-cmd: Add --no-filter option to not filter out
recording processes
Add trace-cmd --no-filter option that disables filtering out of trace-cmd
recording processes from the trace.
Link: http://lore.kernel.org/linux-trace-devel/20190417183157.8776-2-kaslevs@vmware.com
Tested-by: Phil Auld <pauld@redhat.com>
Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
Documentation/trace-cmd-record.1.txt | 5 +++++
trace-record.c | 14 +++++++++++---
trace-usage.c | 1 +
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/Documentation/trace-cmd-record.1.txt b/Documentation/trace-cmd-record.1.txt
index 68afa161ac32..26a8299cd860 100644
--- a/Documentation/trace-cmd-record.1.txt
+++ b/Documentation/trace-cmd-record.1.txt
@@ -83,6 +83,11 @@ OPTIONS
The above are usually safe to use to compare fields.
+*--no-filter*::
+ Do not filter out the trace-cmd threads. By default, the threads are
+ filtered out to not be traced by events. This option will have the trace-cmd
+ threads also be traced.
+
*-R* 'trigger'::
Specify a trigger for the previous event. This must come after a *-e*.
This will add a given trigger to the given event. To only enable the trigger
diff --git a/trace-record.c b/trace-record.c
index e636c97d701d..ef4c4c873fd4 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -99,6 +99,7 @@ static int do_ptrace;
static int filter_task;
static int filter_pid = -1;
+static bool no_filter = false;
static int local_cpu_count;
@@ -1018,6 +1019,9 @@ static void update_task_filter(void)
struct buffer_instance *instance;
int pid = getpid();
+ if (no_filter)
+ return;
+
if (filter_task)
add_filter_pid(pid, 0);
@@ -4343,9 +4347,9 @@ void update_first_instance(struct buffer_instance *instance, int topt)
}
enum {
-
- OPT_quiet = 246,
- OPT_debug = 247,
+ OPT_quiet = 245,
+ OPT_debug = 246,
+ OPT_no_filter = 247,
OPT_max_graph_depth = 248,
OPT_tsoffset = 249,
OPT_bycomm = 250,
@@ -4592,6 +4596,7 @@ static void parse_record_options(int argc,
{"by-comm", no_argument, NULL, OPT_bycomm},
{"ts-offset", required_argument, NULL, OPT_tsoffset},
{"max-graph-depth", required_argument, NULL, OPT_max_graph_depth},
+ {"no-filter", no_argument, NULL, OPT_no_filter},
{"debug", no_argument, NULL, OPT_debug},
{"quiet", no_argument, NULL, OPT_quiet},
{"help", no_argument, NULL, '?'},
@@ -4866,6 +4871,9 @@ static void parse_record_options(int argc,
if (!ctx->max_graph_depth)
die("Could not allocate option");
break;
+ case OPT_no_filter:
+ no_filter = true;
+ break;
case OPT_debug:
debug = 1;
break;
diff --git a/trace-usage.c b/trace-usage.c
index 10f737b340df..dc73d4d90688 100644
--- a/trace-usage.c
+++ b/trace-usage.c
@@ -56,6 +56,7 @@ static struct usage_help usage_help[] = {
" --func-stack perform a stack trace for function tracer\n"
" (use with caution)\n"
" --max-graph-depth limit function_graph depth\n"
+ " --no-filter include trace-cmd threads in the trace\n"
},
{
"start",
--
2.20.1

View File

@ -1,174 +0,0 @@
From b206acf0f4bb4a8aff22b14139b6d5fdcb110b77 Mon Sep 17 00:00:00 2001
From: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Date: Wed, 2 Jun 2021 11:08:03 +0200
Subject: [PATCH] trace-cmd: Add option to poll trace buffers
Waiting for data to be available on the trace ring-buffers may trigger
IPIs. This might generate unacceptable trace noise when debugging low
latency or real time systems. So introduce the poll option. When
enabled, it forces trace-cmd to use O_NONBLOCK. The drawback to using it
is that traces will be extracted by busy waiting, which will
unnecessarily hog the CPUs, so only use when really needed.
Link: https://lore.kernel.org/linux-trace-devel/20210602090803.12233-1-nsaenzju@redhat.com
Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
Documentation/trace-cmd-record.1.txt | 7 +++++++
trace-cmd.h | 4 +++-
trace-record.c | 9 ++++++++-
trace-recorder.c | 29 +++++++++++++++-------------
trace-usage.c | 1 +
5 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/Documentation/trace-cmd-record.1.txt b/Documentation/trace-cmd-record.1.txt
index 26a8299c..2b3ce636 100644
--- a/Documentation/trace-cmd-record.1.txt
+++ b/Documentation/trace-cmd-record.1.txt
@@ -331,6 +331,13 @@ OPTIONS
executed will not be changed. This is useful if you want to monitor the
output of the command being executed, but not see the output from trace-cmd.
+*--poll*::
+ Waiting for data to be available on the trace ring-buffers may trigger
+ IPIs. This might generate unacceptable trace noise when tracing low latency
+ or real time systems. The poll option forces trace-cmd to use O_NONBLOCK.
+ Traces are extracted by busy waiting, which will hog the CPUs, so only use
+ when really needed.
+
EXAMPLES
--------
diff --git a/trace-cmd.h b/trace-cmd.h
index 75951b5e..4cc9db2a 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -279,7 +279,9 @@ int tracecmd_attach_cpu_data_fd(int fd, int cpus, char * const *cpu_data_files);
enum {
TRACECMD_RECORD_NOSPLICE = (1 << 0), /* Use read instead of splice */
TRACECMD_RECORD_SNAPSHOT = (1 << 1), /* extract from snapshot */
- TRACECMD_RECORD_BLOCK = (1 << 2), /* Block on splice write */
+ TRACECMD_RECORD_BLOCK_SPLICE = (1 << 2), /* Block on splice write */
+ TRACECMD_RECORD_NOBRASS = (1 << 3), /* Splice directly without a brass pipe */
+ TRACECMD_RECORD_POLL = (1 << 4), /* Use O_NONBLOCK, poll trace buffers */
};
void tracecmd_free_recorder(struct tracecmd_recorder *recorder);
diff --git a/trace-record.c b/trace-record.c
index ef4c4c87..1872e3c4 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -2622,7 +2622,7 @@ create_recorder_instance_pipe(struct buffer_instance *instance,
int cpu, int *brass)
{
struct tracecmd_recorder *recorder;
- unsigned flags = recorder_flags | TRACECMD_RECORD_BLOCK;
+ unsigned flags = recorder_flags | TRACECMD_RECORD_BLOCK_SPLICE;
char *path;
if (instance->name)
@@ -4359,6 +4359,9 @@ enum {
OPT_funcstack = 254,
OPT_date = 255,
OPT_module = 256,
+ OPT_nofifos = 257,
+ OPT_cmdlines_size = 258,
+ OPT_poll = 259,
};
void trace_stop(int argc, char **argv)
@@ -4601,6 +4604,7 @@ static void parse_record_options(int argc,
{"quiet", no_argument, NULL, OPT_quiet},
{"help", no_argument, NULL, '?'},
{"module", required_argument, NULL, OPT_module},
+ {"poll", no_argument, NULL, OPT_poll},
{NULL, 0, NULL, 0}
};
@@ -4884,6 +4888,9 @@ static void parse_record_options(int argc,
ctx->instance->filter_mod = optarg;
ctx->filtered = 0;
break;
+ case OPT_poll:
+ recorder_flags |= TRACECMD_RECORD_POLL;
+ break;
case OPT_quiet:
case 'q':
quiet = 1;
diff --git a/trace-recorder.c b/trace-recorder.c
index 75290285..97dceccf 100644
--- a/trace-recorder.c
+++ b/trace-recorder.c
@@ -115,6 +115,18 @@ void tracecmd_free_recorder(struct tracecmd_recorder *recorder)
free(recorder);
}
+static void set_nonblock(struct tracecmd_recorder *recorder)
+{
+ long flags;
+
+ /* Do not block on reads for flushing */
+ flags = fcntl(recorder->trace_fd, F_GETFL);
+ fcntl(recorder->trace_fd, F_SETFL, flags | O_NONBLOCK);
+
+ /* Do not block on streams for write */
+ recorder->fd_flags |= 2; /* NON_BLOCK */
+}
+
struct tracecmd_recorder *
tracecmd_create_buffer_recorder_fd2(int fd, int fd2, int cpu, unsigned flags,
const char *buffer, int maxkb)
@@ -133,7 +145,7 @@ tracecmd_create_buffer_recorder_fd2(int fd, int fd2, int cpu, unsigned flags,
recorder->fd_flags = 1; /* SPLICE_F_MOVE */
- if (!(recorder->flags & TRACECMD_RECORD_BLOCK))
+ if (!(recorder->flags & TRACECMD_RECORD_BLOCK_SPLICE))
recorder->fd_flags |= 2; /* and NON_BLOCK */
/* Init to know what to free and release */
@@ -192,6 +204,9 @@ tracecmd_create_buffer_recorder_fd2(int fd, int fd2, int cpu, unsigned flags,
recorder->pipe_size = pipe_size;
}
+ if (recorder->flags & TRACECMD_RECORD_POLL)
+ set_nonblock(recorder);
+
free(path);
return recorder;
@@ -421,18 +436,6 @@ static long read_data(struct tracecmd_recorder *recorder)
return r;
}
-static void set_nonblock(struct tracecmd_recorder *recorder)
-{
- long flags;
-
- /* Do not block on reads for flushing */
- flags = fcntl(recorder->trace_fd, F_GETFL);
- fcntl(recorder->trace_fd, F_SETFL, flags | O_NONBLOCK);
-
- /* Do not block on streams for write */
- recorder->fd_flags |= 2; /* NON_BLOCK */
-}
-
long tracecmd_flush_recording(struct tracecmd_recorder *recorder)
{
char buf[recorder->page_size];
diff --git a/trace-usage.c b/trace-usage.c
index dc73d4d9..a9474ad3 100644
--- a/trace-usage.c
+++ b/trace-usage.c
@@ -57,6 +57,7 @@ static struct usage_help usage_help[] = {
" (use with caution)\n"
" --max-graph-depth limit function_graph depth\n"
" --no-filter include trace-cmd threads in the trace\n"
+ " --poll don't block while reading from the trace buffer\n"
},
{
"start",
--
2.31.1

View File

@ -1,35 +0,0 @@
From 34762bbe9ecd4913bd4a8d04a3ef24cfac6c3d54 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Mon, 11 Jun 2018 14:41:22 +0200
Subject: [PATCH] trace-cmd: Force no build of python2 plugin
Force no build of python2 plugin
Signed-off-by: John Kacur <jkacur@redhat.com>
---
Makefile | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index a5d2c384415b..62c469393a76 100644
--- a/Makefile
+++ b/Makefile
@@ -92,11 +92,12 @@ ifndef VERBOSE
VERBOSE = 0
endif
-SWIG_DEFINED := $(shell if swig -help &> /dev/null; then echo 1; else echo 0; fi)
-ifeq ($(SWIG_DEFINED), 0)
+# SWIG_DEFINED := $(shell if swig -help &> /dev/null; then echo 1; else echo 0; fi)
+# Don't build python2 plugin
+#ifeq ($(SWIG_DEFINED), 0)
BUILD_PYTHON := report_noswig
NO_PYTHON = 1
-endif
+#endif
ifndef NO_PYTHON
PYTHON := ctracecmd.so
--
2.14.4

View File

@ -1,32 +0,0 @@
From a7f654a1fa9087312e77be82574abc1fe10c2ab6 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Tue, 31 Jul 2018 14:53:31 +0200
Subject: [PATCH] trace-cmd: Makefile: Consistent ELF application hardening
build flags
These are the recommend build changes for Redhat
Signed-off-by: John Kacur <jkacur@redhat.com>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 62c469393a76..17eacc114450 100644
--- a/Makefile
+++ b/Makefile
@@ -243,9 +243,9 @@ INCLUDES = -I. -I ./include -I $(srctree)/../../include $(CONFIG_INCLUDES)
include $(src)/features.mk
# Set compile option CFLAGS if not set elsewhere
-CFLAGS ?= -g -Wall
+CFLAGS ?= -g -Wall -fPIE -fstack-protector-strong --param=ssp-buffer-size=4 -fstack-clash-protection -fexceptions
CPPFLAGS ?=
-LDFLAGS ?=
+LDFLAGS ?= -pie -Wl,-z,now
# Required CFLAGS
override CFLAGS += -D_GNU_SOURCE
--
2.14.4

View File

@ -1,182 +0,0 @@
From db8893838433972feafe545117b60dca8c7318df Mon Sep 17 00:00:00 2001
From: Slavomir Kaslev <kaslevs@vmware.com>
Date: Wed, 17 Apr 2019 16:09:58 +0300
Subject: [PATCH 1/2] trace-cmd: Optimize how pid filters are expressed
Express pid filters as allowed/disallowed filter ranges
(pid>=100&&pid<=103)
instead of specifying them per pid
(pid==100||pid==101||pid==102||pid==103)
This makes the size of the resulting filter smaller (and faster) and avoids
overflowing the filter size limit of one page which we can hit on bigger
machines (say >160 CPUs).
Link: http://lore.kernel.org/linux-trace-devel/20190417130959.10064-2-kaslevs@vmware.com
Reported-by: Phil Auld <pauld@redhat.com>
Tested-by: Phil Auld <pauld@redhat.com>
Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
trace-record.c | 117 ++++++++++++++++++++++++++++++++++---------------
1 file changed, 81 insertions(+), 36 deletions(-)
diff --git a/trace-record.c b/trace-record.c
index 9479f5f8073c..e636c97d701d 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -903,10 +903,63 @@ static void update_ftrace_pids(int reset)
static void update_event_filters(struct buffer_instance *instance);
static void update_pid_event_filters(struct buffer_instance *instance);
+static void append_filter_pid_range(char **filter, int *curr_len,
+ const char *field,
+ int start_pid, int end_pid, bool exclude)
+{
+ const char *op = "", *op1, *op2, *op3;
+ int len;
+
+ if (*filter && **filter)
+ op = exclude ? "&&" : "||";
+
+ /* Handle thus case explicitly so that we get `pid==3` instead of
+ * `pid>=3&&pid<=3` for singleton ranges
+ */
+ if (start_pid == end_pid) {
+#define FMT "%s(%s%s%d)"
+ len = snprintf(NULL, 0, FMT, op,
+ field, exclude ? "!=" : "==", start_pid);
+ *filter = realloc(*filter, *curr_len + len + 1);
+ if (!*filter)
+ die("realloc");
+
+ len = snprintf(*filter + *curr_len, len + 1, FMT, op,
+ field, exclude ? "!=" : "==", start_pid);
+ *curr_len += len;
+
+ return;
+#undef FMT
+ }
+
+ if (exclude) {
+ op1 = "<";
+ op2 = "||";
+ op3 = ">";
+ } else {
+ op1 = ">=";
+ op2 = "&&";
+ op3 = "<=";
+ }
+
+#define FMT "%s(%s%s%d%s%s%s%d)"
+ len = snprintf(NULL, 0, FMT, op,
+ field, op1, start_pid, op2,
+ field, op3, end_pid);
+ *filter = realloc(*filter, *curr_len + len + 1);
+ if (!*filter)
+ die("realloc");
+
+ len = snprintf(*filter + *curr_len, len + 1, FMT, op,
+ field, op1, start_pid, op2,
+ field, op3, end_pid);
+ *curr_len += len;
+}
+
/**
* make_pid_filter - create a filter string to all pids against @field
* @curr_filter: Append to a previous filter (may realloc). Can be NULL
- * @field: The fild to compare the pids against
+ * @field: The field to compare the pids against
*
* Creates a new string or appends to an existing one if @curr_filter
* is not NULL. The new string will contain a filter with all pids
@@ -916,54 +969,46 @@ static void update_pid_event_filters(struct buffer_instance *instance);
*/
static char *make_pid_filter(char *curr_filter, const char *field)
{
+ int start_pid = -1, last_pid = -1;
+ int last_exclude = -1;
struct filter_pids *p;
- char *filter;
- char *orit;
- char *match;
- char *str;
+ char *filter = NULL;
int curr_len = 0;
- int len;
/* Use the new method if possible */
if (have_set_event_pid)
return NULL;
- len = len_filter_pids + (strlen(field) + strlen("(==)||")) * nr_filter_pids;
-
- if (curr_filter) {
- curr_len = strlen(curr_filter);
- filter = realloc(curr_filter, curr_len + len + strlen("(&&())"));
- if (!filter)
- die("realloc");
- memmove(filter+1, curr_filter, curr_len);
- filter[0] = '(';
- strcat(filter, ")&&(");
- curr_len = strlen(filter);
- } else
- filter = malloc(len);
- if (!filter)
- die("Failed to allocate pid filter");
-
- /* Last '||' that is not used will cover the \0 */
- str = filter + curr_len;
+ if (!filter_pids)
+ return curr_filter;
for (p = filter_pids; p; p = p->next) {
- if (p->exclude) {
- match = "!=";
- orit = "&&";
- } else {
- match = "==";
- orit = "||";
+ /*
+ * PIDs are inserted in `filter_pids` from the front and that's
+ * why we expect them in descending order here.
+ */
+ if (p->pid == last_pid - 1 && p->exclude == last_exclude) {
+ last_pid = p->pid;
+ continue;
}
- if (p == filter_pids)
- orit = "";
- len = sprintf(str, "%s(%s%s%d)", orit, field, match, p->pid);
- str += len;
+ if (start_pid != -1)
+ append_filter_pid_range(&filter, &curr_len, field,
+ last_pid, start_pid,
+ last_exclude);
+
+ start_pid = last_pid = p->pid;
+ last_exclude = p->exclude;
+
}
+ append_filter_pid_range(&filter, &curr_len, field,
+ last_pid, start_pid, last_exclude);
- if (curr_len)
- sprintf(str, ")");
+ if (curr_filter) {
+ char *save = filter;
+ asprintf(&filter, "(%s)&&(%s)", curr_filter, filter);
+ free(save);
+ }
return filter;
}
--
2.20.1

View File

@ -1,272 +0,0 @@
# git tag
#%%global git_commit trace-cmd-v2.6.2
#%%global git_commit 57371aaa2f469d0ba15fd85276deca7bfdd7ce36
Name: trace-cmd
Version: 2.7
Release: 10%{?dist}
License: GPLv2 and LGPLv2
Summary: A user interface to Ftrace
URL: http://git.kernel.org/?p=linux/kernel/git/rostedt/trace-cmd.git;a=summary
# If upstream does not provide tarballs, to generate:
# git clone git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/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/linux/kernel/git/rostedt/trace-cmd.git/snapshot/%{name}-v%{version}.tar.gz
Source1: kernelshark.desktop
Patch1: 0001-trace-cmd-Figure-out-the-arch-and-install-library-to.patch
Patch2: trace-cmd-Force-no-build-of-python2-plugin.patch
Patch3: Add-trace-cmd-flightrecorder-service.patch
Patch4: Various-fixes-for-trace-cmd-flightrecorder-systemd.patch
Patch5: trace-cmd-Makefile-Consistent-ELF-application-harden.patch
Patch6: trace-cmd-Optimize-how-pid-filters-are-expressed.patch
Patch7: trace-cmd-Add-no-filter-option-to-not-filter-out-rec.patch
Patch8: tools-lib-traceevent-Fix-missing-equality-check.patch
Patch9: trace-cmd-Add-option-to-poll-trace-buffers.patch
BuildRequires: xmlto
BuildRequires: asciidoc
BuildRequires: mlocate
BuildRequires: systemd
# needed for the GUI parts
BuildRequires: libxml2-devel
BuildRequires: gtk2-devel
BuildRequires: glib2-devel
BuildRequires: desktop-file-utils
%description
trace-cmd is a user interface to Ftrace. Instead of needing to use the
debugfs directly, trace-cmd will handle of setting of options and
tracers and will record into a data file.
%package -n kernelshark
Summary: GUI analysis for Ftrace data captured by trace-cmd
Requires: trace-cmd%{_isa} = %{version}-%{release}
%description -n kernelshark
Kernelshark is the GUI frontend for analyzing data produced by
'trace-cmd extract'
%prep
%autosetup -p1 -n %{name}-v%{version}
%build
# MANPAGE_DOCBOOK_XSL define is hack to avoid using locate
MANPAGE_DOCBOOK_XSL=`rpm -ql docbook-style-xsl | grep manpages/docbook.xsl`
make V=1 CFLAGS="%{optflags} -D_GNU_SOURCE -g -Wall -fPIE -fstack-protector-strong --param=ssp-buffer-size=4 -fstack-clash-protection -fexceptions" LDFLAGS="%{build_ldflags} -pie -Wl,-z,now" \
MANPAGE_DOCBOOK_XSL=$MANPAGE_DOCBOOK_XSL prefix=%{_prefix} all doc gui
%install
make V=1 DESTDIR=%{buildroot}/ prefix=%{_prefix} install install_doc install_gui
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
find %{buildroot}%{_libdir} -type f -iname "*.so" | xargs chmod 0755
install -dm 755 %{buildroot}/%{_datadir}/applications
install -pm 644 %{SOURCE1} %{buildroot}/%{_datadir}/applications/kernelshark.desktop
mkdir -p %{buildroot}/%{_unitdir}/
mkdir -p %{buildroot}/%{_sysconfdir}/sysconfig/
mkdir -p %{buildroot}/%{_udevrulesdir}
install -p -m 644 trace-cmd.service %{buildroot}/%{_unitdir}/
install -p -m 644 trace-cmd.conf %{buildroot}/%{_sysconfdir}/sysconfig/
install -p -m 644 98-trace-cmd.rules %{buildroot}/%{_udevrulesdir}/
desktop-file-validate %{buildroot}/%{_datadir}/applications/kernelshark.desktop
%files
%doc COPYING COPYING.LIB README
%{_bindir}/trace-cmd
%dir %{_libdir}/%{name}
%dir %{_libdir}/%{name}/plugins
%{_libdir}/%{name}/plugins/plugin_blk.so
%{_libdir}/%{name}/plugins/plugin_cfg80211.so
%{_libdir}/%{name}/plugins/plugin_function.so
%{_libdir}/%{name}/plugins/plugin_hrtimer.so
%{_libdir}/%{name}/plugins/plugin_jbd2.so
%{_libdir}/%{name}/plugins/plugin_kmem.so
%{_libdir}/%{name}/plugins/plugin_kvm.so
%{_libdir}/%{name}/plugins/plugin_mac80211.so
%{_libdir}/%{name}/plugins/plugin_sched_switch.so
%{_libdir}/%{name}/plugins/plugin_scsi.so
%{_libdir}/%{name}/plugins/plugin_tlb.so
%{_libdir}/%{name}/plugins/plugin_xen.so
%{_mandir}/man1/trace-cmd*
%{_mandir}/man5/*
%{_unitdir}/trace-cmd.service
%{_sysconfdir}/sysconfig/trace-cmd.conf
%{_udevrulesdir}/98-trace-cmd.rules
%files -n kernelshark
%{_bindir}/trace-view
%{_bindir}/trace-graph
%{_bindir}/kernelshark
%{_datadir}/kernelshark
%{_datadir}/applications/kernelshark.desktop
%{_sysconfdir}/bash_completion.d/trace-cmd.bash
%{_mandir}/man1/kernelshark.1.gz
%changelog
* Fri Oct 08 2021 Jerome Marchand <jmarchan@redhat.com> - 2.7-10
- Add poll option
* Wed Feb 03 2021 Jerome Marchand <jmarchan@redhat.com> - 2.7-9
- Filter fixes.
* Fri Apr 26 2019 John Kacur <jkacur@redhat.com> - 2.7-8
- Install kernelshark manpage with kernelshark subpackage, not with trace-cmd
Resolves: rhbz#1678252
* Tue Apr 02 2019 Clark Williams <williams@redhat.com> - 2.7-7
- added OSCI gating framework
Resolves: rhbz#1682420
* Thu Nov 15 2018 John Kacur <jkacur@redhat.com> - 2.7-6
- The changes to the Makefile need to be applied from the specfile too.
Resolves: rhbz#1601040
* Tue Jul 31 2018 John Kacur <jkacur@redhat.com> - 2.7-5
- trace-cmd-Makefile-Consistent-ELF-application-harden.patch
Resolves: rhbz#1601040
* Mon Jun 11 2018 John Kacur <jkacur@redhat.com> - 2.7-4
- Remove the unsupported python2 plugin
Resolves: rhbz#1589786
* Tue May 29 2018 John Kacur <jkacur@redhat.com> - 2.7-3
- Add trace-cmd flightrecorder services
Resolves: rhbz#1574544
* Fri Mar 02 2018 Zamir SUN <sztsian@gmail.com> - 2.7-2
- Add python plugins
* Fri Mar 02 2018 Zamir SUN <sztsian@gmail.com> - 2.7-1
- Update to 2.7
- Remove Groups tag
* Fri Feb 23 2018 Florian Weimer <fweimer@redhat.com> - 2.6.2-3
- Use LDFLAGS from redhat-rpm-config
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Sat Nov 11 2017 Zamir SUN <zsun@fedoraproject.org> - 2.6.2-1
- Rebase to 2.6.2.
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Tue May 23 2017 Zamir SUN <zsun@fedoraproject.org> - 2.6.1-1
- Rebase to 2.6.1.
* Thu Mar 30 2017 Zamir SUN <zsun@fedoraproject.org> - 2.6-4.20170330git013205
- Rebase to newest upstream version to include various bug fixes.
* Mon Mar 27 2017 Zamir SUN <zsun@fedoraproject.org> - 2.6-4
- Fix bz1389219 segmentation fault in trace-cmd snapshot
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Wed Oct 19 2016 Zamir SUN <zsun@fedoraproject.org> - 2.6-2
- Add bz1386451-trace-cmd-record-crash-f-before-e.patch
- Fix rpmlint error unstripped-binary-or-object
- Resolves: rhbz#1386451
* Thu Aug 18 2016 Jon Stanley <jonstanley@gmail.com> - 2.6-1
- Upgrade to uptream 2.6
- Rebase distro patch
- Resolves: rhbz#1365951
* Fri Feb 05 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Mon Aug 18 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Wed Jul 24 2013 Jon Stanley <jonstanley@gmail.com> - 2.2.1-2
- Remove addition to %%files - not needed with Makefile patch
* Tue Jul 23 2013 Dwight Engen <dwight.engen@oracle.com> - 2.2.1-1
- Update to 2.2.1
* Wed Feb 13 2013 Jon Stanley <jonstanley@gmail.com> - 2.1.0-1
- Update to latest upstream
* Thu Sep 13 2012 Jon Stanley <jonstanley@gmail.com> - 1.2-4.20120606git8266dff
- Remove %%defattr
* Thu Sep 06 2012 Jon Stanley <jonstanley@gmail.com> - 1.2-3.20120606git8266dff
- More review fixups
* Tue Aug 28 2012 Jon Stanley <jonstanley@gmail.com> - 1.2-2.20120606git8266dff
- Rebase to git snapshot so it builds
- Fix license tag per review
- Move plugin dir per review
* Mon Aug 27 2012 Jon Stanley <jonstanley@gmail.com> - 1.2-1
- Rebase to 1.2
- Makefile now supports CFLAGS, drop patch
* Sat Feb 19 2011 Jon Stanley <jonstanley@gmail.com> - 1.0.5-1
- Rebase to 1.0.5
- Add Makefile patch to support passing RPM_OPT_FLAGS
- Add kernelshark subpackage
- Initial Fedora version
* Mon Jul 5 2010 John Kacur <jkacur@redhat.com> - 1.0.4-7
- Rebasing to trace-cmd-1.0.4
* Wed Jun 16 2010 John Kacur <jkacur@redhat.com>
- Rebasing to trace-cmd-1.0.2
- Added parse-events-Do-not-fail-on-FORMAT-TOO-BIG-event-err.patch
- Added trace-cmd-Prevent-latency-tracer-plugins-from-doing-.patch
- Added trace-cmd-Prevent-print_graph_duration-buffer-overfl.patch
* Wed Jun 9 2010 John Kacur <jkacur@redhat.com>
- Added trace-cmd-Makefile-EXTRAVERSION-should-be-set-withou.patch
- Added trace-cmd-Makefile-use-a-substitution-reference.patch
- add-DESTDIR-to-make.patch
- Related: rhbz599507
* Fri Jun 4 2010 John Kacur <jkacur@redhat.com>
- Updating to trace-cmd-1.0.1
- Related: rhbz599507
* Wed Apr 21 2010 John Kacur <jkacur@redhat.com>
- Using trick from William Cohen to avoid the "locate" problem.
* Fri Apr 16 2010 John Kacur <jkacur@redhat.com>
- Update the source to the 1.0.0 version
- Many fixes to the spec file.
* Mon Apr 12 2010 William Cohen <wcohen@redhat.com>
- Include manpages in the package.
* Fri Apr 9 2010 John Kacur <jkacur@redhat.com>
- disabled #patch01
- Updated the trace-cmd source
- Changed version to 0.7.0
- Added bogus patch to satisfy rpm requirements
- Related:bz519630
* Mon Mar 15 2010 John Kacur <jkacur@redhat.com>
- disabled trace-cmd_rusage.patch
- Updated the trace-cmd source
- Related:bz519630
* Fri Nov 16 2007 Luis Claudio R. Goncalves <lgoncalv@redhat.com> - 1.0-1%{?dist}
- Initial packaging
- Added a patch to display rusage information

7
gating.yaml Normal file
View File

@ -0,0 +1,7 @@
--- !Policy
product_versions:
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (trace-cmd-v3.3.1.tar.gz) = a643efc2868d08871a7359dd0a17389685fb229f26328ee96f27a3dd94b5f3eb62009b945c14725eda1f09fa15367ffe2e2c3611d89860dcc031bbd6403cdee0

44
tests/README.md Normal file
View File

@ -0,0 +1,44 @@
About
Trace-cmd tests according to the CI wiki specifically the standard test interface in the [spec](https://fedoraproject.org/wiki/Changes/InvokingTests).
The playbook includes Tier1 level test cases that have been tested in classic contexts and is passing reliably.
The following steps are used to execute the tests using the standard test interface:
Test environment
Make sure you have installed packages from the spec
`# dnf install ansible python2-dnf libselinux-python standard-test-roles ansible python2-dnf libselinux-python standard-test-roles`
Run tests for Classic
~~~~
# export TEST_SUBJECTS=
# sudo ansible-playbook --tags=classic tests.yml
~~~~
Snip of the example test run for Classic tests:
> TASK [standard-test-beakerlib : Run beakerlib tests] *****************************************************************************************************************************************
>
> changed: [localhost] => (item=sanity)
>
> TASK [standard-test-beakerlib : Make the master tests summary log artifact] ******************************************************************************************************************
>
> changed: [localhost] => (item=sanity)
>
> TASK [standard-test-beakerlib : Check the results] *******************************************************************************************************************************************
>
> changed: [localhost]
>
> TASK [standard-test-beakerlib : include_role] ************************************************************************************************************************************************
>
> TASK [str-common : Pull out the logs from test environment to test runner] *******************************************************************************************************************
>
> changed: [localhost]
>
> PLAY RECAP ***********************************************************************************************************************************************************************************
>
> localhost : ok=27 changed=16 unreachable=0 failed=0
>

59
tests/sanity/Makefile Normal file
View File

@ -0,0 +1,59 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Description: Basic sanity test for trace-cmd
# Author: Ziqian SUN (Zamir) <zsun@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2018 Red Hat, Inc. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export PACKAGE_NAME=trace-cmd
export TEST=/kernel/general/ftrace/tools/trace-cmd/upstream
export TESTVERSION=0.1
FILES=$(METADATA) runtest.sh Makefile PURPOSE
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build:
chmod a+x runtest.sh
clean:
rm -fr *~ tests-*.rpm
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Ziqian SUN (Zamir) <zsun@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Basic sanity test for trace-cmd" >> $(METADATA)
@echo "TestTime: 30m" >> $(METADATA)
@echo "RunFor: trace-cmd" >> $(METADATA)
@echo "Requires: @development" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv3" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
rhts-lint $(METADATA)

1
tests/sanity/PURPOSE Normal file
View File

@ -0,0 +1 @@
Basic sanity test for trace-cmd

58
tests/sanity/runtest.sh Executable file
View File

@ -0,0 +1,58 @@
#!/bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Description: Basic sanity test for trace-cmd
# Author: Ziqian SUN (Zamir) <zsun@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2018 Red Hat, Inc. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/share/beakerlib/beakerlib.sh
if ! mount | grep -q debugfs ; then
mount -t debugfs nodev /sys/kernel/debug
fi
trace-cmd reset
rlJournalStart
for TRACER in $(cat /sys/kernel/debug/tracing/available_tracers) ; do
rlPhaseStartTest "Enable ${TRACER} using trace-cmd"
rlRun "trace-cmd start -p ${TRACER}"
rlAssertEquals "Check current tracer" "$(cat /sys/kernel/debug/tracing/current_tracer)" "${TRACER}"
rlAssertEquals "Check tracing status" "$(cat /sys/kernel/debug/tracing/tracing_on)" "1"
rlRun "trace-cmd stop"
rlAssertEquals "Check tracing status" "$(cat /sys/kernel/debug/tracing/tracing_on)" "0"
rlRun "trace-cmd reset"
rlPhaseEnd
if [[ "${TRACER}" == "function" ]]; then
rlPhaseStartTest "Test trace-cmd show"
rlRun "trace-cmd start -p ${TRACER}"
rlWatchdog "trace-cmd show | grep -v '^#' > trace-cmd-show-function.log" 5 INT
rlAssertGreater "At least one line of trace data" $(cat trace-cmd-show-function.log | wc -l) 1
rlRun "trace-cmd stop"
rlRun "trace-cmd reset"
rlFileSubmit trace-cmd-show-function.log
rm -f trace-cmd-show-function.log
rlPhaseEnd
fi
done
rlJournalEnd

11
tests/tests.yml Normal file
View File

@ -0,0 +1,11 @@
- hosts: localhost
tags:
- classic
roles:
- role: standard-test-beakerlib
tests:
- sanity
required_packages:
- kernel
- trace-cmd

View File

@ -0,0 +1,37 @@
From c76f2404340e4fa3159536355a0e095631fb7920 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 29 Oct 2024 09:47:05 +0100
Subject: [PATCH] trace-cmd: Prevent buffer overflow in update_pid_filters()
The buffer in which the updated filter is written in
update_pid_filters() is missing one byte to store the null character.
It fixes the following error:
$ trace-cmd start -e irq:* -e sched:* -P 1
*** buffer overflow detected ***: terminated
Aborted (core dumped)
Fixes: 5502bcef0f962 ("trace-cmd: Handle filtered PIDs per ftarce instance")
Link: https://lore.kernel.org/20241029084705.629605-1-jmarchan@redhat.com
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tracecmd/trace-record.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 6e9b4535..c7c43e17 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -2852,7 +2852,7 @@ static void update_pid_filters(struct buffer_instance *instance)
if (fd < 0)
die("Failed to access set_event_pid");
- len = instance->len_filter_pids + instance->nr_filter_pids;
+ len = instance->len_filter_pids + instance->nr_filter_pids + 1;
filter = malloc(len);
if (!filter)
die("Failed to allocate pid filter");
--
2.47.1

View File

@ -0,0 +1,34 @@
From 7a0d3baf2ab09f7a729e4de592b784e307caa70f Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 29 Oct 2024 09:01:13 +0100
Subject: [PATCH 4/8] trace-cmd dump: Prevent buffer overrun in dump_clock()
The clock isn't big enough to hold the string with the null
terminating character. Worse, clock[size], which is out of range, is
set to 0. Allocate a big enough buffer.
Fixes an OVERRUN error (CWE-119)
Link: https://lore.kernel.org/20241029080117.625177-5-jmarchan@redhat.com
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tracecmd/trace-dump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c
index 11c1baf1..0a21356e 100644
--- a/tracecmd/trace-dump.c
+++ b/tracecmd/trace-dump.c
@@ -961,7 +961,7 @@ static void dump_clock(int fd)
}
if (read_file_number(fd, &size, 8))
die("cannot read clock size");
- clock = calloc(1, size);
+ clock = calloc(1, size + 1);
if (!clock)
die("cannot allocate clock %lld bytes", size);
--
2.47.0

View File

@ -0,0 +1,36 @@
From ea419e8e8f5e56c166b14aef26be814daebe2832 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 29 Oct 2024 09:01:12 +0100
Subject: [PATCH 3/8] trace-cmd lib: Check the return value of do_lseek() in
trace_get_options()
Check that do_lseek doesn't fail before calling malloc() with a -1
argument.
This is flagged as an overrun error (CWE-119) by static anaysis
because of the call to read() later, but I don't imagine that malloc
would succeed.
Link: https://lore.kernel.org/20241029080117.625177-4-jmarchan@redhat.com
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-output.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
index 66e11ddc..8bc9325c 100644
--- a/lib/trace-cmd/trace-output.c
+++ b/lib/trace-cmd/trace-output.c
@@ -2070,6 +2070,8 @@ __hidden void *trace_get_options(struct tracecmd_output *handle, size_t *len)
}
offset = do_lseek(&out_handle, 0, SEEK_CUR);
+ if (offset == (off_t)-1)
+ goto out;
buf = malloc(offset);
if (!buf)
goto out;
--
2.47.0

View File

@ -0,0 +1,57 @@
From 3be4066b9a9c6a76a824fc7a7a6a983fd23088a7 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 29 Oct 2024 09:01:10 +0100
Subject: [PATCH 1/8] trace-cmd lib: Prevent a memory leak in handle_options()
Buf isn't always fred in the error path. Instead of freing buf at the
end of the loop, free it in the exit path and before reallocating it.
Fixes a RESOURCE_LEAK error (CWE-772)
Link: https://lore.kernel.org/20241029080117.625177-2-jmarchan@redhat.com
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-input.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 8b6e3d0c..ad662fc6 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -4006,7 +4006,7 @@ static int handle_options(struct tracecmd_input *handle)
char *cpustats = NULL;
struct hook_list *hook;
bool compress = false;
- char *buf;
+ char *buf = NULL;
int cpus;
int ret;
@@ -4036,6 +4036,7 @@ static int handle_options(struct tracecmd_input *handle)
ret = read4(handle, &size);
if (ret)
goto out;
+ free(buf);
buf = malloc(size);
if (!buf) {
ret = -ENOMEM;
@@ -4189,14 +4190,12 @@ static int handle_options(struct tracecmd_input *handle)
tracecmd_warning("unknown option %d", option);
break;
}
-
- free(buf);
-
}
ret = 0;
out:
+ free(buf);
if (compress)
in_uncompress_reset(handle);
return ret;
--
2.47.0

View File

@ -0,0 +1,33 @@
From cbe42ab193ac866e9a6644b8509ab341a8aa474d Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 29 Oct 2024 09:01:15 +0100
Subject: [PATCH 6/8] trace-cmd lib: Prevent memory leak in
tracecmd_create_event_hook()
Free hook and hook->str in the error path.
Fixes a RESOURCE_LEAK error (CWE-772)
Link: https://lore.kernel.org/20241029080117.625177-7-jmarchan@redhat.com
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-hooks.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/trace-cmd/trace-hooks.c b/lib/trace-cmd/trace-hooks.c
index a58b5356..aa12f6e9 100644
--- a/lib/trace-cmd/trace-hooks.c
+++ b/lib/trace-cmd/trace-hooks.c
@@ -151,6 +151,8 @@ struct hook_list *tracecmd_create_event_hook(const char *arg)
invalid_tok:
tracecmd_warning("Invalid hook format '%s'", arg);
+ free(hook->str);
+ free(hook);
return NULL;
}
--
2.47.0

View File

@ -0,0 +1,36 @@
From b0e1a9c5c099282d30fee8f6aa89bd12ce5e8a73 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 29 Oct 2024 09:01:16 +0100
Subject: [PATCH 7/8] trace-cmd mem: Prevent a memory leak in trace_mem()
Close the tracecmd handle in the error path.
Fixes a RESOURCE_LEAK error (CWE-772)
Link: https://lore.kernel.org/20241029080117.625177-8-jmarchan@redhat.com
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tracecmd/trace-mem.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tracecmd/trace-mem.c b/tracecmd/trace-mem.c
index 3e1ac9f3..b8babbbc 100644
--- a/tracecmd/trace-mem.c
+++ b/tracecmd/trace-mem.c
@@ -554,10 +554,8 @@ void trace_mem(int argc, char **argv)
die("can't open %s\n", input_file);
ret = tracecmd_read_headers(handle, 0);
- if (ret)
- return;
-
- do_trace_mem(handle);
+ if (!ret)
+ do_trace_mem(handle);
tracecmd_close(handle);
}
--
2.47.0

View File

@ -0,0 +1,39 @@
From 75d8bba90d8b4cbe1a80381f1dfbd80cbb0fbd60 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 29 Oct 2024 09:01:17 +0100
Subject: [PATCH 8/8] trace-cmd record: Check the length of the protocol
version received
In check_protocol_version we compare the protocol version string with
the expected one ("V3") with memcmp(). The received string could be
longer than the constant string used for the comparison. That could
lead to out of range access.
Use the known length of the fixed "V3" string for the comparison and
check that the received protocol version is not too short.
Fixes a OVERRUN error (CWE-119)
Link: https://lore.kernel.org/20241029080117.625177-9-jmarchan@redhat.com
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tracecmd/trace-record.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index d78c13c2..febf8578 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -3811,7 +3811,7 @@ static void check_protocol_version(struct tracecmd_msg_handle *msg_handle)
msg_handle->version = V1_PROTOCOL;
tracecmd_plog("Use the v1 protocol\n");
} else {
- if (memcmp(buf, "V3", n) != 0)
+ if (n < 3 || memcmp(buf, "V3", 3) != 0)
die("Cannot handle the protocol %s", buf);
/* OK, let's use v3 protocol */
write(fd, V3_MAGIC, sizeof(V3_MAGIC));
--
2.47.0

View File

@ -0,0 +1,38 @@
From 8e7de34bca5fdfcd8276116db4dd02308de0e194 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 29 Oct 2024 09:01:11 +0100
Subject: [PATCH 2/8] trace-cmd record: Prevent a memory leak in show_error()
In show_error() the pointer p is used for several functions. At first,
it contain a substring of path.
Then it is replaced by either an allocated string containing the path
to the error log file or the result of read_path(), neither of which
are freed when exiting.
Free p in both case in the exit path.
Fixes a RESOURCE_LEAK error (CWE-772)
Link: https://lore.kernel.org/20241029080117.625177-3-jmarchan@redhat.com
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tracecmd/trace-record.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 0063d528..bdfa57b0 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -2374,6 +2374,7 @@ static void show_error(const char *file, const char *type)
out:
printf("Failed %s of %s\n", type, file);
+ free(p);
free(path);
return;
}
--
2.47.0

View File

@ -0,0 +1,41 @@
From e48db64dcb0dfddb6b8f6cd8624e1e2ff2c1302c Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 29 Oct 2024 09:01:14 +0100
Subject: [PATCH 5/8] trace-cmd record: Prevent memory leak in setup_network()
Because of the again label, msg_handle can be already allocated if we
exit after we got a negative socket file descriptor. Free it there.
Also unassign msg_handle->fd as to not double close sfd.
Fixes a RESOURCE_LEAK error (CWE-772)
Link: https://lore.kernel.org/20241029080117.625177-6-jmarchan@redhat.com
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
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 bdfa57b0..d78c13c2 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -3904,6 +3904,7 @@ static struct tracecmd_msg_handle *setup_network(struct buffer_instance *instanc
if (sfd < 0) {
free(thost);
+ tracecmd_msg_handle_close(msg_handle);
return NULL;
}
@@ -3934,6 +3935,7 @@ static struct tracecmd_msg_handle *setup_network(struct buffer_instance *instanc
if (msg_handle->version == V1_PROTOCOL) {
/* reconnect to the server for using the v1 protocol */
close(sfd);
+ msg_handle->fd = -1;
free(host);
host = NULL;
goto again;
--
2.47.0

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

377
trace-cmd.spec Normal file
View File

@ -0,0 +1,377 @@
# git tag
#%%global git_commit trace-cmd-v2.6.2
#%%global git_commit 57371aaa2f469d0ba15fd85276deca7bfdd7ce36
%global srcversion 3.3.1
Name: trace-cmd
Version: %{srcversion}
Release: 2%{?dist}
License: LGPL-2.1-only AND LGPL-2.1-or-later AND GPL-2.0-only AND GPL-2.0-or-later
Summary: A user interface to Ftrace
ExcludeArch: %{ix86} %{arm}
URL: http://git.kernel.org/?p=linux/kernel/git/rostedt/trace-cmd.git;a=summary
# 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%{srcversion}.tar.gz
Source1: trace-cmd.conf
Source2: trace-cmd.service
Source3: 98-trace-cmd.rules
Patch0: trace-cmd-lib-Prevent-a-memory-leak-in-handle_option.patch
Patch1: trace-cmd-record-Prevent-a-memory-leak-in-show_error.patch
Patch2: trace-cmd-lib-Check-the-return-value-of-do_lseek-in-.patch
Patch3: trace-cmd-dump-Prevent-buffer-overrun-in-dump_clock.patch
Patch4: trace-cmd-record-Prevent-memory-leak-in-setup_networ.patch
Patch5: trace-cmd-lib-Prevent-memory-leak-in-tracecmd_create.patch
Patch6: trace-cmd-mem-Prevent-a-memory-leak-in-trace_mem.patch
Patch7: trace-cmd-record-Check-the-length-of-the-protocol-ve.patch
Patch8: trace-cmd-Prevent-buffer-overflow-in-update_pid_filt.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: systemd-rpm-macros
BuildRequires: libtracecmd-devel
BuildRequires: libzstd-devel
%description
trace-cmd is a user interface to Ftrace. Instead of needing to use the
debugfs directly, trace-cmd will handle of setting of options and
tracers and will record into a data file.
%package python3
Summary: Python plugin support for trace-cmd
Requires: trace-cmd%{_isa} = %{version}-%{release}
BuildRequires: python3-devel
%description python3
Python plugin support for trace-cmd
%prep
%autosetup -p1 -n %{name}-v%{srcversion}
cp %{SOURCE1} .
cp %{SOURCE2} .
cp %{SOURCE3} .
%build
# MANPAGE_DOCBOOK_XSL define is hack to avoid using locate
MANPAGE_DOCBOOK_XSL=`rpm -ql docbook-style-xsl | grep manpages/docbook.xsl`
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 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
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
find %{buildroot}%{_libdir} -type f -iname "*.so" | xargs chmod 0755
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
%systemd_preun %{name}.service
%files
%doc COPYING COPYING.LIB README
%{_bindir}/trace-cmd
%{_mandir}/man1/%{name}*
%{_mandir}/man5/%{name}*
%{_docdir}/trace-cmd/trace-cmd*.html
%{_sysconfdir}/bash_completion.d/trace-cmd.bash
%{_sysconfdir}/sysconfig/trace-cmd.conf
%{_unitdir}/trace-cmd.service
%{_udevrulesdir}/98-trace-cmd.rules
%files python3
%doc Documentation/README.PythonPlugin
%{_libdir}/%{name}/python/
%changelog
* Wed Jan 15 2025 Jerome Marchand <jmarchan@redhat.com> - 3.3.1-2
- Prevent buffer overflow in update_pid_filters() (RHEL-56731)
* Thu Nov 28 2024 Jerome Marchand <jmarchan@redhat.com> - 3.3.1-1
- Rebase to 3.3.1 and backport further SAST patches (RHEL-40111)
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 3.2-5
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 3.2-4
- Bump release for June 2024 mass rebuild
* Mon Jun 03 2024 Jerome Marchand <jmarchan@redhat.com> - 3.2-3
- Drop useless mlocate dependency (RHEL-39377)
* Sat Jan 27 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Tue Jan 23 2024 Zamir SUN <sztsian@gmail.com> - 3.2
- Update to 3.2 (#2213350)
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.1.6-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Thu Jun 22 2023 Yaakov Selkowitz <yselkowi@redhat.com> - 3.1.6-3
- Remove lingering kernelshark dependencies
* Mon Jun 05 2023 Zamir SUN <sztsian@gmail.com> - 3.1.6-2
- SPDX migration
* Tue Apr 18 2023 Zamir SUN <sztsian@gmail.com> - 3.1.6-1
- Update to 3.1.6
* Fri Mar 31 2023 Jerome Marchand <jmarchan@redhat.com> - 3.1.4-3
- Fix build: RHBZ#2171770
- Also remove explicit lib dependency that fedpkg lint complains about.
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.1.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Tue Oct 11 2022 Zamir SUN <sztsian@gmail.com> - 3.1.4-1
- Update to 3.1.4
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Fri Apr 15 2022 Zamir SUN <sztsian@gmail.com> - 3.0.3-2
- Get rid of the libtracecmd man pages
* Wed Apr 13 2022 Zamir SUN <sztsian@gmail.com> - 3.0.3-1
- Update to 3.0.3
* Fri Mar 18 2022 KUDOH Takashi <t-kudoh@fujitsu.com> - 2.9.7-2
- Add flight recoder service
* Wed Feb 16 2022 Zamir SUN <sztsian@gmail.com> - 2.9.7-1
- Update to 2.9.7
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.9.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.9.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Fri Apr 23 2021 Jerome Marchand <jmarchan@redhat.com> - 2.9.2-3
- Build w/o rpath as per Fedora packaging guideline
* Mon Mar 29 2021 Zamir SUN <sztsian@gmail.com> - 2.9.2-2
- Fix dependency of libtracecmd
- Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1943919
* Fri Mar 26 2021 Zamir SUN <sztsian@gmail.com> - 2.9.2-1
- Update to 2.9.2
* Wed Mar 24 2021 Jerome Marchand <jmarchan@redhat.com> - 2.9.1-6
- Build with external libtraceevent and libtracefs
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.9.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Dec 02 2020 Zamir SUN <sztsian@gmail.com> - 2.9.1-4
- Move %{_libdir}/trace-cmd/python/ to trace-cmd-python3
* Mon Oct 12 2020 Zamir SUN <sztsian@gmail.com> - 2.9.1-3
- Temporary move libtraceevent back to trace-cmd/plugins to mitigate the conflicts
* Tue Sep 29 2020 Zamir SUN <sztsian@gmail.com> - 2.9.1-2
- Remove kernelsharl as it's now separate package
* Fri Aug 07 2020 Zamir SUN <sztsian@gmail.com> - 2.9.1-1
- Update to 2.9.1
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.8.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue May 26 2020 Jeff Law <law@redhat.com> - 2.8.3-3
- TRACECMD_LIBRARY can reference things in TRACEEVENT_LIBRARY, so
link TRACEEVENT_LIBRARY after TRACECMD_LIBRARY.
* Tue Apr 21 2020 Björn Esser <besser82@fedoraproject.org> - 2.8.3-2
- Rebuild (json-c)
* Sat Feb 08 2020 Zamir SUN <sztsian@gmail.com> - 2.8.3-1
- Update to 2.8
- Add workaround to resolve gcc 10 multiple definition of `common_type_field' problem
- Resolves 1794296
- Resolves 1727368
* Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.7-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 2.7-8
- Rebuilt for Python 3.8
* Wed Aug 07 2019 Zamir SUN <sztsian@gmail.com> - 2.7-7
- Fix more python2 residuals.
- Fixes 1738158
* Sat Aug 03 2019 Zamir SUN <sztsian@gmail.com> - 2.7-6
- Switch the python plugin to python3
* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.7-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.7-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.7-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Fri Mar 02 2018 Zamir SUN <sztsian@gmail.com> - 2.7-2
- Add python plugins
* Fri Mar 02 2018 Zamir SUN <sztsian@gmail.com> - 2.7-1
- Update to 2.7
- Remove Groups tag
* Fri Feb 23 2018 Florian Weimer <fweimer@redhat.com> - 2.6.2-3
- Use LDFLAGS from redhat-rpm-config
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Sat Nov 11 2017 Zamir SUN <zsun@fedoraproject.org> - 2.6.2-1
- Rebase to 2.6.2.
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Tue May 23 2017 Zamir SUN <zsun@fedoraproject.org> - 2.6.1-1
- Rebase to 2.6.1.
* Thu Mar 30 2017 Zamir SUN <zsun@fedoraproject.org> - 2.6-4.20170330git013205
- Rebase to newest upstream version to include various bug fixes.
* Mon Mar 27 2017 Zamir SUN <zsun@fedoraproject.org> - 2.6-4
- Fix bz1389219 segmentation fault in trace-cmd snapshot
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Wed Oct 19 2016 Zamir SUN <zsun@fedoraproject.org> - 2.6-2
- Add bz1386451-trace-cmd-record-crash-f-before-e.patch
- Fix rpmlint error unstripped-binary-or-object
- Resolves: rhbz#1386451
* Thu Aug 18 2016 Jon Stanley <jonstanley@gmail.com> - 2.6-1
- Upgrade to uptream 2.6
- Rebase distro patch
- Resolves: rhbz#1365951
* Fri Feb 05 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Mon Aug 18 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.2.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Wed Jul 24 2013 Jon Stanley <jonstanley@gmail.com> - 2.2.1-2
- Remove addition to %%files - not needed with Makefile patch
* Tue Jul 23 2013 Dwight Engen <dwight.engen@oracle.com> - 2.2.1-1
- Update to 2.2.1
* Wed Feb 13 2013 Jon Stanley <jonstanley@gmail.com> - 2.1.0-1
- Update to latest upstream
* Thu Sep 13 2012 Jon Stanley <jonstanley@gmail.com> - 1.2-4.20120606git8266dff
- Remove %%defattr
* Thu Sep 06 2012 Jon Stanley <jonstanley@gmail.com> - 1.2-3.20120606git8266dff
- More review fixups
* Tue Aug 28 2012 Jon Stanley <jonstanley@gmail.com> - 1.2-2.20120606git8266dff
- Rebase to git snapshot so it builds
- Fix license tag per review
- Move plugin dir per review
* Mon Aug 27 2012 Jon Stanley <jonstanley@gmail.com> - 1.2-1
- Rebase to 1.2
- Makefile now supports CFLAGS, drop patch
* Sat Feb 19 2011 Jon Stanley <jonstanley@gmail.com> - 1.0.5-1
- Rebase to 1.0.5
- Add Makefile patch to support passing RPM_OPT_FLAGS
- Add kernelshark subpackage
- Initial Fedora version
* Mon Jul 5 2010 John Kacur <jkacur@redhat.com> - 1.0.4-7
- Rebasing to trace-cmd-1.0.4
* Wed Jun 16 2010 John Kacur <jkacur@redhat.com>
- Rebasing to trace-cmd-1.0.2
- Added parse-events-Do-not-fail-on-FORMAT-TOO-BIG-event-err.patch
- Added trace-cmd-Prevent-latency-tracer-plugins-from-doing-.patch
- Added trace-cmd-Prevent-print_graph_duration-buffer-overfl.patch
* Wed Jun 9 2010 John Kacur <jkacur@redhat.com>
- Added trace-cmd-Makefile-EXTRAVERSION-should-be-set-withou.patch
- Added trace-cmd-Makefile-use-a-substitution-reference.patch
- add-DESTDIR-to-make.patch
- Related: rhbz599507
* Fri Jun 4 2010 John Kacur <jkacur@redhat.com>
- Updating to trace-cmd-1.0.1
- Related: rhbz599507
* Wed Apr 21 2010 John Kacur <jkacur@redhat.com>
- Using trick from William Cohen to avoid the "locate" problem.
* Fri Apr 16 2010 John Kacur <jkacur@redhat.com>
- Update the source to the 1.0.0 version
- Many fixes to the spec file.
* Mon Apr 12 2010 William Cohen <wcohen@redhat.com>
- Include manpages in the package.
* Fri Apr 9 2010 John Kacur <jkacur@redhat.com>
- disabled #patch01
- Updated the trace-cmd source
- Changed version to 0.7.0
- Added bogus patch to satisfy rpm requirements
- Related:bz519630
* Mon Mar 15 2010 John Kacur <jkacur@redhat.com>
- disabled trace-cmd_rusage.patch
- Updated the trace-cmd source
- Related:bz519630
* Fri Nov 16 2007 Luis Claudio R. Goncalves <lgoncalv@redhat.com> - 1.0-1%{?dist}
- Initial packaging
- Added a patch to display rusage information