File indexing completed on 2024-05-12 05:46:49
0001 /* This file is part of the KDE project 0002 Copyright (C) 2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> 0003 Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org> 0004 Copyright (C) 2007 Hamish Rodda <rodda@kde.org> 0005 Copyright (C) 2009 Niko Sams <niko.sams@gmail.com> 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 0020 Boston, MA 02111-1307, USA. 0021 */ 0022 #ifndef MIBREAKPOINTCONTROLLER_H 0023 #define MIBREAKPOINTCONTROLLER_H 0024 0025 #include "dbgglobal.h" 0026 0027 #include <debugger/interfaces/ibreakpointcontroller.h> 0028 #include <debugger/interfaces/idebugsession.h> 0029 0030 namespace KDevMI { 0031 0032 namespace MI { 0033 struct AsyncRecord; 0034 struct ResultRecord; 0035 struct Value; 0036 } 0037 0038 struct BreakpointData { 0039 int debuggerId = -1; 0040 KDevelop::BreakpointModel::ColumnFlags dirty; 0041 KDevelop::BreakpointModel::ColumnFlags sent; 0042 KDevelop::BreakpointModel::ColumnFlags errors; 0043 bool pending = false; 0044 0045 BreakpointData() 0046 {} 0047 }; 0048 0049 using BreakpointDataPtr = QSharedPointer<BreakpointData>; 0050 0051 class MIDebugSession; 0052 /** 0053 * Handles signals from the editor that relate to breakpoints and the execution 0054 * point of the debugger. 0055 * We may change, add or remove breakpoints in this class. 0056 */ 0057 class MIBreakpointController : public KDevelop::IBreakpointController 0058 { 0059 Q_OBJECT 0060 public: 0061 explicit MIBreakpointController(MIDebugSession* parent); 0062 0063 using IBreakpointController::breakpointModel; 0064 0065 /** 0066 * Controls whether when duplicate breakpoints are received via async notification from GDB, 0067 * one of the duplicates will be deleted. 0068 */ 0069 void setDeleteDuplicateBreakpoints(bool enable); 0070 0071 void breakpointAdded(int row) override; 0072 void breakpointModelChanged(int row, KDevelop::BreakpointModel::ColumnFlags columns) override; 0073 void breakpointAboutToBeDeleted(int row) override; 0074 void debuggerStateChanged(KDevelop::IDebugSession::DebuggerState) override; 0075 0076 void notifyBreakpointCreated(const MI::AsyncRecord& r); 0077 void notifyBreakpointModified(const MI::AsyncRecord& r); 0078 void notifyBreakpointDeleted(const MI::AsyncRecord& r); 0079 0080 public Q_SLOTS: 0081 void initSendBreakpoints(); 0082 0083 private Q_SLOTS: 0084 void programStopped(const MI::AsyncRecord &r); 0085 0086 private: 0087 MIDebugSession* debugSession() const; 0088 0089 int breakpointRow(const BreakpointDataPtr& breakpoint); 0090 void createBreakpoint(int row); 0091 void sendUpdates(int row); 0092 void recalculateState(int row); 0093 0094 void sendMaybe(KDevelop::Breakpoint *breakpoint) override; 0095 0096 void createFromDebugger(const MI::Value& miBkpt); 0097 void updateFromDebugger(int row, const MI::Value& miBkpt, 0098 KDevelop::BreakpointModel::ColumnFlags lockedColumns = {}); 0099 0100 int rowFromDebuggerId(int gdbId) const; 0101 0102 struct Handler; 0103 struct InsertedHandler; 0104 struct UpdateHandler; 0105 struct DeleteHandler; 0106 struct IgnoreChanges; 0107 0108 QList<BreakpointDataPtr> m_breakpoints; 0109 QList<BreakpointDataPtr> m_pendingDeleted; 0110 int m_ignoreChanges = 0; 0111 bool m_deleteDuplicateBreakpoints = false; 0112 }; 0113 0114 } // end of namespace KDevMI 0115 0116 #endif // MIBREAKPOINTCONTROLLER_H