5 #include "../libmarkers/marker.h"
9 void probe(const struct marker
*mdata
,
10 void *probe_private
, void *call_private
,
11 const char *fmt
, va_list *args
)
16 //ust// void try_map()
20 //ust// /* maybe add MAP_LOCKED */
21 //ust// m = mmap(NULL, 4096, PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE , -1, 0);
22 //ust// if(m == (char*)-1) {
23 //ust// perror("mmap");
27 //ust// printf("The mapping is at %p.\n", m);
28 //ust// strcpy(m, "Hello, Mapping!");
31 //sig_atomic_t must_quit;
33 void inthandler(int sig
)
35 printf("in handler\n");
39 int init_int_handler(void)
44 result
= sigemptyset(&act
.sa_mask
);
46 PERROR("sigemptyset");
50 act
.sa_handler
= inthandler
;
51 act
.sa_flags
= SA_RESTART
;
53 /* Only defer ourselves. Also, try to restart interrupted
54 * syscalls to disturb the traced program as little as possible.
56 result
= sigaction(SIGINT
, &act
, NULL
);
65 DEFINE_MUTEX(probes_mutex
);
67 static LIST_HEAD(probes_registered_list
);
69 int ltt_marker_connect(const char *channel
, const char *mname
,
74 struct ltt_active_marker
*pdata
;
75 struct ltt_available_probe
*probe
;
78 mutex_lock(&probes_mutex
);
79 probe
= get_probe_from_name(pname
);
84 pdata
= marker_get_private_data(channel
, mname
, probe
->probe_func
, 0);
85 if (pdata
&& !IS_ERR(pdata
)) {
89 pdata
= kmem_cache_zalloc(markers_loaded_cachep
, GFP_KERNEL
);
96 * ID has priority over channel in case of conflict.
98 ret
= marker_probe_register(channel
, mname
, NULL
,
99 probe
->probe_func
, pdata
);
101 kmem_cache_free(markers_loaded_cachep
, pdata
);
103 list_add(&pdata
->node
, &markers_loaded_list
);
105 mutex_unlock(&probes_mutex
);
111 int ltt_probe_register(struct ltt_available_probe
*pdata
)
115 struct ltt_available_probe
*iter
;
117 mutex_lock(&probes_mutex
);
118 list_for_each_entry_reverse(iter
, &probes_registered_list
, node
) {
119 comparison
= strcmp(pdata
->name
, iter
->name
);
123 } else if (comparison
> 0) {
124 /* We belong to the location right after iter. */
125 list_add(&pdata
->node
, &iter
->node
);
129 /* Should be added at the head of the list */
130 list_add(&pdata
->node
, &probes_registered_list
);
132 mutex_unlock(&probes_mutex
);
137 struct ltt_available_probe default_probe
= {
140 .probe_func
= ltt_vtrace
,
141 .callbacks
[0] = ltt_serialize_data
,
150 init_ustrelay_transport();
152 printf("page size is %d\n", sysconf(_SC_PAGE_SIZE
));
154 char trace_name
[] = "theusttrace";
155 char trace_type
[] = "ustrelay";
157 marker_probe_register("abc", "testmark", "", probe
, NULL
);
158 marker_probe_register("metadata", "core_marker_id", "channel %s name %s event_id %hu int #1u%zu long #1u%zu pointer #1u%zu size_t #1u%zu alignment #1u%u", probe
, NULL
);
159 result
= ltt_probe_register(&default_probe
);
161 ERR("ltt_probe_register");
163 result
= ltt_marker_connect("abc", "testmark2", "default");
165 ERR("ltt_marker_connect");
168 result
= ltt_trace_setup(trace_name
);
170 ERR("ltt_trace_setup failed");
174 result
= ltt_trace_set_type(trace_name
, trace_type
);
176 ERR("ltt_trace_set_type failed");
180 result
= ltt_trace_alloc(trace_name
);
182 ERR("ltt_trace_alloc failed");
186 result
= ltt_trace_start(trace_name
);
188 ERR("ltt_trace_start failed");
193 printf("Hello, World!\n");
196 trace_mark(abc
, testmark
, "", MARK_NOARGS
);
197 trace_mark(abc
, testmark2
, "", MARK_NOARGS
);