File indexing completed on 2024-05-05 16:45:29
0001 /* 0002 SPDX-FileCopyrightText: 2009 Vladimir Prus <ghost@cs.msu.su> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef MIVARIABLE_H 0008 #define MIVARIABLE_H 0009 0010 #include "mi/mi.h" 0011 0012 #include <debugger/variable/variablecollection.h> 0013 0014 #include <QPointer> 0015 0016 0017 class CreateVarobjHandler; 0018 class FetchMoreChildrenHandler; 0019 class SetFormatHandler; 0020 namespace KDevMI { 0021 class MIDebugSession; 0022 class MIVariable : public KDevelop::Variable 0023 { 0024 Q_OBJECT 0025 0026 0027 public: 0028 MIVariable(MIDebugSession *session, KDevelop::TreeModel* model, KDevelop::TreeItem* parent, 0029 const QString& expression, const QString& display = QString()); 0030 0031 ~MIVariable() override; 0032 0033 /* FIXME: should eventually remove, so that existence of 0034 varobjs is fully encapsulalated inside GdbVariable. */ 0035 const QString& varobj() const; 0036 void handleUpdate(const MI::Value& var); 0037 0038 /* Called when debugger dies. Clears the association between varobj names 0039 and Variable instances. */ 0040 void markAsDead(); 0041 0042 bool canSetFormat() const override { return true; } 0043 0044 protected: // Variable overrides 0045 void attachMaybe(QObject *callback, const char *callbackMethod) override; 0046 void fetchMoreChildren() override; 0047 void formatChanged() override; 0048 0049 protected: // Internal 0050 friend class ::CreateVarobjHandler; 0051 friend class ::FetchMoreChildrenHandler; 0052 friend class ::SetFormatHandler; 0053 0054 /** 0055 * Construct a MIVariable child directly from a MI value 0056 */ 0057 MIVariable *createChild(const MI::Value &child); 0058 0059 QString enquotedExpression() const; 0060 virtual QString formatValue(const QString &rawValue) const; 0061 0062 bool sessionIsAlive() const; 0063 0064 void setVarobj(const QString& v); 0065 0066 protected: 0067 QPointer<MIDebugSession> m_debugSession; 0068 0069 private: 0070 QString m_varobj; 0071 0072 // How many children should be fetched in one 0073 // increment. 0074 static const int s_fetchStep = 5; 0075 }; 0076 } // end of KDevMI 0077 0078 #endif