Add demo test back as an example
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mathieu Desnoyers
AppliedQuoted 2 lines · * Jérémie Galarneau ([email protected]) wrote:
Updated the lttng-ust man page to point to doc/examples/demo instead of the now moved /tests/demo.
Merged, thanks! I added demo to doc/examples/Makefile.am too.
Moreover, do we need "hello" under tests ? Why not move it under doc/examples ?
Also, we'd need to add capability to build examples within the tree from automake. e.g.
make examples
from lttng-ust root. (or with just a simple "make" or "make check" maybe ?)
Thanks,
Mathieu
Quoted 528 lines
Minor typo fix.
Signed-off-by Jérémie Galarneau <[email protected]>--- doc/examples/demo/Makefile | 42 ++++++++++++++++++++++ doc/examples/demo/README | 27 ++++++++++++++ doc/examples/demo/demo-trace | 6 ++++ doc/examples/demo/demo.c | 65 +++++++++++++++++++++++++++++++++ doc/examples/demo/tp.c | 26 ++++++++++++++ doc/examples/demo/tp2.c | 26 ++++++++++++++ doc/examples/demo/tp3.c | 26 ++++++++++++++ doc/examples/demo/ust_tests_demo.h | 71 +++++++++++++++++++++++++++++++++++++ doc/examples/demo/ust_tests_demo2.h | 68 +++++++++++++++++++++++++++++++++++ doc/examples/demo/ust_tests_demo3.h | 53 +++++++++++++++++++++++++++ doc/man/lttng-ust.3 | 4 +-- 11 files changed, 412 insertions(+), 2 deletions(-) create mode 100644 doc/examples/demo/Makefile create mode 100644 doc/examples/demo/README create mode 100755 doc/examples/demo/demo-trace create mode 100644 doc/examples/demo/demo.c create mode 100644 doc/examples/demo/tp.c create mode 100644 doc/examples/demo/tp2.c create mode 100644 doc/examples/demo/tp3.c create mode 100644 doc/examples/demo/ust_tests_demo.h create mode 100644 doc/examples/demo/ust_tests_demo2.h create mode 100644 doc/examples/demo/ust_tests_demo3.hdoc/examples/demo/Makefile new file +42
-0@@ -0,0 +1,42 @@ +# 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 people may see how to build +# a program and tracepoint provider probes as stand-alone shared objects. + +CC = gcc +LIBS = -ldl # On Linux +#LIBS = -lc # On BSD +CFLAGS = -I. + +all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so + +lttng-ust-provider-ust-tests-demo.o: tp.c tp2.c ust_tests_demo.h ust_tests_demo2.h + $(CC) $(CFLAGS) -fpic -c -o $@ $< + +lttng-ust-provider-ust-tests-demo.so: lttng-ust-provider-ust-tests-demo.o + $(CC) -shared -o $@ -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 $< + +demo.o: demo.c + $(CC) $(CFLAGS) -c -o $@ $< + +demo: demo.o + $(CC) demo.o -o $@ $(LIBS) + +.PHONY: clean +clean: + rm -f *.o *.so demodoc/examples/demo/README new file +27
-0@@ -0,0 +1,27 @@ +This is a demo application used to test the LTTng userspace tracer. + +demo-trace shell script preloads the provider shared objects before +executing the demo. Executing "demo" without the shell wrapper will not +provide any tracing support. This ensures the demo binary can be +distributed on distros without depending on having liblttng-ust.so in +place. Note: the "demo" program must be compiled with "-ldl" on Linux, +with "-lc" on BSD. + +The simplest command to trace the demo program are: +lttng create +lttng enable-event -u -a +lttng start +./demo-trace +lttng destroy + +That will create a trace in your $HOME/lttng-traces directory. + +The resulting babeltrace output should look like this: +[554297567999315] ust_tests_demo:starting: { 1 }, { value = 123 } +[554297568020834] ust_tests_demo2:loop: { 1 }, { intfield = 0, intfield2 = 0x0, longfield = 0, netintfield = 0, netintfieldhex = 0x0, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } +[554297568024780] ust_tests_demo2:loop: { 1 }, { intfield = 1, intfield2 = 0x1, longfield = 1, netintfield = 1, netintfieldhex = 0x1, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } +[554297568027050] ust_tests_demo2:loop: { 1 }, { intfield = 2, intfield2 = 0x2, longfield = 2, netintfield = 2, netintfieldhex = 0x2, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } +[554297568029014] ust_tests_demo2:loop: { 1 }, { intfield = 3, intfield2 = 0x3, longfield = 3, netintfield = 3, netintfieldhex = 0x3, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } +[554297568030861] ust_tests_demo2:loop: { 1 }, { intfield = 4, intfield2 = 0x4, longfield = 4, netintfield = 4, netintfieldhex = 0x4, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } +[554297568033138] ust_tests_demo:done: { 1 }, { value = 456 } +[554297568034533] ust_tests_demo3:done: { 1 }, { value = 42 }doc/examples/demo/demo-trace new file +6
-0@@ -0,0 +1,6 @@ +#!/bin/sh + +DIR=$(dirname $0) +DIR=$(readlink -f $DIR) + +LD_PRELOAD=$DIR/lttng-ust-provider-ust-tests-demo.so:$DIR/lttng-ust-provider-ust-tests-demo3.so $DIR/demo ${*}doc/examples/demo/demo.c new file +65
-0@@ -0,0 +1,65 @@ +/* +* 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 +#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE +#include "ust_tests_demo.h" +#include "ust_tests_demo2.h" +#include "ust_tests_demo3.h" + +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 ; + +if (argc ==2 ) + delay =atoi (argv[1 ]); + +fprintf (stderr,"Demo program starting.\n" ); + +sleep (delay); + +fprintf (stderr,"Tracing... " ); +tracepoint (ust_tests_demo, starting,123 ); +for (i =0 ; i <5 ; i++) { + netint =htonl (i); +tracepoint (ust_tests_demo2, loop, i, netint, values, + text,strlen (text), dbl, flt); + } +tracepoint (ust_tests_demo, done,456 ); +tracepoint (ust_tests_demo3, done,42 ); +fprintf (stderr," done.\n" ); +return 0 ; +}doc/examples/demo/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_demo.h" doc/examples/demo/tp2.c new file +26
-0@@ -0,0 +1,26 @@ +/* +* tp2.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_demo2.h" doc/examples/demo/tp3.c new file +26
-0@@ -0,0 +1,26 @@ +/* +* tp3.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_demo3.h" doc/examples/demo/ust_tests_demo.h new file +71
-0@@ -0,0 +1,71 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO_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_demo, starting, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo, starting, TRACE_CRIT) + +/* + * Dummy model information, just for example. TODO: we should check if + * EMF model URI have some standard format we should follow. + */ +TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, starting, + "http://example.com/path_to_model?q=ust_tests_demo:starting") + +TRACEPOINT_EVENT(ust_tests_demo, done, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo, done, TRACE_CRIT) + +TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, done, + "http://example.com/path_to_model?q=ust_tests_demo:done") + +#endif /* _TRACEPOINT_UST_TESTS_DEMO_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_demo.h" + +/* This part must be outside ifdef protection */ +#include <lttng/tracepoint-event.h> + +#ifdef __cplusplus +} +#endifdoc/examples/demo/ust_tests_demo2.h new file +68
-0@@ -0,0 +1,68 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo2 + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO2_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO2_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_demo2, loop, + 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_LOGLEVEL(ust_tests_demo2, loop, TRACE_WARNING) + +#endif /* _TRACEPOINT_UST_TESTS_DEMO2_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_demo2.h" + +/* This part must be outside ifdef protection */ +#include <lttng/tracepoint-event.h> + +#ifdef __cplusplus +} +#endifdoc/examples/demo/ust_tests_demo3.h new file +53
-0@@ -0,0 +1,53 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo3 + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO3_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO3_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_demo3, done, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo3, done, TRACE_WARNING) + +#endif /* _TRACEPOINT_UST_TESTS_DEMO3_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_demo3.h" + +/* This part must be outside ifdef protection */ +#include <lttng/tracepoint-event.h> + +#ifdef __cplusplus +} +#endifdoc/man/lttng-ust.3 +2
-2@@ -283,7 +283,7 @@ carefully: 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 - Note about dlclose() usage: it is not safe to use dlclose on a provider shared object that is being actively used for tracing due@@ -365,7 +365,7 @@ lttng-gen-tp(1), lttng(1), babeltrace(1), lttng-sessiond(8) .SH "BUGS" .PP -No knows bugs at this point. +No known bugs at this point. If you encounter any issues or usability problem, please report it on our mailing list <[email protected]> to help improve thisSignature · 7 lines
1.8.2 _______________________________________________ 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