struct processtop *tmp, *tmp2, *new;
struct cputime *tmpcpu, *newcpu;
struct files *tmpfile, *newfile;
+ struct kprobes *tmpprobe, *newprobe;
dst = g_new0(struct lttngtop, 1);
dst->start = start;
dst->process_table = g_ptr_array_new();
dst->files_table = g_ptr_array_new();
dst->cpu_table = g_ptr_array_new();
+ dst->kprobes_table = g_ptr_array_new();
dst->process_hash_table = g_hash_table_new(g_direct_hash, g_direct_equal);
g_hash_table_foreach(lttngtop.process_hash_table, copy_process_table,
dst->process_hash_table);
*/
g_ptr_array_add(dst->cpu_table, newcpu);
}
+ for (i = 0; i < lttngtop.kprobes_table->len; i++) {
+ tmpprobe = g_ptr_array_index(lttngtop.kprobes_table, i);
+ newprobe = g_new0(struct kprobes, 1);
+ memcpy(newprobe, tmpprobe, sizeof(struct kprobes));
+ tmpprobe->count = 0;
+ g_ptr_array_add(dst->kprobes_table, newprobe);
+ }
/* FIXME : better algo */
/* create the threads index if required */
for (i = 0; i < dst->process_table->len; i++) {
struct header_view cputopview[6];
struct header_view iostreamtopview[3];
struct header_view fileview[3];
+struct header_view kprobeview[2];
void reset_ncurses()
{
void update_kprobes_display()
{
int i, column;
+ struct kprobes *probe;
+ int header_offset = 2;
+ int current_line = 0;
- set_window_title(center, "Kprobes Top");
- /*
+ 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) {
+ for (i = 0; i < 2; i++) {
+ if (kprobeview[i].sort) {
wattron(center, A_UNDERLINE);
pref_current_sort = i;
}
- mvwprintw(center, 1, column, cputopview[i].title);
+ mvwprintw(center, 1, column, "%s", kprobeview[i].title);
wattroff(center, A_UNDERLINE);
- column += 10;
+ column += 30;
}
wattroff(center, A_BOLD);
- */
+
+ for (i = 0; i < data->kprobes_table->len; i++) {
+ column = 1;
+ probe = g_ptr_array_index(data->kprobes_table, i);
+ mvwprintw(center, current_line + header_offset, column,
+ "%s", probe->probe_name + 6);
+ column += 30;
+ mvwprintw(center, current_line + header_offset, column,
+ "%d", probe->count);
+ current_line++;
+ }
}
void update_cputop_display()
fileview[1].title = strdup("READ");
fileview[1].sort = 1;
fileview[2].title = strdup("WRITE");
+
+ kprobeview[0].title = strdup("NAME");
+ kprobeview[1].title = strdup("HIT");
+ kprobeview[1].sort = 1;
}
void init_ncurses()
return BT_CB_ERROR_STOP;
}
+enum bt_cb_ret handle_kprobes(struct bt_ctf_event *call_data, void *private_data)
+{
+ int i;
+ struct kprobes *kprobe;
+
+ /* for kprobes */
+ for (i = 0; i < lttngtop.kprobes_table->len; i++) {
+ kprobe = g_ptr_array_index(lttngtop.kprobes_table, i);
+ if (strcmp(bt_ctf_event_name(call_data), kprobe->probe_name) == 0) {
+ kprobe->count++;
+ }
+ }
+
+ return BT_CB_OK;
+}
+
/*
* hook on each event to check the timestamp and refresh the display if
* necessary
lttngtop.process_table = g_ptr_array_new();
lttngtop.files_table = g_ptr_array_new();
lttngtop.cpu_table = g_ptr_array_new();
+ lttngtop.kprobes_table = g_ptr_array_new();
}
void usage(FILE *fp)
{
struct bt_ctf_iter *iter;
struct bt_iter_pos begin_pos;
+ struct kprobes *kprobe;
const struct bt_ctf_event *event;
+ int i;
int ret = 0;
begin_pos.type = BT_SEEK_BEGIN;
"lttng_statedump_file_descriptor"),
NULL, 0, handle_statedump_file_descriptor,
NULL, NULL, NULL);
+
+ /* for kprobes */
+ for (i = 0; i < lttngtop.kprobes_table->len; i++) {
+ kprobe = g_ptr_array_index(lttngtop.kprobes_table, i);
+ bt_ctf_iter_add_callback(iter,
+ g_quark_from_static_string(
+ kprobe->probe_name),
+ NULL, 0, handle_kprobes,
+ NULL, NULL, NULL);
+ }
}
while ((event = bt_ctf_iter_read_event(iter)) != NULL) {
return ret;
}
+int enable_kprobes(struct lttng_handle *handle, char *channel_name)
+{
+ struct lttng_event ev;
+ struct kprobes *kprobe;
+ int ret = 0;
+ int i;
+
+ /*
+ kprobe = g_new0(struct kprobes, 1);
+ kprobe->probe_addr = 0;
+ kprobe->probe_offset = 0;
+ asprintf(&kprobe->probe_name, "probe_sys_open");
+ asprintf(&kprobe->symbol_name, "sys_open");
+ g_ptr_array_add(lttngtop.kprobes_table, kprobe);
+
+ kprobe = g_new0(struct kprobes, 1);
+ kprobe->probe_addr = 0;
+ kprobe->probe_offset = 0;
+ asprintf(&kprobe->probe_name, "probe_sys_close");
+ asprintf(&kprobe->symbol_name, "sys_close");
+ g_ptr_array_add(lttngtop.kprobes_table, kprobe);
+ */
+
+ for (i = 0; i < lttngtop.kprobes_table->len; i++) {
+ kprobe = g_ptr_array_index(lttngtop.kprobes_table, i);
+
+ memset(&ev, '\0', sizeof(struct lttng_event));
+ ev.type = LTTNG_EVENT_PROBE;
+ sprintf(ev.attr.probe.symbol_name, "%s", kprobe->symbol_name);
+ sprintf(ev.name, "%s", kprobe->probe_name);
+ ev.attr.probe.addr = kprobe->probe_addr;
+ ev.attr.probe.offset = kprobe->probe_offset;
+ if ((ret = lttng_enable_event(handle, &ev, channel_name)) < 0) {
+ fprintf(stderr,"error enabling kprobes : %s\n",
+ helper_lttcomm_get_readable_code(ret));
+ goto end;
+ }
+ }
+
+end:
+ return ret;
+}
+
int setup_live_tracing()
{
struct lttng_domain dom;
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));
+ ret = enable_kprobes(handle, channel_name);
+ if (ret < 0) {
goto error_session;
}
- */
kctxpid.ctx = LTTNG_EVENT_CONTEXT_PID;
lttng_add_context(handle, &kctxpid, NULL, NULL);
signal(SIGTERM, handle_textdump_sigterm);
signal(SIGINT, handle_textdump_sigterm);
}
+ init_lttngtop();
ret = setup_live_tracing();
if (ret < 0) {
goto end;
}
- init_lttngtop();
if (!opt_textdump) {
pthread_create(&display_thread, NULL, ncurses_display, (void *) NULL);
pthread_create(&timer_thread, NULL, refresh_thread, (void *) NULL);