├── README.md ├── xdebugscript.cmake ├── xdebugscript.pri ├── LICENSE ├── xdebugscripthelper.cpp ├── xdebugscripthelper.h ├── xdebugscript.h ├── xdebugscriptengine.h ├── xdebugscript.cpp └── xdebugscriptengine.cpp /README.md: -------------------------------------------------------------------------------- 1 | # XDebugScript 2 | 3 | Scripts for Windows debugging 4 | -------------------------------------------------------------------------------- /xdebugscript.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | set(XDEBUGSCRIPT_SOURCES 4 | ${CMAKE_CURRENT_LIST_DIR}/xdebugscript.cpp 5 | ${CMAKE_CURRENT_LIST_DIR}/xdebugscript.h 6 | ${CMAKE_CURRENT_LIST_DIR}/xdebugscriptengine.cpp 7 | ${CMAKE_CURRENT_LIST_DIR}/xdebugscriptengine.h 8 | ${CMAKE_CURRENT_LIST_DIR}/xdebugscripthelper.cpp 9 | ${CMAKE_CURRENT_LIST_DIR}/xdebugscripthelper.h 10 | ) 11 | -------------------------------------------------------------------------------- /xdebugscript.pri: -------------------------------------------------------------------------------- 1 | lessThan(QT_MAJOR_VERSION, 6): QT += script 2 | greaterThan(QT_MAJOR_VERSION, 5): QT += qml 3 | 4 | INCLUDEPATH += $$PWD 5 | DEPENDPATH += $$PWD 6 | 7 | HEADERS += \ 8 | $$PWD/xdebugscript.h \ 9 | $$PWD/xdebugscriptengine.h \ 10 | $$PWD/xdebugscripthelper.h 11 | 12 | SOURCES += \ 13 | $$PWD/xdebugscript.cpp \ 14 | $$PWD/xdebugscriptengine.cpp \ 15 | $$PWD/xdebugscripthelper.cpp 16 | 17 | DISTFILES += \ 18 | $$PWD/LICENSE \ 19 | $$PWD/README.md 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-2025 hors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /xdebugscripthelper.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xdebugscripthelper.h" 22 | 23 | XDebugScriptHelper::XDebugScriptHelper(QObject *pParent) : QObject(pParent) 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /xdebugscripthelper.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XDEBUGSCRIPTHELPER_H 22 | #define XDEBUGSCRIPTHELPER_H 23 | 24 | #include 25 | 26 | class XDebugScriptHelper : public QObject { 27 | Q_OBJECT 28 | public: 29 | explicit XDebugScriptHelper(QObject *pParent = nullptr); 30 | 31 | signals: 32 | }; 33 | 34 | #endif // XDEBUGSCRIPTHELPER_H 35 | -------------------------------------------------------------------------------- /xdebugscript.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XDEBUGSCRIPT_H 22 | #define XDEBUGSCRIPT_H 23 | 24 | #include "xdebugscriptengine.h" 25 | 26 | class XDebugScript : public QObject { 27 | Q_OBJECT 28 | 29 | public: 30 | XDebugScript(QObject *pParent = nullptr); 31 | ~XDebugScript(); 32 | 33 | bool setData(XAbstractDebugger *pDebugger, const QString &sScriptFileName); 34 | XDebugScriptEngine::INFO getInfo(); 35 | 36 | private: 37 | bool _handleError(QScriptValue scriptValue); 38 | void _onBreakPoint(XInfoDB::BREAKPOINT_INFO *pBreakPointInfo, QString sFunction); 39 | void _onSharedObject(XInfoDB::SHAREDOBJECT_INFO *pSharedObjectInfo, QString sFunction); 40 | void _onFunction(XInfoDB::FUNCTION_INFO *pFunctionInfo, QString sFunction); 41 | void _getInfo(); 42 | 43 | private slots: 44 | void onEventCreateProcess(XInfoDB::PROCESS_INFO *pProcessInfo); 45 | void onEventExitProcess(XInfoDB::EXITPROCESS_INFO *pExitProcessInfo); 46 | void onEventCreateThread(XInfoDB::THREAD_INFO *pThreadInfo); 47 | void onEventExitThread(XInfoDB::EXITTHREAD_INFO *pExitThreadInfo); 48 | void onEventLoadSharedObject(XInfoDB::SHAREDOBJECT_INFO *pSharedObjectInfo); 49 | void onEventUnloadSharedObject(XInfoDB::SHAREDOBJECT_INFO *pSharedObjectInfo); 50 | void onEventDebugString(XInfoDB::DEBUGSTRING_INFO *pDebugString); 51 | void onEventBreakPoint(XInfoDB::BREAKPOINT_INFO *pBreakPointInfo); 52 | void onEventProgramEntryPoint(XInfoDB::BREAKPOINT_INFO *pBreakPointInfo); 53 | void onEventFunctionEnter(XInfoDB::FUNCTION_INFO *pFunctionInfo); 54 | void onEventFunctionLeave(XInfoDB::FUNCTION_INFO *pFunctionInfo); 55 | 56 | signals: 57 | void errorMessage(QString sText); 58 | void infoMessage(QString sText); 59 | 60 | private: 61 | XAbstractDebugger *g_pDebugger; 62 | XDebugScriptEngine *g_DebugScriptEngine; 63 | QScriptValue g_script; 64 | }; 65 | 66 | #endif // XDEBUGSCRIPT_H 67 | -------------------------------------------------------------------------------- /xdebugscriptengine.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XDEBUGSCRIPTENGINE_H 22 | #define XDEBUGSCRIPTENGINE_H 23 | 24 | #include // TODO use QJSEngine 25 | #ifdef Q_OS_WIN 26 | #include "xwindowsdebugger.h" 27 | #endif 28 | #ifdef Q_OS_LINUX 29 | #include "xlinuxdebugger.h" 30 | #endif 31 | #ifdef Q_OS_OSX 32 | #include "xosxdebugger.h" 33 | #endif 34 | 35 | struct XDEBUGSCRIPT_BREAKPOINT_INFO { 36 | qsreal address; 37 | QString info; 38 | qsreal thread_id; 39 | }; 40 | 41 | Q_DECLARE_METATYPE(XDEBUGSCRIPT_BREAKPOINT_INFO) 42 | 43 | struct XDEBUGSCRIPT_SHAREDOBJECT_INFO { 44 | QString name; 45 | QString file_name; 46 | qsreal image_base; 47 | qsreal image_size; 48 | }; 49 | 50 | Q_DECLARE_METATYPE(XDEBUGSCRIPT_SHAREDOBJECT_INFO) 51 | 52 | struct XDEBUGSCRIPT_FUNCTION_INFO { 53 | QString name; 54 | qsreal address; 55 | qsreal ret_address; 56 | qsreal parameter[10]; 57 | }; 58 | 59 | Q_DECLARE_METATYPE(XDEBUGSCRIPT_FUNCTION_INFO) 60 | 61 | class XDebugScriptEngine : public QScriptEngine { 62 | Q_OBJECT 63 | 64 | public: 65 | enum OPTION_TYPE { 66 | OPTION_TYPE_UNKNOWN = 0, 67 | OPTION_TYPE_BOOL, 68 | OPTION_TYPE_STRING, 69 | OPTION_TYPE_INTEGER 70 | }; 71 | 72 | struct OPTION { 73 | QVariant varValue; 74 | OPTION_TYPE optionType; 75 | }; 76 | 77 | struct INFO { 78 | QString sName; 79 | QString sFileName; 80 | QString sVersion; 81 | QString sAuthor; 82 | QString sShortInfo; 83 | QString sInfo; 84 | QList listMethods; 85 | QList