char consumer_stack[10000];
-char trace_name[] = "theusttrace";
-char trace_type[] = "ustrelay";
#define CPRINTF(fmt, args...) safe_printf(fmt "\n", ## args)
struct ltt_trace_struct *trace;
struct consumer_channel *consumer_channels;
int i;
+ char trace_name[] = "auto";
ltt_lock_traces();
trace = _ltt_trace_find(trace_name);
init_int_handler();
- result = ltt_marker_connect("foo", "bar", "default");
- if(result)
- ERR("ltt_marker_connect");
-
- result = ltt_trace_setup(trace_name);
- if(result < 0) {
- ERR("ltt_trace_setup failed");
- return 1;
- }
-
- result = ltt_trace_set_type(trace_name, trace_type);
- if(result < 0) {
- ERR("ltt_trace_set_type failed");
- return 1;
- }
-
- result = ltt_trace_alloc(trace_name);
- if(result < 0) {
- ERR("ltt_trace_alloc failed");
- return 1;
- }
-
- result = ltt_trace_start(trace_name);
- if(result < 0) {
- ERR("ltt_trace_start failed");
- return 1;
- }
-
start_consumer();
printf("Hello, World!\n");
usleep(100000);
}
- ltt_trace_stop(trace_name);
- ltt_trace_destroy(trace_name);
+ ltt_trace_stop("auto");
+ ltt_trace_destroy("auto");
scanf("%*s");
}
}
-int __attribute__((constructor)) marker_control_init(void)
+static char initialized = 0;
+
+void __attribute__((constructor)) init_marker_control(void)
{
- int ret;
+ if(!initialized) {
+ int ret;
//ust// pentry = create_proc_entry("ltt", S_IRUSR|S_IWUSR, NULL);
//ust// if (!pentry)
//ust// return -EBUSY;
//ust// markers_loaded_cachep = KMEM_CACHE(ltt_active_marker, 0);
- ret = ltt_probe_register(&default_probe);
- BUG_ON(ret);
- ret = ltt_marker_connect("metadata", "core_marker_format",
- DEFAULT_PROBE);
- BUG_ON(ret);
- ret = ltt_marker_connect("metadata", "core_marker_id", DEFAULT_PROBE);
- BUG_ON(ret);
+ ret = ltt_probe_register(&default_probe);
+ BUG_ON(ret);
+ ret = ltt_marker_connect("metadata", "core_marker_format",
+ DEFAULT_PROBE);
+ BUG_ON(ret);
+ ret = ltt_marker_connect("metadata", "core_marker_id", DEFAULT_PROBE);
+ BUG_ON(ret);
//ust// pentry->proc_fops = <t_fops;
+ initialized = 1;
+ }
+
return 0;
}
//ust// module_init(marker_control_init);
/*
* ignore error, continue
*/
+
+ /* This is added for UST. We emit a core_marker_id event
+ * for markers that are already registered to a probe
+ * upon library load. Otherwise, no core_marker_id will
+ * be generated for these markers. Is this the right thing
+ * to do?
+ */
+ trace_mark(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",
+ iter->channel, iter->name, mark_entry->event_id,
+ sizeof(int), sizeof(long), sizeof(void *),
+ sizeof(size_t), ltt_get_alignment());
} else {
disable_marker(iter);
}
list_add(&pl->list, &libs);
+ /* FIXME: update just the loaded lib */
+ lib_update_markers();
+
printf("just registered a markers section from %p and having %d markers\n", markers_start, markers_count);
return 0;
}
-static void __attribute__((constructor)) __markers__init(void)
+static int initialized = 0;
+
+void __attribute__((constructor)) init_markers(void)
{
- marker_register_lib(__start___markers, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker));
- printf("markers_start: %p, markers_stop: %p\n", __start___markers, __stop___markers);
+ if(!initialized) {
+ marker_register_lib(__start___markers, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker));
+ printf("markers_start: %p, markers_stop: %p\n", __start___markers, __stop___markers);
+ initialized = 1;
+ }
}
mypid = getpid();
+ if(getenv("UST_TRACE")) {
+ char trace_name[] = "auto";
+ char trace_type[] = "ustrelay";
+
+ DBG("starting early tracing");
+
+ /* Ensure marker control is initialized */
+ init_marker_control();
+
+ /* Ensure relay is initialized */
+ init_ustrelay_transport();
+
+ /* Ensure markers are initialized */
+ init_markers();
+
+ result = ltt_marker_connect("foo", "bar", "default");
+ if(result)
+ ERR("ltt_marker_connect");
+
+ result = ltt_trace_setup(trace_name);
+ if(result < 0) {
+ ERR("ltt_trace_setup failed");
+ return;
+ }
+
+ result = ltt_trace_set_type(trace_name, trace_type);
+ if(result < 0) {
+ ERR("ltt_trace_set_type failed");
+ return;
+ }
+
+ result = ltt_trace_alloc(trace_name);
+ if(result < 0) {
+ ERR("ltt_trace_alloc failed");
+ return;
+ }
+
+ result = ltt_trace_start(trace_name);
+ if(result < 0) {
+ ERR("ltt_trace_start failed");
+ return;
+ }
+ }
+
/* Must create socket before signal handler to prevent races
* on pfd variable.
*/
//ust// return 0;
//ust// }
+static char initialized = 0;
+
void __attribute__((constructor)) init_ustrelay_transport(void)
{
- ltt_transport_register(&ust_relay_transport);
+ if(!initialized) {
+ ltt_transport_register(&ust_relay_transport);
+ initialized = 1;
+ }
}
static void __exit ltt_relay_exit(void)