trace-cmd: Clean ups and fixes for installing libraries
Subsystems (2)
cover trace-cmd: Clean ups and fixes for installing libraries
Steven Rostedt (VMware) (6):
trace-cmd: Fix whitespace in usage message of trace-cmd report --ts-diff
trace-cmd: Add reference to trace-cmd.org in README
trace-cmd: Add --ts-check option to report
trace-cmd: Update .gitignore
trace-cmd: Have "make test" use system libraries if present
trace-cmd: Only install libtraceevent and libtracefs if not in system
Tzvetomir (VMware) Stoyanov (2):
libtracefs: Extend tracefs_iterate_raw_events() to iterate per CPU
libtracefs: Unit test for tracefs_iterate_raw_events() per CPU
Tzvetomir Stoyanov (VMware) (1):
trace-cmd: Use system trace libraries, if available
----
.gitignore | 10 ++-- Documentation/trace-cmd-report.1.txt | 4 ++ Makefile | 67 ++++++++++++++++++--------- README | 3 ++ include/tracefs/tracefs.h | 2 + kernel-shark/.gitignore | 22 +++++++++ lib/traceevent/Makefile | 2 + lib/tracefs/Makefile | 2 + lib/tracefs/tracefs-events.c | 6 +++ tracecmd/.gitignore | 1 + tracecmd/Makefile | 6 ++- tracecmd/trace-read.c | 29 +++++++++++- tracecmd/trace-record.c | 2 +- tracecmd/trace-usage.c | 3 +- utest/Makefile | 4 +- utest/tracefs-utest.c | 89 ++++++++++++++++++++++++++++-------- 16 files changed, 200 insertions(+), 52 deletions(-) create mode 100644 kernel-shark/.gitignore create mode 100644 tracecmd/.gitignore
PATCH 1/9 trace-cmd: Fix whitespace in usage message of trace-cmd report --ts-diff
From: "Steven Rostedt (VMware)" <[email protected]>
The "--ts-diff" description in "trace-cmd report -h" is not lined up with the other long options. Fix the whitespace so that it is.
--- tracecmd/trace-usage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tracecmd/trace-usage.c +1 -1
@@ -228,7 +228,7 @@ static struct usage_help usage_help[] = {" to convert the displayed timestamps to seconds\n" " Affects the previous data file, unless there was no\n" " previous data file, in which case it becomes default\n" -" --ts-diff Show the delta timestamp between events.\n" +" --ts-diff Show the delta timestamp between events.\n" }, { "stream",
Signature · 1 line
2.29.2
PATCH 2/9 trace-cmd: Add reference to trace-cmd.org in README
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
This repo is mirrored in my personal github account, but that account is not mirrored, and there's been people submitting issues there. Add to the README, a reference to trace-cmd.org so that people will hopefully know the correct way to contribute.
--- README | 3 +++ 1 file changed, 3 insertions(+)
README +3 -0
@@ -1,4 +1,7 @@ + + For more information on contributing please see: https://www.trace-cmd.org + Note: The official repositiory for trace-cmd and KernelShark is here: git://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git
Signature · 1 line
2.29.2
PATCH 3/9 trace-cmd: Add --ts-check option to report
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Add a --ts-check option to trace-cmd report that will make sure that the timestamps do not go backwards, and will print out an error message if they do.
--- Documentation/trace-cmd-report.1.txt | 4 ++++ tracecmd/trace-read.c | 29 +++++++++++++++++++++++++++- tracecmd/trace-usage.c | 1 + 3 files changed, 33 insertions(+), 1 deletion(-)
Documentation/trace-cmd-report.1.txt +4 -0
@@ -305,6 +305,10 @@ OPTIONS Show the time differences between events. The difference will appear in parenthesis just after the timestamp. +*--ts-check*:: + Make sure no timestamp goes backwards, and if it does, print out a warning + message of the fact. + EXAMPLES --------
tracecmd/trace-read.c +28 -1
@@ -99,6 +99,7 @@ static int no_irqs;static int no_softirqs;static int tsdiff; +static int tscheck;static int latency_format;static bool raw_format;
@@ -1192,6 +1193,7 @@ enum output_type {static void read_data_info (struct list_head *handle_list,enum output_type otype,int global) { +unsigned long long *last_timestamp;struct handle_list *handles;struct handle_list *last_handle;struct tep_record *record;
@@ -1216,6 +1218,10 @@ static void read_data_info(struct list_head *handle_list, enum output_type otypeprint_handle_file (handles);printf ("cpus=%d\n" , cpus); + last_timestamp =calloc (cpus,sizeof (*last_timestamp)); +if (!last_timestamp) +die ("allocating timestamps" ); +/* Latency trace is just all ASCII */ if (ret >0 ) {if (multi_inputs)
@@ -1286,6 +1292,8 @@ static void read_data_info(struct list_head *handle_list, enum output_type otypelist_for_each_entry (handles, handle_list, list) { record =get_next_record (handles); +if (!record) +continue ;if (!last_record || (record && record->ts < last_record->ts)) { last_record = record;
@@ -1293,12 +1301,26 @@ static void read_data_info(struct list_head *handle_list, enum output_type otype } }if (last_record) { +int cpu = last_record->cpu; +if (cpu >= cpus) +die ("cpu %d creater than %d\n" , cpu, cpus); +if (tscheck && + last_timestamp[cpu] > last_record->ts) { + errno =0 ; +warning ("WARNING: Record on cpu %d went backwards: %lld to %lld delta: -%lld\n" , + cpu, last_timestamp[cpu], + last_record->ts, + last_timestamp[cpu] - last_record->ts); + } + last_timestamp[cpu] = last_record->ts;print_handle_file (last_handle);trace_show_data (last_handle->handle, last_record);free_handle_record (last_handle); } }while (last_record); +free (last_timestamp); +if (profile)do_trace_profile ();
@@ -1463,7 +1485,8 @@ static void add_hook(const char *arg) }enum { - OPT_version =238 , + OPT_version =237 , + OPT_tscheck =238 , OPT_tsdiff =239 , OPT_ts2secs =240 , OPT_tsoffset =241 ,
@@ -1550,6 +1573,7 @@ void trace_report (int argc, char **argv) {"ts-offset", required_argument, NULL, OPT_tsoffset}, {"ts2secs", required_argument, NULL, OPT_ts2secs}, {"ts-diff", no_argument, NULL, OPT_tsdiff}, + {"ts-check", no_argument, NULL, OPT_tscheck}, {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} };
@@ -1719,6 +1743,9 @@ void trace_report (int argc, char **argv)case OPT_tsdiff: tsdiff =1 ;break ; +case OPT_tscheck: + tscheck =1 ; +break ;default :usage (argv); }
tracecmd/trace-usage.c +1 -0
@@ -229,6 +229,7 @@ static struct usage_help usage_help[] = {" Affects the previous data file, unless there was no\n" " previous data file, in which case it becomes default\n" " --ts-diff Show the delta timestamp between events.\n" +" --ts-check Check to make sure no time stamp on any CPU goes backwards.\n" }, { "stream",
Signature · 1 line
2.29.2
PATCH 4/9 trace-cmd: Update .gitignore
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
The .gitignore file is somewhat out of date. Update the main file as well as adding a .gitignore in the tracecmd and kernel-shark directories.
Remove the exec names that use to be included in the top level directory, and place them into the .gitignore in the directories that may build them.
Ignore files caused by running "patch".
Add *.data for perf files that may be in the directory.
Add .pc and patches/ to ignore quilt directories.
Add #*# to ignore emacs meta files.
Add a .gitignore file in kernel-shark to include all the files that are built by the kernelshark build.
--- .gitignore | 10 ++++++---- kernel-shark/.gitignore | 22 ++++++++++++++++++++++ tracecmd/.gitignore | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 kernel-shark/.gitignore create mode 100644 tracecmd/.gitignore
.gitignore +6 -4
@@ -1,16 +1,18 @@ *.o -trace-cmd *.so *.a *.dat +*.data *.patch .*.d +*.orig +*.rej +.pc *~ -kernelshark -trace-graph -trace-view *.pyc *.swp +\#*\# +patches/ tc_version.h ks_version.h ctracecmd_wrap.c
kernel-shark/.gitignore new file +22 -0
@@ -0,0 +1,22 @@ +bin/cmd_split +bin/confio +bin/dfilter +bin/dhisto +bin/dload +bin/dplot +bin/kernelshark +bin/kshark-record +bin/widgetdemo +build/CMakeCache.txt +build/CMakeDoxyfile.in +build/CMakeDoxygenDefaults.cmake +build/CMakeFiles/ +build/Makefile +build/cmake_install.cmake +build/examples/ +build/src/ +kernelshark.desktop +lib/ +org.freedesktop.kshark-record.policy +src/KsCmakeDef.hpp +
tracecmd/.gitignore new file +1 -0
@@ -0,0 +1 @@ +trace-cmd
Signature · 1 line
2.29.2
PATCH 5/9 libtracefs: Extend tracefs_iterate_raw_events() to iterate per CPU
In reply to Steven RostedtFrom: "Tzvetomir (VMware) Stoyanov" <[email protected]>
There are some use cases where only raw events from particular CPUs should be iterated. An additional parameter is added to this API which allows only trace buffers for specified CPUs to be iterated.
--- include/tracefs/tracefs.h | 2 ++ lib/tracefs/tracefs-events.c | 6 ++++++ tracecmd/trace-record.c | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-)
include/tracefs/tracefs.h +2 -0
@@ -6,6 +6,7 @@#ifndef _TRACE_FS_H#define _TRACE_FS_H +#include <sched.h> #include "traceevent/event-parse.h" char *tracefs_get_tracing_file (const char *name);
@@ -44,6 +45,7 @@ char **tracefs_event_systems(const char *tracing_dir);char **tracefs_system_events (const char *tracing_dir,const char *system); int tracefs_iterate_raw_events(struct tep_handle *tep, struct tracefs_instance *instance, + cpu_set_t *cpus, int cpu_size, int (*callback)(struct tep_event *, struct tep_record *, int, void *),
lib/tracefs/tracefs-events.c +6 -0
@@ -116,6 +116,9 @@ get_events_in_page(struct tep_handle *tep, void *page,* per CPU trace buffers * @tep: a handle to the trace event parser context * @instance: ftrace instance, can be NULL for the top instance +* @cpus: Iterate only through the buffers of CPUs, set in the mask. +* If NULL, iterate through all CPUs. +* @cpu_size: size of @cpus set * @callback: A user function, called for each record from the file * @callback_context: A custom context, passed to the user callback function *
@@ -126,6 +129,7 @@ get_events_in_page(struct tep_handle *tep, void *page,*/ int tracefs_iterate_raw_events(struct tep_handle *tep, struct tracefs_instance *instance, + cpu_set_t *cpus, int cpu_size, int (*callback)(struct tep_event *, struct tep_record *, int, void *),
@@ -166,6 +170,8 @@ int tracefs_iterate_raw_events(struct tep_handle *tep,if (strlen (name) <4 ||strncmp (name,"cpu" ,3 ) !=0 )continue ; cpu =atoi (name +3 ); +if (cpus && !CPU_ISSET_S (cpu, cpu_size, cpus)) +continue ;sprintf (file,"%s/%s" , path, name); ret =stat (file, &st);if (ret <0 || !S_ISDIR (st.st_mode))
tracecmd/trace-record.c +1 -1
@@ -4585,7 +4585,7 @@ static unsigned long long find_time_stamp(struct tep_handle *tep) {unsigned long long ts =0 ; -if (!tracefs_iterate_raw_events (tep,NULL , find_ts, &ts)) +if (!tracefs_iterate_raw_events (tep,NULL ,NULL ,0 , find_ts, &ts))return ts;return 0 ;
Signature · 1 line
2.29.2
PATCH 6/9 libtracefs: Unit test for tracefs_iterate_raw_events() per CPU
In reply to Steven RostedtFrom: "Tzvetomir (VMware) Stoyanov" <[email protected]>
The tracefs_iterate_raw_events() unit test is extended to verify per CPU iteration.
--- utest/tracefs-utest.c | 89 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 19 deletions(-)
utest/tracefs-utest.c +70 -19
@@ -18,25 +18,34 @@#define TRACEFS_SUITE "trasefs library"#define TEST_INSTANCE_NAME "cunit_test_iter" -#define TEST_ARRAY_SIZE 50 +#define TEST_ARRAY_SIZE 500static struct tracefs_instance *test_instance;static struct tep_handle *test_tep; -static int test_array[TEST_ARRAY_SIZE ]; +struct test_sample { +int cpu; +int value; +}; +static struct test_sample test_array[TEST_ARRAY_SIZE ];static int test_found;static int test_callback (struct tep_event *event,struct tep_record *record,int cpu,void *context) {struct tep_format_field *field; -int val, i; +struct test_sample *sample; +int *cpu_test = (int *)context; +int i; +if (cpu_test && *cpu_test >=0 && *cpu_test != cpu) +return 0 ; field =tep_find_field (event,"buf" );if (field) { - val = *((int *)(record->data + field->offset)); + sample = ((struct test_sample *)(record->data + field->offset));for (i =0 ; i <TEST_ARRAY_SIZE ; i++) { -if (test_array[i] == val) { - test_array[i] =0 ; +if (test_array[i].value == sample->value && + test_array[i].cpu == cpu) { + test_array[i].value =0 ; test_found++;break ; }
@@ -48,43 +57,85 @@ static int test_callback(struct tep_event *event, struct tep_record *record,static void test_iter_write (void ) { +int cpus =sysconf (_SC_NPROCESSORS_CONF); +cpu_set_t *cpuset, *cpusave; +int cpu_size;char *path;int i, fd;int ret; + cpuset =CPU_ALLOC (cpus); + cpusave =CPU_ALLOC (cpus); + cpu_size =CPU_ALLOC_SIZE (cpus); +CPU_ZERO_S (cpu_size, cpuset); + +sched_getaffinity (0 , cpu_size, cpusave); path =tracefs_instance_get_file (test_instance,"trace_marker" );CU_TEST (path !=NULL ); fd =open (path,O_WRONLY ); +tracefs_put_tracing_file (path);CU_TEST (fd >=0 );for (i =0 ; i <TEST_ARRAY_SIZE ; i++) { - test_array[i] =random (); - ret =write (fd, test_array + i,sizeof (int )); -CU_TEST (ret ==sizeof (int )); + test_array[i].cpu =rand () % cpus; + test_array[i].value =random (); +if (!test_array[i].value) + test_array[i].value++; +CU_TEST (test_array[i].cpu < cpus); +CPU_ZERO_S (cpu_size, cpuset); +CPU_SET (test_array[i].cpu, cpuset); +sched_setaffinity (0 , cpu_size, cpuset); + ret =write (fd, test_array + i,sizeof (struct test_sample )); +CU_TEST (ret ==sizeof (struct test_sample )); } -tracefs_put_tracing_file (path); +sched_setaffinity (0 , cpu_size, cpusave);close (fd); } +static void iter_raw_events_on_cpu (int cpu) +{ +int check =0 ; +int ret; +int i; + + test_found =0 ; +test_iter_write (); + ret =tracefs_iterate_raw_events (test_tep, test_instance,NULL ,0 , + test_callback, &cpu); +CU_TEST (ret ==0 ); +if (cpu <0 ) { +CU_TEST (test_found ==TEST_ARRAY_SIZE ); + }else { +for (i =0 ; i <TEST_ARRAY_SIZE ; i++) { +if (test_array[i].cpu == cpu) { + check++; + CU_TEST(test_array[i].value == 0) + }else { + CU_TEST(test_array[i].value != 0) + } + } +CU_TEST (test_found == check); + } +} +static void test_iter_raw_events (void ) { +int cpus =sysconf (_SC_NPROCESSORS_CONF);int ret; +int i; - ret =tracefs_iterate_raw_events (NULL , test_instance, test_callback,NULL ); + ret =tracefs_iterate_raw_events (NULL , test_instance,NULL ,0 , test_callback,NULL );CU_TEST (ret <0 ); - ret =tracefs_iterate_raw_events (test_tep,NULL , test_callback,NULL ); + ret =tracefs_iterate_raw_events (test_tep,NULL ,NULL ,0 , test_callback,NULL );CU_TEST (ret ==0 ); - ret =tracefs_iterate_raw_events (test_tep, test_instance,NULL ,NULL ); + ret =tracefs_iterate_raw_events (test_tep, test_instance,NULL ,0 ,NULL ,NULL );CU_TEST (ret <0 ); - test_found =0 ; -test_iter_write (); - ret =tracefs_iterate_raw_events (test_tep, test_instance, - test_callback,NULL ); -CU_TEST (ret ==0 ); -CU_TEST (test_found ==TEST_ARRAY_SIZE ); +iter_raw_events_on_cpu (-1 ); +for (i =0 ; i < cpus; i++) +iter_raw_events_on_cpu (i); }#define RAND_STR_SIZE 20
Signature · 1 line
2.29.2
PATCH 7/9 trace-cmd: Use system trace libraries, if available
In reply to Steven RostedtFrom: "Tzvetomir Stoyanov (VMware)" <[email protected]>
Check if libtraceevent and libtracefs are installed in the system and use them, otherwise build and use the local implementations.
--- Makefile | 40 ++++++++++++++++++++++++++++------------ lib/traceevent/Makefile | 2 ++ lib/tracefs/Makefile | 2 ++ tracecmd/Makefile | 6 ++++-- 4 files changed, 36 insertions(+), 14 deletions(-)
Makefile +28 -12
@@ -191,6 +191,8 @@ export prefix bindir src obj kshark-dir LIBS = -ldl + +LIBTRACEEVENT=libtraceevent LIBTRACEEVENT_DIR = $(obj)/lib/traceevent LIBTRACEEVENT_STATIC = $(LIBTRACEEVENT_DIR)/libtraceevent.a LIBTRACEEVENT_SHARED = $(LIBTRACEEVENT_DIR)/libtraceevent.so
@@ -199,35 +201,48 @@ LIBTRACECMD_DIR = $(obj)/lib/trace-cmd LIBTRACECMD_STATIC = $(LIBTRACECMD_DIR)/libtracecmd.a LIBTRACECMD_SHARED = $(LIBTRACECMD_DIR)/libtracecmd.so +LIBTRACEFS=libtracefs LIBTRACEFS_DIR = $(obj)/lib/tracefs LIBTRACEFS_STATIC = $(LIBTRACEFS_DIR)/libtracefs.a LIBTRACEFS_SHARED = $(LIBTRACEFS_DIR)/libtracefs.so -TRACE_LIBS = -L$(LIBTRACECMD_DIR) -ltracecmd \ - -L$(LIBTRACEEVENT_DIR) -ltraceevent \ - -L$(LIBTRACEFS_DIR) -ltracefs +ifeq ($(shell sh -c "pkg-config --cflags $(LIBTRACEEVENT) > /dev/null 2>&1 && echo y"), y) +LIBTRACEEVENT_CFLAGS = $(shell sh -c "pkg-config --cflags $(LIBTRACEEVENT)") +LIBTRACEEVENT_LDLAGS = $(shell sh -c "pkg-config --libs $(LIBTRACEEVENT)") +else +LIBTRACEEVENT_CFLAGS = -I$(src)/include/traceevent -I$(src)/lib/traceevent/include +LIBTRACEEVENT_LDLAGS = -L$(LIBTRACEEVENT_DIR) -ltraceevent +LIBTRACEEVENT_STATIC_BUILD = $(LIBTRACEEVENT_STATIC) +endif + +ifeq ($(shell sh -c "pkg-config --cflags $(LIBTRACEFS) > /dev/null 2>&1 && echo y"), y) +LIBTRACEFS_CFLAGS = $(shell sh -c "pkg-config --cflags $(LIBTRACEFS)") +LIBTRACEFS_LDLAGS = $(shell sh -c "pkg-config --libs $(LIBTRACEFS)") +else +LIBTRACEFS_CFLAGS = -I$(src)/include/tracefs +LIBTRACEFS_LDLAGS = -L$(LIBTRACEFS_DIR) -ltracefs +LIBTRACEFS_STATIC_BUILD = $(LIBTRACEFS_STATIC) +endif + + +TRACE_LIBS = -L$(LIBTRACECMD_DIR) -ltracecmd \ + $(LIBTRACEEVENT_LDLAGS) $(LIBTRACEFS_LDLAGS) export LIBS TRACE_LIBS export LIBTRACEEVENT_DIR LIBTRACECMD_DIR LIBTRACEFS_DIR export LIBTRACECMD_STATIC LIBTRACECMD_SHARED -export LIBTRACEEVENT_STATIC LIBTRACEEVENT_SHARED -export LIBTRACEFS_STATIC LIBTRACEFS_SHARED - export Q SILENT VERBOSE EXT # Include the utils include scripts/utils.mk INCLUDES = -I$(src)/include -I$(src)/../../include -INCLUDES += -I$(src)/include/traceevent INCLUDES += -I$(src)/include/trace-cmd -INCLUDES += -I$(src)/include/tracefs -INCLUDES += -I$(src)/lib/traceevent/include INCLUDES += -I$(src)/lib/trace-cmd/include INCLUDES += -I$(src)/lib/trace-cmd/include/private -INCLUDES += -I$(src)/lib/tracefs/include INCLUDES += -I$(src)/tracecmd/include -INCLUDES += -I$(obj)/tracecmd/include +INCLUDES += $(LIBTRACEEVENT_CFLAGS) +INCLUDES += $(LIBTRACEFS_CFLAGS) include $(src)/features.mk
@@ -288,6 +303,7 @@ CMD_TARGETS = trace-cmd $(BUILD_PYTHON) # Default we just build trace-cmd # # If you want kernelshark, then do: make gui +# If you want all libraries, then do: make libs ### all: all_cmd plugins show_gui_make
@@ -309,7 +325,7 @@ gui: force @echo "gui build complete" @echo " kernelshark located at $(kshark-dir)/bin" -trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC) $(LIBTRACEFS_STATIC) \ +trace-cmd: force $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACECMD_STATIC) $(LIBTRACEFS_STATIC_BUILD) \ force $(obj)/lib/trace-cmd/plugins/tracecmd_plugin_dir $(Q)$(MAKE) -C $(src)/tracecmd $(obj)/tracecmd/$@
lib/traceevent/Makefile +2 -0
@@ -6,6 +6,8 @@ bdir:=$(obj)/lib/traceevent DEFAULT_TARGET = $(bdir)/libtraceevent.a +CFLAGS += -I$(bdir)/include + OBJS = OBJS += event-parse.o OBJS += event-plugin.o
lib/tracefs/Makefile +2 -0
@@ -6,6 +6,8 @@ bdir:=$(obj)/lib/tracefs DEFAULT_TARGET = $(bdir)/libtracefs.a +CFLAGS += -I$(bdir)/include + OBJS = OBJS += tracefs-utils.o OBJS += tracefs-instance.o
tracecmd/Makefile +4 -2
@@ -11,6 +11,8 @@ TARGETS = $(bdir)/trace-cmd $(TC_VERSION) BUILDGUI := 0 include $(src)/scripts/utils.mk +CFLAGS += -I$(bdir)/include + TRACE_CMD_OBJS = TRACE_CMD_OBJS += trace-cmd.o TRACE_CMD_OBJS += trace-record.o
@@ -47,7 +49,7 @@ all_objs := $(sort $(ALL_OBJS)) all_deps := $(all_objs:$(bdir)/%.o=$(bdir)/.%.d) CONFIG_INCLUDES = -CONFIG_LIBS = -lrt -lpthread +CONFIG_LIBS = -lrt -lpthread $(TRACE_LIBS) CONFIG_FLAGS = all: $(TARGETS)
@@ -67,7 +69,7 @@ $(all_objs): | $(bdir) $(bdir)/trace-cmd: $(ALL_OBJS) $(Q)$(do_app_build) -$(bdir)/trace-cmd: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC) $(LIBTRACEFS_STATIC) +$(bdir)/trace-cmd: $(LIBTRACECMD_STATIC) $(bdir)/%.o: %.c $(Q)$(call do_compile)
Signature · 1 line
2.29.2
PATCH 8/9 trace-cmd: Have "make test" use system libraries if present
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
Update the Makefiles so that "make test" will use the system libraries of libtraceevent and libtracefs if they are present, and only build them locally if they are not.
--- Makefile | 5 ++++- utest/Makefile | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-)
Makefile +4 -1
@@ -215,6 +215,8 @@ LIBTRACEEVENT_LDLAGS = -L$(LIBTRACEEVENT_DIR) -ltraceevent LIBTRACEEVENT_STATIC_BUILD = $(LIBTRACEEVENT_STATIC) endif +export LIBTRACEEVENT_CFLAGS LIBTRACEEVENT_LDLAGS + ifeq ($(shell sh -c "pkg-config --cflags $(LIBTRACEFS) > /dev/null 2>&1 && echo y"), y) LIBTRACEFS_CFLAGS = $(shell sh -c "pkg-config --cflags $(LIBTRACEFS)") LIBTRACEFS_LDLAGS = $(shell sh -c "pkg-config --libs $(LIBTRACEFS)")
@@ -224,6 +226,7 @@ LIBTRACEFS_LDLAGS = -L$(LIBTRACEFS_DIR) -ltracefs LIBTRACEFS_STATIC_BUILD = $(LIBTRACEFS_STATIC) endif +export LIBTRACEFS_CFLAGS LIBTRACEFS_LDLAGS TRACE_LIBS = -L$(LIBTRACECMD_DIR) -ltracecmd \ $(LIBTRACEEVENT_LDLAGS) $(LIBTRACEFS_LDLAGS)
@@ -358,7 +361,7 @@ libtracefs.so: $(LIBTRACEFS_SHARED) libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED) $(LIBTRACEFS_SHARED) -test: force $(LIBTRACEEVENT_STATIC) $(LIBTRACEFS_STATIC) $(LIBTRACECMD_STATIC) +test: force $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACEFS_STATIC_BUILD) $(LIBTRACECMD_STATIC) ifneq ($(CUNIT_INSTALLED),1) $(error CUnit framework not installed, cannot build unit tests)) endif
utest/Makefile +1 -3
@@ -9,9 +9,7 @@ OBJS = OBJS += trace-utest.o OBJS += tracefs-utest.o -LIBS += -lcunit \ - -L$(LIBTRACEFS_DIR) -ltracefs \ - -L$(LIBTRACEEVENT_DIR) -ltraceevent +LIBS += -lcunit $(LIBTRACEEVENT_LDLAGS) $(LIBTRACEFS_LDLAGS) OBJS := $(OBJS:%.o=$(bdir)/%.o) DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d)
Signature · 1 line
2.29.2
PATCH 9/9 trace-cmd: Only install libtraceevent and libtracefs if not in system
In reply to Steven RostedtFrom: "Steven Rostedt (VMware)" <[email protected]>
If libtraceevent and libtracefs are not built locally, because they are already on the local system, do not install them either.
--- Makefile | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
Makefile +14 -8
@@ -213,6 +213,7 @@ else LIBTRACEEVENT_CFLAGS = -I$(src)/include/traceevent -I$(src)/lib/traceevent/include LIBTRACEEVENT_LDLAGS = -L$(LIBTRACEEVENT_DIR) -ltraceevent LIBTRACEEVENT_STATIC_BUILD = $(LIBTRACEEVENT_STATIC) +INSTALL_TRACEEVENT = install_traceevent endif export LIBTRACEEVENT_CFLAGS LIBTRACEEVENT_LDLAGS
@@ -224,6 +225,7 @@ else LIBTRACEFS_CFLAGS = -I$(src)/include/tracefs LIBTRACEFS_LDLAGS = -L$(LIBTRACEFS_DIR) -ltracefs LIBTRACEFS_STATIC_BUILD = $(LIBTRACEFS_STATIC) +INSTALL_TRACEFS = install_tracefs endif export LIBTRACEFS_CFLAGS LIBTRACEFS_LDLAGS
@@ -343,7 +345,7 @@ $(LIBTRACEEVENT_STATIC): force $(obj)/lib/traceevent/plugins/trace_python_dir \ $(LIBTRACECMD_STATIC): force $(Q)$(MAKE) -C $(src)/lib/trace-cmd $@ -$(LIBTRACECMD_SHARED): force $(LIBTRACEEVENT_SHARED) +$(LIBTRACECMD_SHARED): force $(LIBTRACEEVENT_SHARED_BUILD) $(Q)$(MAKE) -C $(src)/lib/trace-cmd $@ $(LIBTRACEFS_STATIC): force
@@ -359,7 +361,7 @@ libtracecmd.so: $(LIBTRACECMD_SHARED) libtracefs.a: $(LIBTRACEFS_STATIC) libtracefs.so: $(LIBTRACEFS_SHARED) -libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED) $(LIBTRACEFS_SHARED) +libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED_BUILD) $(LIBTRACEFS_SHARED_BUILD) test: force $(LIBTRACEEVENT_STATIC_BUILD) $(LIBTRACEFS_STATIC_BUILD) $(LIBTRACECMD_STATIC) ifneq ($(CUNIT_INSTALLED),1)
@@ -432,18 +434,22 @@ install: install_cmd install_gui: install_cmd gui $(Q)$(MAKE) $(S) -C $(kshark-dir)/build install -install_libs: libs - $(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ)/trace-cmd) +install_traceevent: $(LIBTRACEEVENT_STATIC_BUILD) $(Q)$(call do_install,$(LIBTRACEEVENT_SHARED),$(libdir_SQ)/traceevent) - $(Q)$(call do_install,$(LIBTRACEFS_SHARED),$(libdir_SQ)/tracefs) $(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_SQ)/traceevent) $(Q)$(call do_install,$(src)/include/traceevent/trace-seq.h,$(includedir_SQ)/traceevent) - $(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ)/trace-cmd) - $(Q)$(call do_install,$(src)/include/tracefs/tracefs.h,$(includedir_SQ)/tracefs) - $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/trace-cmd) $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/traceevent) + +install_tracefs: $(LIBTRACEFS_STATIC_BUILD) + $(Q)$(call do_install,$(LIBTRACEFS_SHARED),$(libdir_SQ)/tracefs) + $(Q)$(call do_install,$(src)/include/tracefs/tracefs.h,$(includedir_SQ)/tracefs) $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/tracefs) +install_libs: libs $(INSTALL_TRACEEVENT) $(INSTALL_TRACEFS) + $(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ)/trace-cmd) + $(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ)/trace-cmd) + $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/trace-cmd) + doc: $(MAKE) -C $(src)/Documentation all doc_gui:
Signature · 1 line
2.29.2