*/
#define _GNU_SOURCE
+#define LTT_TRACE
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/param.h>
#include <sys/time.h>
+#include <errno.h>
#include <asm/atomic.h>
#include <asm/timex.h> //for get_cycles()
+_syscall0(pid_t,gettid)
+
#include "ltt-usertrace-fast.h"
enum force_switch_mode { FORCE_ACTIVE, FORCE_FLUSH };
/* Reader (the disk dumper daemon) */
static pid_t traced_pid = 0;
-static pthread_t traced_thread = 0;
+static pid_t traced_tid = 0;
static int parent_exited = 0;
/* signal handling */
}
}
-/* In the writer :
- *
- * if(buffer full condition) {
- * put myself in the wait queue
- * ltt_buf->full = 1;
- * schedule
- * }
- *{
- if(buffer_is_full) {
- atomic_set(<t_buf->full, 1);
- ret = do_futex((unsigned long)<t_buf->full, 1, 0, 0, 0);
- }
-}
-
- */
-
static int read_subbuffer(struct ltt_buf *ltt_buf, int fd)
{
unsigned int consumed_old;
err = ltt_buffer_get(ltt_buf, &consumed_old);
- if(err != -EAGAIN && err != 0) {
- printf("LTT Reserving sub buffer failed\n");
+ if(err != 0) {
+ if(err != -EAGAIN) printf("LTT Reserving sub buffer failed\n");
goto get_error;
}
/* This function is called by ltt_rw_init which has signals blocked */
static void ltt_usertrace_fast_daemon(struct ltt_trace_info *shared_trace_info,
- sigset_t oldset, pid_t l_traced_pid, pthread_t l_traced_thread)
+ sigset_t oldset, pid_t l_traced_pid, pthread_t l_traced_tid)
{
struct sigaction act;
int ret;
traced_pid = l_traced_pid;
- traced_thread = l_traced_thread;
+ traced_tid = l_traced_tid;
- printf("LTT ltt_usertrace_fast_daemon : init is %d, pid is %lu, traced_pid is %lu\n",
- shared_trace_info->init, getpid(), traced_pid);
+ printf("LTT ltt_usertrace_fast_daemon : init is %d, pid is %lu, traced_pid is %lu, traced_tid is %lu\n",
+ shared_trace_info->init, getpid(), traced_pid, traced_tid);
act.sa_handler = handler_sigusr1;
act.sa_flags = 0;
exit(-1);
}
snprintf(identifier_name, PATH_MAX-1, "%lu.%lu.%llu",
- traced_pid, traced_thread, get_cycles());
+ traced_tid, traced_pid, get_cycles());
snprintf(outfile_name, PATH_MAX-1, "facilities-%s", identifier_name);
fd_fac = creat(outfile_name, 0644);
int ret;
sigset_t set, oldset;
pid_t l_traced_pid = getpid();
- pthread_t l_traced_thread = pthread_self();
+ pid_t l_traced_tid = gettid();
/* parent : create the shared memory map */
shared_trace_info = mmap(0, sizeof(*thread_trace_info),
shared_trace_info->channel.facilities.subbuf_size = LTT_SUBBUF_SIZE_FACILITIES;
shared_trace_info->channel.facilities.start =
shared_trace_info->channel.facilities_buf;
+ ltt_buffer_begin_callback(&shared_trace_info->channel.facilities,
+ ltt_get_timestamp(), 0);
atomic_set(&shared_trace_info->channel.cpu.full, 0);
shared_trace_info->channel.cpu.alloc_size = LTT_BUF_SIZE_CPU;
shared_trace_info->channel.cpu.subbuf_size = LTT_SUBBUF_SIZE_CPU;
shared_trace_info->channel.cpu.start = shared_trace_info->channel.cpu_buf;
+ ltt_buffer_begin_callback(&shared_trace_info->channel.cpu,
+ ltt_get_timestamp(), 0);
+
shared_trace_info->init = 1;
/* Disable signals */
/* Child */
role = LTT_ROLE_READER;
ltt_usertrace_fast_daemon(shared_trace_info, oldset, l_traced_pid,
- l_traced_thread);
+ l_traced_tid);
/* Should never return */
exit(-1);
} else if(pid < 0) {