Jump to content

Guidelines and HOWTOs/Debugging/KCM: Difference between revisions

From KDE Community Wiki
Nmariusp (talk | contribs)
Add chapter "Debug KCM built using kdesrc-build in the IDE Qt Creator"
Nmariusp (talk | contribs)
Line 38: Line 38:
Command line arguments: kcm_networkmanagement
Command line arguments: kcm_networkmanagement


Run in terminal
I edit "Environment" as per https://community.kde.org/Get_Involved/development/IDE_configuration/Qt_Creator#If_Qt_Creator_fails_to_run_the_executable_correctly .


I edit "Environment" as per https://community.kde.org/Get_Involved/development/IDE_configuration/Qt_Creator#If_Qt_Creator_fails_to_run_the_executable_correctly .
Build the KCM using Qt Creator.
 
Since Qt Creator does not run <code>make install</code>. The file <code>kcm_networkmanagement.so</code> will not be copied/installed to the directory <code>~/kde/usr/lib/</code>. You can e.g. create a symlink:
<pre>
rm -rf ~/kde/usr/lib/x86_64-linux-gnu/plugins/plasma/kcms/systemsettings_qwidgets/kcm_networkmanagement.so
ln -s ~/kde/build/plasma-nm/bin/plasma/kcms/systemsettings_qwidgets/kcm_networkmanagement.so ~/kde/usr/lib/x86_64-linux-gnu/plugins/plasma/kcms/systemsettings_qwidgets/kcm_networkmanagement.so
</pre>


I build, I start the debugger. And Qt creator IDE's debugger stops at the correct breakpoint ~/kde/src/plasma-nm/kcm/kcm.cpp:58.
Now you can start Qt Creator IDE's debugger. The debugger will stop at the first breakpoint at line <code>~/kde/src/plasma-nm/kcm/kcm.cpp:58</code>.

Revision as of 17:15, 5 February 2023

Open a System Settings module (KCM) from your Linux OS

which -a kcmshell5
kcmshell5 --help-all
kcmshell5 kcm_networkmanagement

Open a System Settings module (KCM) built using kdesrc-build

kdesrc-build plasma-nm kde-cli-tools
source ~/kde/build/plasma-nm/prefix.sh
which -a kcmshell5
kcmshell5 --help-all
kcmshell5 kcm_networkmanagement
# In a new terminal:
lsof | grep kcmshell5 |& tee ~/a.txt
kate ~/a.txt
# From the kate main menu > Tools > Highlighting > 3D > GLSL. For a random syntax highlighting.
# All KDE *.so files should come from ~/kde/usr. E.g. "/home/username/kde/usr/lib/x86_64-linux-gnu/plugins/imageformats/kimg_xcf.so".
# All KDE *.qml files should come from your Linux user's home directory (i.e. "~"). E.g. "/home/username/.cache/kcmshell5/qmlcache/20f578eeb7bf80e91733db06de9bc7f19f8b3a22.qmlc".
# All non KDE things including Qt should come from "/usr". E.g. "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so", "/usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Controls/Styles/Desktop/ButtonStyle.qmlc", "/usr/lib/x86_64-linux-gnu/libdeflate.so.0".

See https://community.kde.org/Solid/Projects/ScreenManagement#Debugging_Information

Debug KCM built using kdesrc-build in the IDE Qt Creator

In Qt Creator, as per https://community.kde.org/Get_Involved/development/IDE_configuration/Qt_Creator I open the project "~/kde/src/plasma-nm".

I put a breakpoint on the line ~/kde/src/plasma-nm/kcm/kcm.cpp:58 in KCMNetworkmanagement ctor.

In the left hand bar "Switch to Projects mode Ctrl+5" > Build & Run > Imported kit > Run Run Settings > Run > Run configuration: > Add... > Custom Executable

Executable: /home/username/kde/usr/bin/kcmshell5

Command line arguments: kcm_networkmanagement

I edit "Environment" as per https://community.kde.org/Get_Involved/development/IDE_configuration/Qt_Creator#If_Qt_Creator_fails_to_run_the_executable_correctly .

Build the KCM using Qt Creator.

Since Qt Creator does not run make install. The file kcm_networkmanagement.so will not be copied/installed to the directory ~/kde/usr/lib/. You can e.g. create a symlink:

rm -rf ~/kde/usr/lib/x86_64-linux-gnu/plugins/plasma/kcms/systemsettings_qwidgets/kcm_networkmanagement.so
ln -s ~/kde/build/plasma-nm/bin/plasma/kcms/systemsettings_qwidgets/kcm_networkmanagement.so ~/kde/usr/lib/x86_64-linux-gnu/plugins/plasma/kcms/systemsettings_qwidgets/kcm_networkmanagement.so

Now you can start Qt Creator IDE's debugger. The debugger will stop at the first breakpoint at line ~/kde/src/plasma-nm/kcm/kcm.cpp:58.