88cb3792f4529aec3e04f98cf482c39761d77930
1 /* Copyright (C) 2010 David Goulet <david.goulet@polymtl.ca>
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * This test is aimed at testing tracepoint *with* ust_marker :
21 * 1) tracepoint named : "ust_event"
22 * -) Probe 1 registered and recording the value 13 (x5)
23 * -) Probe 2 registered and recording the value 42 (x5)
24 * -) Probe 3 registered and recording the payload of the struct message
25 * but using a *different* tracepoint (event_msg)
27 * 2) tracepoint named : "ust_event2"
28 * -) Probe 4 registered and recording the value 42 (x100)
32 #include <ust/marker.h>
33 #include "tracepoint_test.h"
35 DEFINE_TRACE(ust_event
);
36 DEFINE_TRACE(ust_event2
);
38 static struct message msg_probe3
= {
43 * Probe 4 --> ust_event2
44 * Will record 100 times the value 42
46 void tp_probe4(void *data
, unsigned int p4
)
49 for (i
= 0; i
< 100; i
++) {
50 ust_marker(event2
, "probe4 %u", p4
);
55 * Probe 3 --> ust_event *and* event_msg (from inside)
56 * Will record the payload of msg_prob3 struct
57 * from the data pointer of the probe
59 void tp_probe3(void *data
, unsigned int p3
)
62 msg
= (struct message
*) data
;
64 "probe %s", msg
->payload
);
68 * Probe 2 --> ust_event
69 * Will record 5 times the number 13
71 void tp_probe2(void *data
, unsigned int p2
)
74 for (i
= 0; i
< 5; i
++) {
75 ust_marker(event
, "probe %u", 13);
80 * Probe 1 --> ust_event
81 * Will record 5 times the unsigned int v = 42
83 void tp_probe(void *data
, unsigned int p1
)
86 for (i
= 0; i
< 5; i
++) {
87 ust_marker(event
, "probe %u", p1
);
91 static void __attribute__((constructor
)) init()
93 __register_tracepoint(ust_event
, tp_probe
, NULL
);
94 __register_tracepoint(ust_event
, tp_probe2
, NULL
);
95 __register_tracepoint(ust_event
, tp_probe3
, &msg_probe3
);
96 __register_tracepoint(ust_event2
, tp_probe4
, NULL
);
99 int main(int argc
, char **argv
) {
101 /* Tracepoint 1 : ust_event */
102 tracepoint(ust_event
, v
);
103 /* Tracepoint 2 : ust_event2 */
104 tracepoint(ust_event2
, v
);
This page took 0.033432 seconds and 5 git commands to generate.