Remove redondant "hello" test and move "hello-static-lib" to doc/examples
A message that is not in the archive (sent off-list or not yet received): 20130328135040.GA29485@Krystal
PATCH 1/1 Remove redondant "hello" test and move "hello-static-lib" to doc/examples
The examples are now automatically built as part of the default make target.
The "hello" test verified that an application with statically embedded tracepoint providers could be built. This is now covered by "easy-ust" in doc/examples since we now build the examples.
Move the "hello-static-lib" test to doc/examples.
This should provide complete and easy to understand Makefile examples to users who wish to integrate tracepoint providers to their applications.
--- .gitignore | 6 +- README | 2 +- configure.ac | 2 - doc/examples/Makefile.am | 15 ++++ doc/examples/README | 3 + doc/examples/demo/Makefile | 27 +++++-- doc/examples/easy-ust/Makefile | 30 ++++++-- doc/examples/hello-static-lib/Makefile | 53 ++++++++++++++ doc/examples/hello-static-lib/README | 3 + doc/examples/hello-static-lib/hello.c | 94 ++++++++++++++++++++++++ doc/examples/hello-static-lib/tp.c | 26 +++++++ doc/examples/hello-static-lib/ust_tests_hello.h | 72 ++++++++++++++++++ doc/man/lttng-ust.3 | 62 ++++++++-------- tests/Makefile.am | 2 +- tests/hello-static-lib/Makefile.am | 18 ----- tests/hello-static-lib/README | 3 - tests/hello-static-lib/hello.c | 95 ------------------------ tests/hello-static-lib/tp.c | 26 ------- tests/hello-static-lib/ust_tests_hello.h | 72 ------------------ tests/hello/Makefile.am | 13 ---- tests/hello/Makefile.example.bsd | 8 -- tests/hello/Makefile.example.linux | 8 -- tests/hello/README | 2 - tests/hello/hello.c | 97 ------------------------- tests/hello/tp.c | 26 ------- tests/hello/ust_tests_hello.h | 76 ------------------- 26 files changed, 349 insertions(+), 492 deletions(-) create mode 100644 doc/examples/README create mode 100644 doc/examples/hello-static-lib/Makefile create mode 100644 doc/examples/hello-static-lib/README create mode 100644 doc/examples/hello-static-lib/hello.c create mode 100644 doc/examples/hello-static-lib/tp.c create mode 100644 doc/examples/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello-static-lib/Makefile.am delete mode 100644 tests/hello-static-lib/README delete mode 100644 tests/hello-static-lib/hello.c delete mode 100644 tests/hello-static-lib/tp.c delete mode 100644 tests/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello/Makefile.am delete mode 100644 tests/hello/Makefile.example.bsd delete mode 100644 tests/hello/Makefile.example.linux delete mode 100644 tests/hello/README delete mode 100644 tests/hello/hello.c delete mode 100644 tests/hello/tp.c delete mode 100644 tests/hello/ust_tests_hello.h
.gitignore +4 -2
@@ -31,7 +31,10 @@ lttng-ust.pc ustctl/ustctl ust-consumerd/ust-consumerd -tests/hello/hello +doc/examples/demo/demo +doc/examples/easy-ust/sample +doc/examples/hello-static-lib/hello + tests/hello.cxx/hello tests/same_line_tracepoint/same_line_tracepoint tests/ust-basic-tracing/ust-basic-tracing
@@ -39,5 +42,4 @@ tests/ust-multi-test/ust-multi-test tests/trace_event/trace_event_test tests/tracepoint/benchmark/tracepoint_benchmark tests/tracepoint/tracepoint_test -tests/hello-static-lib/hello tests/snprintf/prog
README +1 -1
@@ -72,7 +72,7 @@ USAGE: - If building the provider directly into the application, link the application with "-llttng-ust". - If building a static library for the provider, link the static - library with "-lllttng-ust". + library with "-llttng-ust". - Include the tracepoint provider header into all C files using the provider. - Example:
configure.ac +0 -2
@@ -265,8 +265,6 @@ AC_CONFIG_FILES([ liblttng-ust-cyg-profile/Makefile tools/Makefile tests/Makefile - tests/hello/Makefile - tests/hello-static-lib/Makefile tests/hello.cxx/Makefile tests/same_line_tracepoint/Makefile tests/snprintf/Makefile
doc/examples/Makefile.am +15 -0
@@ -1,6 +1,12 @@ +SUBDIRS = easy-ust demo hello-static-lib + +doc_examplesdir = ${docdir}/examples doc_examples_easy_ustdir = ${docdir}/examples/easy-ust doc_examples_gen_tpdir = ${docdir}/examples/gen-tp doc_examples_demodir = ${docdir}/examples/demo +doc_examples_hello_static_libdir = ${docdir}/examples/hello-static-lib + +dist_doc_examples_DATA = README dist_doc_examples_easy_ust_DATA = easy-ust/Makefile \ easy-ust/sample.c \
@@ -19,3 +25,12 @@ dist_doc_examples_demo_DATA = demo/demo.c \ demo/ust_tests_demo2.h \ demo/ust_tests_demo3.h \ demo/ust_tests_demo.h + +dist_doc_examples_hello_static_lib_DATA = hello-static-lib/Makefile \ + hello-static-lib/hello.c \ + hello-static-lib/README \ + hello-static-lib/ust_tests_hello.h \ + hello-static-lib/tp.c + +BUILD_EXAMPLES_FROM_TREE = 1 +export
doc/examples/README new file +3 -0
@@ -0,0 +1,3 @@ +To build the examples from the source tree, the BUILD_EXAMPLES_FROM_TREE +environment variable must be defined. This will force the examples' +Makefiles to use the source tree's public header files and libraries.
doc/examples/demo/Makefile +22 -5
@@ -9,13 +9,30 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This Makefile is not using automake so that people may see how to build -# a program and tracepoint provider probes as stand-alone shared objects. +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes as stand-alone shared objects. CC = gcc LIBS = -ldl # On Linux #LIBS = -lc # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so
@@ -23,13 +40,13 @@ lttng-ust-provider-ust-tests-demo.o: tp.c tp2.c ust_tests_demo.h ust_tests_demo2 $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo.so: lttng-ust-provider-ust-tests-demo.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< lttng-ust-provider-ust-tests-demo3.o: tp3.c ust_tests_demo3.h $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo3.so: lttng-ust-provider-ust-tests-demo3.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< demo.o: demo.c $(CC) $(CFLAGS) -c -o $@ $<
doc/examples/easy-ust/Makefile +23 -7
@@ -10,20 +10,36 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This makefile is not using automake so that people can see how to make -# simply. It builds a program with a statically embedded tracepoint -# provider probe. +# This makefile is not using automake so that users can see how to build +# a program with a statically embedded tracepoint provider probe. # the "html" target helps for documentation (req. code2html) CC = gcc LIBS = -ldl -llttng-ust # On Linux #LIBS = -lc -llttng-ust # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: sample sample: sample.o tp.o - $(CC) -o $@ $^ $(LIBS) + $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) sample.o: sample.c sample_component_provider.h $(CC) $(CFLAGS) -c -o $@ $<
@@ -33,7 +49,7 @@ tp.o: tp.c sample_component_provider.h html: sample_component_provider.html sample.html tp.html -%.html: %.c +%.html: %.c code2html -lc $< $@ %.html : %.h
@@ -41,5 +57,5 @@ html: sample_component_provider.html sample.html tp.html .PHONY: clean clean: - rm -f *.html + rm -f *.html rm -f *.o sample
doc/examples/hello-static-lib/Makefile new file +53 -0
53 lines not on this page · raw message
doc/examples/hello-static-lib/README new file +3 -0
@@ -0,0 +1,3 @@ +This is a "hello world" application used to verify that an instrumented +program can be built successfully and linked with tracepoint providers +built as a separate static library.
doc/examples/hello-static-lib/hello.c new file +94 -0
94 lines not on this page · raw message
doc/examples/hello-static-lib/tp.c new file +26 -0
@@ -0,0 +1,26 @@ +/* +* tp.c +* +* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_hello.h"
doc/examples/hello-static-lib/ust_tests_hello.h new file +72 -0
72 lines not on this page · raw message
doc/man/lttng-ust.3 +32 -30
158 lines not on this page · raw message
tests/Makefile.am +1 -1
@@ -1,4 +1,4 @@ -SUBDIRS = . hello hello-static-lib same_line_tracepoint snprintf +SUBDIRS = . same_line_tracepoint snprintf if CXX_WORKS SUBDIRS += hello.cxx
tests/hello-static-lib/Makefile.am deleted +0 -18
@@ -1,18 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_LTLIBRARIES = liblttng-ust-provider-ust-test-hello.la -liblttng_ust_provider_ust_test_hello_la_SOURCES = \ - tp.c ust_tests_hello.h -liblttng_ust_provider_ust_test_hello_la_LIBADD = \ - $(top_builddir)/liblttng-ust/liblttng-ust.la - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c -hello_LDADD = liblttng-ust-provider-ust-test-hello.la - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endif
tests/hello-static-lib/README deleted +0 -3
@@ -1,3 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully and linked with tracepoint providers -built as a separate static library.
tests/hello-static-lib/hello.c deleted +0 -95
95 lines not on this page · raw message
tests/hello-static-lib/tp.c deleted +0 -26
@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h"
tests/hello-static-lib/ust_tests_hello.h deleted +0 -72
72 lines not on this page · raw message
tests/hello/Makefile.am deleted +0 -13
@@ -1,13 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c tp.c ust_tests_hello.h -hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la -hello_CFLAGS = -Werror=old-style-definition - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endif
tests/hello/Makefile.example.bsd deleted +0 -8
@@ -1,8 +0,0 @@ -# Example makefile for build outside of the LTTng-UST tree. - -hello: - ${CC} -O2 -I. -o hello -lc -llttng-ust hello.c tp.c - -.PHONY: clean -clean: - rm -f hello
tests/hello/Makefile.example.linux deleted +0 -8
@@ -1,8 +0,0 @@ -# Example makefile for build outside of the LTTng-UST tree. - -hello: - ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c - -.PHONY: clean -clean: - rm -f hello
tests/hello/README deleted +0 -2
@@ -1,2 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully.
tests/hello/hello.c deleted +0 -97
97 lines not on this page · raw message
tests/hello/tp.c deleted +0 -26
@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h"
tests/hello/ust_tests_hello.h deleted +0 -76
76 lines not on this page · raw message
Signature · 7 lines
1.8.2.1 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
redondant -> redundant
Quoted 5 lines · * Jérémie Galarneau ([email protected]) wrote:
The examples are now automatically built as part of the default make target.
The "hello" test verified that an application with statically embedded tracepoint providers could be built. This is now covered by "easy-ust" in doc/examples since we now build the examples.
No, hello is referenced by lttng-ust(3) manpage.
Please leave it there, but move it to examples.
Thanks,
Mathieu
Quoted 1,240 lines
Move the "hello-static-lib" test to doc/examples.
This should provide complete and easy to understand
Makefileexamples to users who wish to integrate tracepoint providers to their applications.Signed-off-by Jérémie Galarneau <[email protected]>--- .gitignore | 6 +- README | 2 +- configure.ac | 2 - doc/examples/Makefile.am | 15 ++++ doc/examples/README | 3 + doc/examples/demo/Makefile | 27 +++++-- doc/examples/easy-ust/Makefile | 30 ++++++-- doc/examples/hello-static-lib/Makefile | 53 ++++++++++++++ doc/examples/hello-static-lib/README | 3 + doc/examples/hello-static-lib/hello.c | 94 ++++++++++++++++++++++++ doc/examples/hello-static-lib/tp.c | 26 +++++++ doc/examples/hello-static-lib/ust_tests_hello.h | 72 ++++++++++++++++++ doc/man/lttng-ust.3 | 62 ++++++++-------- tests/Makefile.am | 2 +- tests/hello-static-lib/Makefile.am | 18 ----- tests/hello-static-lib/README | 3 - tests/hello-static-lib/hello.c | 95 ------------------------ tests/hello-static-lib/tp.c | 26 ------- tests/hello-static-lib/ust_tests_hello.h | 72 ------------------ tests/hello/Makefile.am | 13 ---- tests/hello/Makefile.example.bsd | 8 -- tests/hello/Makefile.example.linux | 8 -- tests/hello/README | 2 - tests/hello/hello.c | 97 ------------------------- tests/hello/tp.c | 26 ------- tests/hello/ust_tests_hello.h | 76 ------------------- 26 files changed, 349 insertions(+), 492 deletions(-) create mode 100644 doc/examples/README create mode 100644 doc/examples/hello-static-lib/Makefile create mode 100644 doc/examples/hello-static-lib/README create mode 100644 doc/examples/hello-static-lib/hello.c create mode 100644 doc/examples/hello-static-lib/tp.c create mode 100644 doc/examples/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello-static-lib/Makefile.am delete mode 100644 tests/hello-static-lib/README delete mode 100644 tests/hello-static-lib/hello.c delete mode 100644 tests/hello-static-lib/tp.c delete mode 100644 tests/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello/Makefile.am delete mode 100644 tests/hello/Makefile.example.bsd delete mode 100644 tests/hello/Makefile.example.linux delete mode 100644 tests/hello/README delete mode 100644 tests/hello/hello.c delete mode 100644 tests/hello/tp.c delete mode 100644 tests/hello/ust_tests_hello.h.gitignore +4
-2@@ -31,7 +31,10 @@ lttng-ust.pc ustctl/ustctl ust-consumerd/ust-consumerd -tests/hello/hello +doc/examples/demo/demo +doc/examples/easy-ust/sample +doc/examples/hello-static-lib/hello + tests/hello.cxx/hello tests/same_line_tracepoint/same_line_tracepoint tests/ust-basic-tracing/ust-basic-tracing@@ -39,5 +42,4 @@ tests/ust-multi-test/ust-multi-test tests/trace_event/trace_event_test tests/tracepoint/benchmark/tracepoint_benchmark tests/tracepoint/tracepoint_test -tests/hello-static-lib/hello tests/snprintf/progREADME +1
-1@@ -72,7 +72,7 @@ USAGE: - If building the provider directly into the application, link the application with "-llttng-ust". - If building a static library for the provider, link the static - library with "-lllttng-ust". + library with "-llttng-ust". - Include the tracepoint provider header into all C files using the provider. - Example:configure.ac +0
-2@@ -265,8 +265,6 @@ AC_CONFIG_FILES([ liblttng-ust-cyg-profile/Makefile tools/Makefile tests/Makefile - tests/hello/Makefile - tests/hello-static-lib/Makefile tests/hello.cxx/Makefile tests/same_line_tracepoint/Makefile tests/snprintf/Makefiledoc/examples/Makefile.am +15
-0@@ -1,6 +1,12 @@ +SUBDIRS = easy-ust demo hello-static-lib + +doc_examplesdir = ${docdir}/examples doc_examples_easy_ustdir = ${docdir}/examples/easy-ust doc_examples_gen_tpdir = ${docdir}/examples/gen-tp doc_examples_demodir = ${docdir}/examples/demo +doc_examples_hello_static_libdir = ${docdir}/examples/hello-static-lib + +dist_doc_examples_DATA = README dist_doc_examples_easy_ust_DATA = easy-ust/Makefile \ easy-ust/sample.c \@@ -19,3 +25,12 @@ dist_doc_examples_demo_DATA = demo/demo.c \ demo/ust_tests_demo2.h \ demo/ust_tests_demo3.h \ demo/ust_tests_demo.h + +dist_doc_examples_hello_static_lib_DATA = hello-static-lib/Makefile \ + hello-static-lib/hello.c \ + hello-static-lib/README \ + hello-static-lib/ust_tests_hello.h \ + hello-static-lib/tp.c + +BUILD_EXAMPLES_FROM_TREE = 1 +exportdoc/examples/README new file +3
-0@@ -0,0 +1,3 @@ +To build the examples from the source tree, the BUILD_EXAMPLES_FROM_TREE +environment variable must be defined. This will force the examples' +Makefiles to use the source tree's public header files and libraries.doc/examples/demo/Makefile +22
-5@@ -9,13 +9,30 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This Makefile is not using automake so that people may see how to build -# a program and tracepoint provider probes as stand-alone shared objects. +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes as stand-alone shared objects. CC = gcc LIBS = -ldl # On Linux #LIBS = -lc # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so@@ -23,13 +40,13 @@ lttng-ust-provider-ust-tests-demo.o: tp.c tp2.c ust_tests_demo.h ust_tests_demo2 $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo.so: lttng-ust-provider-ust-tests-demo.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< lttng-ust-provider-ust-tests-demo3.o: tp3.c ust_tests_demo3.h $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo3.so: lttng-ust-provider-ust-tests-demo3.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< demo.o: demo.c $(CC) $(CFLAGS) -c -o $@ $<doc/examples/easy-ust/Makefile +23
-7@@ -10,20 +10,36 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This makefile is not using automake so that people can see how to make -# simply. It builds a program with a statically embedded tracepoint -# provider probe. +# This makefile is not using automake so that users can see how to build +# a program with a statically embedded tracepoint provider probe. # the "html" target helps for documentation (req. code2html) CC = gcc LIBS = -ldl -llttng-ust # On Linux #LIBS = -lc -llttng-ust # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: sample sample: sample.o tp.o - $(CC) -o $@ $^ $(LIBS) + $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) sample.o: sample.c sample_component_provider.h $(CC) $(CFLAGS) -c -o $@ $<@@ -33,7 +49,7 @@ tp.o: tp.c sample_component_provider.h html: sample_component_provider.html sample.html tp.html -%.html: %.c +%.html: %.c code2html -lc $< $@ %.html : %.h@@ -41,5 +57,5 @@ html: sample_component_provider.html sample.html tp.html .PHONY: clean clean: - rm -f *.html + rm -f *.html rm -f *.o sampledoc/examples/hello-static-lib/Makefile new file +53
-0@@ -0,0 +1,53 @@ +# Copyright (C) 2013 Jérémie Galarneau <[email protected]> +# +# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. +# +# Permission is hereby granted to use or copy this program for any +# purpose, provided the above notices are retained on all copies. +# Permission to modify the code and to distribute modified code is +# granted, provided the above notices are retained, and a notice that +# the code was modified is included with the above copyright notice. + +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes in static libraries. + +CC = gcc +CFLAGS += -I. +LIBS = -ldl -llttng-ust # On Linux +#LIBS = -lc -llttng-ust # On BSD + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif + +all: hello + +lttng-ust-provider-hello.o: tp.c ust_tests_hello.h + $(CC) $(CFLAGS) -c -o $@ $< + +lttng-ust-provider-hello.a: lttng-ust-provider-hello.o + ar -rc $@ $< + +hello.o: hello.c + $(CC) $(CFLAGS) -c -o $@ $< + +hello: hello.o lttng-ust-provider-hello.a + $(CC) -o $@ $(LDFLAGS) $(LIBS) $^ + +.PHONY: clean +clean: + rm -f *.o *.a hellodoc/examples/hello-static-lib/README new file +3
-0@@ -0,0 +1,3 @@ +This is a "hello world" application used to verify that an instrumented +program can be built successfully and linked with tracepoint providers +built as a separate static library.doc/examples/hello-static-lib/hello.c new file +94
-0@@ -0,0 +1,94 @@ +/* +* Copyright (C) 2009 Pierre-Marc Fournier +* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; version 2.1 of +* the License. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <stdio.h> +#include <unistd.h> +#include <sys/mman.h> +#include <stdarg.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <signal.h> +#include <string.h> +#include <arpa/inet.h> +#include <stdlib.h> + +#define TRACEPOINT_DEFINE +#include "ust_tests_hello.h" + +void inthandler (int sig) +{ +printf ("in SIGUSR1 handler\n" ); +tracepoint (ust_tests_hello, tptest_sighandler); +} + +int init_int_handler (void ) +{ +int result; +struct sigaction act; + +memset (&act,0 ,sizeof (act)); + result =sigemptyset (&act.sa_mask); +if (result ==-1 ) { +perror ("sigemptyset" ); +return -1 ; + } + + act.sa_handler = inthandler; + act.sa_flags =SA_RESTART ; + +/* Only defer ourselves. Also, try to restart interrupted +* syscalls to disturb the traced program as little as possible. +*/ + result =sigaction (SIGUSR1 , &act,NULL ); +if (result ==-1 ) { +perror ("sigaction" ); +return -1 ; + } + +return 0 ; +} + +int main (int argc,char **argv) +{ +int i, netint; +long values[] = {1 ,2 ,3 }; +char text[10 ] ="test" ; +double dbl =2.0 ; +float flt =2222.0 ; +int delay =0 ; + +init_int_handler (); + +if (argc ==2 ) + delay =atoi (argv[1 ]); + +fprintf (stderr,"Hello, World!\n" ); + +sleep (delay); + +fprintf (stderr,"Tracing... " ); +for (i =0 ; i <1000000 ; i++) { + netint =htonl (i); +tracepoint (ust_tests_hello, tptest, i, netint, values, + text,strlen (text), dbl, flt); + } +fprintf (stderr," done.\n" ); +return 0 ; +}doc/examples/hello-static-lib/tp.c new file +26
-0@@ -0,0 +1,26 @@ +/* +* tp.c +* +* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_hello.h" doc/examples/hello-static-lib/ust_tests_hello.h new file +72
-0@@ -0,0 +1,72 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_hello + +#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_HELLO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include <lttng/tracepoint.h> + +TRACEPOINT_EVENT(ust_tests_hello, tptest, + TP_ARGS(int, anint, int, netint, long *, values, + char *, text, size_t, textlen, + double, doublearg, float, floatarg), + TP_FIELDS( + ctf_integer(int, intfield, anint) + ctf_integer_hex(int, intfield2, anint) + ctf_integer(long, longfield, anint) + ctf_integer_network(int, netintfield, netint) + ctf_integer_network_hex(int, netintfieldhex, netint) + ctf_array(long, arrfield1, values, 3) + ctf_array_text(char, arrfield2, text, 10) + ctf_sequence(char, seqfield1, text, + size_t, textlen) + ctf_sequence_text(char, seqfield2, text, + size_t, textlen) + ctf_string(stringfield, text) + ctf_float(float, floatfield, floatarg) + ctf_float(double, doublefield, doublearg) + ) +) + +TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, + TP_ARGS(), + TP_FIELDS() +) + +#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" + +/* This part must be outside ifdef protection */ +#include <lttng/tracepoint-event.h> + +#ifdef __cplusplus +} +#endifdoc/man/lttng-ust.3 +32
-30@@ -40,11 +40,11 @@ focus on the various types that can be recorded into a trace event: TRACEPOINT_EVENT( /* * provider name, not a variable but a string starting with a - * letter and containing either letters, numbers or underscores. + * letter and containing either letters, numbers or underscores. * Needs to be the same as TRACEPOINT_PROVIDER. Needs to * follow the namespacing guide-lines in lttng/tracepoint.h: - * - * Must be included before include tracepoint provider + * + * Must be included before include tracepoint provider * ex.: project_event * ex.: project_component_event *@@ -59,19 +59,19 @@ TRACEPOINT_EVENT( /* * tracepoint name, same format as sample provider. Does not * need to be declared before. in this case the name is - * "message" + * "message" */ message, /* - * TP_ARGS macro contains the arguments passed for the tracepoint + * TP_ARGS macro contains the arguments passed for the tracepoint * it is in the following format * TP_ARGS(type1, name1, type2, name2, ... type10, name10) - * where there can be from zero to ten elements. - * typeN is the datatype, such as int, struct or double **. + * where there can be from zero to ten elements. + * typeN is the datatype, such as int, struct or double **. * name is the variable name (in "int myInt" the name would be - * myint) + * myint) * TP_ARGS() is valid to mean no arguments * TP_ARGS(void) is valid too */@@ -80,7 +80,7 @@ TRACEPOINT_EVENT( double, doublearg, float, floatarg), /* - * TP_FIELDS describes how to write the fields of the trace event. + * TP_FIELDS describes how to write the fields of the trace event. * You can put expressions in the "argument expression" area, * typically using the input arguments from TP_ARGS. */@@ -109,14 +109,14 @@ TRACEPOINT_EVENT( /* * ctf_array: a statically-sized array. * args: (type, field name, argument expression, value) - */ + */ ctf_array(long, arrfield1, values, 3) /* * ctf_array_text: a statically-sized array, printed as * a string. No need to be terminated by a null * character. - */ + */ ctf_array_text(char, arrfield2, text, 10) /*@@ -127,7 +127,7 @@ TRACEPOINT_EVENT( * unsigned type. As a reminder, "unsigned char" should * be preferred to "char", since the signedness of * "char" is implementation-defined. - */ + */ ctf_sequence(char, seqfield1, text, size_t, textlen)@@ -172,54 +172,54 @@ declared before declaring a TRACEPOINT_LOGLEVEL. The loglevels go from 0 to 14. Higher numbers imply the most verbosity (higher event throughput expected. - + Loglevels 0 through 6, and loglevel 14, match syslog(3) loglevels semantic. Loglevels 7 through 13 offer more fine-grained selection of debug information. - + TRACE_EMERG 0 system is unusable - + TRACE_ALERT 1 action must be taken immediately - + TRACE_CRIT 2 critical conditions - + TRACE_ERR 3 error conditions - + TRACE_WARNING 4 warning conditions - + TRACE_NOTICE 5 normal, but significant, condition - + TRACE_INFO 6 informational message - + TRACE_DEBUG_SYSTEM 7 debug information with system-level scope (set of programs) - + TRACE_DEBUG_PROGRAM 8 debug information with program-level scope (set of processes) - + TRACE_DEBUG_PROCESS 9 debug information with process-level scope (set of modules) - + TRACE_DEBUG_MODULE 10 debug information with module (executable/library) scope (set of units) - + TRACE_DEBUG_UNIT 11 debug information with compilation unit scope (set of functions) - + TRACE_DEBUG_FUNCTION 12 debug information with function-level scope - + TRACE_DEBUG_LINE 13 debug information with line-level scope (TRACEPOINT_EVENT default) - + TRACE_DEBUG 14 debug-level message (trace_printf default)@@ -269,7 +269,9 @@ carefully: - Include the tracepoint provider header into all C files using the provider. - Example: - - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example + - doc/examples/easy-ust/ sample.c sample_component_provider.h tp.c + Makefile + - doc/examples/hello-static-lib/ hello.c tp.c ust_test_hello.h Makefile 2) Compile the Tracepoint Provider separately from the application, using dynamic linking:@@ -287,7 +289,7 @@ carefully: needed. Another way is to dlopen the tracepoint probe when needed by the application. - Example: - - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace + - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace Makefile - Note about dlclose() usage: it is not safe to use dlclose on a provider shared object that is being actively used for tracing duetests/Makefile.am +1
-1@@ -1,4 +1,4 @@ -SUBDIRS = . hello hello-static-lib same_line_tracepoint snprintf +SUBDIRS = . same_line_tracepoint snprintf if CXX_WORKS SUBDIRS += hello.cxxtests/hello-static-lib/Makefile.am deleted +0
-18@@ -1,18 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_LTLIBRARIES = liblttng-ust-provider-ust-test-hello.la -liblttng_ust_provider_ust_test_hello_la_SOURCES = \ - tp.c ust_tests_hello.h -liblttng_ust_provider_ust_test_hello_la_LIBADD = \ - $(top_builddir)/liblttng-ust/liblttng-ust.la - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c -hello_LDADD = liblttng-ust-provider-ust-test-hello.la - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endiftests/hello-static-lib/README deleted +0
-3@@ -1,3 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully and linked with tracepoint providers -built as a separate static library.tests/hello-static-lib/hello.c deleted +0
-95@@ -1,95 +0,0 @@ -/* -* Copyright (C) 2009 Pierre-Marc Fournier -* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; version 2.1 of -* the License. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <arpa/inet.h> -#include <stdlib.h> - -#define TRACEPOINT_DEFINE -#include "ust_tests_hello.h" - -void inthandler (int sig) -{ -printf ("in SIGUSR1 handler\n" ); -tracepoint (ust_tests_hello, tptest_sighandler); -} - -int init_int_handler (void ) -{ -int result; -struct sigaction act; - -memset (&act,0 ,sizeof (act)); - result =sigemptyset (&act.sa_mask); -if (result ==-1 ) { -perror ("sigemptyset" ); -return -1 ; - } - - act.sa_handler = inthandler; - act.sa_flags =SA_RESTART ; - -/* Only defer ourselves. Also, try to restart interrupted -* syscalls to disturb the traced program as little as possible. -*/ - result =sigaction (SIGUSR1 , &act,NULL ); -if (result ==-1 ) { -perror ("sigaction" ); -return -1 ; - } - -return 0 ; -} - -int main (int argc,char **argv) -{ -int i, netint; -long values[] = {1 ,2 ,3 }; -char text[10 ] ="test" ; -double dbl =2.0 ; -float flt =2222.0 ; -int delay =0 ; - -init_int_handler (); - -if (argc ==2 ) - delay =atoi (argv[1 ]); - -fprintf (stderr,"Hello, World!\n" ); - -sleep (delay); - -fprintf (stderr,"Tracing... " ); -for (i =0 ; i <1000000 ; i++) { - netint =htonl (i); -tracepoint (ust_tests_hello, tptest, i, netint, values, - text,strlen (text), dbl, flt); -//usleep(100000); - } -fprintf (stderr," done.\n" ); -return 0 ; -}tests/hello-static-lib/tp.c deleted +0
-26@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h" tests/hello-static-lib/ust_tests_hello.h deleted +0
-72@@ -1,72 +0,0 @@ -#undef TRACEPOINT_PROVIDER -#define TRACEPOINT_PROVIDER ust_tests_hello - -#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) -#define _TRACEPOINT_UST_TESTS_HELLO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <lttng/tracepoint.h> - -TRACEPOINT_EVENT(ust_tests_hello, tptest, - TP_ARGS(int, anint, int, netint, long *, values, - char *, text, size_t, textlen, - double, doublearg, float, floatarg), - TP_FIELDS( - ctf_integer(int, intfield, anint) - ctf_integer_hex(int, intfield2, anint) - ctf_integer(long, longfield, anint) - ctf_integer_network(int, netintfield, netint) - ctf_integer_network_hex(int, netintfieldhex, netint) - ctf_array(long, arrfield1, values, 3) - ctf_array_text(char, arrfield2, text, 10) - ctf_sequence(char, seqfield1, text, - size_t, textlen) - ctf_sequence_text(char, seqfield2, text, - size_t, textlen) - ctf_string(stringfield, text) - ctf_float(float, floatfield, floatarg) - ctf_float(double, doublefield, doublearg) - ) -) - -TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, - TP_ARGS(), - TP_FIELDS() -) - -#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ - -#undef TRACEPOINT_INCLUDE -#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" - -/* This part must be outside ifdef protection */ -#include <lttng/tracepoint-event.h> - -#ifdef __cplusplus -} -#endiftests/hello/Makefile.am deleted +0
-13@@ -1,13 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c tp.c ust_tests_hello.h -hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la -hello_CFLAGS = -Werror=old-style-definition - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endiftests/hello/Makefile.example.bsd deleted +0
-8@@ -1,8 +0,0 @@ -# Example makefile for build outside of the LTTng-UST tree. - -hello: - ${CC} -O2 -I. -o hello -lc -llttng-ust hello.c tp.c - -.PHONY: clean -clean: - rm -f hellotests/hello/Makefile.example.linux deleted +0
-8@@ -1,8 +0,0 @@ -# Example makefile for build outside of the LTTng-UST tree. - -hello: - ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c - -.PHONY: clean -clean: - rm -f hellotests/hello/README deleted +0
-2@@ -1,2 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully.tests/hello/hello.c deleted +0
-97@@ -1,97 +0,0 @@ -/* -* Copyright (C) 2009 Pierre-Marc Fournier -* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; version 2.1 of -* the License. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <arpa/inet.h> -#include <stdlib.h> -#include <stdbool.h> - -#define TRACEPOINT_DEFINE -#include "ust_tests_hello.h" - -void inthandler (int sig) -{ -printf ("in SIGUSR1 handler\n" ); -tracepoint (ust_tests_hello, tptest_sighandler); -} - -int init_int_handler (void ) -{ -int result; -struct sigaction act; - -memset (&act,0 ,sizeof (act)); - result =sigemptyset (&act.sa_mask); -if (result ==-1 ) { -perror ("sigemptyset" ); -return -1 ; - } - - act.sa_handler = inthandler; - act.sa_flags =SA_RESTART ; - -/* Only defer ourselves. Also, try to restart interrupted -* syscalls to disturb the traced program as little as possible. -*/ - result =sigaction (SIGUSR1 , &act,NULL ); -if (result ==-1 ) { -perror ("sigaction" ); -return -1 ; - } - -return 0 ; -} - -int main (int argc,char **argv) -{ -int i, netint; -long values[] = {1 ,2 ,3 }; -char text[10 ] ="test" ; -double dbl =2.0 ; -float flt =2222.0 ; -int delay =0 ; -bool mybool =123 ;/* should print "1" */ - -init_int_handler (); - -if (argc ==2 ) - delay =atoi (argv[1 ]); - -fprintf (stderr,"Hello, World!\n" ); - -sleep (delay); - -fprintf (stderr,"Tracing... " ); -for (i =0 ; i <1000000 ; i++) { - netint =htonl (i); -tracepoint (ust_tests_hello, tptest, i, netint, values, - text,strlen (text), dbl, flt, mybool); -//usleep(100000); - } -fprintf (stderr," done.\n" ); -return 0 ; -}tests/hello/tp.c deleted +0
-26@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h" tests/hello/ust_tests_hello.h deleted +0
-76@@ -1,76 +0,0 @@ -#undef TRACEPOINT_PROVIDER -#define TRACEPOINT_PROVIDER ust_tests_hello - -#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) -#define _TRACEPOINT_UST_TESTS_HELLO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <lttng/tracepoint.h> -#include <stdbool.h> - -TRACEPOINT_EVENT(ust_tests_hello, tptest, - TP_ARGS(int, anint, int, netint, long *, values, - char *, text, size_t, textlen, - double, doublearg, float, floatarg, - bool, boolarg), - TP_FIELDS( - ctf_integer(int, intfield, anint) - ctf_integer_hex(int, intfield2, anint) - ctf_integer(long, longfield, anint) - ctf_integer_network(int, netintfield, netint) - ctf_integer_network_hex(int, netintfieldhex, netint) - ctf_array(long, arrfield1, values, 3) - ctf_array_text(char, arrfield2, text, 10) - ctf_sequence(char, seqfield1, text, - size_t, textlen) - ctf_sequence_text(char, seqfield2, text, - size_t, textlen) - ctf_string(stringfield, text) - ctf_float(float, floatfield, floatarg) - ctf_float(double, doublefield, doublearg) - ctf_integer(bool, boolfield, boolarg) - ctf_integer_nowrite(int, filterfield, anint) - ) -) - -TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, - TP_ARGS(), - TP_FIELDS() -) - -#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ - -#undef TRACEPOINT_INCLUDE -#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" - -/* This part must be outside ifdef protection */ -#include <lttng/tracepoint-event.h> - -#ifdef __cplusplus -} -#endifSignature · 7 lines
1.8.2.1 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
A message that is not in the archive (sent off-list or not yet received): 20130411215427.GA31573@Krystal
Quoted 1 line · Mathieu Desnoyers
redondant -> redundant
Indeed, will fix.
Quoted 10 lines · * Jérémie Galarneau ([email protected]) wrote:
Quoted 5 lines
The examples are now automatically built as part of the default make target.
The "hello" test verified that an application with statically embedded tracepoint providers could be built. This is now covered by "easy-ust" in doc/examples since we now build the examples.
No, hello is referenced by lttng-ust(3) manpage.
Not anymore since I also changed the manpage in this patch to reflect the change.
Quoted 2 lines
Please leave it there, but move it to examples.
I don't mind keeping either easy-ust or hello as examples. However, I don't see the point in keeping them both since they demonstrate the same thing; that is building an application with built-in providers. What do you think?
Jérémie
Quoted 1,240 lines
Thanks,
Mathieu
Quoted 1,236 lines
Move the "hello-static-lib" test to doc/examples.
This should provide complete and easy to understand
Makefileexamples to users who wish to integrate tracepoint providers to their applications.Signed-off-by Jérémie Galarneau <[email protected]>--- .gitignore | 6 +- README | 2 +- configure.ac | 2 - doc/examples/Makefile.am | 15 ++++ doc/examples/README | 3 + doc/examples/demo/Makefile | 27 +++++-- doc/examples/easy-ust/Makefile | 30 ++++++-- doc/examples/hello-static-lib/Makefile | 53 ++++++++++++++ doc/examples/hello-static-lib/README | 3 + doc/examples/hello-static-lib/hello.c | 94 ++++++++++++++++++++++++ doc/examples/hello-static-lib/tp.c | 26 +++++++ doc/examples/hello-static-lib/ust_tests_hello.h | 72 ++++++++++++++++++ doc/man/lttng-ust.3 | 62 ++++++++-------- tests/Makefile.am | 2 +- tests/hello-static-lib/Makefile.am | 18 ----- tests/hello-static-lib/README | 3 - tests/hello-static-lib/hello.c | 95 ------------------------ tests/hello-static-lib/tp.c | 26 ------- tests/hello-static-lib/ust_tests_hello.h | 72 ------------------ tests/hello/Makefile.am | 13 ---- tests/hello/Makefile.example.bsd | 8 -- tests/hello/Makefile.example.linux | 8 -- tests/hello/README | 2 - tests/hello/hello.c | 97 ------------------------- tests/hello/tp.c | 26 ------- tests/hello/ust_tests_hello.h | 76 ------------------- 26 files changed, 349 insertions(+), 492 deletions(-) create mode 100644 doc/examples/README create mode 100644 doc/examples/hello-static-lib/Makefile create mode 100644 doc/examples/hello-static-lib/README create mode 100644 doc/examples/hello-static-lib/hello.c create mode 100644 doc/examples/hello-static-lib/tp.c create mode 100644 doc/examples/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello-static-lib/Makefile.am delete mode 100644 tests/hello-static-lib/README delete mode 100644 tests/hello-static-lib/hello.c delete mode 100644 tests/hello-static-lib/tp.c delete mode 100644 tests/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello/Makefile.am delete mode 100644 tests/hello/Makefile.example.bsd delete mode 100644 tests/hello/Makefile.example.linux delete mode 100644 tests/hello/README delete mode 100644 tests/hello/hello.c delete mode 100644 tests/hello/tp.c delete mode 100644 tests/hello/ust_tests_hello.h.gitignore +4
-2@@ -31,7 +31,10 @@ lttng-ust.pc ustctl/ustctl ust-consumerd/ust-consumerd -tests/hello/hello +doc/examples/demo/demo +doc/examples/easy-ust/sample +doc/examples/hello-static-lib/hello + tests/hello.cxx/hello tests/same_line_tracepoint/same_line_tracepoint tests/ust-basic-tracing/ust-basic-tracing@@ -39,5 +42,4 @@ tests/ust-multi-test/ust-multi-test tests/trace_event/trace_event_test tests/tracepoint/benchmark/tracepoint_benchmark tests/tracepoint/tracepoint_test -tests/hello-static-lib/hello tests/snprintf/progREADME +1
-1@@ -72,7 +72,7 @@ USAGE: - If building the provider directly into the application, link the application with "-llttng-ust". - If building a static library for the provider, link the static - library with "-lllttng-ust". + library with "-llttng-ust". - Include the tracepoint provider header into all C files using the provider. - Example:configure.ac +0
-2@@ -265,8 +265,6 @@ AC_CONFIG_FILES([ liblttng-ust-cyg-profile/Makefile tools/Makefile tests/Makefile - tests/hello/Makefile - tests/hello-static-lib/Makefile tests/hello.cxx/Makefile tests/same_line_tracepoint/Makefile tests/snprintf/Makefiledoc/examples/Makefile.am +15
-0@@ -1,6 +1,12 @@ +SUBDIRS = easy-ust demo hello-static-lib + +doc_examplesdir = ${docdir}/examples doc_examples_easy_ustdir = ${docdir}/examples/easy-ust doc_examples_gen_tpdir = ${docdir}/examples/gen-tp doc_examples_demodir = ${docdir}/examples/demo +doc_examples_hello_static_libdir = ${docdir}/examples/hello-static-lib + +dist_doc_examples_DATA = README dist_doc_examples_easy_ust_DATA = easy-ust/Makefile \ easy-ust/sample.c \@@ -19,3 +25,12 @@ dist_doc_examples_demo_DATA = demo/demo.c \ demo/ust_tests_demo2.h \ demo/ust_tests_demo3.h \ demo/ust_tests_demo.h + +dist_doc_examples_hello_static_lib_DATA = hello-static-lib/Makefile \ + hello-static-lib/hello.c \ + hello-static-lib/README \ + hello-static-lib/ust_tests_hello.h \ + hello-static-lib/tp.c + +BUILD_EXAMPLES_FROM_TREE = 1 +exportdoc/examples/README new file +3
-0@@ -0,0 +1,3 @@ +To build the examples from the source tree, the BUILD_EXAMPLES_FROM_TREE +environment variable must be defined. This will force the examples' +Makefiles to use the source tree's public header files and libraries.doc/examples/demo/Makefile +22
-5@@ -9,13 +9,30 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This Makefile is not using automake so that people may see how to build -# a program and tracepoint provider probes as stand-alone shared objects. +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes as stand-alone shared objects. CC = gcc LIBS = -ldl # On Linux #LIBS = -lc # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so@@ -23,13 +40,13 @@ lttng-ust-provider-ust-tests-demo.o: tp.c tp2.c ust_tests_demo.h ust_tests_demo2 $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo.so: lttng-ust-provider-ust-tests-demo.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< lttng-ust-provider-ust-tests-demo3.o: tp3.c ust_tests_demo3.h $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo3.so: lttng-ust-provider-ust-tests-demo3.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< demo.o: demo.c $(CC) $(CFLAGS) -c -o $@ $<doc/examples/easy-ust/Makefile +23
-7@@ -10,20 +10,36 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This makefile is not using automake so that people can see how to make -# simply. It builds a program with a statically embedded tracepoint -# provider probe. +# This makefile is not using automake so that users can see how to build +# a program with a statically embedded tracepoint provider probe. # the "html" target helps for documentation (req. code2html) CC = gcc LIBS = -ldl -llttng-ust # On Linux #LIBS = -lc -llttng-ust # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: sample sample: sample.o tp.o - $(CC) -o $@ $^ $(LIBS) + $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) sample.o: sample.c sample_component_provider.h $(CC) $(CFLAGS) -c -o $@ $<@@ -33,7 +49,7 @@ tp.o: tp.c sample_component_provider.h html: sample_component_provider.html sample.html tp.html -%.html: %.c +%.html: %.c code2html -lc $< $@ %.html : %.h@@ -41,5 +57,5 @@ html: sample_component_provider.html sample.html tp.html .PHONY: clean clean: - rm -f *.html + rm -f *.html rm -f *.o sampledoc/examples/hello-static-lib/Makefile new file +53
-0@@ -0,0 +1,53 @@ +# Copyright (C) 2013 Jérémie Galarneau <[email protected]> +# +# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. +# +# Permission is hereby granted to use or copy this program for any +# purpose, provided the above notices are retained on all copies. +# Permission to modify the code and to distribute modified code is +# granted, provided the above notices are retained, and a notice that +# the code was modified is included with the above copyright notice. + +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes in static libraries. + +CC = gcc +CFLAGS += -I. +LIBS = -ldl -llttng-ust # On Linux +#LIBS = -lc -llttng-ust # On BSD + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif + +all: hello + +lttng-ust-provider-hello.o: tp.c ust_tests_hello.h + $(CC) $(CFLAGS) -c -o $@ $< + +lttng-ust-provider-hello.a: lttng-ust-provider-hello.o + ar -rc $@ $< + +hello.o: hello.c + $(CC) $(CFLAGS) -c -o $@ $< + +hello: hello.o lttng-ust-provider-hello.a + $(CC) -o $@ $(LDFLAGS) $(LIBS) $^ + +.PHONY: clean +clean: + rm -f *.o *.a hellodoc/examples/hello-static-lib/README new file +3
-0@@ -0,0 +1,3 @@ +This is a "hello world" application used to verify that an instrumented +program can be built successfully and linked with tracepoint providers +built as a separate static library.doc/examples/hello-static-lib/hello.c new file +94
-0@@ -0,0 +1,94 @@ +/* +* Copyright (C) 2009 Pierre-Marc Fournier +* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; version 2.1 of +* the License. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <stdio.h> +#include <unistd.h> +#include <sys/mman.h> +#include <stdarg.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <signal.h> +#include <string.h> +#include <arpa/inet.h> +#include <stdlib.h> + +#define TRACEPOINT_DEFINE +#include "ust_tests_hello.h" + +void inthandler (int sig) +{ +printf ("in SIGUSR1 handler\n" ); +tracepoint (ust_tests_hello, tptest_sighandler); +} + +int init_int_handler (void ) +{ +int result; +struct sigaction act; + +memset (&act,0 ,sizeof (act)); + result =sigemptyset (&act.sa_mask); +if (result ==-1 ) { +perror ("sigemptyset" ); +return -1 ; + } + + act.sa_handler = inthandler; + act.sa_flags =SA_RESTART ; + +/* Only defer ourselves. Also, try to restart interrupted +* syscalls to disturb the traced program as little as possible. +*/ + result =sigaction (SIGUSR1 , &act,NULL ); +if (result ==-1 ) { +perror ("sigaction" ); +return -1 ; + } + +return 0 ; +} + +int main (int argc,char **argv) +{ +int i, netint; +long values[] = {1 ,2 ,3 }; +char text[10 ] ="test" ; +double dbl =2.0 ; +float flt =2222.0 ; +int delay =0 ; + +init_int_handler (); + +if (argc ==2 ) + delay =atoi (argv[1 ]); + +fprintf (stderr,"Hello, World!\n" ); + +sleep (delay); + +fprintf (stderr,"Tracing... " ); +for (i =0 ; i <1000000 ; i++) { + netint =htonl (i); +tracepoint (ust_tests_hello, tptest, i, netint, values, + text,strlen (text), dbl, flt); + } +fprintf (stderr," done.\n" ); +return 0 ; +}doc/examples/hello-static-lib/tp.c new file +26
-0@@ -0,0 +1,26 @@ +/* +* tp.c +* +* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_hello.h" doc/examples/hello-static-lib/ust_tests_hello.h new file +72
-0@@ -0,0 +1,72 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_hello + +#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_HELLO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include <lttng/tracepoint.h> + +TRACEPOINT_EVENT(ust_tests_hello, tptest, + TP_ARGS(int, anint, int, netint, long *, values, + char *, text, size_t, textlen, + double, doublearg, float, floatarg), + TP_FIELDS( + ctf_integer(int, intfield, anint) + ctf_integer_hex(int, intfield2, anint) + ctf_integer(long, longfield, anint) + ctf_integer_network(int, netintfield, netint) + ctf_integer_network_hex(int, netintfieldhex, netint) + ctf_array(long, arrfield1, values, 3) + ctf_array_text(char, arrfield2, text, 10) + ctf_sequence(char, seqfield1, text, + size_t, textlen) + ctf_sequence_text(char, seqfield2, text, + size_t, textlen) + ctf_string(stringfield, text) + ctf_float(float, floatfield, floatarg) + ctf_float(double, doublefield, doublearg) + ) +) + +TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, + TP_ARGS(), + TP_FIELDS() +) + +#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" + +/* This part must be outside ifdef protection */ +#include <lttng/tracepoint-event.h> + +#ifdef __cplusplus +} +#endifdoc/man/lttng-ust.3 +32
-30@@ -40,11 +40,11 @@ focus on the various types that can be recorded into a trace event: TRACEPOINT_EVENT( /* * provider name, not a variable but a string starting with a - * letter and containing either letters, numbers or underscores. + * letter and containing either letters, numbers or underscores. * Needs to be the same as TRACEPOINT_PROVIDER. Needs to * follow the namespacing guide-lines in lttng/tracepoint.h: - * - * Must be included before include tracepoint provider + * + * Must be included before include tracepoint provider * ex.: project_event * ex.: project_component_event *@@ -59,19 +59,19 @@ TRACEPOINT_EVENT( /* * tracepoint name, same format as sample provider. Does not * need to be declared before. in this case the name is - * "message" + * "message" */ message, /* - * TP_ARGS macro contains the arguments passed for the tracepoint + * TP_ARGS macro contains the arguments passed for the tracepoint * it is in the following format * TP_ARGS(type1, name1, type2, name2, ... type10, name10) - * where there can be from zero to ten elements. - * typeN is the datatype, such as int, struct or double **. + * where there can be from zero to ten elements. + * typeN is the datatype, such as int, struct or double **. * name is the variable name (in "int myInt" the name would be - * myint) + * myint) * TP_ARGS() is valid to mean no arguments * TP_ARGS(void) is valid too */@@ -80,7 +80,7 @@ TRACEPOINT_EVENT( double, doublearg, float, floatarg), /* - * TP_FIELDS describes how to write the fields of the trace event. + * TP_FIELDS describes how to write the fields of the trace event. * You can put expressions in the "argument expression" area, * typically using the input arguments from TP_ARGS. */@@ -109,14 +109,14 @@ TRACEPOINT_EVENT( /* * ctf_array: a statically-sized array. * args: (type, field name, argument expression, value) - */ + */ ctf_array(long, arrfield1, values, 3) /* * ctf_array_text: a statically-sized array, printed as * a string. No need to be terminated by a null * character. - */ + */ ctf_array_text(char, arrfield2, text, 10) /*@@ -127,7 +127,7 @@ TRACEPOINT_EVENT( * unsigned type. As a reminder, "unsigned char" should * be preferred to "char", since the signedness of * "char" is implementation-defined. - */ + */ ctf_sequence(char, seqfield1, text, size_t, textlen)@@ -172,54 +172,54 @@ declared before declaring a TRACEPOINT_LOGLEVEL. The loglevels go from 0 to 14. Higher numbers imply the most verbosity (higher event throughput expected. - + Loglevels 0 through 6, and loglevel 14, match syslog(3) loglevels semantic. Loglevels 7 through 13 offer more fine-grained selection of debug information. - + TRACE_EMERG 0 system is unusable - + TRACE_ALERT 1 action must be taken immediately - + TRACE_CRIT 2 critical conditions - + TRACE_ERR 3 error conditions - + TRACE_WARNING 4 warning conditions - + TRACE_NOTICE 5 normal, but significant, condition - + TRACE_INFO 6 informational message - + TRACE_DEBUG_SYSTEM 7 debug information with system-level scope (set of programs) - + TRACE_DEBUG_PROGRAM 8 debug information with program-level scope (set of processes) - + TRACE_DEBUG_PROCESS 9 debug information with process-level scope (set of modules) - + TRACE_DEBUG_MODULE 10 debug information with module (executable/library) scope (set of units) - + TRACE_DEBUG_UNIT 11 debug information with compilation unit scope (set of functions) - + TRACE_DEBUG_FUNCTION 12 debug information with function-level scope - + TRACE_DEBUG_LINE 13 debug information with line-level scope (TRACEPOINT_EVENT default) - + TRACE_DEBUG 14 debug-level message (trace_printf default)@@ -269,7 +269,9 @@ carefully: - Include the tracepoint provider header into all C files using the provider. - Example: - - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example + - doc/examples/easy-ust/ sample.c sample_component_provider.h tp.c + Makefile + - doc/examples/hello-static-lib/ hello.c tp.c ust_test_hello.h Makefile 2) Compile the Tracepoint Provider separately from the application, using dynamic linking:@@ -287,7 +289,7 @@ carefully: needed. Another way is to dlopen the tracepoint probe when needed by the application. - Example: - - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace + - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace Makefile - Note about dlclose() usage: it is not safe to use dlclose on a provider shared object that is being actively used for tracing duetests/Makefile.am +1
-1@@ -1,4 +1,4 @@ -SUBDIRS = . hello hello-static-lib same_line_tracepoint snprintf +SUBDIRS = . same_line_tracepoint snprintf if CXX_WORKS SUBDIRS += hello.cxxtests/hello-static-lib/Makefile.am deleted +0
-18@@ -1,18 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_LTLIBRARIES = liblttng-ust-provider-ust-test-hello.la -liblttng_ust_provider_ust_test_hello_la_SOURCES = \ - tp.c ust_tests_hello.h -liblttng_ust_provider_ust_test_hello_la_LIBADD = \ - $(top_builddir)/liblttng-ust/liblttng-ust.la - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c -hello_LDADD = liblttng-ust-provider-ust-test-hello.la - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endiftests/hello-static-lib/README deleted +0
-3@@ -1,3 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully and linked with tracepoint providers -built as a separate static library.tests/hello-static-lib/hello.c deleted +0
-95@@ -1,95 +0,0 @@ -/* -* Copyright (C) 2009 Pierre-Marc Fournier -* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; version 2.1 of -* the License. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <arpa/inet.h> -#include <stdlib.h> - -#define TRACEPOINT_DEFINE -#include "ust_tests_hello.h" - -void inthandler (int sig) -{ -printf ("in SIGUSR1 handler\n" ); -tracepoint (ust_tests_hello, tptest_sighandler); -} - -int init_int_handler (void ) -{ -int result; -struct sigaction act; - -memset (&act,0 ,sizeof (act)); - result =sigemptyset (&act.sa_mask); -if (result ==-1 ) { -perror ("sigemptyset" ); -return -1 ; - } - - act.sa_handler = inthandler; - act.sa_flags =SA_RESTART ; - -/* Only defer ourselves. Also, try to restart interrupted -* syscalls to disturb the traced program as little as possible. -*/ - result =sigaction (SIGUSR1 , &act,NULL ); -if (result ==-1 ) { -perror ("sigaction" ); -return -1 ; - } - -return 0 ; -} - -int main (int argc,char **argv) -{ -int i, netint; -long values[] = {1 ,2 ,3 }; -char text[10 ] ="test" ; -double dbl =2.0 ; -float flt =2222.0 ; -int delay =0 ; - -init_int_handler (); - -if (argc ==2 ) - delay =atoi (argv[1 ]); - -fprintf (stderr,"Hello, World!\n" ); - -sleep (delay); - -fprintf (stderr,"Tracing... " ); -for (i =0 ; i <1000000 ; i++) { - netint =htonl (i); -tracepoint (ust_tests_hello, tptest, i, netint, values, - text,strlen (text), dbl, flt); -//usleep(100000); - } -fprintf (stderr," done.\n" ); -return 0 ; -}tests/hello-static-lib/tp.c deleted +0
-26@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h" tests/hello-static-lib/ust_tests_hello.h deleted +0
-72@@ -1,72 +0,0 @@ -#undef TRACEPOINT_PROVIDER -#define TRACEPOINT_PROVIDER ust_tests_hello - -#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) -#define _TRACEPOINT_UST_TESTS_HELLO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <lttng/tracepoint.h> - -TRACEPOINT_EVENT(ust_tests_hello, tptest, - TP_ARGS(int, anint, int, netint, long *, values, - char *, text, size_t, textlen, - double, doublearg, float, floatarg), - TP_FIELDS( - ctf_integer(int, intfield, anint) - ctf_integer_hex(int, intfield2, anint) - ctf_integer(long, longfield, anint) - ctf_integer_network(int, netintfield, netint) - ctf_integer_network_hex(int, netintfieldhex, netint) - ctf_array(long, arrfield1, values, 3) - ctf_array_text(char, arrfield2, text, 10) - ctf_sequence(char, seqfield1, text, - size_t, textlen) - ctf_sequence_text(char, seqfield2, text, - size_t, textlen) - ctf_string(stringfield, text) - ctf_float(float, floatfield, floatarg) - ctf_float(double, doublefield, doublearg) - ) -) - -TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, - TP_ARGS(), - TP_FIELDS() -) - -#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ - -#undef TRACEPOINT_INCLUDE -#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" - -/* This part must be outside ifdef protection */ -#include <lttng/tracepoint-event.h> - -#ifdef __cplusplus -} -#endiftests/hello/Makefile.am deleted +0
-13@@ -1,13 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c tp.c ust_tests_hello.h -hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la -hello_CFLAGS = -Werror=old-style-definition - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endiftests/hello/Makefile.example.bsd deleted +0
-8@@ -1,8 +0,0 @@ -# Example makefile for build outside of the LTTng-UST tree. - -hello: - ${CC} -O2 -I. -o hello -lc -llttng-ust hello.c tp.c - -.PHONY: clean -clean: - rm -f hellotests/hello/Makefile.example.linux deleted +0
-8@@ -1,8 +0,0 @@ -# Example makefile for build outside of the LTTng-UST tree. - -hello: - ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c - -.PHONY: clean -clean: - rm -f hellotests/hello/README deleted +0
-2@@ -1,2 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully.tests/hello/hello.c deleted +0
-97@@ -1,97 +0,0 @@ -/* -* Copyright (C) 2009 Pierre-Marc Fournier -* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; version 2.1 of -* the License. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <arpa/inet.h> -#include <stdlib.h> -#include <stdbool.h> - -#define TRACEPOINT_DEFINE -#include "ust_tests_hello.h" - -void inthandler (int sig) -{ -printf ("in SIGUSR1 handler\n" ); -tracepoint (ust_tests_hello, tptest_sighandler); -} - -int init_int_handler (void ) -{ -int result; -struct sigaction act; - -memset (&act,0 ,sizeof (act)); - result =sigemptyset (&act.sa_mask); -if (result ==-1 ) { -perror ("sigemptyset" ); -return -1 ; - } - - act.sa_handler = inthandler; - act.sa_flags =SA_RESTART ; - -/* Only defer ourselves. Also, try to restart interrupted -* syscalls to disturb the traced program as little as possible. -*/ - result =sigaction (SIGUSR1 , &act,NULL ); -if (result ==-1 ) { -perror ("sigaction" ); -return -1 ; - } - -return 0 ; -} - -int main (int argc,char **argv) -{ -int i, netint; -long values[] = {1 ,2 ,3 }; -char text[10 ] ="test" ; -double dbl =2.0 ; -float flt =2222.0 ; -int delay =0 ; -bool mybool =123 ;/* should print "1" */ - -init_int_handler (); - -if (argc ==2 ) - delay =atoi (argv[1 ]); - -fprintf (stderr,"Hello, World!\n" ); - -sleep (delay); - -fprintf (stderr,"Tracing... " ); -for (i =0 ; i <1000000 ; i++) { - netint =htonl (i); -tracepoint (ust_tests_hello, tptest, i, netint, values, - text,strlen (text), dbl, flt, mybool); -//usleep(100000); - } -fprintf (stderr," done.\n" ); -return 0 ; -}tests/hello/tp.c deleted +0
-26@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h" tests/hello/ust_tests_hello.h deleted +0
-77@@ -1,76 +0,0 @@ -#undef TRACEPOINT_PROVIDER -#define TRACEPOINT_PROVIDER ust_tests_hello - -#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) -#define _TRACEPOINT_UST_TESTS_HELLO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <lttng/tracepoint.h> -#include <stdbool.h> - -TRACEPOINT_EVENT(ust_tests_hello, tptest, - TP_ARGS(int, anint, int, netint, long *, values, - char *, text, size_t, textlen, - double, doublearg, float, floatarg, - bool, boolarg), - TP_FIELDS( - ctf_integer(int, intfield, anint) - ctf_integer_hex(int, intfield2, anint) - ctf_integer(long, longfield, anint) - ctf_integer_network(int, netintfield, netint) - ctf_integer_network_hex(int, netintfieldhex, netint) - ctf_array(long, arrfield1, values, 3) - ctf_array_text(char, arrfield2, text, 10) - ctf_sequence(char, seqfield1, text, - size_t, textlen) - ctf_sequence_text(char, seqfield2, text, - size_t, textlen) - ctf_string(stringfield, text) - ctf_float(float, floatfield, floatarg) - ctf_float(double, doublefield, doublearg) - ctf_integer(bool, boolfield, boolarg) - ctf_integer_nowrite(int, filterfield, anint) - ) -) - -TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, - TP_ARGS(), - TP_FIELDS() -) - -#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ - -#undef TRACEPOINT_INCLUDE -#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" - -/* This part must be outside ifdef protection */ -#include <lttng/tracepoint-event.h> - -#ifdef __cplusplus -} -#endif --1.8.2.1
Quoted 9 lines
Quoted 4 lines
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
A message that is not in the archive (sent off-list or not yet received): CA+jJMxsMfAb7t5Uuf-Ns90eLe2YQ=r143Wp8Qi+jURyip+3+6A@mail.gmail.com
Quoted 20 lines · * Jérémie Galarneau ([email protected]) wrote:
Quoted 1 line · Mathieu Desnoyers
redondant -> redundant
Indeed, will fix.
Quoted 10 lines · * Jérémie Galarneau ([email protected]) wrote:
Quoted 5 lines
The examples are now automatically built as part of the default make target.
The "hello" test verified that an application with statically embedded tracepoint providers could be built. This is now covered by "easy-ust" in doc/examples since we now build the examples.
No, hello is referenced by lttng-ust(3) manpage.
Not anymore since I also changed the manpage in this patch to reflect the change.
Quoted 7 lines
Quoted 2 lines
Please leave it there, but move it to examples.
I don't mind keeping either easy-ust or hello as examples. However, I don't see the point in keeping them both since they demonstrate the same thing; that is building an application with built-in providers. What do you think?
I personally use "hello" to put every type of fields that need to be tested. I notice that the other test programs don't have all the fields hello has, so we lose in coverage if we remove it.
But I agree it's more for tests. So we might want to leave "hello" in tests/.
Thanks,
Mathieu
Quoted 1,259 lines
Jérémie
Quoted 1,240 lines
Thanks,
Mathieu
Quoted 1,236 lines
Move the "hello-static-lib" test to doc/examples.
This should provide complete and easy to understand
Makefileexamples to users who wish to integrate tracepoint providers to their applications.Signed-off-by Jérémie Galarneau <[email protected]>--- .gitignore | 6 +- README | 2 +- configure.ac | 2 - doc/examples/Makefile.am | 15 ++++ doc/examples/README | 3 + doc/examples/demo/Makefile | 27 +++++-- doc/examples/easy-ust/Makefile | 30 ++++++-- doc/examples/hello-static-lib/Makefile | 53 ++++++++++++++ doc/examples/hello-static-lib/README | 3 + doc/examples/hello-static-lib/hello.c | 94 ++++++++++++++++++++++++ doc/examples/hello-static-lib/tp.c | 26 +++++++ doc/examples/hello-static-lib/ust_tests_hello.h | 72 ++++++++++++++++++ doc/man/lttng-ust.3 | 62 ++++++++-------- tests/Makefile.am | 2 +- tests/hello-static-lib/Makefile.am | 18 ----- tests/hello-static-lib/README | 3 - tests/hello-static-lib/hello.c | 95 ------------------------ tests/hello-static-lib/tp.c | 26 ------- tests/hello-static-lib/ust_tests_hello.h | 72 ------------------ tests/hello/Makefile.am | 13 ---- tests/hello/Makefile.example.bsd | 8 -- tests/hello/Makefile.example.linux | 8 -- tests/hello/README | 2 - tests/hello/hello.c | 97 ------------------------- tests/hello/tp.c | 26 ------- tests/hello/ust_tests_hello.h | 76 ------------------- 26 files changed, 349 insertions(+), 492 deletions(-) create mode 100644 doc/examples/README create mode 100644 doc/examples/hello-static-lib/Makefile create mode 100644 doc/examples/hello-static-lib/README create mode 100644 doc/examples/hello-static-lib/hello.c create mode 100644 doc/examples/hello-static-lib/tp.c create mode 100644 doc/examples/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello-static-lib/Makefile.am delete mode 100644 tests/hello-static-lib/README delete mode 100644 tests/hello-static-lib/hello.c delete mode 100644 tests/hello-static-lib/tp.c delete mode 100644 tests/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello/Makefile.am delete mode 100644 tests/hello/Makefile.example.bsd delete mode 100644 tests/hello/Makefile.example.linux delete mode 100644 tests/hello/README delete mode 100644 tests/hello/hello.c delete mode 100644 tests/hello/tp.c delete mode 100644 tests/hello/ust_tests_hello.h.gitignore +4
-2@@ -31,7 +31,10 @@ lttng-ust.pc ustctl/ustctl ust-consumerd/ust-consumerd -tests/hello/hello +doc/examples/demo/demo +doc/examples/easy-ust/sample +doc/examples/hello-static-lib/hello + tests/hello.cxx/hello tests/same_line_tracepoint/same_line_tracepoint tests/ust-basic-tracing/ust-basic-tracing@@ -39,5 +42,4 @@ tests/ust-multi-test/ust-multi-test tests/trace_event/trace_event_test tests/tracepoint/benchmark/tracepoint_benchmark tests/tracepoint/tracepoint_test -tests/hello-static-lib/hello tests/snprintf/progREADME +1
-1@@ -72,7 +72,7 @@ USAGE: - If building the provider directly into the application, link the application with "-llttng-ust". - If building a static library for the provider, link the static - library with "-lllttng-ust". + library with "-llttng-ust". - Include the tracepoint provider header into all C files using the provider. - Example:configure.ac +0
-2@@ -265,8 +265,6 @@ AC_CONFIG_FILES([ liblttng-ust-cyg-profile/Makefile tools/Makefile tests/Makefile - tests/hello/Makefile - tests/hello-static-lib/Makefile tests/hello.cxx/Makefile tests/same_line_tracepoint/Makefile tests/snprintf/Makefiledoc/examples/Makefile.am +15
-0@@ -1,6 +1,12 @@ +SUBDIRS = easy-ust demo hello-static-lib + +doc_examplesdir = ${docdir}/examples doc_examples_easy_ustdir = ${docdir}/examples/easy-ust doc_examples_gen_tpdir = ${docdir}/examples/gen-tp doc_examples_demodir = ${docdir}/examples/demo +doc_examples_hello_static_libdir = ${docdir}/examples/hello-static-lib + +dist_doc_examples_DATA = README dist_doc_examples_easy_ust_DATA = easy-ust/Makefile \ easy-ust/sample.c \@@ -19,3 +25,12 @@ dist_doc_examples_demo_DATA = demo/demo.c \ demo/ust_tests_demo2.h \ demo/ust_tests_demo3.h \ demo/ust_tests_demo.h + +dist_doc_examples_hello_static_lib_DATA = hello-static-lib/Makefile \ + hello-static-lib/hello.c \ + hello-static-lib/README \ + hello-static-lib/ust_tests_hello.h \ + hello-static-lib/tp.c + +BUILD_EXAMPLES_FROM_TREE = 1 +exportdoc/examples/README new file +3
-0@@ -0,0 +1,3 @@ +To build the examples from the source tree, the BUILD_EXAMPLES_FROM_TREE +environment variable must be defined. This will force the examples' +Makefiles to use the source tree's public header files and libraries.doc/examples/demo/Makefile +22
-5@@ -9,13 +9,30 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This Makefile is not using automake so that people may see how to build -# a program and tracepoint provider probes as stand-alone shared objects. +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes as stand-alone shared objects. CC = gcc LIBS = -ldl # On Linux #LIBS = -lc # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so@@ -23,13 +40,13 @@ lttng-ust-provider-ust-tests-demo.o: tp.c tp2.c ust_tests_demo.h ust_tests_demo2 $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo.so: lttng-ust-provider-ust-tests-demo.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< lttng-ust-provider-ust-tests-demo3.o: tp3.c ust_tests_demo3.h $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo3.so: lttng-ust-provider-ust-tests-demo3.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< demo.o: demo.c $(CC) $(CFLAGS) -c -o $@ $<doc/examples/easy-ust/Makefile +23
-7@@ -10,20 +10,36 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This makefile is not using automake so that people can see how to make -# simply. It builds a program with a statically embedded tracepoint -# provider probe. +# This makefile is not using automake so that users can see how to build +# a program with a statically embedded tracepoint provider probe. # the "html" target helps for documentation (req. code2html) CC = gcc LIBS = -ldl -llttng-ust # On Linux #LIBS = -lc -llttng-ust # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: sample sample: sample.o tp.o - $(CC) -o $@ $^ $(LIBS) + $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) sample.o: sample.c sample_component_provider.h $(CC) $(CFLAGS) -c -o $@ $<@@ -33,7 +49,7 @@ tp.o: tp.c sample_component_provider.h html: sample_component_provider.html sample.html tp.html -%.html: %.c +%.html: %.c code2html -lc $< $@ %.html : %.h@@ -41,5 +57,5 @@ html: sample_component_provider.html sample.html tp.html .PHONY: clean clean: - rm -f *.html + rm -f *.html rm -f *.o sampledoc/examples/hello-static-lib/Makefile new file +53
-0@@ -0,0 +1,53 @@ +# Copyright (C) 2013 Jérémie Galarneau <[email protected]> +# +# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. +# +# Permission is hereby granted to use or copy this program for any +# purpose, provided the above notices are retained on all copies. +# Permission to modify the code and to distribute modified code is +# granted, provided the above notices are retained, and a notice that +# the code was modified is included with the above copyright notice. + +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes in static libraries. + +CC = gcc +CFLAGS += -I. +LIBS = -ldl -llttng-ust # On Linux +#LIBS = -lc -llttng-ust # On BSD + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif + +all: hello + +lttng-ust-provider-hello.o: tp.c ust_tests_hello.h + $(CC) $(CFLAGS) -c -o $@ $< + +lttng-ust-provider-hello.a: lttng-ust-provider-hello.o + ar -rc $@ $< + +hello.o: hello.c + $(CC) $(CFLAGS) -c -o $@ $< + +hello: hello.o lttng-ust-provider-hello.a + $(CC) -o $@ $(LDFLAGS) $(LIBS) $^ + +.PHONY: clean +clean: + rm -f *.o *.a hellodoc/examples/hello-static-lib/README new file +3
-0@@ -0,0 +1,3 @@ +This is a "hello world" application used to verify that an instrumented +program can be built successfully and linked with tracepoint providers +built as a separate static library.doc/examples/hello-static-lib/hello.c new file +94
-0@@ -0,0 +1,94 @@ +/* +* Copyright (C) 2009 Pierre-Marc Fournier +* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; version 2.1 of +* the License. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <stdio.h> +#include <unistd.h> +#include <sys/mman.h> +#include <stdarg.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <signal.h> +#include <string.h> +#include <arpa/inet.h> +#include <stdlib.h> + +#define TRACEPOINT_DEFINE +#include "ust_tests_hello.h" + +void inthandler (int sig) +{ +printf ("in SIGUSR1 handler\n" ); +tracepoint (ust_tests_hello, tptest_sighandler); +} + +int init_int_handler (void ) +{ +int result; +struct sigaction act; + +memset (&act,0 ,sizeof (act)); + result =sigemptyset (&act.sa_mask); +if (result ==-1 ) { +perror ("sigemptyset" ); +return -1 ; + } + + act.sa_handler = inthandler; + act.sa_flags =SA_RESTART ; + +/* Only defer ourselves. Also, try to restart interrupted +* syscalls to disturb the traced program as little as possible. +*/ + result =sigaction (SIGUSR1 , &act,NULL ); +if (result ==-1 ) { +perror ("sigaction" ); +return -1 ; + } + +return 0 ; +} + +int main (int argc,char **argv) +{ +int i, netint; +long values[] = {1 ,2 ,3 }; +char text[10 ] ="test" ; +double dbl =2.0 ; +float flt =2222.0 ; +int delay =0 ; + +init_int_handler (); + +if (argc ==2 ) + delay =atoi (argv[1 ]); + +fprintf (stderr,"Hello, World!\n" ); + +sleep (delay); + +fprintf (stderr,"Tracing... " ); +for (i =0 ; i <1000000 ; i++) { + netint =htonl (i); +tracepoint (ust_tests_hello, tptest, i, netint, values, + text,strlen (text), dbl, flt); + } +fprintf (stderr," done.\n" ); +return 0 ; +}doc/examples/hello-static-lib/tp.c new file +26
-0@@ -0,0 +1,26 @@ +/* +* tp.c +* +* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_hello.h" doc/examples/hello-static-lib/ust_tests_hello.h new file +72
-0@@ -0,0 +1,72 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_hello + +#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_HELLO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include <lttng/tracepoint.h> + +TRACEPOINT_EVENT(ust_tests_hello, tptest, + TP_ARGS(int, anint, int, netint, long *, values, + char *, text, size_t, textlen, + double, doublearg, float, floatarg), + TP_FIELDS( + ctf_integer(int, intfield, anint) + ctf_integer_hex(int, intfield2, anint) + ctf_integer(long, longfield, anint) + ctf_integer_network(int, netintfield, netint) + ctf_integer_network_hex(int, netintfieldhex, netint) + ctf_array(long, arrfield1, values, 3) + ctf_array_text(char, arrfield2, text, 10) + ctf_sequence(char, seqfield1, text, + size_t, textlen) + ctf_sequence_text(char, seqfield2, text, + size_t, textlen) + ctf_string(stringfield, text) + ctf_float(float, floatfield, floatarg) + ctf_float(double, doublefield, doublearg) + ) +) + +TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, + TP_ARGS(), + TP_FIELDS() +) + +#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" + +/* This part must be outside ifdef protection */ +#include <lttng/tracepoint-event.h> + +#ifdef __cplusplus +} +#endifdoc/man/lttng-ust.3 +32
-30@@ -40,11 +40,11 @@ focus on the various types that can be recorded into a trace event: TRACEPOINT_EVENT( /* * provider name, not a variable but a string starting with a - * letter and containing either letters, numbers or underscores. + * letter and containing either letters, numbers or underscores. * Needs to be the same as TRACEPOINT_PROVIDER. Needs to * follow the namespacing guide-lines in lttng/tracepoint.h: - * - * Must be included before include tracepoint provider + * + * Must be included before include tracepoint provider * ex.: project_event * ex.: project_component_event *@@ -59,19 +59,19 @@ TRACEPOINT_EVENT( /* * tracepoint name, same format as sample provider. Does not * need to be declared before. in this case the name is - * "message" + * "message" */ message, /* - * TP_ARGS macro contains the arguments passed for the tracepoint + * TP_ARGS macro contains the arguments passed for the tracepoint * it is in the following format * TP_ARGS(type1, name1, type2, name2, ... type10, name10) - * where there can be from zero to ten elements. - * typeN is the datatype, such as int, struct or double **. + * where there can be from zero to ten elements. + * typeN is the datatype, such as int, struct or double **. * name is the variable name (in "int myInt" the name would be - * myint) + * myint) * TP_ARGS() is valid to mean no arguments * TP_ARGS(void) is valid too */@@ -80,7 +80,7 @@ TRACEPOINT_EVENT( double, doublearg, float, floatarg), /* - * TP_FIELDS describes how to write the fields of the trace event. + * TP_FIELDS describes how to write the fields of the trace event. * You can put expressions in the "argument expression" area, * typically using the input arguments from TP_ARGS. */@@ -109,14 +109,14 @@ TRACEPOINT_EVENT( /* * ctf_array: a statically-sized array. * args: (type, field name, argument expression, value) - */ + */ ctf_array(long, arrfield1, values, 3) /* * ctf_array_text: a statically-sized array, printed as * a string. No need to be terminated by a null * character. - */ + */ ctf_array_text(char, arrfield2, text, 10) /*@@ -127,7 +127,7 @@ TRACEPOINT_EVENT( * unsigned type. As a reminder, "unsigned char" should * be preferred to "char", since the signedness of * "char" is implementation-defined. - */ + */ ctf_sequence(char, seqfield1, text, size_t, textlen)@@ -172,54 +172,54 @@ declared before declaring a TRACEPOINT_LOGLEVEL. The loglevels go from 0 to 14. Higher numbers imply the most verbosity (higher event throughput expected. - + Loglevels 0 through 6, and loglevel 14, match syslog(3) loglevels semantic. Loglevels 7 through 13 offer more fine-grained selection of debug information. - + TRACE_EMERG 0 system is unusable - + TRACE_ALERT 1 action must be taken immediately - + TRACE_CRIT 2 critical conditions - + TRACE_ERR 3 error conditions - + TRACE_WARNING 4 warning conditions - + TRACE_NOTICE 5 normal, but significant, condition - + TRACE_INFO 6 informational message - + TRACE_DEBUG_SYSTEM 7 debug information with system-level scope (set of programs) - + TRACE_DEBUG_PROGRAM 8 debug information with program-level scope (set of processes) - + TRACE_DEBUG_PROCESS 9 debug information with process-level scope (set of modules) - + TRACE_DEBUG_MODULE 10 debug information with module (executable/library) scope (set of units) - + TRACE_DEBUG_UNIT 11 debug information with compilation unit scope (set of functions) - + TRACE_DEBUG_FUNCTION 12 debug information with function-level scope - + TRACE_DEBUG_LINE 13 debug information with line-level scope (TRACEPOINT_EVENT default) - + TRACE_DEBUG 14 debug-level message (trace_printf default)@@ -269,7 +269,9 @@ carefully: - Include the tracepoint provider header into all C files using the provider. - Example: - - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example + - doc/examples/easy-ust/ sample.c sample_component_provider.h tp.c + Makefile + - doc/examples/hello-static-lib/ hello.c tp.c ust_test_hello.h Makefile 2) Compile the Tracepoint Provider separately from the application, using dynamic linking:@@ -287,7 +289,7 @@ carefully: needed. Another way is to dlopen the tracepoint probe when needed by the application. - Example: - - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace + - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace Makefile - Note about dlclose() usage: it is not safe to use dlclose on a provider shared object that is being actively used for tracing duetests/Makefile.am +1
-1@@ -1,4 +1,4 @@ -SUBDIRS = . hello hello-static-lib same_line_tracepoint snprintf +SUBDIRS = . same_line_tracepoint snprintf if CXX_WORKS SUBDIRS += hello.cxxtests/hello-static-lib/Makefile.am deleted +0
-18@@ -1,18 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_LTLIBRARIES = liblttng-ust-provider-ust-test-hello.la -liblttng_ust_provider_ust_test_hello_la_SOURCES = \ - tp.c ust_tests_hello.h -liblttng_ust_provider_ust_test_hello_la_LIBADD = \ - $(top_builddir)/liblttng-ust/liblttng-ust.la - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c -hello_LDADD = liblttng-ust-provider-ust-test-hello.la - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endiftests/hello-static-lib/README deleted +0
-3@@ -1,3 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully and linked with tracepoint providers -built as a separate static library.tests/hello-static-lib/hello.c deleted +0
-95@@ -1,95 +0,0 @@ -/* -* Copyright (C) 2009 Pierre-Marc Fournier -* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; version 2.1 of -* the License. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <arpa/inet.h> -#include <stdlib.h> - -#define TRACEPOINT_DEFINE -#include "ust_tests_hello.h" - -void inthandler (int sig) -{ -printf ("in SIGUSR1 handler\n" ); -tracepoint (ust_tests_hello, tptest_sighandler); -} - -int init_int_handler (void ) -{ -int result; -struct sigaction act; - -memset (&act,0 ,sizeof (act)); - result =sigemptyset (&act.sa_mask); -if (result ==-1 ) { -perror ("sigemptyset" ); -return -1 ; - } - - act.sa_handler = inthandler; - act.sa_flags =SA_RESTART ; - -/* Only defer ourselves. Also, try to restart interrupted -* syscalls to disturb the traced program as little as possible. -*/ - result =sigaction (SIGUSR1 , &act,NULL ); -if (result ==-1 ) { -perror ("sigaction" ); -return -1 ; - } - -return 0 ; -} - -int main (int argc,char **argv) -{ -int i, netint; -long values[] = {1 ,2 ,3 }; -char text[10 ] ="test" ; -double dbl =2.0 ; -float flt =2222.0 ; -int delay =0 ; - -init_int_handler (); - -if (argc ==2 ) - delay =atoi (argv[1 ]); - -fprintf (stderr,"Hello, World!\n" ); - -sleep (delay); - -fprintf (stderr,"Tracing... " ); -for (i =0 ; i <1000000 ; i++) { - netint =htonl (i); -tracepoint (ust_tests_hello, tptest, i, netint, values, - text,strlen (text), dbl, flt); -//usleep(100000); - } -fprintf (stderr," done.\n" ); -return 0 ; -}tests/hello-static-lib/tp.c deleted +0
-26@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h" tests/hello-static-lib/ust_tests_hello.h deleted +0
-72@@ -1,72 +0,0 @@ -#undef TRACEPOINT_PROVIDER -#define TRACEPOINT_PROVIDER ust_tests_hello - -#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) -#define _TRACEPOINT_UST_TESTS_HELLO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <lttng/tracepoint.h> - -TRACEPOINT_EVENT(ust_tests_hello, tptest, - TP_ARGS(int, anint, int, netint, long *, values, - char *, text, size_t, textlen, - double, doublearg, float, floatarg), - TP_FIELDS( - ctf_integer(int, intfield, anint) - ctf_integer_hex(int, intfield2, anint) - ctf_integer(long, longfield, anint) - ctf_integer_network(int, netintfield, netint) - ctf_integer_network_hex(int, netintfieldhex, netint) - ctf_array(long, arrfield1, values, 3) - ctf_array_text(char, arrfield2, text, 10) - ctf_sequence(char, seqfield1, text, - size_t, textlen) - ctf_sequence_text(char, seqfield2, text, - size_t, textlen) - ctf_string(stringfield, text) - ctf_float(float, floatfield, floatarg) - ctf_float(double, doublefield, doublearg) - ) -) - -TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, - TP_ARGS(), - TP_FIELDS() -) - -#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ - -#undef TRACEPOINT_INCLUDE -#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" - -/* This part must be outside ifdef protection */ -#include <lttng/tracepoint-event.h> - -#ifdef __cplusplus -} -#endiftests/hello/Makefile.am deleted +0
-13@@ -1,13 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c tp.c ust_tests_hello.h -hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la -hello_CFLAGS = -Werror=old-style-definition - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endiftests/hello/Makefile.example.bsd deleted +0
-8@@ -1,8 +0,0 @@ -# Example makefile for build outside of the LTTng-UST tree. - -hello: - ${CC} -O2 -I. -o hello -lc -llttng-ust hello.c tp.c - -.PHONY: clean -clean: - rm -f hellotests/hello/Makefile.example.linux deleted +0
-8@@ -1,8 +0,0 @@ -# Example makefile for build outside of the LTTng-UST tree. - -hello: - ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c - -.PHONY: clean -clean: - rm -f hellotests/hello/README deleted +0
-2@@ -1,2 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully.tests/hello/hello.c deleted +0
-97@@ -1,97 +0,0 @@ -/* -* Copyright (C) 2009 Pierre-Marc Fournier -* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; version 2.1 of -* the License. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <arpa/inet.h> -#include <stdlib.h> -#include <stdbool.h> - -#define TRACEPOINT_DEFINE -#include "ust_tests_hello.h" - -void inthandler (int sig) -{ -printf ("in SIGUSR1 handler\n" ); -tracepoint (ust_tests_hello, tptest_sighandler); -} - -int init_int_handler (void ) -{ -int result; -struct sigaction act; - -memset (&act,0 ,sizeof (act)); - result =sigemptyset (&act.sa_mask); -if (result ==-1 ) { -perror ("sigemptyset" ); -return -1 ; - } - - act.sa_handler = inthandler; - act.sa_flags =SA_RESTART ; - -/* Only defer ourselves. Also, try to restart interrupted -* syscalls to disturb the traced program as little as possible. -*/ - result =sigaction (SIGUSR1 , &act,NULL ); -if (result ==-1 ) { -perror ("sigaction" ); -return -1 ; - } - -return 0 ; -} - -int main (int argc,char **argv) -{ -int i, netint; -long values[] = {1 ,2 ,3 }; -char text[10 ] ="test" ; -double dbl =2.0 ; -float flt =2222.0 ; -int delay =0 ; -bool mybool =123 ;/* should print "1" */ - -init_int_handler (); - -if (argc ==2 ) - delay =atoi (argv[1 ]); - -fprintf (stderr,"Hello, World!\n" ); - -sleep (delay); - -fprintf (stderr,"Tracing... " ); -for (i =0 ; i <1000000 ; i++) { - netint =htonl (i); -tracepoint (ust_tests_hello, tptest, i, netint, values, - text,strlen (text), dbl, flt, mybool); -//usleep(100000); - } -fprintf (stderr," done.\n" ); -return 0 ; -}tests/hello/tp.c deleted +0
-26@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h" tests/hello/ust_tests_hello.h deleted +0
-77@@ -1,76 +0,0 @@ -#undef TRACEPOINT_PROVIDER -#define TRACEPOINT_PROVIDER ust_tests_hello - -#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) -#define _TRACEPOINT_UST_TESTS_HELLO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <lttng/tracepoint.h> -#include <stdbool.h> - -TRACEPOINT_EVENT(ust_tests_hello, tptest, - TP_ARGS(int, anint, int, netint, long *, values, - char *, text, size_t, textlen, - double, doublearg, float, floatarg, - bool, boolarg), - TP_FIELDS( - ctf_integer(int, intfield, anint) - ctf_integer_hex(int, intfield2, anint) - ctf_integer(long, longfield, anint) - ctf_integer_network(int, netintfield, netint) - ctf_integer_network_hex(int, netintfieldhex, netint) - ctf_array(long, arrfield1, values, 3) - ctf_array_text(char, arrfield2, text, 10) - ctf_sequence(char, seqfield1, text, - size_t, textlen) - ctf_sequence_text(char, seqfield2, text, - size_t, textlen) - ctf_string(stringfield, text) - ctf_float(float, floatfield, floatarg) - ctf_float(double, doublefield, doublearg) - ctf_integer(bool, boolfield, boolarg) - ctf_integer_nowrite(int, filterfield, anint) - ) -) - -TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, - TP_ARGS(), - TP_FIELDS() -) - -#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ - -#undef TRACEPOINT_INCLUDE -#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" - -/* This part must be outside ifdef protection */ -#include <lttng/tracepoint-event.h> - -#ifdef __cplusplus -} -#endif --1.8.2.1
Quoted 9 lines
Quoted 4 lines
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com
A message that is not in the archive (sent off-list or not yet received): 20130411224234.GA927@Krystal
Quoted 24 lines · Mathieu Desnoyers
Quoted 23 lines · * Jérémie Galarneau ([email protected]) wrote:
Quoted 1 line · Mathieu Desnoyers
redondant -> redundant
Indeed, will fix.
Quoted 10 lines · * Jérémie Galarneau ([email protected]) wrote:
Quoted 5 lines
The examples are now automatically built as part of the default make target.
The "hello" test verified that an application with statically embedded tracepoint providers could be built. This is now covered by "easy-ust" in doc/examples since we now build the examples.
No, hello is referenced by lttng-ust(3) manpage.
Not anymore since I also changed the manpage in this patch to reflect the change.
Quoted 2 lines
Please leave it there, but move it to examples.
Quoted 9 lines
Quoted 4 lines
I don't mind keeping either easy-ust or hello as examples. However, I don't see the point in keeping them both since they demonstrate the same thing; that is building an application with built-in providers. What do you think?
I personally use "hello" to put every type of fields that need to be tested. I notice that the other test programs don't have all the fields hello has, so we lose in coverage if we remove it.
Good point.
Quoted 3 lines
But I agree it's more for tests. So we might want to leave "hello" in tests/.
Fair enough. I'll submit a new patch.
Thanks for the comments,
Jérémie
Quoted 1,264 lines
Thanks,
Mathieu
Quoted 1,255 lines
Jérémie
Quoted 1,240 lines
Thanks,
Mathieu
Quoted 1,236 lines
Move the "hello-static-lib" test to doc/examples.
This should provide complete and easy to understand
Makefileexamples to users who wish to integrate tracepoint providers to their applications.Signed-off-by Jérémie Galarneau <[email protected]>--- .gitignore | 6 +- README | 2 +- configure.ac | 2 - doc/examples/Makefile.am | 15 ++++ doc/examples/README | 3 + doc/examples/demo/Makefile | 27 +++++-- doc/examples/easy-ust/Makefile | 30 ++++++-- doc/examples/hello-static-lib/Makefile | 53 ++++++++++++++ doc/examples/hello-static-lib/README | 3 + doc/examples/hello-static-lib/hello.c | 94 ++++++++++++++++++++++++ doc/examples/hello-static-lib/tp.c | 26 +++++++ doc/examples/hello-static-lib/ust_tests_hello.h | 72 ++++++++++++++++++ doc/man/lttng-ust.3 | 62 ++++++++-------- tests/Makefile.am | 2 +- tests/hello-static-lib/Makefile.am | 18 ----- tests/hello-static-lib/README | 3 - tests/hello-static-lib/hello.c | 95 ------------------------ tests/hello-static-lib/tp.c | 26 ------- tests/hello-static-lib/ust_tests_hello.h | 72 ------------------ tests/hello/Makefile.am | 13 ---- tests/hello/Makefile.example.bsd | 8 -- tests/hello/Makefile.example.linux | 8 -- tests/hello/README | 2 - tests/hello/hello.c | 97 ------------------------- tests/hello/tp.c | 26 ------- tests/hello/ust_tests_hello.h | 76 ------------------- 26 files changed, 349 insertions(+), 492 deletions(-) create mode 100644 doc/examples/README create mode 100644 doc/examples/hello-static-lib/Makefile create mode 100644 doc/examples/hello-static-lib/README create mode 100644 doc/examples/hello-static-lib/hello.c create mode 100644 doc/examples/hello-static-lib/tp.c create mode 100644 doc/examples/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello-static-lib/Makefile.am delete mode 100644 tests/hello-static-lib/README delete mode 100644 tests/hello-static-lib/hello.c delete mode 100644 tests/hello-static-lib/tp.c delete mode 100644 tests/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello/Makefile.am delete mode 100644 tests/hello/Makefile.example.bsd delete mode 100644 tests/hello/Makefile.example.linux delete mode 100644 tests/hello/README delete mode 100644 tests/hello/hello.c delete mode 100644 tests/hello/tp.c delete mode 100644 tests/hello/ust_tests_hello.h.gitignore +4
-2@@ -31,7 +31,10 @@ lttng-ust.pc ustctl/ustctl ust-consumerd/ust-consumerd -tests/hello/hello +doc/examples/demo/demo +doc/examples/easy-ust/sample +doc/examples/hello-static-lib/hello + tests/hello.cxx/hello tests/same_line_tracepoint/same_line_tracepoint tests/ust-basic-tracing/ust-basic-tracing@@ -39,5 +42,4 @@ tests/ust-multi-test/ust-multi-test tests/trace_event/trace_event_test tests/tracepoint/benchmark/tracepoint_benchmark tests/tracepoint/tracepoint_test -tests/hello-static-lib/hello tests/snprintf/progREADME +1
-1@@ -72,7 +72,7 @@ USAGE: - If building the provider directly into the application, link the application with "-llttng-ust". - If building a static library for the provider, link the static - library with "-lllttng-ust". + library with "-llttng-ust". - Include the tracepoint provider header into all C files using the provider. - Example:configure.ac +0
-2@@ -265,8 +265,6 @@ AC_CONFIG_FILES([ liblttng-ust-cyg-profile/Makefile tools/Makefile tests/Makefile - tests/hello/Makefile - tests/hello-static-lib/Makefile tests/hello.cxx/Makefile tests/same_line_tracepoint/Makefile tests/snprintf/Makefiledoc/examples/Makefile.am +15
-0@@ -1,6 +1,12 @@ +SUBDIRS = easy-ust demo hello-static-lib + +doc_examplesdir = ${docdir}/examples doc_examples_easy_ustdir = ${docdir}/examples/easy-ust doc_examples_gen_tpdir = ${docdir}/examples/gen-tp doc_examples_demodir = ${docdir}/examples/demo +doc_examples_hello_static_libdir = ${docdir}/examples/hello-static-lib + +dist_doc_examples_DATA = README dist_doc_examples_easy_ust_DATA = easy-ust/Makefile \ easy-ust/sample.c \@@ -19,3 +25,12 @@ dist_doc_examples_demo_DATA = demo/demo.c \ demo/ust_tests_demo2.h \ demo/ust_tests_demo3.h \ demo/ust_tests_demo.h + +dist_doc_examples_hello_static_lib_DATA = hello-static-lib/Makefile \ + hello-static-lib/hello.c \ + hello-static-lib/README \ + hello-static-lib/ust_tests_hello.h \ + hello-static-lib/tp.c + +BUILD_EXAMPLES_FROM_TREE = 1 +exportdoc/examples/README new file +3
-0@@ -0,0 +1,3 @@ +To build the examples from the source tree, the BUILD_EXAMPLES_FROM_TREE +environment variable must be defined. This will force the examples' +Makefiles to use the source tree's public header files and libraries.doc/examples/demo/Makefile +22
-5@@ -9,13 +9,30 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This Makefile is not using automake so that people may see how to build -# a program and tracepoint provider probes as stand-alone shared objects. +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes as stand-alone shared objects. CC = gcc LIBS = -ldl # On Linux #LIBS = -lc # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so@@ -23,13 +40,13 @@ lttng-ust-provider-ust-tests-demo.o: tp.c tp2.c ust_tests_demo.h ust_tests_demo2 $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo.so: lttng-ust-provider-ust-tests-demo.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< lttng-ust-provider-ust-tests-demo3.o: tp3.c ust_tests_demo3.h $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo3.so: lttng-ust-provider-ust-tests-demo3.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< demo.o: demo.c $(CC) $(CFLAGS) -c -o $@ $<doc/examples/easy-ust/Makefile +23
-7@@ -10,20 +10,36 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This makefile is not using automake so that people can see how to make -# simply. It builds a program with a statically embedded tracepoint -# provider probe. +# This makefile is not using automake so that users can see how to build +# a program with a statically embedded tracepoint provider probe. # the "html" target helps for documentation (req. code2html) CC = gcc LIBS = -ldl -llttng-ust # On Linux #LIBS = -lc -llttng-ust # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: sample sample: sample.o tp.o - $(CC) -o $@ $^ $(LIBS) + $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) sample.o: sample.c sample_component_provider.h $(CC) $(CFLAGS) -c -o $@ $<@@ -33,7 +49,7 @@ tp.o: tp.c sample_component_provider.h html: sample_component_provider.html sample.html tp.html -%.html: %.c +%.html: %.c code2html -lc $< $@ %.html : %.h@@ -41,5 +57,5 @@ html: sample_component_provider.html sample.html tp.html .PHONY: clean clean: - rm -f *.html + rm -f *.html rm -f *.o sampledoc/examples/hello-static-lib/Makefile new file +53
-0@@ -0,0 +1,53 @@ +# Copyright (C) 2013 Jérémie Galarneau <[email protected]> +# +# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. +# +# Permission is hereby granted to use or copy this program for any +# purpose, provided the above notices are retained on all copies. +# Permission to modify the code and to distribute modified code is +# granted, provided the above notices are retained, and a notice that +# the code was modified is included with the above copyright notice. + +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes in static libraries. + +CC = gcc +CFLAGS += -I. +LIBS = -ldl -llttng-ust # On Linux +#LIBS = -lc -llttng-ust # On BSD + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif + +all: hello + +lttng-ust-provider-hello.o: tp.c ust_tests_hello.h + $(CC) $(CFLAGS) -c -o $@ $< + +lttng-ust-provider-hello.a: lttng-ust-provider-hello.o + ar -rc $@ $< + +hello.o: hello.c + $(CC) $(CFLAGS) -c -o $@ $< + +hello: hello.o lttng-ust-provider-hello.a + $(CC) -o $@ $(LDFLAGS) $(LIBS) $^ + +.PHONY: clean +clean: + rm -f *.o *.a hellodoc/examples/hello-static-lib/README new file +3
-0@@ -0,0 +1,3 @@ +This is a "hello world" application used to verify that an instrumented +program can be built successfully and linked with tracepoint providers +built as a separate static library.doc/examples/hello-static-lib/hello.c new file +94
-0@@ -0,0 +1,94 @@ +/* +* Copyright (C) 2009 Pierre-Marc Fournier +* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; version 2.1 of +* the License. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <stdio.h> +#include <unistd.h> +#include <sys/mman.h> +#include <stdarg.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <signal.h> +#include <string.h> +#include <arpa/inet.h> +#include <stdlib.h> + +#define TRACEPOINT_DEFINE +#include "ust_tests_hello.h" + +void inthandler (int sig) +{ +printf ("in SIGUSR1 handler\n" ); +tracepoint (ust_tests_hello, tptest_sighandler); +} + +int init_int_handler (void ) +{ +int result; +struct sigaction act; + +memset (&act,0 ,sizeof (act)); + result =sigemptyset (&act.sa_mask); +if (result ==-1 ) { +perror ("sigemptyset" ); +return -1 ; + } + + act.sa_handler = inthandler; + act.sa_flags =SA_RESTART ; + +/* Only defer ourselves. Also, try to restart interrupted +* syscalls to disturb the traced program as little as possible. +*/ + result =sigaction (SIGUSR1 , &act,NULL ); +if (result ==-1 ) { +perror ("sigaction" ); +return -1 ; + } + +return 0 ; +} + +int main (int argc,char **argv) +{ +int i, netint; +long values[] = {1 ,2 ,3 }; +char text[10 ] ="test" ; +double dbl =2.0 ; +float flt =2222.0 ; +int delay =0 ; + +init_int_handler (); + +if (argc ==2 ) + delay =atoi (argv[1 ]); + +fprintf (stderr,"Hello, World!\n" ); + +sleep (delay); + +fprintf (stderr,"Tracing... " ); +for (i =0 ; i <1000000 ; i++) { + netint =htonl (i); +tracepoint (ust_tests_hello, tptest, i, netint, values, + text,strlen (text), dbl, flt); + } +fprintf (stderr," done.\n" ); +return 0 ; +}doc/examples/hello-static-lib/tp.c new file +26
-0@@ -0,0 +1,26 @@ +/* +* tp.c +* +* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_hello.h" doc/examples/hello-static-lib/ust_tests_hello.h new file +72
-0@@ -0,0 +1,72 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_hello + +#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_HELLO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include <lttng/tracepoint.h> + +TRACEPOINT_EVENT(ust_tests_hello, tptest, + TP_ARGS(int, anint, int, netint, long *, values, + char *, text, size_t, textlen, + double, doublearg, float, floatarg), + TP_FIELDS( + ctf_integer(int, intfield, anint) + ctf_integer_hex(int, intfield2, anint) + ctf_integer(long, longfield, anint) + ctf_integer_network(int, netintfield, netint) + ctf_integer_network_hex(int, netintfieldhex, netint) + ctf_array(long, arrfield1, values, 3) + ctf_array_text(char, arrfield2, text, 10) + ctf_sequence(char, seqfield1, text, + size_t, textlen) + ctf_sequence_text(char, seqfield2, text, + size_t, textlen) + ctf_string(stringfield, text) + ctf_float(float, floatfield, floatarg) + ctf_float(double, doublefield, doublearg) + ) +) + +TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, + TP_ARGS(), + TP_FIELDS() +) + +#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" + +/* This part must be outside ifdef protection */ +#include <lttng/tracepoint-event.h> + +#ifdef __cplusplus +} +#endifdoc/man/lttng-ust.3 +32
-30@@ -40,11 +40,11 @@ focus on the various types that can be recorded into a trace event: TRACEPOINT_EVENT( /* * provider name, not a variable but a string starting with a - * letter and containing either letters, numbers or underscores. + * letter and containing either letters, numbers or underscores. * Needs to be the same as TRACEPOINT_PROVIDER. Needs to * follow the namespacing guide-lines in lttng/tracepoint.h: - * - * Must be included before include tracepoint provider + * + * Must be included before include tracepoint provider * ex.: project_event * ex.: project_component_event *@@ -59,19 +59,19 @@ TRACEPOINT_EVENT( /* * tracepoint name, same format as sample provider. Does not * need to be declared before. in this case the name is - * "message" + * "message" */ message, /* - * TP_ARGS macro contains the arguments passed for the tracepoint + * TP_ARGS macro contains the arguments passed for the tracepoint * it is in the following format * TP_ARGS(type1, name1, type2, name2, ... type10, name10) - * where there can be from zero to ten elements. - * typeN is the datatype, such as int, struct or double **. + * where there can be from zero to ten elements. + * typeN is the datatype, such as int, struct or double **. * name is the variable name (in "int myInt" the name would be - * myint) + * myint) * TP_ARGS() is valid to mean no arguments * TP_ARGS(void) is valid too */@@ -80,7 +80,7 @@ TRACEPOINT_EVENT( double, doublearg, float, floatarg), /* - * TP_FIELDS describes how to write the fields of the trace event. + * TP_FIELDS describes how to write the fields of the trace event. * You can put expressions in the "argument expression" area, * typically using the input arguments from TP_ARGS. */@@ -109,14 +109,14 @@ TRACEPOINT_EVENT( /* * ctf_array: a statically-sized array. * args: (type, field name, argument expression, value) - */ + */ ctf_array(long, arrfield1, values, 3) /* * ctf_array_text: a statically-sized array, printed as * a string. No need to be terminated by a null * character. - */ + */ ctf_array_text(char, arrfield2, text, 10) /*@@ -127,7 +127,7 @@ TRACEPOINT_EVENT( * unsigned type. As a reminder, "unsigned char" should * be preferred to "char", since the signedness of * "char" is implementation-defined. - */ + */ ctf_sequence(char, seqfield1, text, size_t, textlen)@@ -172,54 +172,54 @@ declared before declaring a TRACEPOINT_LOGLEVEL. The loglevels go from 0 to 14. Higher numbers imply the most verbosity (higher event throughput expected. - + Loglevels 0 through 6, and loglevel 14, match syslog(3) loglevels semantic. Loglevels 7 through 13 offer more fine-grained selection of debug information. - + TRACE_EMERG 0 system is unusable - + TRACE_ALERT 1 action must be taken immediately - + TRACE_CRIT 2 critical conditions - + TRACE_ERR 3 error conditions - + TRACE_WARNING 4 warning conditions - + TRACE_NOTICE 5 normal, but significant, condition - + TRACE_INFO 6 informational message - + TRACE_DEBUG_SYSTEM 7 debug information with system-level scope (set of programs) - + TRACE_DEBUG_PROGRAM 8 debug information with program-level scope (set of processes) - + TRACE_DEBUG_PROCESS 9 debug information with process-level scope (set of modules) - + TRACE_DEBUG_MODULE 10 debug information with module (executable/library) scope (set of units) - + TRACE_DEBUG_UNIT 11 debug information with compilation unit scope (set of functions) - + TRACE_DEBUG_FUNCTION 12 debug information with function-level scope - + TRACE_DEBUG_LINE 13 debug information with line-level scope (TRACEPOINT_EVENT default) - + TRACE_DEBUG 14 debug-level message (trace_printf default)@@ -269,7 +269,9 @@ carefully: - Include the tracepoint provider header into all C files using the provider. - Example: - - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example + - doc/examples/easy-ust/ sample.c sample_component_provider.h tp.c + Makefile + - doc/examples/hello-static-lib/ hello.c tp.c ust_test_hello.h Makefile 2) Compile the Tracepoint Provider separately from the application, using dynamic linking:@@ -287,7 +289,7 @@ carefully: needed. Another way is to dlopen the tracepoint probe when needed by the application. - Example: - - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace + - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace Makefile - Note about dlclose() usage: it is not safe to use dlclose on a provider shared object that is being actively used for tracing duetests/Makefile.am +1
-1@@ -1,4 +1,4 @@ -SUBDIRS = . hello hello-static-lib same_line_tracepoint snprintf +SUBDIRS = . same_line_tracepoint snprintf if CXX_WORKS SUBDIRS += hello.cxxtests/hello-static-lib/Makefile.am deleted +0
-18@@ -1,18 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_LTLIBRARIES = liblttng-ust-provider-ust-test-hello.la -liblttng_ust_provider_ust_test_hello_la_SOURCES = \ - tp.c ust_tests_hello.h -liblttng_ust_provider_ust_test_hello_la_LIBADD = \ - $(top_builddir)/liblttng-ust/liblttng-ust.la - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c -hello_LDADD = liblttng-ust-provider-ust-test-hello.la - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endiftests/hello-static-lib/README deleted +0
-3@@ -1,3 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully and linked with tracepoint providers -built as a separate static library.tests/hello-static-lib/hello.c deleted +0
-95@@ -1,95 +0,0 @@ -/* -* Copyright (C) 2009 Pierre-Marc Fournier -* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; version 2.1 of -* the License. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <arpa/inet.h> -#include <stdlib.h> - -#define TRACEPOINT_DEFINE -#include "ust_tests_hello.h" - -void inthandler (int sig) -{ -printf ("in SIGUSR1 handler\n" ); -tracepoint (ust_tests_hello, tptest_sighandler); -} - -int init_int_handler (void ) -{ -int result; -struct sigaction act; - -memset (&act,0 ,sizeof (act)); - result =sigemptyset (&act.sa_mask); -if (result ==-1 ) { -perror ("sigemptyset" ); -return -1 ; - } - - act.sa_handler = inthandler; - act.sa_flags =SA_RESTART ; - -/* Only defer ourselves. Also, try to restart interrupted -* syscalls to disturb the traced program as little as possible. -*/ - result =sigaction (SIGUSR1 , &act,NULL ); -if (result ==-1 ) { -perror ("sigaction" ); -return -1 ; - } - -return 0 ; -} - -int main (int argc,char **argv) -{ -int i, netint; -long values[] = {1 ,2 ,3 }; -char text[10 ] ="test" ; -double dbl =2.0 ; -float flt =2222.0 ; -int delay =0 ; - -init_int_handler (); - -if (argc ==2 ) - delay =atoi (argv[1 ]); - -fprintf (stderr,"Hello, World!\n" ); - -sleep (delay); - -fprintf (stderr,"Tracing... " ); -for (i =0 ; i <1000000 ; i++) { - netint =htonl (i); -tracepoint (ust_tests_hello, tptest, i, netint, values, - text,strlen (text), dbl, flt); -//usleep(100000); - } -fprintf (stderr," done.\n" ); -return 0 ; -}tests/hello-static-lib/tp.c deleted +0
-26@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h" tests/hello-static-lib/ust_tests_hello.h deleted +0
-72@@ -1,72 +0,0 @@ -#undef TRACEPOINT_PROVIDER -#define TRACEPOINT_PROVIDER ust_tests_hello - -#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) -#define _TRACEPOINT_UST_TESTS_HELLO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <lttng/tracepoint.h> - -TRACEPOINT_EVENT(ust_tests_hello, tptest, - TP_ARGS(int, anint, int, netint, long *, values, - char *, text, size_t, textlen, - double, doublearg, float, floatarg), - TP_FIELDS( - ctf_integer(int, intfield, anint) - ctf_integer_hex(int, intfield2, anint) - ctf_integer(long, longfield, anint) - ctf_integer_network(int, netintfield, netint) - ctf_integer_network_hex(int, netintfieldhex, netint) - ctf_array(long, arrfield1, values, 3) - ctf_array_text(char, arrfield2, text, 10) - ctf_sequence(char, seqfield1, text, - size_t, textlen) - ctf_sequence_text(char, seqfield2, text, - size_t, textlen) - ctf_string(stringfield, text) - ctf_float(float, floatfield, floatarg) - ctf_float(double, doublefield, doublearg) - ) -) - -TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, - TP_ARGS(), - TP_FIELDS() -) - -#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ - -#undef TRACEPOINT_INCLUDE -#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" - -/* This part must be outside ifdef protection */ -#include <lttng/tracepoint-event.h> - -#ifdef __cplusplus -} -#endiftests/hello/Makefile.am deleted +0
-13@@ -1,13 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c tp.c ust_tests_hello.h -hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la -hello_CFLAGS = -Werror=old-style-definition - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endiftests/hello/Makefile.example.bsd deleted +0
-8@@ -1,8 +0,0 @@ -# Example makefile for build outside of the LTTng-UST tree. - -hello: - ${CC} -O2 -I. -o hello -lc -llttng-ust hello.c tp.c - -.PHONY: clean -clean: - rm -f hellotests/hello/Makefile.example.linux deleted +0
-8@@ -1,8 +0,0 @@ -# Example makefile for build outside of the LTTng-UST tree. - -hello: - ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c - -.PHONY: clean -clean: - rm -f hellotests/hello/README deleted +0
-2@@ -1,2 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully.tests/hello/hello.c deleted +0
-97@@ -1,97 +0,0 @@ -/* -* Copyright (C) 2009 Pierre-Marc Fournier -* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; version 2.1 of -* the License. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <arpa/inet.h> -#include <stdlib.h> -#include <stdbool.h> - -#define TRACEPOINT_DEFINE -#include "ust_tests_hello.h" - -void inthandler (int sig) -{ -printf ("in SIGUSR1 handler\n" ); -tracepoint (ust_tests_hello, tptest_sighandler); -} - -int init_int_handler (void ) -{ -int result; -struct sigaction act; - -memset (&act,0 ,sizeof (act)); - result =sigemptyset (&act.sa_mask); -if (result ==-1 ) { -perror ("sigemptyset" ); -return -1 ; - } - - act.sa_handler = inthandler; - act.sa_flags =SA_RESTART ; - -/* Only defer ourselves. Also, try to restart interrupted -* syscalls to disturb the traced program as little as possible. -*/ - result =sigaction (SIGUSR1 , &act,NULL ); -if (result ==-1 ) { -perror ("sigaction" ); -return -1 ; - } - -return 0 ; -} - -int main (int argc,char **argv) -{ -int i, netint; -long values[] = {1 ,2 ,3 }; -char text[10 ] ="test" ; -double dbl =2.0 ; -float flt =2222.0 ; -int delay =0 ; -bool mybool =123 ;/* should print "1" */ - -init_int_handler (); - -if (argc ==2 ) - delay =atoi (argv[1 ]); - -fprintf (stderr,"Hello, World!\n" ); - -sleep (delay); - -fprintf (stderr,"Tracing... " ); -for (i =0 ; i <1000000 ; i++) { - netint =htonl (i); -tracepoint (ust_tests_hello, tptest, i, netint, values, - text,strlen (text), dbl, flt, mybool); -//usleep(100000); - } -fprintf (stderr," done.\n" ); -return 0 ; -}tests/hello/tp.c deleted +0
-26@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h" tests/hello/ust_tests_hello.h deleted +0
-77@@ -1,76 +0,0 @@ -#undef TRACEPOINT_PROVIDER -#define TRACEPOINT_PROVIDER ust_tests_hello - -#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) -#define _TRACEPOINT_UST_TESTS_HELLO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <lttng/tracepoint.h> -#include <stdbool.h> - -TRACEPOINT_EVENT(ust_tests_hello, tptest, - TP_ARGS(int, anint, int, netint, long *, values, - char *, text, size_t, textlen, - double, doublearg, float, floatarg, - bool, boolarg), - TP_FIELDS( - ctf_integer(int, intfield, anint) - ctf_integer_hex(int, intfield2, anint) - ctf_integer(long, longfield, anint) - ctf_integer_network(int, netintfield, netint) - ctf_integer_network_hex(int, netintfieldhex, netint) - ctf_array(long, arrfield1, values, 3) - ctf_array_text(char, arrfield2, text, 10) - ctf_sequence(char, seqfield1, text, - size_t, textlen) - ctf_sequence_text(char, seqfield2, text, - size_t, textlen) - ctf_string(stringfield, text) - ctf_float(float, floatfield, floatarg) - ctf_float(double, doublefield, doublearg) - ctf_integer(bool, boolfield, boolarg) - ctf_integer_nowrite(int, filterfield, anint) - ) -) - -TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, - TP_ARGS(), - TP_FIELDS() -) - -#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ - -#undef TRACEPOINT_INCLUDE -#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" - -/* This part must be outside ifdef protection */ -#include <lttng/tracepoint-event.h> - -#ifdef __cplusplus -} -#endif --1.8.2.1
Quoted 9 lines
Quoted 4 lines
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.comQuoted 4 lines
--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
Quoted 4 lines
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
PATCH 1/1 Move "hello-static-lib" to doc/examples and add non-automake Makefiles
In reply to a message not in the archiveThe examples are now automatically built as part of the default make target and plain Makefiles with no dependency on automake are provided for clarity.
Update the manpage and README to reflect the change and remove lots of trailing whitespace.
--- .gitignore | 5 +- README | 18 +++-- configure.ac | 1 - doc/examples/Makefile.am | 15 ++++ doc/examples/README | 3 + doc/examples/demo/Makefile | 27 +++++-- doc/examples/easy-ust/Makefile | 30 ++++++-- doc/examples/hello-static-lib/Makefile | 53 ++++++++++++++ doc/examples/hello-static-lib/README | 3 + doc/examples/hello-static-lib/hello.c | 94 ++++++++++++++++++++++++ doc/examples/hello-static-lib/tp.c | 26 +++++++ doc/examples/hello-static-lib/ust_tests_hello.h | 72 +++++++++++++++++++ doc/man/lttng-ust.3 | 64 +++++++++-------- tests/Makefile.am | 2 +- tests/demo/README | 6 +- tests/hello-static-lib/Makefile.am | 18 ----- tests/hello-static-lib/README | 3 - tests/hello-static-lib/hello.c | 95 ------------------------- tests/hello-static-lib/tp.c | 26 ------- tests/hello-static-lib/ust_tests_hello.h | 72 ------------------- 20 files changed, 362 insertions(+), 271 deletions(-) create mode 100644 doc/examples/README create mode 100644 doc/examples/hello-static-lib/Makefile create mode 100644 doc/examples/hello-static-lib/README create mode 100644 doc/examples/hello-static-lib/hello.c create mode 100644 doc/examples/hello-static-lib/tp.c create mode 100644 doc/examples/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello-static-lib/Makefile.am delete mode 100644 tests/hello-static-lib/README delete mode 100644 tests/hello-static-lib/hello.c delete mode 100644 tests/hello-static-lib/tp.c delete mode 100644 tests/hello-static-lib/ust_tests_hello.h
.gitignore +4 -1
@@ -31,6 +31,10 @@ lttng-ust.pc ustctl/ustctl ust-consumerd/ust-consumerd +doc/examples/demo/demo +doc/examples/easy-ust/sample +doc/examples/hello-static-lib/hello + tests/hello/hello tests/hello.cxx/hello tests/same_line_tracepoint/same_line_tracepoint
@@ -39,5 +43,4 @@ tests/ust-multi-test/ust-multi-test tests/trace_event/trace_event_test tests/tracepoint/benchmark/tracepoint_benchmark tests/tracepoint/tracepoint_test -tests/hello-static-lib/hello tests/snprintf/prog
README +12 -6
@@ -72,11 +72,13 @@ USAGE: - If building the provider directly into the application, link the application with "-llttng-ust". - If building a static library for the provider, link the static - library with "-lllttng-ust". + library with "-llttng-ust". - Include the tracepoint provider header into all C files using the provider. - - Example: - - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example.* + - Examples: + - doc/examples/easy-ust/ sample.c sample_component_provider.h tp.c + Makefile + - doc/examples/hello-static-lib/ hello.c tp.c ust_test_hello.h Makefile 2) Compile the Tracepoint Provider separately from the application, using dynamic linking:
@@ -94,14 +96,18 @@ USAGE: needed. Another way is to dlopen the tracepoint probe when needed by the application. - Example: - - tests/demo/ demo.c tp*.c ust_tests_demo*.h demo-trace + - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace Makefile - - Enable instrumentation and control tracing with the "lttng" command - from lttng-tools. See lttng-tools doc/quickstart.txt. - Note about dlclose() usage: it is not safe to use dlclose on a provider shared object that is being actively used for tracing due to a lack of reference counting from lttng-ust to the used shared object. + - Enable instrumentation and control tracing with the "lttng" command + from lttng-tools. See lttng-tools doc/quickstart.txt. + - Note for C++ support: although an application instrumented with + tracepoints can be compiled with g++, tracepoint probes should be + compiled with gcc (only tested with gcc so far). + ENVIRONMENT VARIABLES:
configure.ac +0 -1
@@ -266,7 +266,6 @@ AC_CONFIG_FILES([ tools/Makefile tests/Makefile tests/hello/Makefile - tests/hello-static-lib/Makefile tests/hello.cxx/Makefile tests/same_line_tracepoint/Makefile tests/snprintf/Makefile
doc/examples/Makefile.am +15 -0
@@ -1,6 +1,12 @@ +SUBDIRS = easy-ust demo hello-static-lib + +doc_examplesdir = ${docdir}/examples doc_examples_easy_ustdir = ${docdir}/examples/easy-ust doc_examples_gen_tpdir = ${docdir}/examples/gen-tp doc_examples_demodir = ${docdir}/examples/demo +doc_examples_hello_static_libdir = ${docdir}/examples/hello-static-lib + +dist_doc_examples_DATA = README dist_doc_examples_easy_ust_DATA = easy-ust/Makefile \ easy-ust/sample.c \
@@ -19,3 +25,12 @@ dist_doc_examples_demo_DATA = demo/demo.c \ demo/ust_tests_demo2.h \ demo/ust_tests_demo3.h \ demo/ust_tests_demo.h + +dist_doc_examples_hello_static_lib_DATA = hello-static-lib/Makefile \ + hello-static-lib/hello.c \ + hello-static-lib/README \ + hello-static-lib/ust_tests_hello.h \ + hello-static-lib/tp.c + +BUILD_EXAMPLES_FROM_TREE = 1 +export
doc/examples/README new file +3 -0
@@ -0,0 +1,3 @@ +To build the examples from the source tree, the BUILD_EXAMPLES_FROM_TREE +environment variable must be defined. This will ensure the examples' +Makefiles use the source tree's public header files and binaries.
doc/examples/demo/Makefile +22 -5
@@ -9,13 +9,30 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This Makefile is not using automake so that people may see how to build -# a program and tracepoint provider probes as stand-alone shared objects. +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes as stand-alone shared objects. CC = gcc LIBS = -ldl # On Linux #LIBS = -lc # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so
@@ -23,13 +40,13 @@ lttng-ust-provider-ust-tests-demo.o: tp.c tp2.c ust_tests_demo.h ust_tests_demo2 $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo.so: lttng-ust-provider-ust-tests-demo.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< lttng-ust-provider-ust-tests-demo3.o: tp3.c ust_tests_demo3.h $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo3.so: lttng-ust-provider-ust-tests-demo3.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< demo.o: demo.c $(CC) $(CFLAGS) -c -o $@ $<
doc/examples/easy-ust/Makefile +23 -7
@@ -10,20 +10,36 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This makefile is not using automake so that people can see how to make -# simply. It builds a program with a statically embedded tracepoint -# provider probe. +# This makefile is not using automake so that users can see how to build +# a program with a statically embedded tracepoint provider probe. # the "html" target helps for documentation (req. code2html) CC = gcc LIBS = -ldl -llttng-ust # On Linux #LIBS = -lc -llttng-ust # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: sample sample: sample.o tp.o - $(CC) -o $@ $^ $(LIBS) + $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) sample.o: sample.c sample_component_provider.h $(CC) $(CFLAGS) -c -o $@ $<
@@ -33,7 +49,7 @@ tp.o: tp.c sample_component_provider.h html: sample_component_provider.html sample.html tp.html -%.html: %.c +%.html: %.c code2html -lc $< $@ %.html : %.h
@@ -41,5 +57,5 @@ html: sample_component_provider.html sample.html tp.html .PHONY: clean clean: - rm -f *.html + rm -f *.html rm -f *.o sample
doc/examples/hello-static-lib/Makefile new file +53 -0
53 lines not on this page · raw message
doc/examples/hello-static-lib/README new file +3 -0
@@ -0,0 +1,3 @@ +This is a "hello world" application used to verify that an instrumented +program can be built successfully and linked with tracepoint providers +built as a separate static library.
doc/examples/hello-static-lib/hello.c new file +94 -0
94 lines not on this page · raw message
doc/examples/hello-static-lib/tp.c new file +26 -0
@@ -0,0 +1,26 @@ +/* +* tp.c +* +* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_hello.h"
doc/examples/hello-static-lib/ust_tests_hello.h new file +72 -0
72 lines not on this page · raw message
doc/man/lttng-ust.3 +33 -31
160 lines not on this page · raw message
tests/Makefile.am +1 -1
@@ -1,4 +1,4 @@ -SUBDIRS = . hello hello-static-lib same_line_tracepoint snprintf +SUBDIRS = . hello same_line_tracepoint snprintf if CXX_WORKS SUBDIRS += hello.cxx
tests/demo/README +1 -5
@@ -1,5 +1 @@ -"demo" and "demo-trace" are moved to lttng-tools, under: - - tests/regression/ust/linking/ - -The "demo-trace" script was renamed to "demo_preload". +"demo" and "demo-trace" are moved to doc/examples/demo
tests/hello-static-lib/Makefile.am deleted +0 -18
@@ -1,18 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_LTLIBRARIES = liblttng-ust-provider-ust-test-hello.la -liblttng_ust_provider_ust_test_hello_la_SOURCES = \ - tp.c ust_tests_hello.h -liblttng_ust_provider_ust_test_hello_la_LIBADD = \ - $(top_builddir)/liblttng-ust/liblttng-ust.la - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c -hello_LDADD = liblttng-ust-provider-ust-test-hello.la - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endif
tests/hello-static-lib/README deleted +0 -3
@@ -1,3 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully and linked with tracepoint providers -built as a separate static library.
tests/hello-static-lib/hello.c deleted +0 -95
95 lines not on this page · raw message
tests/hello-static-lib/tp.c deleted +0 -26
@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h"
tests/hello-static-lib/ust_tests_hello.h deleted +0 -72
72 lines not on this page · raw message
Signature · 7 lines
1.8.2.1 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mathieu Desnoyers
AppliedRe: [PATCH lttng-ust] Move "hello-static-lib" to doc/examples and add non-automake Makefiles
Quoted 5 lines · * Jérémie Galarneau ([email protected]) wrote:
The examples are now automatically built as part of the default make target and plain Makefiles with no dependency on automake are provided for clarity.
Update the manpage and README to reflect the change and remove lots of trailing whitespace.
merged into master branch. Since it does not change features, this will go into 2.2. Thanks!
Mathieu
Quoted 990 lines
Signed-off-by Jérémie Galarneau <[email protected]>--- .gitignore | 5 +- README | 18 +++-- configure.ac | 1 - doc/examples/Makefile.am | 15 ++++ doc/examples/README | 3 + doc/examples/demo/Makefile | 27 +++++-- doc/examples/easy-ust/Makefile | 30 ++++++-- doc/examples/hello-static-lib/Makefile | 53 ++++++++++++++ doc/examples/hello-static-lib/README | 3 + doc/examples/hello-static-lib/hello.c | 94 ++++++++++++++++++++++++ doc/examples/hello-static-lib/tp.c | 26 +++++++ doc/examples/hello-static-lib/ust_tests_hello.h | 72 +++++++++++++++++++ doc/man/lttng-ust.3 | 64 +++++++++-------- tests/Makefile.am | 2 +- tests/demo/README | 6 +- tests/hello-static-lib/Makefile.am | 18 ----- tests/hello-static-lib/README | 3 - tests/hello-static-lib/hello.c | 95 ------------------------- tests/hello-static-lib/tp.c | 26 ------- tests/hello-static-lib/ust_tests_hello.h | 72 ------------------- 20 files changed, 362 insertions(+), 271 deletions(-) create mode 100644 doc/examples/README create mode 100644 doc/examples/hello-static-lib/Makefile create mode 100644 doc/examples/hello-static-lib/README create mode 100644 doc/examples/hello-static-lib/hello.c create mode 100644 doc/examples/hello-static-lib/tp.c create mode 100644 doc/examples/hello-static-lib/ust_tests_hello.h delete mode 100644 tests/hello-static-lib/Makefile.am delete mode 100644 tests/hello-static-lib/README delete mode 100644 tests/hello-static-lib/hello.c delete mode 100644 tests/hello-static-lib/tp.c delete mode 100644 tests/hello-static-lib/ust_tests_hello.h.gitignore +4
-1@@ -31,6 +31,10 @@ lttng-ust.pc ustctl/ustctl ust-consumerd/ust-consumerd +doc/examples/demo/demo +doc/examples/easy-ust/sample +doc/examples/hello-static-lib/hello + tests/hello/hello tests/hello.cxx/hello tests/same_line_tracepoint/same_line_tracepoint@@ -39,5 +43,4 @@ tests/ust-multi-test/ust-multi-test tests/trace_event/trace_event_test tests/tracepoint/benchmark/tracepoint_benchmark tests/tracepoint/tracepoint_test -tests/hello-static-lib/hello tests/snprintf/progREADME +12
-6@@ -72,11 +72,13 @@ USAGE: - If building the provider directly into the application, link the application with "-llttng-ust". - If building a static library for the provider, link the static - library with "-lllttng-ust". + library with "-llttng-ust". - Include the tracepoint provider header into all C files using the provider. - - Example: - - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example.* + - Examples: + - doc/examples/easy-ust/ sample.c sample_component_provider.h tp.c + Makefile + - doc/examples/hello-static-lib/ hello.c tp.c ust_test_hello.h Makefile 2) Compile the Tracepoint Provider separately from the application, using dynamic linking:@@ -94,14 +96,18 @@ USAGE: needed. Another way is to dlopen the tracepoint probe when needed by the application. - Example: - - tests/demo/ demo.c tp*.c ust_tests_demo*.h demo-trace + - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace Makefile - - Enable instrumentation and control tracing with the "lttng" command - from lttng-tools. See lttng-tools doc/quickstart.txt. - Note about dlclose() usage: it is not safe to use dlclose on a provider shared object that is being actively used for tracing due to a lack of reference counting from lttng-ust to the used shared object. + - Enable instrumentation and control tracing with the "lttng" command + from lttng-tools. See lttng-tools doc/quickstart.txt. + - Note for C++ support: although an application instrumented with + tracepoints can be compiled with g++, tracepoint probes should be + compiled with gcc (only tested with gcc so far). + ENVIRONMENT VARIABLES:configure.ac +0
-1@@ -266,7 +266,6 @@ AC_CONFIG_FILES([ tools/Makefile tests/Makefile tests/hello/Makefile - tests/hello-static-lib/Makefile tests/hello.cxx/Makefile tests/same_line_tracepoint/Makefile tests/snprintf/Makefiledoc/examples/Makefile.am +15
-0@@ -1,6 +1,12 @@ +SUBDIRS = easy-ust demo hello-static-lib + +doc_examplesdir = ${docdir}/examples doc_examples_easy_ustdir = ${docdir}/examples/easy-ust doc_examples_gen_tpdir = ${docdir}/examples/gen-tp doc_examples_demodir = ${docdir}/examples/demo +doc_examples_hello_static_libdir = ${docdir}/examples/hello-static-lib + +dist_doc_examples_DATA = README dist_doc_examples_easy_ust_DATA = easy-ust/Makefile \ easy-ust/sample.c \@@ -19,3 +25,12 @@ dist_doc_examples_demo_DATA = demo/demo.c \ demo/ust_tests_demo2.h \ demo/ust_tests_demo3.h \ demo/ust_tests_demo.h + +dist_doc_examples_hello_static_lib_DATA = hello-static-lib/Makefile \ + hello-static-lib/hello.c \ + hello-static-lib/README \ + hello-static-lib/ust_tests_hello.h \ + hello-static-lib/tp.c + +BUILD_EXAMPLES_FROM_TREE = 1 +exportdoc/examples/README new file +3
-0@@ -0,0 +1,3 @@ +To build the examples from the source tree, the BUILD_EXAMPLES_FROM_TREE +environment variable must be defined. This will ensure the examples' +Makefiles use the source tree's public header files and binaries.doc/examples/demo/Makefile +22
-5@@ -9,13 +9,30 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This Makefile is not using automake so that people may see how to build -# a program and tracepoint provider probes as stand-alone shared objects. +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes as stand-alone shared objects. CC = gcc LIBS = -ldl # On Linux #LIBS = -lc # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so@@ -23,13 +40,13 @@ lttng-ust-provider-ust-tests-demo.o: tp.c tp2.c ust_tests_demo.h ust_tests_demo2 $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo.so: lttng-ust-provider-ust-tests-demo.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< lttng-ust-provider-ust-tests-demo3.o: tp3.c ust_tests_demo3.h $(CC) $(CFLAGS) -fpic -c -o $@ $< lttng-ust-provider-ust-tests-demo3.so: lttng-ust-provider-ust-tests-demo3.o - $(CC) -shared -o $@ -llttng-ust $< + $(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $< demo.o: demo.c $(CC) $(CFLAGS) -c -o $@ $<doc/examples/easy-ust/Makefile +23
-7@@ -10,20 +10,36 @@ # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. -# This makefile is not using automake so that people can see how to make -# simply. It builds a program with a statically embedded tracepoint -# provider probe. +# This makefile is not using automake so that users can see how to build +# a program with a statically embedded tracepoint provider probe. # the "html" target helps for documentation (req. code2html) CC = gcc LIBS = -ldl -llttng-ust # On Linux #LIBS = -lc -llttng-ust # On BSD -CFLAGS = -I. +CFLAGS += -I. + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif all: sample sample: sample.o tp.o - $(CC) -o $@ $^ $(LIBS) + $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) sample.o: sample.c sample_component_provider.h $(CC) $(CFLAGS) -c -o $@ $<@@ -33,7 +49,7 @@ tp.o: tp.c sample_component_provider.h html: sample_component_provider.html sample.html tp.html -%.html: %.c +%.html: %.c code2html -lc $< $@ %.html : %.h@@ -41,5 +57,5 @@ html: sample_component_provider.html sample.html tp.html .PHONY: clean clean: - rm -f *.html + rm -f *.html rm -f *.o sampledoc/examples/hello-static-lib/Makefile new file +53
-0@@ -0,0 +1,53 @@ +# Copyright (C) 2013 Jérémie Galarneau <[email protected]> +# +# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. +# +# Permission is hereby granted to use or copy this program for any +# purpose, provided the above notices are retained on all copies. +# Permission to modify the code and to distribute modified code is +# granted, provided the above notices are retained, and a notice that +# the code was modified is included with the above copyright notice. + +# This Makefile is not using automake so that users may see how to build +# a program with tracepoint provider probes compiled as static libraries. + +CC = gcc +CFLAGS += -I. +LIBS = -ldl -llttng-ust # On Linux +#LIBS = -lc -llttng-ust # On BSD + +# Only necessary when building from the source tree and lttng-ust is not +# installed +ifdef BUILD_EXAMPLES_FROM_TREE +CFLAGS += -I../../../include/ +LIBLTTNG_UST_PATH = ../../../liblttng-ust/.libs/ +LDFLAGS += -L$(LIBLTTNG_UST_PATH) -Wl,-rpath='$$ORIGIN/$(LIBLTTNG_UST_PATH)' + +# Third-party Makefiles have to define these targets to integrate with an +# automake project +EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \ + install-dvi install-html install-info install-ps install-pdf \ + installdirs check installcheck mostlyclean distclean maintainer-clean \ + dvi html pdf ps info tags ctags +.PHONY: $(EMPTY_AUTOMAKE_TARGETS) +$(EMPTY_AUTOMAKE_TARGETS): +endif + +all: hello + +lttng-ust-provider-hello.o: tp.c ust_tests_hello.h + $(CC) $(CFLAGS) -c -o $@ $< + +lttng-ust-provider-hello.a: lttng-ust-provider-hello.o + ar -rc $@ $< + +hello.o: hello.c + $(CC) $(CFLAGS) -c -o $@ $< + +hello: hello.o lttng-ust-provider-hello.a + $(CC) -o $@ $(LDFLAGS) $(LIBS) $^ + +.PHONY: clean +clean: + rm -f *.o *.a hellodoc/examples/hello-static-lib/README new file +3
-0@@ -0,0 +1,3 @@ +This is a "hello world" application used to verify that an instrumented +program can be built successfully and linked with tracepoint providers +built as a separate static library.doc/examples/hello-static-lib/hello.c new file +94
-0@@ -0,0 +1,94 @@ +/* +* Copyright (C) 2009 Pierre-Marc Fournier +* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; version 2.1 of +* the License. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <stdio.h> +#include <unistd.h> +#include <sys/mman.h> +#include <stdarg.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <signal.h> +#include <string.h> +#include <arpa/inet.h> +#include <stdlib.h> + +#define TRACEPOINT_DEFINE +#include "ust_tests_hello.h" + +void inthandler (int sig) +{ +printf ("in SIGUSR1 handler\n" ); +tracepoint (ust_tests_hello, tptest_sighandler); +} + +int init_int_handler (void ) +{ +int result; +struct sigaction act; + +memset (&act,0 ,sizeof (act)); + result =sigemptyset (&act.sa_mask); +if (result ==-1 ) { +perror ("sigemptyset" ); +return -1 ; + } + + act.sa_handler = inthandler; + act.sa_flags =SA_RESTART ; + +/* Only defer ourselves. Also, try to restart interrupted +* syscalls to disturb the traced program as little as possible. +*/ + result =sigaction (SIGUSR1 , &act,NULL ); +if (result ==-1 ) { +perror ("sigaction" ); +return -1 ; + } + +return 0 ; +} + +int main (int argc,char **argv) +{ +int i, netint; +long values[] = {1 ,2 ,3 }; +char text[10 ] ="test" ; +double dbl =2.0 ; +float flt =2222.0 ; +int delay =0 ; + +init_int_handler (); + +if (argc ==2 ) + delay =atoi (argv[1 ]); + +fprintf (stderr,"Hello, World!\n" ); + +sleep (delay); + +fprintf (stderr,"Tracing... " ); +for (i =0 ; i <1000000 ; i++) { + netint =htonl (i); +tracepoint (ust_tests_hello, tptest, i, netint, values, + text,strlen (text), dbl, flt); + } +fprintf (stderr," done.\n" ); +return 0 ; +}doc/examples/hello-static-lib/tp.c new file +26
-0@@ -0,0 +1,26 @@ +/* +* tp.c +* +* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_hello.h" doc/examples/hello-static-lib/ust_tests_hello.h new file +72
-0@@ -0,0 +1,72 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_hello + +#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_HELLO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include <lttng/tracepoint.h> + +TRACEPOINT_EVENT(ust_tests_hello, tptest, + TP_ARGS(int, anint, int, netint, long *, values, + char *, text, size_t, textlen, + double, doublearg, float, floatarg), + TP_FIELDS( + ctf_integer(int, intfield, anint) + ctf_integer_hex(int, intfield2, anint) + ctf_integer(long, longfield, anint) + ctf_integer_network(int, netintfield, netint) + ctf_integer_network_hex(int, netintfieldhex, netint) + ctf_array(long, arrfield1, values, 3) + ctf_array_text(char, arrfield2, text, 10) + ctf_sequence(char, seqfield1, text, + size_t, textlen) + ctf_sequence_text(char, seqfield2, text, + size_t, textlen) + ctf_string(stringfield, text) + ctf_float(float, floatfield, floatarg) + ctf_float(double, doublefield, doublearg) + ) +) + +TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, + TP_ARGS(), + TP_FIELDS() +) + +#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" + +/* This part must be outside ifdef protection */ +#include <lttng/tracepoint-event.h> + +#ifdef __cplusplus +} +#endifdoc/man/lttng-ust.3 +33
-31@@ -40,11 +40,11 @@ focus on the various types that can be recorded into a trace event: TRACEPOINT_EVENT( /* * provider name, not a variable but a string starting with a - * letter and containing either letters, numbers or underscores. + * letter and containing either letters, numbers or underscores. * Needs to be the same as TRACEPOINT_PROVIDER. Needs to * follow the namespacing guide-lines in lttng/tracepoint.h: - * - * Must be included before include tracepoint provider + * + * Must be included before include tracepoint provider * ex.: project_event * ex.: project_component_event *@@ -59,19 +59,19 @@ TRACEPOINT_EVENT( /* * tracepoint name, same format as sample provider. Does not * need to be declared before. in this case the name is - * "message" + * "message" */ message, /* - * TP_ARGS macro contains the arguments passed for the tracepoint + * TP_ARGS macro contains the arguments passed for the tracepoint * it is in the following format * TP_ARGS(type1, name1, type2, name2, ... type10, name10) - * where there can be from zero to ten elements. - * typeN is the datatype, such as int, struct or double **. + * where there can be from zero to ten elements. + * typeN is the datatype, such as int, struct or double **. * name is the variable name (in "int myInt" the name would be - * myint) + * myint) * TP_ARGS() is valid to mean no arguments * TP_ARGS(void) is valid too */@@ -80,7 +80,7 @@ TRACEPOINT_EVENT( double, doublearg, float, floatarg), /* - * TP_FIELDS describes how to write the fields of the trace event. + * TP_FIELDS describes how to write the fields of the trace event. * You can put expressions in the "argument expression" area, * typically using the input arguments from TP_ARGS. */@@ -109,14 +109,14 @@ TRACEPOINT_EVENT( /* * ctf_array: a statically-sized array. * args: (type, field name, argument expression, value) - */ + */ ctf_array(long, arrfield1, values, 3) /* * ctf_array_text: a statically-sized array, printed as * a string. No need to be terminated by a null * character. - */ + */ ctf_array_text(char, arrfield2, text, 10) /*@@ -127,7 +127,7 @@ TRACEPOINT_EVENT( * unsigned type. As a reminder, "unsigned char" should * be preferred to "char", since the signedness of * "char" is implementation-defined. - */ + */ ctf_sequence(char, seqfield1, text, size_t, textlen)@@ -172,54 +172,54 @@ declared before declaring a TRACEPOINT_LOGLEVEL. The loglevels go from 0 to 14. Higher numbers imply the most verbosity (higher event throughput expected. - + Loglevels 0 through 6, and loglevel 14, match syslog(3) loglevels semantic. Loglevels 7 through 13 offer more fine-grained selection of debug information. - + TRACE_EMERG 0 system is unusable - + TRACE_ALERT 1 action must be taken immediately - + TRACE_CRIT 2 critical conditions - + TRACE_ERR 3 error conditions - + TRACE_WARNING 4 warning conditions - + TRACE_NOTICE 5 normal, but significant, condition - + TRACE_INFO 6 informational message - + TRACE_DEBUG_SYSTEM 7 debug information with system-level scope (set of programs) - + TRACE_DEBUG_PROGRAM 8 debug information with program-level scope (set of processes) - + TRACE_DEBUG_PROCESS 9 debug information with process-level scope (set of modules) - + TRACE_DEBUG_MODULE 10 debug information with module (executable/library) scope (set of units) - + TRACE_DEBUG_UNIT 11 debug information with compilation unit scope (set of functions) - + TRACE_DEBUG_FUNCTION 12 debug information with function-level scope - + TRACE_DEBUG_LINE 13 debug information with line-level scope (TRACEPOINT_EVENT default) - + TRACE_DEBUG 14 debug-level message (trace_printf default)@@ -268,8 +268,10 @@ carefully: library with "\-llttng-ust". - Include the tracepoint provider header into all C files using the provider. - - Example: - - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example + - Examples: + - doc/examples/easy-ust/ sample.c sample_component_provider.h tp.c + Makefile + - doc/examples/hello-static-lib/ hello.c tp.c ust_test_hello.h Makefile 2) Compile the Tracepoint Provider separately from the application, using dynamic linking:@@ -287,7 +289,7 @@ carefully: needed. Another way is to dlopen the tracepoint probe when needed by the application. - Example: - - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace + - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace Makefile - Note about dlclose() usage: it is not safe to use dlclose on a provider shared object that is being actively used for tracing duetests/Makefile.am +1
-1@@ -1,4 +1,4 @@ -SUBDIRS = . hello hello-static-lib same_line_tracepoint snprintf +SUBDIRS = . hello same_line_tracepoint snprintf if CXX_WORKS SUBDIRS += hello.cxxtests/demo/README +1
-5@@ -1,5 +1 @@ -"demo" and "demo-trace" are moved to lttng-tools, under: - - tests/regression/ust/linking/ - -The "demo-trace" script was renamed to "demo_preload". +"demo" and "demo-trace" are moved to doc/examples/demotests/hello-static-lib/Makefile.am deleted +0
-18@@ -1,18 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers - -noinst_LTLIBRARIES = liblttng-ust-provider-ust-test-hello.la -liblttng_ust_provider_ust_test_hello_la_SOURCES = \ - tp.c ust_tests_hello.h -liblttng_ust_provider_ust_test_hello_la_LIBADD = \ - $(top_builddir)/liblttng-ust/liblttng-ust.la - -noinst_PROGRAMS = hello -hello_SOURCES = hello.c -hello_LDADD = liblttng-ust-provider-ust-test-hello.la - -if LTTNG_UST_BUILD_WITH_LIBDL -hello_LDADD += -ldl -endif -if LTTNG_UST_BUILD_WITH_LIBC_DL -hello_LDADD += -lc -endiftests/hello-static-lib/README deleted +0
-3@@ -1,3 +0,0 @@ -This is a "hello world" application used to verify that an instrumented -program can be built successfully and linked with tracepoint providers -built as a separate static library.tests/hello-static-lib/hello.c deleted +0
-95@@ -1,95 +0,0 @@ -/* -* Copyright (C) 2009 Pierre-Marc Fournier -* Copyright (C) 2011 Mathieu Desnoyers <[email protected]> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; version 2.1 of -* the License. -* -* This library 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 -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include <stdio.h> -#include <unistd.h> -#include <sys/mman.h> -#include <stdarg.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <arpa/inet.h> -#include <stdlib.h> - -#define TRACEPOINT_DEFINE -#include "ust_tests_hello.h" - -void inthandler (int sig) -{ -printf ("in SIGUSR1 handler\n" ); -tracepoint (ust_tests_hello, tptest_sighandler); -} - -int init_int_handler (void ) -{ -int result; -struct sigaction act; - -memset (&act,0 ,sizeof (act)); - result =sigemptyset (&act.sa_mask); -if (result ==-1 ) { -perror ("sigemptyset" ); -return -1 ; - } - - act.sa_handler = inthandler; - act.sa_flags =SA_RESTART ; - -/* Only defer ourselves. Also, try to restart interrupted -* syscalls to disturb the traced program as little as possible. -*/ - result =sigaction (SIGUSR1 , &act,NULL ); -if (result ==-1 ) { -perror ("sigaction" ); -return -1 ; - } - -return 0 ; -} - -int main (int argc,char **argv) -{ -int i, netint; -long values[] = {1 ,2 ,3 }; -char text[10 ] ="test" ; -double dbl =2.0 ; -float flt =2222.0 ; -int delay =0 ; - -init_int_handler (); - -if (argc ==2 ) - delay =atoi (argv[1 ]); - -fprintf (stderr,"Hello, World!\n" ); - -sleep (delay); - -fprintf (stderr,"Tracing... " ); -for (i =0 ; i <1000000 ; i++) { - netint =htonl (i); -tracepoint (ust_tests_hello, tptest, i, netint, values, - text,strlen (text), dbl, flt); -//usleep(100000); - } -fprintf (stderr," done.\n" ); -return 0 ; -}tests/hello-static-lib/tp.c deleted +0
-26@@ -1,26 +0,0 @@ -/* -* tp.c -* -* Copyright (c) 2011 Mathieu Desnoyers <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#define TRACEPOINT_CREATE_PROBES -#include "ust_tests_hello.h" tests/hello-static-lib/ust_tests_hello.h deleted +0
-72@@ -1,72 +0,0 @@ -#undef TRACEPOINT_PROVIDER -#define TRACEPOINT_PROVIDER ust_tests_hello - -#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) -#define _TRACEPOINT_UST_TESTS_HELLO_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Copyright (C) 2011 Mathieu Desnoyers <[email protected]> - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <lttng/tracepoint.h> - -TRACEPOINT_EVENT(ust_tests_hello, tptest, - TP_ARGS(int, anint, int, netint, long *, values, - char *, text, size_t, textlen, - double, doublearg, float, floatarg), - TP_FIELDS( - ctf_integer(int, intfield, anint) - ctf_integer_hex(int, intfield2, anint) - ctf_integer(long, longfield, anint) - ctf_integer_network(int, netintfield, netint) - ctf_integer_network_hex(int, netintfieldhex, netint) - ctf_array(long, arrfield1, values, 3) - ctf_array_text(char, arrfield2, text, 10) - ctf_sequence(char, seqfield1, text, - size_t, textlen) - ctf_sequence_text(char, seqfield2, text, - size_t, textlen) - ctf_string(stringfield, text) - ctf_float(float, floatfield, floatarg) - ctf_float(double, doublefield, doublearg) - ) -) - -TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler, - TP_ARGS(), - TP_FIELDS() -) - -#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */ - -#undef TRACEPOINT_INCLUDE -#define TRACEPOINT_INCLUDE "./ust_tests_hello.h" - -/* This part must be outside ifdef protection */ -#include <lttng/tracepoint-event.h> - -#ifdef __cplusplus -} -#endifSignature · 7 lines
1.8.2.1 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com