"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.10.3/docs/source/developers-docs.rst" (8 May 2020, 7161 Bytes) of package /linux/privat/cutter-1.10.3.tar.gz:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field. See also the latest Fossies "Diffs" side-by-side code changes report for "developers-docs.rst": 1.10.2_vs_1.10.3.

Developer documentation

This page shows some hints about the coding conventions.

developers-docs/* crash-handling-system

Cutter coding advices

CutterCore class

This is the main class where every link with r2 is made. It is unique accross the whole process. To access it, simply call Core().



Calling a radare2 command

There are multiple ways to call a radare2 command:

- CutterCore::cmdRaw(<command>) - Executes a single radare2 command

without going through radare2 shell functionality like output redirects, grep, and multiple command parsing.

The command then returns its output. This should be used when a command doesn't have output or the output should be handled as-is. If possible, using the json variation with cmdj is always preferred.

Generally, if one needs to retrieve information from a radare2 command, it is preferred to use the json API.


QJsonArray array = Core()->cmdj("pdj 1 @ main").array();

Seek the current file

To modify radare2 seek use CutterCore::seek(const RVA offset). This is important because it will emit a CutterCore::seekChanged(RVA offset) signal. Never ever call cmd("s offset");




Cutter also supports a silent seek which doesn't trigger the seekChanged event and doesn't add new entries to the seek history.

Creating a widget

Make sure to connect the CutterCore::seekChanged(RVA offset) signal so your widget refreshes its output when radare2 seek is modified (switching to another function, etc.).

Coding style

In general, we follow the official Qt guidelines to format the code. If in doubt, you can use AStyle 2.06 to format the code. The command line for formatting the code according to the style is:

astyle --project=src/Cutter.astylerc src/filename.cpp

In contrast to the official guidelines of Qt, in Cutter we always use curly braces in conditional statements, even if the body of a conditional statement contains only one line.

// Wrong
if (address.isEmpty())
   return false;

// Correct
if (address.isEmpty()) {
   return false;

// Wrong
for (int i = 0; i < 10; ++i)
   qDebug("%i", i);

// Correct
for (int i = 0; i < 10; ++i) {
   qDebug("%i", i);


Strive to include only required definitions inside header files. This will avoid triggering additional unnecessary compilations.

If you only need to know that a class exists but don't need the prototype, you can declare the class like this:

class MyClassThatExists;

/** ... **/

    MyClassThatExists *classInstance;

And then include the class header inside your .cpp so you can use that class.

If you need something in the source file (.cpp) that is not a class member, then add the include in the source file.

The includes must be ordered from local to global. That is, first include any local header file (with doublequotes like #include "common/Helpers.h". Then, after an empty newline, include Qt definitions like #include <QShortcut>. Finally, include the standard C++ headers you need.

Includes must be sorted by alphabetical order.


Our API reference is generated using Doxygen, so when it comes to function documentation, please use the following format:

 * @brief Add a new param to the accumulator
virtual void accumulate(RefreshDeferrerParams params) =0;


We use the C++11 foreach loop style, which means any “foreach” loop should look like:

for (QJsonValue value : importsArray) {


Please do not use 0 nor Q_NULLPTR, only use nullptr.


QObject *object = nullptr;

Connecting signals

To connect a signal to a slot, this is the preferred syntax:

connect(sender, &QObject::destroyed, this, &MyObject::objectDestroyed);

This syntax performs compile-time type checks and allows the use of lambda functions. Other approaches for connecting signals silently break at runtime.

General coding advices

Functions documentation

You can find the classes documentation in the API Reference menu item.

Updating the submodules

Git submodules play a major part in Cutter. This, because Cutter is powered by radare2, its parent project, and it tries to stay up-to-date with its recent version, which allows us to implement new features, and enjoy bug fixes and performance improvements on radare2. Often, we need to update the radare2 submodule or others, in order to push the most recent version of them to Cutter.

You can view the list of all the submodules from the cutter root folder with:

git config --file .gitmodules --get-regexp path | awk '{ print $2 }'

To update all the submodules at once, run these commands from the cutter root folder:

git submodule foreach git pull origin master
git add submodule_name_1 submodule_name_2
git commit -m "Update submodules"

More likely, you'll only need to update the radare2 submodule. In order to update one submodule individually, use the following code:

cd radare2
git checkout master && git pull
cd ..
git add radare2
git commit -m "Update radare2 submodule"

Useful resources to learn more about Qt development