Jump to content

User:Nmariusp/Debug

From KDE Community Wiki

Example: How to debug Breeze Qt Widgets style

Install kde-builder, Qt Creator IDE, build kcalc using kde-builder, run kcalc in Qt Creator debugger.

kde-builder kcalc breeze

In Qt Creator load two KDE projects: breeze and kcalc.

I have managed from Qt Creator debugger to debug "Breeze::Style::Style()". Patch:

1234567891011121314151617181920212223242526diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp
index 4ba8030b..55aaf876 100644
--- a/kstyle/breezestyle.cpp
+++ b/kstyle/breezestyle.cpp
@@ -57,6 +57,8 @@
 #include <QTreeView>
 #include <QWidgetAction>
 
+#include <unistd.h>
+
 #if HAVE_QTDBUS
 #include <QDBusConnection>
 #endif
@@ -287,6 +289,12 @@ Style::Style()
     , CE_IconButton(newControlElement(QStringLiteral("CE_IconButton")))
 #endif
 {
+    qCritical() << "Breeze::Style::Style()";
+    while (access("/home/n/a.txt", F_OK) != 0)
+    {
+        sleep(1);
+    }
+
 #if HAVE_QTDBUS
     // use DBus connection to update on breeze configuration change
     auto dbus = QDBusConnection::sessionBus();

Konsole tab one. I build using:

kde-builder kcalc breeze --no-src --no-include-dependencies --debug

Konsole tab two. I run using:

mv ~/a.txt ~/a.txt_ ; kde-builder --run kcalc

kcalc process starts and waits for you. From Qt Creator main menu > Debug > "Start Debugging" > "Attach to Running Application..." > Filter: "kcalc" > select the "kcalc" process > "Attach to Process" button.

Konsole tab three:

mv ~/a.txt_ ~/a.txt