const char *opt_input_path;
int opt_textdump;
+int quit = 0;
+
struct lttngtop *copy;
pthread_t display_thread;
pthread_t timer_thread;
unsigned long refresh_display = 1 * NSEC_PER_SEC;
unsigned long last_display_update = 0;
-int quit = 0;
/* list of FDs available for being read with snapshots */
struct mmap_stream_list mmap_list;
void *refresh_thread(void *p)
{
+ struct mmap_stream *mmap_info;
+
while (1) {
- if (quit)
- return NULL;
+ if (quit) {
+ sem_post(&pause_sem);
+ sem_post(&timer);
+ sem_post(&goodtodisplay);
+ pthread_exit(0);
+ }
+ bt_list_for_each_entry(mmap_info, &mmap_list.head, list)
+ helper_kernctl_buffer_flush(mmap_info->fd);
sem_wait(&pause_sem);
sem_post(&pause_sem);
sem_post(&timer);
sem_wait(&goodtodisplay);
sem_wait(&pause_sem);
+ if (quit) {
+ sem_post(&pause_sem);
+ sem_post(&timer);
+ reset_ncurses();
+ pthread_exit(0);
+ }
+
copy = g_ptr_array_index(copies, current_display_index);
assert(copy);
display(current_display_index++);
sem_post(&goodtoupdate);
sem_post(&pause_sem);
-
- if (quit) {
- reset_ncurses();
- pthread_exit(0);
- }
}
}
struct tm start;
uint64_t ts_nsec_start;
-
timestamp = bt_ctf_get_timestamp(call_data);
start = format_timestamp(timestamp);
lttngtop.nbthreads = 0;
lttngtop.nbfiles = 0;
+ lttngtop.process_hash_table = g_hash_table_new(g_direct_hash,
+ g_direct_equal);
lttngtop.process_table = g_ptr_array_new();
lttngtop.files_table = g_ptr_array_new();
lttngtop.cpu_table = g_ptr_array_new();
NULL, NULL, NULL);
}
- while ((event = bt_ctf_iter_read_event(iter)) != NULL) {
+ while (((event = bt_ctf_iter_read_event(iter)) != NULL)) {
+ if (quit)
+ goto end_iter;
ret = bt_iter_next(bt_ctf_get_iter(iter));
if (ret < 0)
goto end_iter;
return ret;
}
-void *live_consume()
+void live_consume(struct bt_context **bt_ctx)
{
- struct bt_context *bt_ctx = NULL;
int ret;
if (!metadata_ready) {
sem_wait(&metadata_available);
if (access("/tmp/livesession/kernel/metadata", F_OK) != 0) {
fprintf(stderr,"no metadata\n");
- return NULL;
+ goto end;
}
metadata_ready = 1;
metadata_fp = fopen("/tmp/livesession/kernel/metadata", "r");
}
if (!trace_opened) {
- bt_ctx = bt_context_create();
- ret = bt_context_add_trace(bt_ctx, NULL, "ctf",
+ *bt_ctx = bt_context_create();
+ ret = bt_context_add_trace(*bt_ctx, NULL, "ctf",
lttngtop_ctf_packet_seek, &mmap_list, metadata_fp);
if (ret < 0) {
printf("Error adding trace\n");
- return NULL;
+ goto end;
}
trace_opened = 1;
}
- iter_trace(bt_ctx);
- return NULL;
+end:
+ return;
}
int setup_consumer(char *command_sock_path, pthread_t *threads,
/* setup the session */
dom.type = LTTNG_DOMAIN_KERNEL;
- ret = system("rm -rf /tmp/livesession");
+ ret = unlink("/tmp/livesession");
lttng_destroy_session("test");
if ((ret = lttng_create_session("test", "/tmp/livesession")) < 0) {
pthread_create(&display_thread, NULL, ncurses_display, (void *) NULL);
pthread_create(&timer_thread, NULL, refresh_thread, (void *) NULL);
}
- live_consume();
+ live_consume(&bt_ctx);
+ iter_trace(bt_ctx);
+
+ pthread_join(timer_thread, NULL);
+ quit = 1;
+ pthread_join(display_thread, NULL);
- sleep(2000);
lttng_stop_tracing("test");
lttng_destroy_session("test");
iter_trace(bt_ctx);
- quit = 1;
pthread_join(display_thread, NULL);
+ quit = 1;
pthread_join(timer_thread, NULL);
}