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* trace_mark :
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 trace_mark_tp(ust
, event2
, ust_event2
, tp_probe4
, "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
;
63 trace_mark_tp(ust
, event_msg
, ust_event_msg
,
64 tp_probe3
, "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 trace_mark_tp(ust
, event
, ust_event
, tp_probe2
, "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 trace_mark_tp(ust
, event
, ust_event
, tp_probe
, "probe %u", p1
);
91 static void __attribute__((constructor
)) init()
93 register_trace_ust_event(tp_probe
, NULL
);
94 register_trace_ust_event(tp_probe2
, NULL
);
95 register_trace_ust_event(tp_probe3
, &msg_probe3
);
96 register_trace_ust_event2(tp_probe4
, NULL
);
99 int main(int argc
, char **argv
) {
101 /* Tracepoint 1 : ust_event */
103 /* Tracepoint 2 : ust_event2 */
This page took 0.030611 seconds and 4 git commands to generate.