File 0017-Add-command-line-option-debug.patch of Package mingw32-kinit
From a97b00ea342f3c8f9afdb99c8b3be4ee12684595 Mon Sep 17 00:00:00 2001
From: Ralf Habacker <ralf.habacker@freenet.de>
Date: Fri, 23 Jul 2021 10:56:03 +0200
Subject: [PATCH 17/18] Add command line option --debug
---
src/kdeinit/kinit_win.cpp | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/kdeinit/kinit_win.cpp b/src/kdeinit/kinit_win.cpp
index 8ba2416..7ce1558 100644
--- a/src/kdeinit/kinit_win.cpp
+++ b/src/kdeinit/kinit_win.cpp
@@ -54,6 +54,7 @@ typedef unsigned int pid_t;
// print verbose messages
int verbose = 0;
+int debug = 0;
/// holds process list for suicide mode
QList<QProcess *> startedProcesses;
@@ -213,6 +214,9 @@ static QString installRoot()
int index = path.lastIndexOf(QLatin1String("\\bin\\"));
if (index > -1)
path = path.left(index);
+ if (debug) {
+ qCDebug(KDEINIT) << "got install root as" << path;
+ }
return path;
}
@@ -230,6 +234,8 @@ public:
handle = _handle;
pid = _pid;
owner = copySid(_owner);
+ if (debug)
+ qCDebug(KDEINIT) << "adding process: path" << path << "name" << name;
}
~ProcessListEntry()
@@ -367,6 +373,8 @@ ProcessListEntry *ProcessList::find(const QString &name)
if (ple->name != name && ple->name != name + ".exe") {
continue;
}
+ if (debug)
+ qCDebug(KDEINIT) << "found process: path" << ple->path << "name" << ple->name;
if (!ple->path.isEmpty() && !ple->path.startsWith(installPrefix)) {
// process is outside of installation directory
@@ -554,6 +562,9 @@ int main(int argc, char **argv, char **envp)
if (strcmp(safe_argv[i], "--verbose") == 0) {
verbose = 1;
}
+ if (strcmp(safe_argv[i], "--debug") == 0) {
+ debug = 1;
+ }
if (strcmp(safe_argv[i], "--version") == 0) {
printf("Qt: %s\n", qVersion());
printf("KDE: %s\n", KINIT_VERSION_STRING);
@@ -561,6 +572,7 @@ int main(int argc, char **argv, char **envp)
}
if (strcmp(safe_argv[i], "--help") == 0) {
printf("Usage: kdeinit5 [options]\n");
+ printf(" --debug print debugging messages\n");
#ifdef ENABLE_EXIT
printf(" --exit Terminate when kded has run\n");
#endif
--
2.26.2