diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index b7bf74282ae589553fb83a964bb2f41e79f6419e..83f3239c03175f47f4a4ffe378a12e8d1928b242 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -95,81 +95,70 @@ private: friend class RemoteGdbAdapter; friend class TrkGdbAdapter; - // - // IDebuggerEngine implementation - // - void stepExec(); - void stepOutExec(); - void nextExec(); - void stepIExec(); - void nextIExec(); - - void shutdown(); - void setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos); - void startDebugger(const DebuggerStartParametersPtr &sp); - void exitDebugger(); - void detachDebugger(); +private: ////////// General Interface ////////// - void continueInferiorInternal(); - void autoContinueInferior(); - void continueInferior(); - void interruptInferior(); + virtual void addOptionPages(QList<Core::IOptionsPage*> *opts) const; - void runToLineExec(const QString &fileName, int lineNumber); - void runToFunctionExec(const QString &functionName); - void jumpToLineExec(const QString &fileName, int lineNumber); + virtual bool checkConfiguration(int toolChain, QString *errorMessage, QString *settingsPage= 0) const; - void activateFrame(int index); - void selectThread(int index); + virtual bool isGdbEngine() const { return true; } - Q_SLOT void attemptBreakpointSynchronization(); + virtual void startDebugger(const DebuggerStartParametersPtr &sp); + virtual void exitDebugger(); + virtual void detachDebugger(); + virtual void shutdown(); - void assignValueInDebugger(const QString &expr, const QString &value); - void executeDebuggerCommand(const QString & command); - void watchPoint(const QPoint &); + virtual void executeDebuggerCommand(const QString &command); - void loadSymbols(const QString &moduleName); - void loadAllSymbols(); - virtual QList<Symbol> moduleSymbols(const QString &moduleName); +private: ////////// General State ////////// - void fetchMemory(MemoryViewAgent *agent, quint64 addr, quint64 length); - void handleFetchMemory(const GdbResponse &response); + void initializeVariables(); + DebuggerStartMode startMode() const; + const DebuggerStartParameters &startParameters() const + { return *m_startParameters; } + Q_SLOT void setAutoDerefPointers(const QVariant &on); - void fetchDisassembler(DisassemblerViewAgent *agent, - const StackFrame &frame); - void fetchDisassemblerByAddress(DisassemblerViewAgent *agent, - bool useMixedMode); - void handleFetchDisassemblerByLine(const GdbResponse &response); - void handleFetchDisassemblerByAddress1(const GdbResponse &response); - void handleFetchDisassemblerByAddress0(const GdbResponse &response); + DebuggerStartParametersPtr m_startParameters; + QSharedPointer<TrkOptions> m_trkOptions; - Q_SLOT void setDebugDebuggingHelpers(const QVariant &on); - Q_SLOT void setUseDebuggingHelpers(const QVariant &on); - Q_SLOT void setAutoDerefPointers(const QVariant &on); - bool isGdbEngine() const { return true; } - bool isSynchroneous() const; +private: ////////// Gdb Process Management ////////// - bool checkConfiguration(int toolChain, QString *errorMessage, QString *settingsPage= 0) const; + AbstractGdbAdapter *createAdapter(const DebuggerStartParametersPtr &dp); + void connectAdapter(); + void startInferior(); - // - // Own stuff - // + void gdbInputAvailable(int channel, const QString &msg) + { m_manager->showDebuggerInput(channel, msg); } + void gdbOutputAvailable(int channel, const QString &msg) + { m_manager->showDebuggerOutput(channel, msg); } - int currentFrame() const; +private slots: + void readGdbStandardOutput(); + void readGdbStandardError(); + void readDebugeeOutput(const QByteArray &data); - bool supportsThreads() const; - void gotoLocation(const StackFrame &frame, bool setLocationMarker); - StackFrame parseStackFrame(const GdbMi &mi, int level); + void handleAdapterStarted(); + void handleAdapterStartFailed(const QString &msg, const QString &settingsIdHint = QString()); - void connectAdapter(); - void initializeVariables(); - QString fullName(const QString &fileName); - // get one usable name out of these, try full names first - QString fullName(const QStringList &candidates); + void handleInferiorStartFailed(const QString &msg); + void handleInferiorShutDown(); + void handleInferiorShutdownFailed(const QString &msg); + + void handleAdapterCrashed(const QString &msg); + void handleAdapterShutDown(); + void handleAdapterShutdownFailed(const QString &msg); - void handleResult(const GdbResponse &response); +private: + QTextCodec *m_outputCodec; + QTextCodec::ConverterState m_outputCodecState; + + QByteArray m_inbuffer; -public: // otherwise the Qt flag macros are unhappy + AbstractGdbAdapter *m_gdbAdapter; + +private: ////////// Gdb Command Management ////////// + + public: // otherwise the Qt flag macros are unhappy enum GdbCommandFlag { NoFlags = 0, NeedsStop = 1, // The command needs a stopped inferior @@ -181,9 +170,8 @@ public: // otherwise the Qt flag macros are unhappy ExitRequest = 32 // Callback expect GdbResultExit instead of GdbResultDone }; Q_DECLARE_FLAGS(GdbCommandFlags, GdbCommandFlag) + private: - -private: typedef void (GdbEngine::*GdbCommandCallback) (const GdbResponse &response); typedef void (AbstractGdbAdapter::*AdapterCallback) @@ -230,78 +218,78 @@ private: void postCommandHelper(const GdbCommand &cmd); void setTokenBarrier(); - void updateAll(); - void updateLocals(const QVariant &cookie = QVariant()); + QHash<int, GdbCommand> m_cookieForToken; - void gdbInputAvailable(int channel, const QString &msg) - { m_manager->showDebuggerInput(channel, msg); } - void gdbOutputAvailable(int channel, const QString &msg) - { m_manager->showDebuggerOutput(channel, msg); } + QByteArray m_pendingConsoleStreamOutput; + QByteArray m_pendingLogStreamOutput; -private slots: - void readGdbStandardOutput(); - void readGdbStandardError(); - void readDebugeeOutput(const QByteArray &data); + // contains the first token number for the current round + // of evaluation. Responses with older tokens are considers + // out of date and discarded. + int m_oldestAcceptableToken; - void handleAdapterStarted(); - void handleAdapterStartFailed(const QString &msg, const QString &settingsIdHint = QString()); + int m_pendingRequests; // Watch updating commands in flight - void handleInferiorStartFailed(const QString &msg); - void handleInferiorShutDown(); - void handleInferiorShutdownFailed(const QString &msg); + typedef void (GdbEngine::*CommandsDoneCallback)(); + // function called after all previous responses have been received + CommandsDoneCallback m_commandsDoneCallback; - void handleAdapterCrashed(const QString &msg); - void handleAdapterShutDown(); - void handleAdapterShutdownFailed(const QString &msg); + QList<GdbCommand> m_commandsToRunOnTemporaryBreak; + +private: ////////// Gdb Output, State & Capability Handling ////////// -private: void handleResponse(const QByteArray &buff); void handleStopResponse(const GdbMi &data); + void handleResultRecord(const GdbResponse &response); void handleStop1(const GdbResponse &response); void handleStop1(const GdbMi &data); void handleStop2(const GdbResponse &response); void handleStop2(const GdbMi &data); - void handleResultRecord(const GdbResponse &response); - void handleExecContinue(const GdbResponse &response); -// void handleExecRunToFunction(const GdbResponse &response); + StackFrame parseStackFrame(const GdbMi &mi, int level); + + virtual bool isSynchroneous() const; + bool supportsThreads() const; + + // Gdb initialization sequence void handleShowVersion(const GdbResponse &response); - void handleQuerySources(const GdbResponse &response); - void handleWatchPoint(const GdbResponse &response); void handleIsSynchroneous(const GdbResponse &response); - bool showToolTip(); - // Convenience - QMainWindow *mainWindow() const; - DebuggerStartMode startMode() const; - qint64 inferiorPid() const { return m_manager->inferiorPid(); } - void handleInferiorPidChanged(qint64 pid) { manager()->notifyInferiorPidChanged(pid); } + int m_gdbVersion; // 6.8.0 is 680 + int m_gdbBuildVersion; // MAC only? + bool m_isSynchroneous; // Can act synchroneously? - void handleChildren(const WatchData &parent, const GdbMi &child, - QList<WatchData> *insertions); - const bool m_dumperInjectionLoad; +private: ////////// Inferior Management ////////// - QTextCodec *m_outputCodec; - QTextCodec::ConverterState m_outputCodecState; + Q_SLOT virtual void attemptBreakpointSynchronization(); - QByteArray m_inbuffer; + virtual void stepExec(); + virtual void stepOutExec(); + virtual void nextExec(); + virtual void stepIExec(); + virtual void nextIExec(); - QHash<int, GdbCommand> m_cookieForToken; + void continueInferiorInternal(); + void autoContinueInferior(); + virtual void continueInferior(); + virtual void interruptInferior(); - QByteArray m_pendingConsoleStreamOutput; - QByteArray m_pendingLogStreamOutput; + virtual void runToLineExec(const QString &fileName, int lineNumber); + virtual void runToFunctionExec(const QString &functionName); +// void handleExecRunToFunction(const GdbResponse &response); + virtual void jumpToLineExec(const QString &fileName, int lineNumber); - // contains the first token number for the current round - // of evaluation. Responses with older tokens are considers - // out of date and discarded. - int m_oldestAcceptableToken; + void handleExecContinue(const GdbResponse &response); - int m_gdbVersion; // 6.8.0 is 680 - int m_gdbBuildVersion; // MAC only? - bool m_isSynchroneous; // Can act synchroneously? + qint64 inferiorPid() const { return m_manager->inferiorPid(); } + void handleInferiorPidChanged(qint64 pid) { manager()->notifyInferiorPidChanged(pid); } + void maybeHandleInferiorPidChanged(const QString &pid); - // awful hack to keep track of used files - QMap<QString, QString> m_shortToFullName; - QMap<QString, QString> m_fullToShortName; +private: ////////// View & Data Stuff ////////// + + virtual void selectThread(int index); + virtual void activateFrame(int index); + + void gotoLocation(const StackFrame &frame, bool setLocationMarker); // // Breakpoint specific stuff @@ -320,9 +308,13 @@ private: // // Modules specific stuff // + virtual void loadSymbols(const QString &moduleName); + virtual void loadAllSymbols(); + virtual QList<Symbol> moduleSymbols(const QString &moduleName); void reloadModules(); void handleModulesList(const GdbResponse &response); + bool m_modulesListOutdated; // // Register specific stuff @@ -332,54 +324,83 @@ private: void handleRegisterListNames(const GdbResponse &response); void handleRegisterListValues(const GdbResponse &response); + // + // Disassembler specific stuff + // + virtual void fetchDisassembler(DisassemblerViewAgent *agent, + const StackFrame &frame); + void fetchDisassemblerByAddress(DisassemblerViewAgent *agent, + bool useMixedMode); + void handleFetchDisassemblerByLine(const GdbResponse &response); + void handleFetchDisassemblerByAddress1(const GdbResponse &response); + void handleFetchDisassemblerByAddress0(const GdbResponse &response); + QString parseDisassembler(const GdbMi &lines); + // // Source file specific stuff // void reloadSourceFiles(); + void handleQuerySources(const GdbResponse &response); + + QString fullName(const QString &fileName); + // get one usable name out of these, try full names first + QString fullName(const QStringList &candidates); + + // awful hack to keep track of used files + QMap<QString, QString> m_shortToFullName; + QMap<QString, QString> m_fullToShortName; // // Stack specific stuff // + void updateAll(); void handleStackListFrames(const GdbResponse &response); void handleStackSelectThread(const GdbResponse &response); void handleStackListThreads(const GdbResponse &response); void handleStackFrame1(const GdbResponse &response); void handleStackFrame2(const GdbResponse &response); - QByteArray m_firstChunk; Q_SLOT void reloadStack(bool forceGotoLocation); Q_SLOT void reloadFullStack(); + int currentFrame() const; + QList<GdbMi> m_currentFunctionArgs; + QByteArray m_firstChunk; + QString m_currentFrame; // - // Tooltip specific stuff + // Watch specific stuff // - void sendToolTipCommand(const QString &command, const QString &cookie); + virtual void setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos); + virtual void assignValueInDebugger(const QString &expr, const QString &value); + + virtual void fetchMemory(MemoryViewAgent *agent, quint64 addr, quint64 length); + void handleFetchMemory(const GdbResponse &response); + + virtual void watchPoint(const QPoint &); + void handleWatchPoint(const GdbResponse &response); - // - // Watch specific stuff - // // FIXME: BaseClass. called to improve situation for a watch item void updateSubItem(const WatchData &data); + void handleChildren(const WatchData &parent, const GdbMi &child, + QList<WatchData> *insertions); void updateWatchData(const WatchData &data); Q_SLOT void updateWatchDataHelper(const WatchData &data); void rebuildModel(); + bool showToolTip(); void insertData(const WatchData &data); void sendWatchParameters(const QByteArray ¶ms0); void createGdbVariable(const WatchData &data); - void maybeHandleInferiorPidChanged(const QString &pid); - - void tryLoadDebuggingHelpers(); - void tryQueryDebuggingHelpers(); - Q_SLOT void recheckDebuggingHelperAvailability(); void runDebuggingHelper(const WatchData &data, bool dumpChildren); void runDirectDebuggingHelper(const WatchData &data, bool dumpChildren); bool hasDebuggingHelperForType(const QString &type) const; void handleVarListChildren(const GdbResponse &response); + void handleVarListChildrenHelper(const GdbMi &child, + const WatchData &parent); void handleVarCreate(const GdbResponse &response); void handleVarAssign(const GdbResponse &response); void handleEvaluateExpression(const GdbResponse &response); @@ -390,55 +411,42 @@ private: void handleDebuggingHelperValue3(const GdbResponse &response); void handleDebuggingHelperEditValue(const GdbResponse &response); void handleDebuggingHelperSetup(const GdbResponse &response); + + void updateLocals(const QVariant &cookie = QVariant()); void handleStackListLocals(const GdbResponse &response); + WatchData localVariable(const GdbMi &item, + const QStringList &uninitializedVariables, + QMap<QByteArray, int> *seen); + void setLocals(const QList<GdbMi> &locals); void handleStackListArguments(const GdbResponse &response); - void handleVarListChildrenHelper(const GdbMi &child, - const WatchData &parent); void setWatchDataType(WatchData &data, const GdbMi &mi); void setWatchDataDisplayedType(WatchData &data, const GdbMi &mi); - inline WatchData localVariable(const GdbMi &item, - const QStringList &uninitializedVariables, - QMap<QByteArray, int> *seen); - void connectDebuggingHelperActions(); - void disconnectDebuggingHelperActions(); - AbstractGdbAdapter *createAdapter(const DebuggerStartParametersPtr &dp); - - bool startModeAllowsDumpers() const; - QString parseDisassembler(const GdbMi &lines); - int m_pendingRequests; QSet<QString> m_processedNames; - - QtDumperHelper m_dumperHelper; - - DebuggingHelperState m_debuggingHelperState; - QList<GdbMi> m_currentFunctionArgs; - QString m_currentFrame; QMap<QString, QString> m_varToType; - typedef void (GdbEngine::*CommandsDoneCallback)(); - // function called after all previous responses have been received - CommandsDoneCallback m_commandsDoneCallback; - void startInferior(); - - bool m_modulesListOutdated; - - QList<GdbCommand> m_commandsToRunOnTemporaryBreak; +private: ////////// Dumper Management ////////// - DebuggerStartParametersPtr m_startParameters; - // make sure to re-initialize new members in initializeVariables(); + bool startModeAllowsDumpers() const; + void tryLoadDebuggingHelpers(); + void tryQueryDebuggingHelpers(); + Q_SLOT void recheckDebuggingHelperAvailability(); + void connectDebuggingHelperActions(); + void disconnectDebuggingHelperActions(); + Q_SLOT void setDebugDebuggingHelpers(const QVariant &on); + Q_SLOT void setUseDebuggingHelpers(const QVariant &on); - QSharedPointer<TrkOptions> m_trkOptions; + const bool m_dumperInjectionLoad; + DebuggingHelperState m_debuggingHelperState; + QtDumperHelper m_dumperHelper; - AbstractGdbAdapter *m_gdbAdapter; +private: ////////// Convenience Functions ////////// -public: QString errorMessage(QProcess::ProcessError error); void showMessageBox(int icon, const QString &title, const QString &text); void debugMessage(const QString &msg); - void addOptionPages(QList<Core::IOptionsPage*> *opts) const; - const DebuggerStartParameters &startParameters() const - { return *m_startParameters; } + QMainWindow *mainWindow() const; + }; } // namespace Internal