https://fcitx-im.org/index.php?title=Debug_fcitx5&feed=atom&action=historyDebug fcitx5 - Revision history2024-03-28T22:49:20ZRevision history for this page on the wikiMediaWiki 1.35.2https://fcitx-im.org/index.php?title=Debug_fcitx5&diff=45790&oldid=prevWeng Xuetian: /* Start Fcitx within a nested X server */2023-04-24T17:30:45Z<p><span dir="auto"><span class="autocomment">Start Fcitx within a nested X server</span></span></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 17:30, 24 April 2023</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l19" >Line 19:</td>
<td colspan="2" class="diff-lineno">Line 19:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Start Fcitx within a nested X server ==</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Start Fcitx within a nested X server ==</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>This special procedure is useful when you want to debug something that requires you to type a sequence of keys. This is because whenever you switch to a different window, the input method will receives focus out and that will commonly reset the state of input method. In that case, it may prevent you from reproducing the issue that requires <del class="diffchange diffchange-inline">lots </del>of <del class="diffchange diffchange-inline">user interaction</del>.</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>This special procedure is useful when you want to debug something that requires you to type a sequence of keys. This is because whenever you switch to a different window, the input method will receives focus out and that will commonly reset the state of input method. In that case, it may prevent you from reproducing the issue that requires <ins class="diffchange diffchange-inline">a sequence </ins>of <ins class="diffchange diffchange-inline">interactions</ins>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Using a nested X server, such as Xephyr, will prevent the focus out event to be generated.</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Using a nested X server, such as Xephyr, will prevent the focus out event to be generated.</div></td></tr>
</table>Weng Xuetianhttps://fcitx-im.org/index.php?title=Debug_fcitx5&diff=45192&oldid=prevWeng Xuetian: Created page with "= Print logs = This is a common way to debug something that you can attach to it. <code>FCITX_INFO()</code> is a convenient macro for print out information. It is a thin wrapp..."2021-11-30T20:22:39Z<p>Created page with "= Print logs = This is a common way to debug something that you can attach to it. <code>FCITX_INFO()</code> is a convenient macro for print out information. It is a thin wrapp..."</p>
<p><b>New page</b></p><div>= Print logs =<br />
This is a common way to debug something that you can attach to it. <code>FCITX_INFO()</code> is a convenient macro for print out information. It is a thin wrapper around std::ostream. It supports not only all types supported by <code>std::ostream</code>, but also common Standard C++ containers and Fcitx own types such as <code>fcitx::RawConfig</code>, <code>fcitx::Color</code>, <code>fcitx::Key</code>, etc.<br />
<br />
The logging with in Fcitx also provides log category so you may explicitly enable certain log only when you want to debug.<br />
<br />
= GDB or other debuggers =<br />
Debugging Fcitx is no different from debugging other C/C++ programs. The only thing that makes it special is that Fcitx is an input method and you need keyboard typing working to do runtime debug like gdb.<br />
<br />
So, either you run gdb within an application that is input method disabled, or you want to disable certain addon that talks to your terminal.<br />
<br />
== Start an input method disabled terminal ==<br />
1. Start a terminal with XMODIFIERS set to some random values, <code>XMODIFIERS=@im=none xterm</code> (or other terminal that uses XIM)<br />
2. Within the xterm, start Fcitx that with correct XMODIFIERS. Fcitx will read the XMODIFIERS from the environment to set its own value, but right now xterm will have <code>XMODIFIERS=@im=none</code>, so you need to override it again to make it mismatch with XMODIFIERS value of xterm. That will make xterm fail to connect to the Fcitx XIM server.<br />
<br />
== Start Fcitx with certain frontend disabled ==<br />
If your environment is set up correctly and you are using a Gtk/Qt based terminal, such as konsole/gnome-terminal, you can also start Fcitx with dbusfrontend disabled, so it will not talk to Gtk/Qt im module. <code>gdb --args fcitx5 --disable=dbusfrontend -r</code> <br />
<br />
You should still be able to use a XIM application to test, such as xterm.<br />
<br />
== Start Fcitx within a nested X server ==<br />
This special procedure is useful when you want to debug something that requires you to type a sequence of keys. This is because whenever you switch to a different window, the input method will receives focus out and that will commonly reset the state of input method. In that case, it may prevent you from reproducing the issue that requires lots of user interaction.<br />
<br />
Using a nested X server, such as Xephyr, will prevent the focus out event to be generated.<br />
<br />
<nowiki>Xephyr :1 &<br />
DISPLAY=:1 openbox & #Start a window manager<br />
DISPLAY=:1 xterm & #Start a XIM application<br />
DISPLAY=:1 gdb --args fcitx --disable dbusfrontend -r # Start Fcitx with dbus frontend disabled</nowiki><br />
<br />
= Use fcitx test addons to reproduce the issue or write new test cases =<br />
By default, Fcitx will come with a few test addons that is designed to generate synthetic user interaction. [https://codedocs.xyz/fcitx/fcitx5/group__FcitxUtils.html#ga81328a61b82a27934eea82d9f494a53d fcitx::setupTestingEnvironment] provides a easy way to setup required environment variables to run a special testing only fcitx instance.<br />
<br />
Usually, you would need to create an [https://codedocs.xyz/fcitx/fcitx5/classfcitx_1_1EventDispatcher.html event dispatcher] to execute some code after Fcitx is initialized. You can check [https://github.com/fcitx/fcitx5/blob/master/test/testunicode.cpp testunicode] as a reference.<br />
<br />
You may also want to explicitly enable only required addons to limit the testing scope.</div>Weng Xuetian