Debug Fcitx

From Fcitx
Revision as of 22:54, 2 February 2016 by Weng Xuetian (talk | contribs) (Text replacement - "<translate1>" to "<translate>")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

You can use gdb to debug fcitx, or any other graphical gdb frontend. But one special thing is, fcitx is communiating with your GUI in a more or less sychronous way, so you DON'T want to use fcitx when you debugging it. Here are several ways to debug:

Debug by TTY or SSH

In order to keep all environment variable in your user session, it is recommended to use virtual terminal like screen, tmux, byobu.

First start a screen (or something else) under your X, detach it.

Then attach it under TTY, or your SSH session. After that you can debug it as other regular applications.

Debug with nested X Server (Recommended)

There are quite a few nested X Servers, like Xvfb, Xephyr, XNest, the recommended one is Xephyr (Said to be the replacement of XNest).

You can use

Xephyr :1

to start a X Server at :1.

Then you can change the DISPLAY environment variable by

export DISPLAY=:1

then you can start fcitx with

gdb fcitx

One thing you need to pay attention to is, fcitx is started as daemon by default, so you might want to use

r -D

to start fcitx.

Other useful arguments include

  • -r , restart exists fcitx.
  • -u [ui name] , specify the ui addon to use. for example
r -u fcitx-classic-ui

You'll also want a window mananger under your nested X, for focus related issues.

The reason why this way is recommended is, you will not make your window lose focus, or send extra key events, since you can simply click the terminal running gdb by mouse.

Debug with fcitx-simple

fcitx-simple is a project that wrap fcitx to be running inside another process as a library. So far there is no released version of fcitx-simple, but it's already available for debugging.

First read about how to compile fcitx related source, Compile from source.

After you successfully compile and install fcitx-simple, you will find a binary fcitx-testbed.

Here's the help message from fcitx-testbed:

Usage: fcitx-testbed [OPTION] <addonname> [inputfile]
        -d <dir>        sandbox directorys
        -i <imname>     im name to use
        -h              display this help and exit
<addonname> is a comma separated list
if inputfile is not specified, it will read stdin as input

The input is a sequence of fcitx hotkey strings, one per line. You can check this link to get some basic idea about how this works. This is useful when you only want a minimal environment for test.

See also

GDB tutorial