File indexing completed on 2024-04-21 16:12:18
0001 /****************************************************************** 0002 * 0003 * kdbgwin - Helper application for DrKonqi 0004 * 0005 * This file is part of the KDE project 0006 * 0007 * SPDX-FileCopyrightText: 2010 Ilie Halip <lupuroshu@gmail.com> 0008 * 0009 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0010 *****************************************************************/ 0011 0012 #include "common.h" 0013 #include "kdbgwin_process.h" 0014 #include "mingw_generator.h" 0015 #include "msvc_generator.h" 0016 #include "outputters.h" 0017 0018 #include <QCoreApplication> 0019 0020 int main(int argc, char *argv[]) 0021 { 0022 QCoreApplication app(argc, argv); 0023 QCoreApplication::setApplicationName(QStringLiteral("kdbgwin")); 0024 0025 if (argc != 3) { 0026 qCCritical(DRKONQI_LOG) << "Parameters are incorrect"; 0027 return -1; 0028 } 0029 0030 if (!Process::EnableDebugPrivilege()) { 0031 qCCritical(DRKONQI_LOG) << "Cannot enable debug privilege, exiting"; 0032 return -1; 0033 } 0034 0035 // ok, argv[1] is the pid of the failing process, 0036 // and argv[2] the current thread id - let's get the info we need 0037 Process proc; 0038 if (!proc.GetInfo(argv[1], argv[2])) { 0039 qCCritical(DRKONQI_LOG) << "Cannot attach to process, exiting"; 0040 return -1; 0041 } 0042 0043 #if defined(Q_CC_MSVC) 0044 MsvcGenerator generator(proc); 0045 #elif defined(Q_CC_GNU) 0046 MingwGenerator generator(proc); 0047 #endif 0048 0049 Outputter outputter; 0050 0051 QObject::connect(&generator, &MingwGenerator::DebugLine, &outputter, &Outputter::OnDebugLine); 0052 0053 TThreadsMap::const_iterator it; 0054 for (it = proc.GetThreads().constBegin(); it != proc.GetThreads().constEnd(); it++) { 0055 generator.Run(it.value(), (it.key() == proc.GetThreadId()) ? true : false); 0056 } 0057 }