int num_pairs;
};
-static char *trace_name = NULL;
-static char *channel_name = NULL;
-static int daemon_mode = 0;
-static int append_mode = 0;
-static unsigned long num_threads = 1;
+static char *trace_name = NULL;
+static char *channel_name = NULL;
+static int daemon_mode = 0;
+static int append_mode = 0;
+static unsigned long num_threads = 1;
volatile static int quit_program = 0; /* For signal handler */
+static int dump_flight_only = 0;
+static int dump_normal_only = 0;
/* Args :
*
printf("-d Run in background (daemon).\n");
printf("-a Append to an possibly existing trace.\n");
printf("-N Number of threads to start.\n");
+ printf("-f Dump only flight recorder channels.\n");
+ printf("-n Dump only normal channels.\n");
printf("\n");
}
argn++;
}
break;
+ case 'f':
+ dump_flight_only = 1;
+ break;
+ case 'n':
+ dump_normal_only = 1;
+ break;
default:
printf("Invalid argument '%s'.\n", argv[argn]);
printf("\n");
char path_trace[PATH_MAX];
int path_trace_len;
char *path_trace_ptr;
- int open_ret = 0;
+ int open_ret = 0;
if(channel_dir == NULL) {
perror(subchannel_name);
open_ret = ENOENT;
- goto end;
+ goto end;
}
printf("Creating trace subdirectory %s\n", subtrace_name);
if(ret == -1) {
if(errno != EEXIST) {
perror(subtrace_name);
- open_ret = -1;
+ open_ret = -1;
goto end;
}
}
ret = open_channel_trace_pairs(path_channel, path_trace, fd_pairs);
if(ret < 0) continue;
} else if(S_ISREG(stat_buf.st_mode)) {
+ if(strncmp(entry->d_name, "flight-", sizeof("flight-")-1) != 0) {
+ if(dump_flight_only) {
+ printf("Skipping normal channel %s\n", path_channel);
+ continue;
+ }
+ } else {
+ if(dump_normal_only) {
+ printf("Skipping flight channel %s\n", path_channel);
+ continue;
+ }
+ }
printf("Opening file.\n");
fd_pairs->pair = realloc(fd_pairs->pair,
} else {
printf("File %s exists, cannot open. Try append mode.\n", path_trace);
open_ret = -1;
- goto end;
+ goto end;
}
} else {
if(errno == ENOENT) {
printf("cookie : %u\n", consumed_old);
if(err != 0) {
ret = errno;
- perror("Reserving sub buffer failed (everything is normal)");
+ perror("Reserving sub buffer failed (everything is normal, it is due to concurrency)");
goto get_error;
}
err = ioctl(pair->channel, RELAYFS_PUT_SUBBUF, &consumed_old);
if(err != 0) {
ret = errno;
- if(errno == -EFAULT) {
+ if(errno == EFAULT) {
perror("Error in unreserving sub buffer\n");
- } else if(errno == -EIO) {
+ } else if(errno == EIO) {
perror("Reader has been pushed by the writer, last subbuffer corrupted.");
/* FIXME : we may delete the last written buffer if we wish. */
}
high_prio = 1;
/* it's ok to have an unavailable subbuffer */
ret = read_subbuffer(&fd_pairs->pair[i]);
- if(ret == -EAGAIN) ret = 0;
+ if(ret == EAGAIN) ret = 0;
ret = pthread_mutex_unlock(&fd_pairs->pair[i].mutex);
if(ret)
printf("Normal read on fd %d\n", pollfd[i].fd);
/* it's ok to have an unavailable subbuffer */
ret = read_subbuffer(&fd_pairs->pair[i]);
- if(ret == -EAGAIN) ret = 0;
+ if(ret == EAGAIN) ret = 0;
ret = pthread_mutex_unlock(&fd_pairs->pair[i].mutex);
if(ret)
if(daemon_mode) {
ret = daemon(0, 0);
-
- if(ret == -1) {
- perror("An error occured while daemonizing.");
- exit(-1);
- }
- }
+
+ if(ret == -1) {
+ perror("An error occured while daemonizing.");
+ exit(-1);
+ }
+ }
/* Connect the signal handlers */
act.sa_handler = handler;