#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include "../libmarkers/marker.h"
#include "usterr.h"
#include "tracer.h"
+#include "marker-control.h"
+#include "relay.h"
+
+
void probe(const struct marker *mdata,
void *probe_private, void *call_private,
printf("In probe\n");
}
-//ust// void try_map()
-//ust// {
-//ust// char *m;
-//ust//
-//ust// /* maybe add MAP_LOCKED */
-//ust// m = mmap(NULL, 4096, PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE , -1, 0);
-//ust// if(m == (char*)-1) {
-//ust// perror("mmap");
-//ust// return;
-//ust// }
-//ust//
-//ust// printf("The mapping is at %p.\n", m);
-//ust// strcpy(m, "Hello, Mapping!");
-//ust// }
+void inthandler(int sig)
+{
+ printf("in handler\n");
+ exit(0);
+}
-int main()
+int init_int_handler(void)
{
int result;
+ struct sigaction act;
- init_ustrelay_transport();
-
- char trace_name[] = "theusttrace";
- char trace_type[] = "usttrace";
+ result = sigemptyset(&act.sa_mask);
+ if(result == -1) {
+ PERROR("sigemptyset");
+ return -1;
+ }
- marker_probe_register("abc", "testmark", "", probe, NULL);
- 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);
+ act.sa_handler = inthandler;
+ act.sa_flags = SA_RESTART;
- result = ltt_trace_setup(trace_name);
- if(result < 0) {
- ERR("ltt_trace_setup failed");
- return 1;
+ /* Only defer ourselves. Also, try to restart interrupted
+ * syscalls to disturb the traced program as little as possible.
+ */
+ result = sigaction(SIGINT, &act, NULL);
+ if(result == -1) {
+ PERROR("sigaction");
+ return -1;
}
-//ust// result = ltt_trace_set_type(trace_name, trace_type);
-//ust// if(result < 0) {
-//ust// ERR("ltt_trace_set_type failed");
-//ust// return 1;
-//ust// }
+ return 0;
+}
- result = ltt_trace_alloc(trace_name);
- if(result < 0) {
- ERR("ltt_trace_alloc failed");
- return 1;
- }
+int main()
+{
+ int result;
+ int i;
-// try_map();
+ init_int_handler();
printf("Hello, World!\n");
-
- trace_mark(abc, testmark, "", MARK_NOARGS);
+ sleep(1);
+ for(i=0; i<5000; i++) {
+ trace_mark(ust, bar, "str %s", "FOOBAZ");
+ trace_mark(ust, bar2, "number1 %d number2 %d", 53, 9800);
+ usleep(100000);
+ }
scanf("%*s");
return 0;
}
+
+MARKER_LIB