File indexing completed on 2024-05-12 04:39:44

0001 /*
0002     SPDX-FileCopyrightText: 2013 Vlas Puhov <vlas.puhov@mail.ru>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef REGISTERSMANAGER_H
0008 #define REGISTERSMANAGER_H
0009 
0010 #include <QObject>
0011 #include <QStringList>
0012 #include <QScopedPointer>
0013 
0014 namespace KDevMI {
0015 namespace MI
0016 {
0017 struct ResultRecord;
0018 }
0019 
0020 class MIDebugSession;
0021 
0022 class RegistersView;
0023 class IRegisterController;
0024 class ModelsManager;
0025 
0026 enum Architecture {x86, x86_64, arm, other = 100, undefined};
0027 
0028 /** @brief Determines current CPU architecture */
0029 class ArchitectureParser : public QObject
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034 
0035     explicit ArchitectureParser(QObject* parent);
0036 
0037     ///Asynchronously determines current architecture. emits @p architectureParsed when ready.
0038     void determineArchitecture(MIDebugSession* debugSession);
0039 
0040 Q_SIGNALS:
0041     ///Emits current CPU architecture. @sa determineArchitecture
0042     void architectureParsed(Architecture arch);
0043 
0044 private:
0045 
0046     void registerNamesHandler(const MI::ResultRecord& r);
0047     void parseArchitecture();
0048 
0049     QStringList m_registerNames;
0050 };
0051 
0052 class RegistersManager : public QObject
0053 {
0054     Q_OBJECT
0055 
0056 public:
0057     explicit RegistersManager(QWidget* parent);
0058 
0059 public Q_SLOTS:
0060     void setSession(MIDebugSession* debugSession);
0061     ///Updates all registers.
0062     void updateRegisters();
0063     ///@sa ArchitectureParser::determineArchitecture
0064     void architectureParsedSlot(const Architecture arch);
0065 
0066 private:
0067     void setController(IRegisterController* c);
0068 
0069     RegistersView* m_registersView;
0070 
0071     QScopedPointer<IRegisterController> m_registerController;
0072 
0073     ArchitectureParser* m_architectureParser;
0074 
0075     MIDebugSession* m_debugSession;
0076 
0077     ModelsManager* m_modelsManager;
0078 
0079     Architecture m_currentArchitecture;
0080 
0081     ///True if architecture could has changed(e.g. from x86 to arm)
0082     bool m_needToCheckArch;
0083 };
0084 
0085 } // end of namespace KDevMI
0086 #endif // REGISTERSMANAGER_H