File indexing completed on 2024-06-09 13:27:30

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 #pragma once
0013 
0014 // the compiler only provides UNICODE. tchar.h checks for the _UNICODE macro
0015 #if defined(MSC_VER) && defined(UNICODE)
0016 #define _UNICODE
0017 #endif
0018 
0019 // clang-format off
0020 // first: windows & compiler includes
0021 #include <tchar.h>
0022 #include <windows.h>
0023 #include <dbghelp.h>
0024 #include <assert.h>
0025 #include <shlwapi.h>
0026 #include <psapi.h>
0027 #include <tlhelp32.h>
0028 
0029 #include "drkonqi_debug.h"
0030 // clang-format on
0031 
0032 // second: Qt includes
0033 
0034 // third: KDE includes
0035 
0036 // common defines
0037 #define SafeCloseHandle(h)                                                                                                                                     \
0038     CloseHandle(h);                                                                                                                                            \
0039     h = NULL;
0040 
0041 #define ArrayCount(x) (sizeof(x) / sizeof(x[0]))
0042 
0043 // Documentation
0044 /**
0045 \mainpage KDbgWin
0046 
0047 KDbgWin (KDE Debugger for Windows) is a helper application for DrKonqi. Because KDE-Windows supports
0048 2 compilers (MSVC and MinGW), and there is no debugger that supports them both, a simple debugger was needed
0049 to make DrKonqi able to generate backtraces - Windows only.
0050 
0051 MSVC generates .pdb files for its binaries, and GNU GCC embeds debugging information in executables. However,
0052 with MinGW, debugging information can be stripped into external files and then loaded on demand. So the only
0053 difference between the two is how symbols are handled. DbgHelp and LibBfd were used for manipulating and getting
0054 the required information from each debugging format.
0055 */