libtraceevent: Add sample program to test events
PATCH 1/1 libtraceevent: Add sample program to test events
From: "Steven Rostedt (Google)" <[email protected]>
Add a samples directory and the program test-event that can be used to parse a given event. I found that when an event fails in trace-cmd, it can be a burden to try to debug it as you may need to go through all the events to get to the buggy event.
The test-event will let you simply copy and paste the event format into a file, and read it and it will parse it, giving any errors that it finds. This makes running the parser under gdb much easier.
Signed-off-by Steven Rostedt (Google) <[email protected]>
--- Makefile | 3 + samples/Makefile | 26 ++++++++ samples/test-event.c | 154 +++++++++++++++++++++++++++++++++++++++++++ scripts/utils.mk | 8 +++ 4 files changed, 191 insertions(+) create mode 100644 samples/Makefile create mode 100644 samples/test-event.c
Makefile +3 -0
@@ -419,6 +419,9 @@ PHONY += install_plugins install_plugins: plugins $(Q)$(call descend,plugins,install) +samples: libtraceevent.a force + $(Q)$(call descend,$(src)/samples,all) + PHONY += clean_plugins clean_plugins: $(Q)$(call descend_clean,plugins)
samples/Makefile new file +26 -0
@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: LGPL-2.1 + +include $(src)/scripts/utils.mk + +TARGETS := +TARGETS += test-event + +sdir := $(obj)/samples + +TARGETS := $(patsubst %,$(sdir)/%,$(TARGETS)) + +all: $(TARGETS) + +$(sdir): + @mkdir -p $(sdir) + +$(TARGETS): $(sdir) $(LIBTRACEEVENT_STATIC) + +$(sdir)/%: $(bdir)/%.o + $(call do_sample_build,$@,$<) + +$(bdir)/%.o: $(bdir)/%.c + $(Q)$(CC) -o $@ -c $< $(CFLAGS) $(INCLUDES) + +clean: + $(Q)$(call do_clean,$(sdir)/*)
samples/test-event.c new file +154 -0
154 lines not on this page · raw message
scripts/utils.mk +8 -0
@@ -91,6 +91,14 @@ do_clean = \ ($(print_clean) \ $(RM) $1) +do_sample_build = \ + $(Q)($(print_sample_build) \ + $(CC) -o $1 $2 $(CFLAGS) $(LIBTRACEEVENT_STATIC) -ldl) + +do_sample_obj = \ + $(Q)($(print_sample_obj) \ + $(CC) -g -Wall -c $(CFLAGS) -o $1 $2 -I../include/) + # # Define a callable command for descending to a new directory #
Signature · 1 line
2.34.1