Skip to content

Commit

Permalink
Merge branch 'tui-support'
Browse files Browse the repository at this point in the history
Add initial support for interactive 'tui' command using ncurses.  The
tui command will provide similar (or better) functionality of graph and
report commands.  Users can navigate the data interactively in a text
console.

Closes: #326

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
  • Loading branch information
namhyung committed May 3, 2018
2 parents 9fd25da + bb347af commit 269a7e7
Show file tree
Hide file tree
Showing 13 changed files with 1,970 additions and 18 deletions.
4 changes: 3 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source.
$ sudo apt-get install libelf-dev # mandatory
$ sudo apt-get install pandoc # for man pages (optional)
$ sudo apt-get install libpython2.7-dev # for python scripting (optional)
$ sudo apt-get install libncursesw5-dev # for TUI (optional)
$ make
$ sudo make install

Expand Down Expand Up @@ -36,7 +37,8 @@ On redhat based systems (like Fedora, RHEL), it'll be `elfutils-libelf-devel`.
$ sudo dnf install elfutils-libelf-devel

It also uses libstdc++ library to demangle C++ symbols in full detail.
But it's not mandatory as uftrace has its own demangler for shorter symbol
And ncursesw library to implement text user interface (TUI) on console.
But they're not mandatory as uftrace has its own demangler for shorter symbol
name (it omits arguments, templates and so on).

Also it needs `pandoc` to build man pages from the markdown document.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ The uftrace command has following subcommands:
* `recv` : saves the trace data from network
* `graph` : shows function call graph in the trace data
* `script` : runs a script for recorded trace data
* `tui` : show text user interface for graph and report

You can use `-?` or `--help` option to see available commands and options.

$ uftrace
Usage: uftrace [OPTION...]
[record|replay|live|report|info|dump|recv|graph|script] [<program>]
[record|replay|live|report|info|dump|recv|graph|script|tui] [<program>]
Try `uftrace --help' or `uftrace --usage' for more information.

If omitted, it defaults to the `live` command which is almost same as running
Expand Down
3 changes: 3 additions & 0 deletions check-deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CHECK_LIST += have_libpython2.7
CHECK_LIST += perf_clockid
CHECK_LIST += perf_context_switch
CHECK_LIST += arm_has_hardfp
CHECK_LIST += have_libncurses

#
# This is needed for checking build dependency
Expand All @@ -20,6 +21,8 @@ LDFLAGS_cxa_demangle = -lstdc++
LDFLAGS_have_libelf = -lelf
CFLAGS_cc_has_mno_sse2 = -mno-sse2
LDFLAGS_have_libpython2.7 = -lpython2.7
CFLAGS_have_libncurses = $(shell pkg-config --cflags ncursesw)
LDFLAGS_have_libncurses = $(shell pkg-config --libs ncursesw)

check-build: check-tstamp $(CHECK_LIST)

Expand Down
5 changes: 5 additions & 0 deletions check-deps/Makefile.check
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ endif
ifneq ($(wildcard $(srcdir)/check-deps/arm_has_hardfp),)
COMMON_CFLAGS += -DHAVE_ARM_HARDFP
endif

ifneq ($(wildcard $(srcdir)/check-deps/have_libncurses),)
COMMON_CFLAGS += -DHAVE_LIBNCURSES $(shell pkg-config --cflags ncursesw)
UFTRACE_LDFLAGS += $(shell pkg-config --libs ncursesw)
endif
8 changes: 8 additions & 0 deletions check-deps/__have_libncurses.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <ncurses.h>

int main(void)
{
initscr();
endwin();
return 0;
}
2 changes: 1 addition & 1 deletion cmd-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ static void print_flame_task_rstack(struct uftrace_dump_ops *ops,
if (graph->node == NULL)
graph->node = &flame_graph.root;

graph_add_node(graph, frs->type, name);
graph_add_node(graph, frs->type, name, sizeof(struct uftrace_graph_node));
}

static void print_flame_task_event(struct uftrace_dump_ops *ops,
Expand Down
6 changes: 4 additions & 2 deletions cmd-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,10 @@ static void build_graph_node(struct ftrace_task_handle *task, uint64_t time,
sym = find_symtabs(&tg->utg.graph->sess->symtabs, addr);
name = symbol_getname(sym, addr);

if (tg->enabled)
graph_add_node(&tg->utg, type, name);
if (tg->enabled) {
graph_add_node(&tg->utg, type, name,
sizeof(struct uftrace_graph_node));
}

/* cannot find a session for this record */
if (tg->utg.graph == NULL)
Expand Down
Loading

0 comments on commit 269a7e7

Please sign in to comment.