2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <debugger/debuggerengine.h>
|
2010-06-30 14:39:41 +02:00
|
|
|
|
2015-01-10 01:07:01 +01:00
|
|
|
#include <debugger/breakhandler.h>
|
2015-07-21 12:52:18 +02:00
|
|
|
#include <debugger/registerhandler.h>
|
2019-07-28 23:32:33 +03:00
|
|
|
#include <debugger/peripheralregisterhandler.h>
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <debugger/watchhandler.h>
|
|
|
|
|
#include <debugger/watchutils.h>
|
2016-07-29 15:55:15 +02:00
|
|
|
#include <debugger/debuggeritem.h>
|
2014-07-10 18:10:56 +02:00
|
|
|
#include <debugger/debuggertooltipmanager.h>
|
2017-09-08 08:53:15 +02:00
|
|
|
#include <debugger/outputcollector.h>
|
2009-02-20 12:33:16 +01:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
#include <utils/id.h>
|
2015-06-08 12:10:11 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2013-11-04 09:47:34 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QProcess>
|
|
|
|
|
#include <QTextCodec>
|
|
|
|
|
#include <QTimer>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
class BreakpointParameters;
|
2012-03-30 17:36:44 +02:00
|
|
|
class DebugInfoTask;
|
|
|
|
|
class DebugInfoTaskHandler;
|
2015-02-05 15:47:07 +01:00
|
|
|
class DebuggerResponse;
|
2017-09-08 08:53:15 +02:00
|
|
|
class DisassemblerAgentCookie;
|
2008-12-02 12:01:29 +01:00
|
|
|
class GdbMi;
|
2013-11-05 18:47:03 +01:00
|
|
|
class MemoryAgentCookie;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
struct CoreInfo
|
|
|
|
|
{
|
|
|
|
|
QString rawStringFromCore;
|
|
|
|
|
QString foundExecutableName; // empty if no corresponding exec could be found
|
|
|
|
|
bool isCore = false;
|
|
|
|
|
|
2018-05-16 15:42:03 +02:00
|
|
|
static CoreInfo readExecutableNameFromCore(const ProjectExplorer::Runnable &debugger,
|
2017-09-08 08:53:15 +02:00
|
|
|
const QString &coreFile);
|
|
|
|
|
};
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2020-01-29 04:15:25 +03:00
|
|
|
class GdbEngine final : public CppDebuggerEngine
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2017-09-26 15:22:14 +02:00
|
|
|
GdbEngine();
|
2017-09-08 08:53:15 +02:00
|
|
|
~GdbEngine() final;
|
2009-09-11 12:30:53 +02:00
|
|
|
|
2009-10-15 12:32:49 +02:00
|
|
|
private: ////////// General Interface //////////
|
2017-09-08 08:53:15 +02:00
|
|
|
void handleGdbStartFailed();
|
|
|
|
|
void prepareForRestart() final;
|
2010-07-08 18:10:50 +02:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
bool hasCapability(unsigned) const final;
|
|
|
|
|
void detachDebugger() final;
|
|
|
|
|
void shutdownInferior() final;
|
2017-09-19 12:31:19 +02:00
|
|
|
void abortDebuggerProcess() final;
|
2017-09-08 08:53:15 +02:00
|
|
|
void resetInferior() final;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
bool acceptsDebuggerCommands() const final;
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
void executeDebuggerCommand(const QString &command) final;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
////////// General State //////////
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
bool m_registerNamesListed = false;
|
2009-08-14 13:04:05 +02:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
////////// Gdb Process Management //////////
|
2009-01-27 15:53:50 +01:00
|
|
|
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleInferiorShutdown(const DebuggerResponse &response);
|
|
|
|
|
void handleGdbExit(const DebuggerResponse &response);
|
2016-04-07 12:34:19 +03:00
|
|
|
void setLinuxOsAbi();
|
2009-10-20 11:02:16 +02:00
|
|
|
|
2011-12-05 08:53:51 +02:00
|
|
|
void loadInitScript();
|
2015-07-15 10:38:15 +03:00
|
|
|
void setEnvironmentVariables();
|
2010-07-08 18:10:50 +02:00
|
|
|
|
2010-07-08 12:41:26 +02:00
|
|
|
// Something went wrong with the adapter *before* adapterStarted() was emitted.
|
|
|
|
|
// Make sure to clean up everything before emitting this signal.
|
2010-03-03 18:08:18 +01:00
|
|
|
void handleAdapterStartFailed(const QString &msg,
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id settingsIdHint = Utils::Id());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2021-01-05 12:02:18 +01:00
|
|
|
// Called after target setup.
|
2009-10-19 19:04:01 +02:00
|
|
|
void handleInferiorPrepared();
|
|
|
|
|
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleDebugInfoLocation(const DebuggerResponse &response);
|
2012-05-10 16:22:06 +02:00
|
|
|
|
2017-09-12 10:33:59 +02:00
|
|
|
// The engine is still running just fine, but it failed to acquire a debuggee.
|
|
|
|
|
void notifyInferiorSetupFailedHelper(const QString &msg);
|
2010-07-09 17:07:59 +02:00
|
|
|
|
2021-05-28 14:48:25 +02:00
|
|
|
void handleGdbFinished();
|
2010-07-08 12:41:26 +02:00
|
|
|
void handleGdbError(QProcess::ProcessError error);
|
|
|
|
|
void readGdbStandardOutput();
|
|
|
|
|
void readGdbStandardError();
|
2016-06-07 17:04:53 +02:00
|
|
|
void readDebuggeeOutput(const QByteArray &ba);
|
2010-07-08 12:41:26 +02:00
|
|
|
|
2016-06-13 11:22:28 +02:00
|
|
|
QTextCodec *m_gdbOutputCodec;
|
|
|
|
|
QTextCodec::ConverterState m_gdbOutputCodecState;
|
|
|
|
|
QTextCodec *m_inferiorOutputCodec;
|
|
|
|
|
QTextCodec::ConverterState m_inferiorOutputCodecState;
|
2009-10-15 12:32:49 +02:00
|
|
|
|
|
|
|
|
QByteArray m_inbuffer;
|
2017-09-08 08:53:15 +02:00
|
|
|
bool m_busy = false;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-19 12:00:01 +02:00
|
|
|
// Name of the convenience variable containing the last
|
|
|
|
|
// known function return value.
|
2016-06-07 17:04:53 +02:00
|
|
|
QString m_resultVarName;
|
2010-05-19 12:00:01 +02:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
////////// Gdb Command Management //////////
|
2009-05-04 18:30:22 +02:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
void runCommand(const DebuggerCommand &command) final;
|
2015-09-11 11:28:55 +02:00
|
|
|
|
2016-04-19 22:49:23 +02:00
|
|
|
void commandTimeout();
|
2008-12-02 12:01:29 +01:00
|
|
|
void setTokenBarrier();
|
|
|
|
|
|
2011-06-06 18:17:51 +02:00
|
|
|
// Sets up an "unexpected result" for the following commeand.
|
2016-06-07 17:04:53 +02:00
|
|
|
void scheduleTestResponse(int testCase, const QString &response);
|
2011-06-06 18:17:51 +02:00
|
|
|
|
2015-02-06 10:30:25 +01:00
|
|
|
QHash<int, DebuggerCommand> m_commandForToken;
|
2015-09-11 11:28:55 +02:00
|
|
|
QHash<int, int> m_flagsForToken;
|
2009-12-11 16:59:34 +01:00
|
|
|
int commandTimeoutTime() const;
|
2010-11-16 12:42:57 +01:00
|
|
|
QTimer m_commandTimer;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-06-07 17:04:53 +02:00
|
|
|
QString m_pendingConsoleStreamOutput;
|
|
|
|
|
QString m_pendingLogStreamOutput;
|
2009-10-09 16:35:52 +02:00
|
|
|
|
2010-03-03 18:08:18 +01:00
|
|
|
// This contains the first token number for the current round
|
2009-10-15 12:32:49 +02:00
|
|
|
// of evaluation. Responses with older tokens are considers
|
|
|
|
|
// out of date and discarded.
|
2017-09-08 08:53:15 +02:00
|
|
|
int m_oldestAcceptableToken = -1;
|
|
|
|
|
int m_nonDiscardableCount = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
bool m_rerunPending = false;
|
2009-09-21 11:09:38 +02:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
////////// Gdb Output, State & Capability Handling //////////
|
2009-10-15 12:32:49 +02:00
|
|
|
|
2016-06-27 22:56:03 +03:00
|
|
|
Q_INVOKABLE void handleResponse(const QString &buff);
|
2016-06-07 17:04:53 +02:00
|
|
|
void handleAsyncOutput(const QString &asyncClass, const GdbMi &result);
|
2009-10-09 10:20:42 +02:00
|
|
|
void handleStopResponse(const GdbMi &data);
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleResultRecord(DebuggerResponse *response);
|
2009-10-09 10:59:56 +02:00
|
|
|
void handleStop1(const GdbMi &data);
|
2012-04-17 10:00:40 +02:00
|
|
|
void handleStop2(const GdbMi &data);
|
2016-04-19 22:49:23 +02:00
|
|
|
void handleStop3();
|
2010-08-11 09:46:39 +02:00
|
|
|
void resetCommandQueue();
|
2009-10-15 12:32:49 +02:00
|
|
|
|
|
|
|
|
// Gdb initialization sequence
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleShowVersion(const DebuggerResponse &response);
|
|
|
|
|
void handlePythonSetup(const DebuggerResponse &response);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
int m_gdbVersion = 100; // 7.6.1 is 70601
|
|
|
|
|
int m_pythonVersion = 0; // 2.7.2 is 20702
|
|
|
|
|
bool m_isQnxGdb = false;
|
2009-09-14 11:02:36 +02:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
////////// Inferior Management //////////
|
2009-05-14 15:03:30 +02:00
|
|
|
|
2009-10-22 22:54:30 +02:00
|
|
|
// This should be always the last call in a function.
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
bool acceptsBreakpoint(const BreakpointParameters &bp) const final;
|
|
|
|
|
void insertBreakpoint(const Breakpoint &bp) final;
|
|
|
|
|
void removeBreakpoint(const Breakpoint &bp) final;
|
|
|
|
|
void updateBreakpoint(const Breakpoint &bp) final;
|
|
|
|
|
void enableSubBreakpoint(const SubBreakpoint &sbp, bool on) final;
|
2017-09-08 08:53:15 +02:00
|
|
|
|
2018-10-02 12:53:07 +02:00
|
|
|
void executeStepIn(bool byInstruction) final;
|
2017-09-08 08:53:15 +02:00
|
|
|
void executeStepOut() final;
|
2018-10-02 12:53:07 +02:00
|
|
|
void executeStepOver(bool byInstruction) final;
|
2017-09-08 08:53:15 +02:00
|
|
|
|
2009-10-15 12:32:49 +02:00
|
|
|
void continueInferiorInternal();
|
2017-09-08 08:53:15 +02:00
|
|
|
void continueInferior() final;
|
|
|
|
|
void interruptInferior() final;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
void executeRunToLine(const ContextData &data) final;
|
|
|
|
|
void executeRunToFunction(const QString &functionName) final;
|
|
|
|
|
void executeJumpToLine(const ContextData &data) final;
|
|
|
|
|
void executeReturn() final;
|
2020-11-18 15:26:38 +01:00
|
|
|
void executeRecordReverse(bool reverse) final;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleExecuteContinue(const DebuggerResponse &response);
|
|
|
|
|
void handleExecuteStep(const DebuggerResponse &response);
|
|
|
|
|
void handleExecuteNext(const DebuggerResponse &response);
|
|
|
|
|
void handleExecuteReturn(const DebuggerResponse &response);
|
|
|
|
|
void handleExecuteJumpToLine(const DebuggerResponse &response);
|
|
|
|
|
void handleExecuteRunToLine(const DebuggerResponse &response);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-11-27 16:10:14 +01:00
|
|
|
QString msgPtraceError(DebuggerStartMode sm);
|
2009-11-09 22:11:56 +01:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
////////// View & Data Stuff //////////
|
2009-10-15 12:32:49 +02:00
|
|
|
|
2018-08-15 17:28:00 +02:00
|
|
|
void selectThread(const Thread &thread) final;
|
2017-09-08 08:53:15 +02:00
|
|
|
void activateFrame(int index) final;
|
2009-10-15 12:32:49 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
//
|
|
|
|
|
// Breakpoint specific stuff
|
|
|
|
|
//
|
2011-06-24 19:02:12 +02:00
|
|
|
void handleBreakModifications(const GdbMi &bkpts);
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
void handleBreakIgnore(const DebuggerResponse &response, const Breakpoint &bp);
|
|
|
|
|
void handleBreakDisable(const DebuggerResponse &response, const Breakpoint &bp);
|
|
|
|
|
void handleBreakEnable(const DebuggerResponse &response, const Breakpoint &bp);
|
|
|
|
|
void handleBreakInsert1(const DebuggerResponse &response, const Breakpoint &bp);
|
|
|
|
|
void handleBreakInsert2(const DebuggerResponse &response, const Breakpoint &bp);
|
|
|
|
|
void handleBreakCondition(const DebuggerResponse &response, const Breakpoint &bp);
|
|
|
|
|
void handleBreakThreadSpec(const DebuggerResponse &response, const Breakpoint &bp);
|
|
|
|
|
void handleBreakLineNumber(const DebuggerResponse &response, const Breakpoint &bp);
|
2021-01-07 13:28:05 +01:00
|
|
|
void handleTracepointInsert(const DebuggerResponse &response, const Breakpoint &bp);
|
|
|
|
|
void handleTracepointHit(const GdbMi &data);
|
|
|
|
|
void handleTracepointModified(const GdbMi &data);
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
void handleInsertInterpreterBreakpoint(const DebuggerResponse &response, const Breakpoint &bp);
|
2015-10-14 13:26:22 +02:00
|
|
|
void handleInterpreterBreakpointModified(const GdbMi &data);
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
void handleWatchInsert(const DebuggerResponse &response, const Breakpoint &bp);
|
|
|
|
|
void handleCatchInsert(const DebuggerResponse &response, const Breakpoint &bp);
|
|
|
|
|
void handleBkpt(const GdbMi &bkpt, const Breakpoint &bp);
|
2016-06-07 17:04:53 +02:00
|
|
|
QString breakpointLocation(const BreakpointParameters &data); // For gdb/MI.
|
|
|
|
|
QString breakpointLocation2(const BreakpointParameters &data); // For gdb/CLI fallback.
|
2009-10-22 22:54:30 +02:00
|
|
|
QString breakLocation(const QString &file) const;
|
2021-01-07 13:28:05 +01:00
|
|
|
void updateTracepointCaptures(const Breakpoint &bp);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Modules specific stuff
|
|
|
|
|
//
|
2017-09-08 08:53:15 +02:00
|
|
|
void loadSymbols(const QString &moduleName) final;
|
|
|
|
|
void loadAllSymbols() final;
|
|
|
|
|
void loadSymbolsForStack() final;
|
|
|
|
|
void requestModuleSymbols(const QString &moduleName) final;
|
|
|
|
|
void requestModuleSections(const QString &moduleName) final;
|
|
|
|
|
void reloadModules() final;
|
|
|
|
|
void examineModules() final;
|
2013-11-27 16:10:14 +01:00
|
|
|
|
2009-10-28 22:08:58 +01:00
|
|
|
void reloadModulesInternal();
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleModulesList(const DebuggerResponse &response);
|
2015-02-06 01:26:47 +01:00
|
|
|
void handleShowModuleSections(const DebuggerResponse &response, const QString &moduleName);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-02 17:25:14 +01:00
|
|
|
//
|
|
|
|
|
// Snapshot specific stuff
|
|
|
|
|
//
|
2017-09-08 08:53:15 +02:00
|
|
|
void createSnapshot() final;
|
2015-02-06 01:26:47 +01:00
|
|
|
void handleMakeSnapshot(const DebuggerResponse &response, const QString &coreFile);
|
2010-02-02 17:25:14 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
//
|
|
|
|
|
// Register specific stuff
|
2009-09-24 11:45:08 +02:00
|
|
|
//
|
2017-09-08 08:53:15 +02:00
|
|
|
void reloadRegisters() final;
|
2019-07-28 23:32:33 +03:00
|
|
|
void reloadPeripheralRegisters() final;
|
2017-09-08 08:53:15 +02:00
|
|
|
void setRegisterValue(const QString &name, const QString &value) final;
|
2019-07-28 23:32:33 +03:00
|
|
|
void setPeripheralRegisterValue(quint64 address, quint64 value) final;
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleRegisterListNames(const DebuggerResponse &response);
|
2015-07-21 12:52:18 +02:00
|
|
|
void handleRegisterListing(const DebuggerResponse &response);
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleRegisterListValues(const DebuggerResponse &response);
|
2019-07-28 23:32:33 +03:00
|
|
|
void handlePeripheralRegisterListValues(const DebuggerResponse &response);
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleMaintPrintRegisters(const DebuggerResponse &response);
|
2015-07-21 12:52:18 +02:00
|
|
|
QHash<int, Register> m_registers; // Map GDB register numbers to indices
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-10-15 12:32:49 +02:00
|
|
|
//
|
|
|
|
|
// Disassembler specific stuff
|
|
|
|
|
//
|
2011-02-10 13:43:02 +01:00
|
|
|
// Chain of fallbacks: PointMixed -> PointPlain -> RangeMixed -> RangePlain.
|
2017-09-08 08:53:15 +02:00
|
|
|
void fetchDisassembler(DisassemblerAgent *agent) final;
|
2011-02-10 13:43:02 +01:00
|
|
|
void fetchDisassemblerByCliPointMixed(const DisassemblerAgentCookie &ac);
|
|
|
|
|
void fetchDisassemblerByCliRangeMixed(const DisassemblerAgentCookie &ac);
|
|
|
|
|
void fetchDisassemblerByCliRangePlain(const DisassemblerAgentCookie &ac);
|
2016-06-07 17:04:53 +02:00
|
|
|
bool handleCliDisassemblerResult(const QString &response, DisassemblerAgent *agent);
|
2011-02-10 13:43:02 +01:00
|
|
|
|
2009-02-17 14:08:49 +01:00
|
|
|
//
|
|
|
|
|
// Source file specific stuff
|
2009-09-24 11:45:08 +02:00
|
|
|
//
|
2017-09-08 08:53:15 +02:00
|
|
|
void reloadSourceFiles() final;
|
2009-10-28 22:08:58 +01:00
|
|
|
void reloadSourceFilesInternal();
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleQuerySources(const DebuggerResponse &response);
|
2009-10-15 12:32:49 +02:00
|
|
|
|
|
|
|
|
QString fullName(const QString &fileName);
|
2009-10-28 11:59:57 +01:00
|
|
|
QString cleanupFullName(const QString &fileName);
|
2009-10-15 12:32:49 +02:00
|
|
|
|
|
|
|
|
// awful hack to keep track of used files
|
|
|
|
|
QMap<QString, QString> m_shortToFullName;
|
|
|
|
|
QMap<QString, QString> m_fullToShortName;
|
2012-03-23 17:53:30 +01:00
|
|
|
QMultiMap<QString, QString> m_baseNameToFullName;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
bool m_sourcesListUpdating = false;
|
2009-10-22 22:54:30 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
//
|
|
|
|
|
// Stack specific stuff
|
2009-09-24 11:45:08 +02:00
|
|
|
//
|
2017-09-08 08:53:15 +02:00
|
|
|
void updateAll() final;
|
2015-02-06 01:26:47 +01:00
|
|
|
void handleStackListFrames(const DebuggerResponse &response, bool isFull);
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleStackSelectThread(const DebuggerResponse &response);
|
|
|
|
|
void handleThreadListIds(const DebuggerResponse &response);
|
|
|
|
|
void handleThreadInfo(const DebuggerResponse &response);
|
|
|
|
|
void handleThreadNames(const DebuggerResponse &response);
|
2015-02-11 16:05:55 +01:00
|
|
|
DebuggerCommand stackCommand(int depth);
|
2016-04-19 22:49:23 +02:00
|
|
|
void reloadStack();
|
2017-09-08 08:53:15 +02:00
|
|
|
void reloadFullStack() final;
|
|
|
|
|
void loadAdditionalQmlStack() final;
|
2009-10-15 12:32:49 +02:00
|
|
|
int currentFrame() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//
|
2009-10-15 12:32:49 +02:00
|
|
|
// Watch specific stuff
|
2009-09-24 11:45:08 +02:00
|
|
|
//
|
2017-09-08 08:53:15 +02:00
|
|
|
void reloadLocals();
|
|
|
|
|
void assignValueInDebugger(WatchItem *item,
|
|
|
|
|
const QString &expr, const QVariant &value) final;
|
2009-10-15 12:32:49 +02:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
void fetchMemory(MemoryAgent *agent, quint64 addr, quint64 length) final;
|
2013-11-05 18:47:03 +01:00
|
|
|
void fetchMemoryHelper(const MemoryAgentCookie &cookie);
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleChangeMemory(const DebuggerResponse &response);
|
2017-09-08 08:53:15 +02:00
|
|
|
void changeMemory(MemoryAgent *agent, quint64 addr, const QByteArray &data) final;
|
2015-02-06 01:26:47 +01:00
|
|
|
void handleFetchMemory(const DebuggerResponse &response, MemoryAgentCookie ac);
|
2009-10-15 12:32:49 +02:00
|
|
|
|
2012-05-18 02:28:41 +02:00
|
|
|
void showToolTip();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-02-05 15:47:07 +01:00
|
|
|
void handleVarAssign(const DebuggerResponse &response);
|
2012-03-28 09:37:02 +02:00
|
|
|
void handleThreadGroupCreated(const GdbMi &result);
|
|
|
|
|
void handleThreadGroupExited(const GdbMi &result);
|
|
|
|
|
|
2016-04-19 22:49:23 +02:00
|
|
|
void createFullBacktrace();
|
2010-03-29 18:44:02 +02:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
void doUpdateLocals(const UpdateParameters ¶meters) final;
|
2015-10-08 16:19:57 +02:00
|
|
|
void handleFetchVariables(const DebuggerResponse &response);
|
2010-01-29 22:49:55 +01:00
|
|
|
|
2009-10-15 12:32:49 +02:00
|
|
|
void setLocals(const QList<GdbMi> &locals);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
//
|
|
|
|
|
// Dumper Management
|
|
|
|
|
//
|
2017-09-08 08:53:15 +02:00
|
|
|
void reloadDebuggingHelpers() final;
|
2009-09-22 10:50:44 +02:00
|
|
|
|
2010-12-16 12:05:48 +01:00
|
|
|
//
|
2010-06-16 11:08:54 +02:00
|
|
|
// Convenience Functions
|
|
|
|
|
//
|
2010-07-09 17:07:59 +02:00
|
|
|
void showExecutionError(const QString &message);
|
2016-07-29 15:55:15 +02:00
|
|
|
QString failedToStartMessage();
|
2010-01-14 15:25:53 +01:00
|
|
|
|
2010-12-17 13:07:17 +01:00
|
|
|
// For short-circuiting stack and thread list evaluation.
|
2017-09-08 08:53:15 +02:00
|
|
|
bool m_stackNeeded = false;
|
2010-12-17 13:07:17 +01:00
|
|
|
|
2015-07-17 13:30:51 +02:00
|
|
|
// For suppressing processing *stopped and *running responses
|
|
|
|
|
// while updating locals.
|
2017-09-08 08:53:15 +02:00
|
|
|
bool m_inUpdateLocals = false;
|
2015-07-17 13:30:51 +02:00
|
|
|
|
2010-06-30 14:39:41 +02:00
|
|
|
// HACK:
|
2016-06-07 17:04:53 +02:00
|
|
|
QString m_currentThread;
|
2011-01-21 16:42:57 +01:00
|
|
|
QString m_lastWinException;
|
2017-09-27 08:22:02 +02:00
|
|
|
bool m_expectTerminalTrap = false;
|
2012-03-09 15:04:59 +01:00
|
|
|
bool usesExecInterrupt() const;
|
2016-04-19 14:01:44 +02:00
|
|
|
bool usesTargetAsync() const;
|
2012-03-09 15:04:59 +01:00
|
|
|
|
2016-12-13 09:46:51 +01:00
|
|
|
DebuggerCommandSequence m_onStop;
|
|
|
|
|
|
2016-06-07 17:04:53 +02:00
|
|
|
QHash<int, QString> m_scheduledTestResponses;
|
2011-06-06 18:17:51 +02:00
|
|
|
QSet<int> m_testCases;
|
2012-03-30 17:36:44 +02:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
bool m_systemDumpersLoaded = false;
|
2012-05-18 02:28:41 +02:00
|
|
|
|
2012-06-13 10:15:56 +02:00
|
|
|
static QString msgGdbStopFailed(const QString &why);
|
|
|
|
|
static QString msgInferiorStopFailed(const QString &why);
|
|
|
|
|
static QString msgAttachedToStoppedInferior();
|
|
|
|
|
static QString msgInferiorSetupOk();
|
|
|
|
|
static QString msgInferiorRunOk();
|
|
|
|
|
static QString msgConnectRemoteServerFailed(const QString &why);
|
|
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
void debugLastCommand() final;
|
2015-02-11 17:51:15 +01:00
|
|
|
DebuggerCommand m_lastDebuggableCommand;
|
2014-01-04 01:34:51 +01:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
bool isPlainEngine() const;
|
|
|
|
|
bool isCoreEngine() const;
|
|
|
|
|
bool isRemoteEngine() const;
|
2021-01-06 16:56:36 +01:00
|
|
|
bool isLocalAttachEngine() const;
|
2017-09-08 08:53:15 +02:00
|
|
|
bool isTermEngine() const;
|
|
|
|
|
|
|
|
|
|
void setupEngine() final;
|
2020-12-18 17:58:05 +01:00
|
|
|
void runEngine();
|
2017-09-08 08:53:15 +02:00
|
|
|
void shutdownEngine() final;
|
|
|
|
|
|
|
|
|
|
void interruptInferior2();
|
2018-07-19 19:48:44 +03:00
|
|
|
QChar mixedDisasmFlag() const;
|
2017-09-08 08:53:15 +02:00
|
|
|
|
|
|
|
|
// Plain
|
|
|
|
|
void handleExecRun(const DebuggerResponse &response);
|
|
|
|
|
void handleFileExecAndSymbols(const DebuggerResponse &response);
|
|
|
|
|
|
|
|
|
|
// Attach
|
2021-01-06 17:06:45 +01:00
|
|
|
void handleLocalAttach(const DebuggerResponse &response);
|
|
|
|
|
void handleRemoteAttach(const DebuggerResponse &response);
|
2017-09-08 08:53:15 +02:00
|
|
|
|
|
|
|
|
// Remote
|
|
|
|
|
void callTargetRemote();
|
|
|
|
|
void handleSetTargetAsync(const DebuggerResponse &response);
|
|
|
|
|
void handleTargetRemote(const DebuggerResponse &response);
|
|
|
|
|
void handleTargetExtendedRemote(const DebuggerResponse &response);
|
|
|
|
|
void handleTargetExtendedAttach(const DebuggerResponse &response);
|
|
|
|
|
void handleTargetQnx(const DebuggerResponse &response);
|
|
|
|
|
void handleSetNtoExecutable(const DebuggerResponse &response);
|
|
|
|
|
void handleInterruptInferior(const DebuggerResponse &response);
|
2012-06-13 10:15:56 +02:00
|
|
|
void interruptLocalInferior(qint64 pid);
|
2013-09-09 16:42:32 +02:00
|
|
|
|
2017-09-08 08:53:15 +02:00
|
|
|
// Terminal
|
2017-09-27 08:22:02 +02:00
|
|
|
void handleStubAttached(const DebuggerResponse &response, qint64 mainThreadId);
|
2017-09-08 08:53:15 +02:00
|
|
|
|
|
|
|
|
// Core
|
|
|
|
|
void handleTargetCore(const DebuggerResponse &response);
|
|
|
|
|
void handleCoreRoundTrip(const DebuggerResponse &response);
|
|
|
|
|
QString coreFileName() const;
|
|
|
|
|
|
2017-09-27 08:22:02 +02:00
|
|
|
QString mainFunction() const;
|
2017-11-15 17:12:03 +01:00
|
|
|
void setupInferior();
|
2021-01-05 17:56:46 +01:00
|
|
|
void claimInitialBreakpoints();
|
2017-09-08 08:53:15 +02:00
|
|
|
|
2015-06-08 12:10:11 +02:00
|
|
|
Utils::QtcProcess m_gdbProc;
|
2017-09-08 08:53:15 +02:00
|
|
|
OutputCollector m_outputCollector;
|
2015-06-08 12:10:11 +02:00
|
|
|
QString m_errorString;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|