From 5dbde311c3d29920b216d5be611823252fa727da Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Mon, 27 Aug 2012 17:30:22 -0400 Subject: [PATCH] bugfix pretty-printing and begin kprobes Signed-off-by: Julien Desfossez --- src/cursesdisplay.c | 34 ++++++++++++++++++++++++++++++++++ src/cursesdisplay.h | 1 + src/lttngtop.c | 30 ++++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/src/cursesdisplay.c b/src/cursesdisplay.c index dd12f0f..1fcc798 100644 --- a/src/cursesdisplay.c +++ b/src/cursesdisplay.c @@ -520,6 +520,30 @@ gint sort_by_cpu_group_by_threads_desc(gconstpointer p1, gconstpointer p2) return -1; } +void update_kprobes_display() +{ + int i, column; + + set_window_title(center, "Kprobes Top"); + /* + wattron(center, A_BOLD); + column = 1; + for (i = 0; i < 6; i++) { + if (toggle_virt < 0 && (i == 3 || i == 4)) { + continue; + } + if (cputopview[i].sort) { + wattron(center, A_UNDERLINE); + pref_current_sort = i; + } + mvwprintw(center, 1, column, cputopview[i].title); + wattroff(center, A_UNDERLINE); + column += 10; + } + wattroff(center, A_BOLD); + */ +} + void update_cputop_display() { int i; @@ -993,6 +1017,9 @@ void update_current_view() case tree: update_cputop_display(); break; + case kprobes: + update_kprobes_display(); + break; default: break; } @@ -1550,6 +1577,13 @@ void *handle_keyboard(void *p) selected_line = 0; update_current_view(); break; + case KEY_F(5): + if (pref_panel_visible) + toggle_pref_panel(); + current_view = kprobes; + selected_line = 0; + update_current_view(); + break; case KEY_F(10): case 'q': reset_ncurses(); diff --git a/src/cursesdisplay.h b/src/cursesdisplay.h index fac2629..82877f9 100644 --- a/src/cursesdisplay.h +++ b/src/cursesdisplay.h @@ -29,6 +29,7 @@ enum view_list process_details, iostream, tree, + kprobes, }; enum view_list current_view; diff --git a/src/lttngtop.c b/src/lttngtop.c index 211d38d..2442884 100644 --- a/src/lttngtop.c +++ b/src/lttngtop.c @@ -181,7 +181,7 @@ void print_fields(struct bt_ctf_event *event) printf("%s", bt_ctf_get_string(list[i])); } else if (type == CTF_TYPE_ARRAY) { str = bt_ctf_get_char_array(list[i]); - if (str) + if (!bt_ctf_field_get_error() && str) printf("%s", str); } } @@ -223,7 +223,7 @@ enum bt_cb_ret print_timestamp(struct bt_ctf_event *call_data, void *private_dat cpu_id = get_cpu_id(call_data); procname = get_context_comm(call_data); - if (strcmp(bt_ctf_event_name(call_data), "exit_syscall") == 0) { + if ((strcmp(bt_ctf_event_name(call_data), "exit_syscall") == 0) && !last_textdump_print_newline) { scope = bt_ctf_get_top_level_scope(call_data, BT_EVENT_FIELDS); syscall_ret = bt_ctf_get_int64(bt_ctf_get_field(call_data, @@ -241,13 +241,12 @@ enum bt_cb_ret print_timestamp(struct bt_ctf_event *call_data, void *private_dat bt_ctf_event_name(call_data)); print_fields(call_data); printf(") "); - /* - if (strncmp(bt_ctf_event_name(call_data), "sys_", 4) == 0) { - } else { + if (strncmp(bt_ctf_event_name(call_data), "sys_", 4) != 0) { printf("\n"); + last_textdump_print_newline = 1; + } else { + last_textdump_print_newline = 0; } - */ - last_textdump_print_newline = 0; } end: @@ -625,7 +624,7 @@ void iter_trace(struct bt_context *bt_ctx) NULL, NULL, NULL); } - while ((event = bt_ctf_iter_read_event(iter, NULL)) != NULL) { + while ((event = bt_ctf_iter_read_event(iter)) != NULL) { if (quit || reload_trace) goto end_iter; ret = bt_iter_next(bt_ctf_get_iter(iter)); @@ -1071,6 +1070,7 @@ int setup_live_tracing() goto error_session; } + memset(&ev, '\0', sizeof(struct lttng_event)); ev.type = LTTNG_EVENT_SYSCALL; if ((ret = lttng_enable_event(handle, &ev, channel_name)) < 0) { fprintf(stderr,"error enabling syscalls : %s\n", @@ -1078,6 +1078,20 @@ int setup_live_tracing() goto error_session; } + /* + memset(&ev, '\0', sizeof(struct lttng_event)); + ev.type = LTTNG_EVENT_PROBE; + sprintf(ev.attr.probe.symbol_name, "sys_open"); + sprintf(ev.name, "probe_sys_open"); + ev.attr.probe.addr = 0; + ev.attr.probe.offset = 0; + if ((ret = lttng_enable_event(handle, &ev, channel_name)) < 0) { + fprintf(stderr,"error enabling kprobes : %s\n", + helper_lttcomm_get_readable_code(ret)); + goto error_session; + } + */ + kctxpid.ctx = LTTNG_EVENT_CONTEXT_PID; lttng_add_context(handle, &kctxpid, NULL, NULL); kctxtid.ctx = LTTNG_EVENT_CONTEXT_TID; -- 2.34.1