Kayrebt::Viewer

Kayrebt::Viewer is a tool from the Kayrebt toolset. Its main purpose is to give users a handy tools to explore the diagrams generated by Kayrebt::Extractor from a code base. It has essentially been tested for the Linux source code.

Compilation

This is a qt project, and there is no autoconf/automake-like compilation chain for now. To compile:

$ cd KayrebtViewer
$ qmake
$ make

You will need Qt 4.8 and a C++11 compiler as well as the Graphviz libraries

Expect some compilation warnings because the Graphviz libraries convert string constants to char*, which is fine in C but prohibited in C++ (GCC tolerates and handles it fine, though).

You may also build KayrebtViewer in another directory than where the source files are. In this case you need to copy the file KayrebtViewer/KayrebtViewer.pro over and modify it to append the path to the KayrebtViewer directory to the DEPENDPATH and INCLUDEPATH variables. Otherwise, the compilation chain will not find your source files.

Usage

Upon running Kayrebt::Viewer, you are greeted by a first window asking you for the paths to the objects the Viewer will display:

  • the code base directory,
  • the database of the functions in the code base,
  • the directory containing the graphs produced by Kayrebt::Extractor from the code base.

Kayrebt::Viewer expects its graphs directory to be organized just like the code base directory itself: the directory hierarchy is the same and each file corresponding to a translation unit (i.e. .c files, except the one which are #include-d) is transformed into a directory, containing .dot graph files, one for each function defined inside the .c source file and extracted with Kayrebt::Extractor.

First window of Kayrebt::Viewer

The main window opens when the first one is closed with “OK”. The main window is divided in three panels. The central panel displays the graphs. It’s possible to open several graphs at a time, they will open in separate tabs. The right-hand panel display the source file containing the function whose graph is currently displayed, even if that source file is a header (.h file) for example. The left-hand panel lets you choose the graph to display. The upper half gives you three different ways of picking a graph:

  • the symbol database tab,
  • the history tab,
  • the filesystem tab.

The symbol database tab is simply a tabular representation of the database of functions you have selected in the first window. If you’ve not selected any, then this tab will remain blank. In this tab, you can look for a function by its name, you can filter functions by the file and directory in which they appear, you can sort them, etc. The “function name” field accepts perl-compatible regexps as input, the “directory” and “file” fields accepts shell globs. In the history tab, you can see the list of graphs you’ve opened in the current session. Finally the filesystem tab represents the hierarchy of files in the graphs directory. In any tab, double-clicking on an entry opens the corresponding graph.

The lower half of the left-hand panel is the source code directory hierarchy. It serves two purposes. When a graph is selected in one of the upper half tabs, the corresponding source file is highlighted in the lower half. This is useful to never get lost in a huge code base, especially when several files or functions share the same name in different places. Double-clicking on a file or a directory in the lower helf also sets the filters in the database tab in the upper half. It’s a way to quickly filter functions by the file they are defined in. The two halves of the left-hand panel are dockable and can be detached, reattached, moved around, etc.

Main window of Kayrebt::Viewer

Some interaction with the graphs is possible and conventional: the mouse wheel allows zooming in and out and it’s possible to pan the view with the left button. Ctrl+click inside a node representing a function call opens the graph of the function that is called (except if it’s a function pointer…). Double-clicking on a node erases the corresponding branch, i.e. the node itself and all the “orphan nodes”, the nodes which are no longer reachable from the entry node. The right click opens a menu with a command to reset the graph.

Licence

Copyright (C) 2015 Georget, Laurent laurent.georget@irisa.fr

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.