2
* Copyright (C) 2010 Nils Carlson
3
* Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
#include <sys/types.h>
30
#include <ust/marker.h>
33
#define TRACEPOINT_CREATE_PROBES
36
struct hello_trace_struct {
40
struct hello_trace_struct hello_struct = {
44
void tptest_probe(void *data, int anint)
46
struct hello_trace_struct *hello;
48
hello = (struct hello_trace_struct *)data;
49
//printf("this is the message: %s\n", hello->message);
50
snprintf(message, 30, "this is the %s\n", hello->message);
54
#define HELLO_LENGTH 100
56
static void *register_thread_main(void *data)
59
struct hello_trace_struct hello[HELLO_LENGTH];
61
for (i = 0; i < HELLO_LENGTH; i++) {
62
hello[i].message = malloc(6 * sizeof(char));
63
hello[i].message[0] = 'a' + (i % 25);
64
memcpy(&hello[i].message[1], "ello", 5);
67
for (i = 0; i < 1000; i++) {
68
while (!__register_tracepoint(hello_tptest, tptest_probe,
69
&hello[j % HELLO_LENGTH])) {
73
printf("Registered all\n");
74
while (!__unregister_tracepoint(hello_tptest, tptest_probe,
75
&hello[j % HELLO_LENGTH])) {
79
printf("Unregistered all\n");
85
int main(int argc, char **argv)
87
pthread_t register_thread;
90
pthread_create(®ister_thread, NULL, register_thread_main, NULL);
91
for(i = 0; i < 1000000; i++) {
92
tracepoint(hello_tptest, i);