File indexing completed on 2024-05-05 04:39:53

0001 /*
0002     SPDX-FileCopyrightText: 1999 John Birch <jbb@kdevelop.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef MEMVIEW_H_
0008 #define MEMVIEW_H_
0009 
0010 #include "dbgglobal.h"
0011 #include "mi/mi.h"
0012 
0013 #include <QWidget>
0014 
0015 namespace Okteta {
0016 class ByteArrayModel;
0017 }
0018 namespace Okteta {
0019 class ByteArrayColumnView;
0020 }
0021 
0022 namespace KDevelop {
0023 class IDebugSession;
0024 }
0025 
0026 class QToolBox;
0027 
0028 
0029 namespace KDevMI
0030 {
0031 namespace GDB
0032 {
0033     class CppDebuggerPlugin;
0034     class MemoryView;
0035     class GDBController;
0036     class MemoryRangeSelector;
0037 
0038     class MemoryViewerWidget : public QWidget
0039     {
0040         Q_OBJECT
0041     public:
0042         explicit MemoryViewerWidget(CppDebuggerPlugin* plugin, QWidget* parent = nullptr);
0043 
0044     public Q_SLOTS:
0045         /** Adds a new memory view. */
0046         void slotAddMemoryView();
0047 
0048     Q_SIGNALS:
0049         void requestRaise();
0050 
0051 
0052     private Q_SLOTS:
0053         void slotChildCaptionChanged(const QString& caption);
0054 
0055     private: // Data
0056         QToolBox* m_toolBox;
0057     };
0058 
0059     class MemoryView : public QWidget
0060     {
0061         Q_OBJECT
0062     public:
0063         explicit MemoryView(QWidget* parent);
0064 
0065         void debuggerStateChanged(DBGStateFlags state);
0066 
0067     Q_SIGNALS:
0068         void captionChanged(const QString& caption);
0069 
0070     private: // Callbacks
0071         void sizeComputed(const QString& value);
0072 
0073         void memoryRead(const MI::ResultRecord& r);
0074 
0075         // Returns true is we successfully created the memoryView, and
0076         // can work.
0077         bool isOk() const;
0078 
0079     private Q_SLOTS:
0080         void memoryEdited(int start, int end);
0081         /** Informs the view about changes in debugger state.
0082          *  Allows view to disable itself when debugger is not running. */
0083         void slotStateChanged(DBGStateFlags oldState, DBGStateFlags newState);
0084 
0085         /** Invoked when user has changed memory range.
0086             Gets memory for the new range. */
0087         void slotChangeMemoryRange();
0088         void slotHideRangeDialog();
0089         void slotEnableOrDisable();
0090 
0091     private: // QWidget overrides
0092         void contextMenuEvent(QContextMenuEvent* e) override;
0093 
0094         void initWidget();
0095 
0096         MemoryRangeSelector* m_rangeSelector;
0097         Okteta::ByteArrayModel *m_memViewModel;
0098         Okteta::ByteArrayColumnView *m_memViewView;
0099 
0100         quintptr m_memStart;
0101         QString m_memStartStr, m_memAmountStr;
0102         QByteArray m_memData;
0103         int m_debuggerState;
0104 
0105     private Q_SLOTS:
0106         void currentSessionChanged(KDevelop::IDebugSession* session);
0107     };
0108 
0109 } // end of namespace GDB
0110 } // end of namespace KDevMI
0111 
0112 #endif