sleep(1);
for(i=0; i<50; i++) {
- trace_mark(foo, bar, "%s", "FOOBAZ");
+ trace_mark(foo, bar, "str %s", "FOOBAZ");
+ trace_mark(foo, bar2, "number1 %d number2 %d", 53, 9800);
usleep(100000);
}
- ltt_trace_stop("auto");
- ltt_trace_destroy("auto");
-
scanf("%*s");
return 0;
uint32_t size;
struct sockaddr_un addr;
socklen_t addrlen = sizeof(addr);
+ char trace_name[] = "auto";
+ char trace_type[] = "ustrelay";
for(;;) {
struct trctl_msg msg;
continue;
}
- if(recvbuf[len-2] == '\n')
- recvbuf[len-2] = '\0';
+ if(recvbuf[len-1] == '\n')
+ recvbuf[len-1] = '\0';
fprintf(stderr, "received a message! it's: %s\n", recvbuf);
}
else if(!strcmp(recvbuf, "trace_setup")) {
DBG("trace setup");
+
+ 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;
+ }
}
else if(!strcmp(recvbuf, "trace_alloc")) {
DBG("trace alloc");
+
+ result = ltt_trace_alloc(trace_name);
+ if(result < 0) {
+ ERR("ltt_trace_alloc failed");
+ return;
+ }
}
else if(!strcmp(recvbuf, "trace_start")) {
DBG("trace start");
+
+ result = ltt_trace_start(trace_name);
+ if(result < 0) {
+ ERR("ltt_trace_start failed");
+ return;
+ }
}
else if(!strcmp(recvbuf, "trace_stop")) {
DBG("trace stop");
+
+ result = ltt_trace_stop(trace_name);
+ if(result < 0) {
+ ERR("ltt_trace_stop failed");
+ return;
+ }
+ }
+ else if(!strcmp(recvbuf, "trace_destroy")) {
+
+ DBG("trace destroy");
+
+ result = ltt_trace_destroy(trace_name);
+ if(result < 0) {
+ ERR("ltt_trace_destroy failed");
+ return;
+ }
}
}
next_conn:;
if(result)
ERR("ltt_marker_connect");
+ result = ltt_marker_connect("foo", "bar2", "default");
+ if(result)
+ ERR("ltt_marker_connect");
+
result = ltt_trace_setup(trace_name);
if(result < 0) {
ERR("ltt_trace_setup failed");
//ust// #include <linux/splice.h>
//ust// #include <linux/bitops.h>
#include <sys/mman.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
#include "kernelcompat.h"
#include "list.h"
#include "relay.h"
unsigned int n_pages;
struct buf_page *buf_page, *n;
- void *result;
+ void *ptr;
+ int result;
+ int shmid;
*size = PAGE_ALIGN(*size);
- /* Maybe do read-ahead */
- result = mmap(NULL, *size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
- if(result == MAP_FAILED) {
- PERROR("mmap");
+ result = shmid = shmget(getpid(), *size, IPC_CREAT | IPC_EXCL | 0700);
+ if(shmid == -1) {
+ PERROR("shmget");
+ return -1;
+ }
+
+ ptr = shmat(shmid, NULL, 0);
+ if(ptr == (void *) -1) {
+ perror("shmat");
+ goto destroy_shmem;
+ }
+
+ /* Already mark the shared memory for destruction. This will occur only
+ * when all users have detached.
+ */
+ result = shmctl(shmid, IPC_RMID, NULL);
+ if(result == -1) {
+ perror("shmctl");
return -1;
}
- buf->buf_data = result;
+ buf->buf_data = ptr;
buf->buf_size = *size;
return 0;
+
+ destroy_shmem:
+ result = shmctl(shmid, IPC_RMID, NULL);
+ if(result == -1) {
+ perror("shmctl");
+ }
+
+ return -1;
}
/**
return 1;
}
- char buf[] = "print_markers\n";
+ char *buf;
+
+ asprintf(&buf, "%s\n", msg);
signal_process(pid);
- result = sendto(fd, buf, sizeof(buf), 0, (struct sockaddr *)&addr, sizeof(addr));
+ result = sendto(fd, buf, strlen(buf), 0, (struct sockaddr *)&addr, sizeof(addr));
if(result == -1) {
perror("sendto");
return 1;
}
+ free(buf);
+
// result = fd = open(sockfile, O_RDWR);
// if(result == -1 && errno == ENXIO) {
// fprintf(stderr, "signalling process\n");