Difference between revisions of "Debug Fcitx"

From Fcitx
Jump to navigation Jump to search
(Created page with "<languages /> <translate> You can use gdb to debug fcitx, or any other graphics gdb frontend. But one special thing is, fcitx is communiating with your GUI in a more or less ...")
 
m (Text replacement - "<translate1>" to "<translate>")
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
<languages />
+
<languages/>
  
 
<translate>
 
<translate>
You can use gdb to debug fcitx, or any other graphics 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, there're some way around this.
+
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 ==
 
== Debug by TTY or SSH ==
Line 9: Line 9:
 
First start a screen (or something else) under your X, detach it.
 
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 any other regular application.
+
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) ==
 
== Debug with nested X Server (Recommended) ==
  
There are quite a few nested X Server, like Xvfb, Xephyr, XNest, the recommended one is Xephyr (Said to be the replacement of XNest).
+
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
 
You can use
Line 35: Line 35:
 
to start fcitx.
 
to start fcitx.
  
Other useful arguments includes
+
Other useful arguments include
  
 
* -r , restart exists fcitx.
 
* -r , restart exists fcitx.
Line 41: Line 41:
 
  r -u fcitx-classic-ui
 
  r -u fcitx-classic-ui
  
You'll also want to have a window mananger under your nested X, for focus related issue.
+
You'll also want a window mananger under your nested X, for focus related issues.
  
The reason that this way is recommended is, you will not make your window lose focus, or send extra key event, since you can just click the terminal running gdb by mouse.
+
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 ==
 
== Debug with fcitx-simple ==
fcitx-simple is a project that wrap fcitx to be run inside another process as a library. So far there is no released version of fcitx-simple, but it's already usable for debugging.
+
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, [[Special:MyLanguage/Compile_from_source|Compile from source]].
 
First read about how to compile fcitx related source, [[Special:MyLanguage/Compile_from_source|Compile from source]].
Line 61: Line 61:
 
  if inputfile is not specified, it will read stdin as input
 
  if inputfile is not specified, it will read stdin as input
  
The input is a sequence of fcitx hotkey string, one per line. You can check [https://github.com/fcitx/fcitx-testcase/tree/master/profile/chttrans this link] to get some basic idea about how this works. This is useful when you only want a minimal environment for testing.
+
The input is a sequence of fcitx hotkey strings, one per line. You can check [https://github.com/fcitx/fcitx-testcase/tree/master/profile/chttrans 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 ==
 
== See also ==

Latest revision as of 22:54, 2 February 2016


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