2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2014-10-17 13:40:04 +02:00
|
|
|
#include "debuggerruncontrol.h"
|
2022-07-05 15:37:08 +02:00
|
|
|
|
|
|
|
#include "debuggermainwindow.h"
|
|
|
|
#include "debuggertr.h"
|
2017-09-27 08:22:02 +02:00
|
|
|
#include "terminal.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-04-10 13:57:05 +02:00
|
|
|
#include "console/console.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggeractions.h"
|
2013-03-22 10:28:49 +01:00
|
|
|
#include "debuggerengine.h"
|
2019-02-18 15:49:05 +01:00
|
|
|
#include "debuggerinternalconstants.h"
|
2013-03-22 10:28:49 +01:00
|
|
|
#include "debuggerkitinformation.h"
|
2013-03-27 13:03:15 +01:00
|
|
|
#include "debuggerrunconfigurationaspect.h"
|
2013-03-22 10:28:49 +01:00
|
|
|
#include "breakhandler.h"
|
2018-09-27 15:09:09 +02:00
|
|
|
#include "enginemanager.h"
|
2010-06-22 12:28:05 +02:00
|
|
|
|
2012-08-15 13:21:37 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2014-10-20 14:03:47 +02:00
|
|
|
#include <projectexplorer/devicesupport/deviceprocessesdialog.h>
|
2022-04-12 21:01:45 +02:00
|
|
|
#include <projectexplorer/devicesupport/idevice.h>
|
2014-10-20 14:03:47 +02:00
|
|
|
#include <projectexplorer/environmentaspect.h> // For the environment
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <projectexplorer/project.h>
|
2012-08-15 13:21:37 +02:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2016-03-25 23:06:17 +01:00
|
|
|
#include <projectexplorer/projectexplorericons.h>
|
2023-02-14 15:47:22 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2018-04-23 15:38:53 +02:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2023-02-14 15:47:22 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <projectexplorer/target.h>
|
2012-11-02 16:14:43 +01:00
|
|
|
#include <projectexplorer/taskhub.h>
|
2014-10-20 14:03:47 +02:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-12-06 10:27:27 +01:00
|
|
|
#include <utils/algorithm.h>
|
2013-09-13 16:12:04 +02:00
|
|
|
#include <utils/checkablemessagebox.h>
|
2022-08-24 14:55:12 +02:00
|
|
|
#include <utils/environment.h>
|
2013-10-23 22:07:46 +03:00
|
|
|
#include <utils/fileutils.h>
|
2017-05-04 12:12:27 +02:00
|
|
|
#include <utils/portlist.h>
|
2023-05-03 17:05:35 +02:00
|
|
|
#include <utils/process.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2017-09-27 15:30:02 +02:00
|
|
|
#include <utils/temporarydirectory.h>
|
|
|
|
#include <utils/temporaryfile.h>
|
2017-09-29 12:41:53 +02:00
|
|
|
#include <utils/url.h>
|
2019-03-01 14:30:02 +01:00
|
|
|
#include <utils/winutils.h>
|
2017-05-04 12:12:27 +02:00
|
|
|
|
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
|
|
|
#include <coreplugin/icontext.h>
|
2009-10-08 17:23:27 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2015-10-19 12:55:13 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2017-08-21 14:32:15 +02:00
|
|
|
#include <coreplugin/messagebox.h>
|
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
|
|
|
|
2015-08-10 17:43:58 +02:00
|
|
|
#include <qmldebug/qmldebugcommandlinearguments.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2015-10-08 16:19:57 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
2013-04-17 17:45:53 +02:00
|
|
|
#include <QTcpServer>
|
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
|
|
|
#include <QTimer>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
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
|
|
|
using namespace Core;
|
2010-06-14 17:23:25 +02:00
|
|
|
using namespace Debugger::Internal;
|
2012-08-09 03:58:37 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
using namespace Utils;
|
2010-06-14 17:23:25 +02:00
|
|
|
|
2011-02-25 09:34:31 +01:00
|
|
|
enum { debug = 0 };
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
namespace Debugger {
|
2011-01-11 11:06:15 +01:00
|
|
|
namespace Internal {
|
2011-01-12 12:10:12 +01:00
|
|
|
|
2017-09-28 11:27:43 +02:00
|
|
|
DebuggerEngine *createCdbEngine();
|
2017-09-26 15:22:14 +02:00
|
|
|
DebuggerEngine *createGdbEngine();
|
2017-05-05 14:45:36 +02:00
|
|
|
DebuggerEngine *createPdbEngine();
|
2017-09-26 16:24:05 +02:00
|
|
|
DebuggerEngine *createQmlEngine();
|
2017-05-05 14:45:36 +02:00
|
|
|
DebuggerEngine *createLldbEngine();
|
2020-01-24 17:08:27 +03:00
|
|
|
DebuggerEngine *createUvscEngine();
|
2023-01-03 15:12:43 +01:00
|
|
|
DebuggerEngine *createDapEngine();
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2021-08-20 12:36:41 +02:00
|
|
|
static QString noEngineMessage()
|
|
|
|
{
|
2022-07-05 15:37:08 +02:00
|
|
|
return Tr::tr("Unable to create a debugging engine.");
|
2021-08-20 12:36:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static QString noDebuggerInKitMessage()
|
|
|
|
{
|
2022-07-05 15:37:08 +02:00
|
|
|
return Tr::tr("The kit does not have a debugger set.");
|
2021-08-20 12:36:41 +02:00
|
|
|
}
|
|
|
|
|
2020-01-29 04:15:25 +03:00
|
|
|
class CoreUnpacker final : public RunWorker
|
2017-09-27 15:30:02 +02:00
|
|
|
{
|
|
|
|
public:
|
2021-09-27 15:52:05 +02:00
|
|
|
CoreUnpacker(RunControl *runControl, const FilePath &coreFilePath)
|
|
|
|
: RunWorker(runControl), m_coreFilePath(coreFilePath)
|
2017-09-27 15:30:02 +02:00
|
|
|
{}
|
|
|
|
|
2021-09-27 15:52:05 +02:00
|
|
|
FilePath coreFileName() const { return m_tempCoreFilePath; }
|
2017-09-27 15:30:02 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
~CoreUnpacker() final
|
|
|
|
{
|
|
|
|
if (m_tempCoreFile.isOpen())
|
|
|
|
m_tempCoreFile.close();
|
|
|
|
|
2021-09-27 15:52:05 +02:00
|
|
|
m_tempCoreFilePath.removeFile();
|
2017-09-27 15:30:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void start() final
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Utils::TemporaryFile tmp("tmpcore-XXXXXX");
|
|
|
|
tmp.open();
|
2021-09-27 15:52:05 +02:00
|
|
|
m_tempCoreFilePath = FilePath::fromString(tmp.fileName());
|
2017-09-27 15:30:02 +02:00
|
|
|
}
|
|
|
|
|
2022-01-18 17:40:19 +01:00
|
|
|
m_coreUnpackProcess.setWorkingDirectory(TemporaryDirectory::masterDirectoryFilePath());
|
2023-05-03 16:00:22 +02:00
|
|
|
connect(&m_coreUnpackProcess, &Process::done, this, [this] {
|
2022-04-14 13:53:45 +02:00
|
|
|
if (m_coreUnpackProcess.error() == QProcess::UnknownError) {
|
|
|
|
reportStopped();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
reportFailure("Error unpacking " + m_coreFilePath.toUserOutput());
|
|
|
|
});
|
2017-09-27 15:30:02 +02:00
|
|
|
|
2022-07-05 15:37:08 +02:00
|
|
|
const QString msg = Tr::tr("Unpacking core file to %1");
|
2021-09-27 15:52:05 +02:00
|
|
|
appendMessage(msg.arg(m_tempCoreFilePath.toUserOutput()), LogMessageFormat);
|
2017-09-27 15:30:02 +02:00
|
|
|
|
2021-09-27 15:52:05 +02:00
|
|
|
if (m_coreFilePath.endsWith(".lzo")) {
|
|
|
|
m_coreUnpackProcess.setCommand({"lzop", {"-o", m_tempCoreFilePath.path(),
|
|
|
|
"-x", m_coreFilePath.path()}});
|
2022-04-14 13:53:45 +02:00
|
|
|
reportStarted();
|
2021-08-20 10:43:35 +02:00
|
|
|
m_coreUnpackProcess.start();
|
2017-09-27 15:30:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-09-27 15:52:05 +02:00
|
|
|
if (m_coreFilePath.endsWith(".gz")) {
|
|
|
|
appendMessage(msg.arg(m_tempCoreFilePath.toUserOutput()), LogMessageFormat);
|
|
|
|
m_tempCoreFile.setFileName(m_tempCoreFilePath.path());
|
2017-09-27 15:30:02 +02:00
|
|
|
m_tempCoreFile.open(QFile::WriteOnly);
|
2023-05-03 16:00:22 +02:00
|
|
|
connect(&m_coreUnpackProcess, &Process::readyReadStandardOutput, this, [this] {
|
2023-01-05 17:55:04 +01:00
|
|
|
m_tempCoreFile.write(m_coreUnpackProcess.readAllRawStandardOutput());
|
2017-09-27 15:30:02 +02:00
|
|
|
});
|
2021-09-27 15:52:05 +02:00
|
|
|
m_coreUnpackProcess.setCommand({"gzip", {"-c", "-d", m_coreFilePath.path()}});
|
2022-04-14 13:53:45 +02:00
|
|
|
reportStarted();
|
2021-08-20 10:43:35 +02:00
|
|
|
m_coreUnpackProcess.start();
|
2017-09-27 15:30:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QTC_CHECK(false);
|
2021-09-27 15:52:05 +02:00
|
|
|
reportFailure("Unknown file extension in " + m_coreFilePath.toUserOutput());
|
2017-09-27 15:30:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QFile m_tempCoreFile;
|
2021-09-27 15:52:05 +02:00
|
|
|
FilePath m_coreFilePath;
|
|
|
|
FilePath m_tempCoreFilePath;
|
2023-05-03 16:00:22 +02:00
|
|
|
Process m_coreUnpackProcess;
|
2017-09-27 15:30:02 +02:00
|
|
|
};
|
|
|
|
|
2017-09-27 08:22:02 +02:00
|
|
|
class DebuggerRunToolPrivate
|
|
|
|
{
|
|
|
|
public:
|
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 useTerminal = false;
|
2017-09-27 15:30:02 +02:00
|
|
|
QPointer<CoreUnpacker> coreUnpacker;
|
2019-12-13 10:30:30 +01:00
|
|
|
QPointer<DebugServerPortsGatherer> portsGatherer;
|
2017-10-19 14:23:43 +02:00
|
|
|
bool addQmlServerInferiorCommandLineArgumentIfNeeded = false;
|
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
|
|
|
TerminalRunner *terminalRunner = nullptr;
|
|
|
|
int snapshotCounter = 0;
|
|
|
|
int engineStartsNeeded = 0;
|
|
|
|
int engineStopsNeeded = 0;
|
2018-09-04 13:29:15 +02:00
|
|
|
QString runId;
|
2017-09-27 08:22:02 +02:00
|
|
|
};
|
2014-10-17 12:37:30 +02:00
|
|
|
|
2017-09-27 08:22:02 +02:00
|
|
|
} // namespace Internal
|
2015-06-24 08:26:35 +02:00
|
|
|
|
2017-07-07 19:11:32 +02:00
|
|
|
static bool breakOnMainNextTime = false;
|
|
|
|
|
|
|
|
void DebuggerRunTool::setBreakOnMainNextTime()
|
|
|
|
{
|
|
|
|
breakOnMainNextTime = true;
|
|
|
|
}
|
|
|
|
|
2017-08-24 15:46:23 +02:00
|
|
|
void DebuggerRunTool::setStartMode(DebuggerStartMode startMode)
|
|
|
|
{
|
2017-09-12 13:12:30 +02:00
|
|
|
if (startMode == AttachToQmlServer) {
|
|
|
|
m_runParameters.startMode = AttachToRemoteProcess;
|
2018-07-25 14:07:08 +02:00
|
|
|
m_runParameters.cppEngineType = NoEngineType;
|
2017-09-20 16:34:54 +02:00
|
|
|
m_runParameters.isQmlDebugging = true;
|
2017-09-12 13:12:30 +02:00
|
|
|
m_runParameters.closeMode = KillAtClose;
|
|
|
|
|
|
|
|
// FIXME: This is horribly wrong.
|
|
|
|
// get files from all the projects in the session
|
2023-02-14 15:47:22 +01:00
|
|
|
QList<Project *> projects = ProjectManager::projects();
|
|
|
|
if (Project *startupProject = ProjectManager::startupProject()) {
|
2017-09-12 13:12:30 +02:00
|
|
|
// startup project first
|
|
|
|
projects.removeOne(startupProject);
|
|
|
|
projects.insert(0, startupProject);
|
|
|
|
}
|
2022-10-07 14:46:06 +02:00
|
|
|
for (Project *project : std::as_const(projects))
|
2018-05-24 11:17:04 +02:00
|
|
|
m_runParameters.projectSourceFiles.append(project->files(Project::SourceFiles));
|
2017-09-12 13:12:30 +02:00
|
|
|
if (!projects.isEmpty())
|
2018-08-21 17:15:53 +02:00
|
|
|
m_runParameters.projectSourceDirectory = projects.first()->projectDirectory();
|
2017-09-12 13:12:30 +02:00
|
|
|
|
|
|
|
} else {
|
|
|
|
m_runParameters.startMode = startMode;
|
|
|
|
}
|
2017-08-24 15:46:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunTool::setCloseMode(DebuggerCloseMode closeMode)
|
|
|
|
{
|
|
|
|
m_runParameters.closeMode = closeMode;
|
|
|
|
}
|
|
|
|
|
2017-08-24 16:53:31 +02:00
|
|
|
void DebuggerRunTool::setAttachPid(ProcessHandle pid)
|
|
|
|
{
|
|
|
|
m_runParameters.attachPID = pid;
|
|
|
|
}
|
|
|
|
|
2017-08-24 19:30:35 +02:00
|
|
|
void DebuggerRunTool::setAttachPid(qint64 pid)
|
|
|
|
{
|
|
|
|
m_runParameters.attachPID = ProcessHandle(pid);
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
void DebuggerRunTool::setSysRoot(const Utils::FilePath &sysRoot)
|
2017-08-24 16:53:31 +02:00
|
|
|
{
|
|
|
|
m_runParameters.sysRoot = sysRoot;
|
|
|
|
}
|
|
|
|
|
2019-06-20 17:19:12 +02:00
|
|
|
void DebuggerRunTool::setSymbolFile(const FilePath &symbolFile)
|
2017-08-24 15:46:23 +02:00
|
|
|
{
|
|
|
|
if (symbolFile.isEmpty())
|
2022-07-05 15:37:08 +02:00
|
|
|
reportFailure(Tr::tr("Cannot debug: Local executable is not set."));
|
2017-08-24 15:46:23 +02:00
|
|
|
m_runParameters.symbolFile = symbolFile;
|
|
|
|
}
|
|
|
|
|
2020-04-02 12:05:08 +02:00
|
|
|
void DebuggerRunTool::setLldbPlatform(const QString &platform)
|
|
|
|
{
|
|
|
|
m_runParameters.platform = platform;
|
|
|
|
}
|
|
|
|
|
2017-08-24 17:38:06 +02:00
|
|
|
void DebuggerRunTool::setRemoteChannel(const QString &channel)
|
2017-08-24 15:46:23 +02:00
|
|
|
{
|
|
|
|
m_runParameters.remoteChannel = channel;
|
|
|
|
}
|
|
|
|
|
2017-12-19 13:01:02 +01:00
|
|
|
void DebuggerRunTool::setRemoteChannel(const QUrl &url)
|
|
|
|
{
|
|
|
|
m_runParameters.remoteChannel = QString("%1:%2").arg(url.host()).arg(url.port());
|
|
|
|
}
|
|
|
|
|
2019-11-11 12:37:50 +01:00
|
|
|
QString DebuggerRunTool::remoteChannel() const
|
|
|
|
{
|
|
|
|
return m_runParameters.remoteChannel;
|
|
|
|
}
|
|
|
|
|
2017-08-24 19:30:35 +02:00
|
|
|
void DebuggerRunTool::setRemoteChannel(const QString &host, int port)
|
|
|
|
{
|
|
|
|
m_runParameters.remoteChannel = QString("%1:%2").arg(host).arg(port);
|
|
|
|
}
|
|
|
|
|
2017-08-24 15:46:23 +02:00
|
|
|
void DebuggerRunTool::setUseExtendedRemote(bool on)
|
|
|
|
{
|
|
|
|
m_runParameters.useExtendedRemote = on;
|
|
|
|
}
|
|
|
|
|
2017-08-24 16:53:31 +02:00
|
|
|
void DebuggerRunTool::setUseContinueInsteadOfRun(bool on)
|
|
|
|
{
|
|
|
|
m_runParameters.useContinueInsteadOfRun = on;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunTool::setUseTargetAsync(bool on)
|
|
|
|
{
|
|
|
|
m_runParameters.useTargetAsync = on;
|
|
|
|
}
|
|
|
|
|
2017-08-24 17:38:06 +02:00
|
|
|
void DebuggerRunTool::setContinueAfterAttach(bool on)
|
|
|
|
{
|
|
|
|
m_runParameters.continueAfterAttach = on;
|
|
|
|
}
|
|
|
|
|
2017-08-24 16:53:31 +02:00
|
|
|
void DebuggerRunTool::setSkipExecutableValidation(bool on)
|
|
|
|
{
|
|
|
|
m_runParameters.skipExecutableValidation = on;
|
|
|
|
}
|
|
|
|
|
2017-09-08 15:15:46 +02:00
|
|
|
void DebuggerRunTool::setUseCtrlCStub(bool on)
|
|
|
|
{
|
|
|
|
m_runParameters.useCtrlCStub = on;
|
|
|
|
}
|
|
|
|
|
2017-09-12 12:38:31 +02:00
|
|
|
void DebuggerRunTool::setBreakOnMain(bool on)
|
|
|
|
{
|
|
|
|
m_runParameters.breakOnMain = on;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunTool::setUseTerminal(bool on)
|
|
|
|
{
|
2018-01-29 08:14:40 +01:00
|
|
|
// CDB has a built-in console that might be preferred by some.
|
|
|
|
bool useCdbConsole = m_runParameters.cppEngineType == CdbEngineType
|
|
|
|
&& (m_runParameters.startMode == StartInternal
|
|
|
|
|| m_runParameters.startMode == StartExternal)
|
2021-03-01 08:59:44 +01:00
|
|
|
&& debuggerSettings()->useCdbConsole.value();
|
2018-01-29 08:14:40 +01:00
|
|
|
|
|
|
|
if (on && !d->terminalRunner && !useCdbConsole) {
|
2021-03-09 11:53:18 +01:00
|
|
|
d->terminalRunner =
|
|
|
|
new TerminalRunner(runControl(), [this] { return m_runParameters.inferior; });
|
2017-09-27 08:22:02 +02:00
|
|
|
addStartDependency(d->terminalRunner);
|
|
|
|
}
|
|
|
|
if (!on && d->terminalRunner) {
|
|
|
|
QTC_CHECK(false); // User code can only switch from no terminal to one terminal.
|
|
|
|
}
|
2017-09-12 12:38:31 +02:00
|
|
|
}
|
|
|
|
|
2021-02-15 16:55:28 +01:00
|
|
|
void DebuggerRunTool::setRunAsRoot(bool on)
|
|
|
|
{
|
|
|
|
m_runParameters.runAsRoot = on;
|
|
|
|
}
|
|
|
|
|
2017-08-25 12:53:44 +02:00
|
|
|
void DebuggerRunTool::setCommandsAfterConnect(const QString &commands)
|
|
|
|
{
|
|
|
|
m_runParameters.commandsAfterConnect = commands;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunTool::setCommandsForReset(const QString &commands)
|
|
|
|
{
|
|
|
|
m_runParameters.commandsForReset = commands;
|
|
|
|
}
|
2021-09-27 11:11:18 +02:00
|
|
|
void DebuggerRunTool::setDebugInfoLocation(const FilePath &debugInfoLocation)
|
2017-09-12 12:38:31 +02:00
|
|
|
{
|
|
|
|
m_runParameters.debugInfoLocation = debugInfoLocation;
|
|
|
|
}
|
|
|
|
|
2018-08-20 11:33:05 +02:00
|
|
|
QUrl DebuggerRunTool::qmlServer() const
|
|
|
|
{
|
|
|
|
return m_runParameters.qmlServer;
|
|
|
|
}
|
|
|
|
|
2017-08-24 15:46:23 +02:00
|
|
|
void DebuggerRunTool::setQmlServer(const QUrl &qmlServer)
|
|
|
|
{
|
|
|
|
m_runParameters.qmlServer = qmlServer;
|
|
|
|
}
|
|
|
|
|
2017-08-24 17:38:06 +02:00
|
|
|
void DebuggerRunTool::setIosPlatform(const QString &platform)
|
|
|
|
{
|
|
|
|
m_runParameters.platform = platform;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunTool::setDeviceSymbolsRoot(const QString &deviceSymbolsRoot)
|
|
|
|
{
|
|
|
|
m_runParameters.deviceSymbolsRoot = deviceSymbolsRoot;
|
|
|
|
}
|
|
|
|
|
2017-09-12 11:28:23 +02:00
|
|
|
void DebuggerRunTool::setTestCase(int testCase)
|
|
|
|
{
|
|
|
|
m_runParameters.testCase = testCase;
|
|
|
|
}
|
|
|
|
|
2021-09-27 15:52:05 +02:00
|
|
|
void DebuggerRunTool::setOverrideStartScript(const FilePath &script)
|
2017-09-12 12:38:31 +02:00
|
|
|
{
|
|
|
|
m_runParameters.overrideStartScript = script;
|
|
|
|
}
|
|
|
|
|
2019-08-26 14:19:07 +03:00
|
|
|
void DebuggerRunTool::setAbi(const Abi &abi)
|
|
|
|
{
|
|
|
|
m_runParameters.toolChainAbi = abi;
|
|
|
|
}
|
|
|
|
|
2017-08-24 15:46:23 +02:00
|
|
|
void DebuggerRunTool::setInferior(const Runnable &runnable)
|
|
|
|
{
|
2018-05-16 15:42:03 +02:00
|
|
|
m_runParameters.inferior = runnable;
|
2017-08-24 15:46:23 +02:00
|
|
|
}
|
|
|
|
|
2019-06-20 17:19:12 +02:00
|
|
|
void DebuggerRunTool::setInferiorExecutable(const FilePath &executable)
|
2017-08-24 17:38:06 +02:00
|
|
|
{
|
2021-08-10 09:19:30 +02:00
|
|
|
m_runParameters.inferior.command.setExecutable(executable);
|
2017-08-24 17:38:06 +02:00
|
|
|
}
|
|
|
|
|
2017-10-11 17:17:16 +02:00
|
|
|
void DebuggerRunTool::setInferiorEnvironment(const Utils::Environment &env)
|
|
|
|
{
|
|
|
|
m_runParameters.inferior.environment = env;
|
|
|
|
}
|
|
|
|
|
2017-08-24 16:04:25 +02:00
|
|
|
void DebuggerRunTool::setRunControlName(const QString &name)
|
|
|
|
{
|
|
|
|
m_runParameters.displayName = name;
|
|
|
|
}
|
|
|
|
|
2017-08-24 19:30:35 +02:00
|
|
|
void DebuggerRunTool::setStartMessage(const QString &msg)
|
|
|
|
{
|
|
|
|
m_runParameters.startMessage = msg;
|
|
|
|
}
|
|
|
|
|
2021-09-27 15:52:05 +02:00
|
|
|
void DebuggerRunTool::setCoreFilePath(const FilePath &coreFile, bool isSnapshot)
|
2017-08-24 19:30:35 +02:00
|
|
|
{
|
2017-09-27 15:30:02 +02:00
|
|
|
if (coreFile.endsWith(".gz") || coreFile.endsWith(".lzo")) {
|
|
|
|
d->coreUnpacker = new CoreUnpacker(runControl(), coreFile);
|
|
|
|
addStartDependency(d->coreUnpacker);
|
|
|
|
}
|
|
|
|
|
2017-08-24 19:30:35 +02:00
|
|
|
m_runParameters.coreFile = coreFile;
|
|
|
|
m_runParameters.isSnapshot = isSnapshot;
|
|
|
|
}
|
|
|
|
|
2017-08-24 15:46:23 +02:00
|
|
|
void DebuggerRunTool::addQmlServerInferiorCommandLineArgumentIfNeeded()
|
|
|
|
{
|
2017-10-19 14:23:43 +02:00
|
|
|
d->addQmlServerInferiorCommandLineArgumentIfNeeded = true;
|
2017-08-24 15:46:23 +02:00
|
|
|
}
|
|
|
|
|
2020-05-13 08:59:35 +02:00
|
|
|
void DebuggerRunTool::modifyDebuggerEnvironment(const EnvironmentItems &items)
|
|
|
|
{
|
|
|
|
m_runParameters.debugger.environment.modify(items);
|
|
|
|
}
|
|
|
|
|
2017-08-24 19:30:35 +02:00
|
|
|
void DebuggerRunTool::setCrashParameter(const QString &event)
|
|
|
|
{
|
|
|
|
m_runParameters.crashParameter = event;
|
|
|
|
}
|
|
|
|
|
2017-08-24 16:53:31 +02:00
|
|
|
void DebuggerRunTool::addExpectedSignal(const QString &signal)
|
|
|
|
{
|
|
|
|
m_runParameters.expectedSignals.append(signal);
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
void DebuggerRunTool::addSearchDirectory(const Utils::FilePath &dir)
|
2017-08-24 16:53:31 +02:00
|
|
|
{
|
|
|
|
m_runParameters.additionalSearchDirectories.append(dir);
|
|
|
|
}
|
|
|
|
|
2017-05-09 10:25:11 +02:00
|
|
|
void DebuggerRunTool::start()
|
2010-06-15 09:13:22 +02:00
|
|
|
{
|
2019-02-18 15:49:05 +01:00
|
|
|
TaskHub::clearTasks(Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO);
|
|
|
|
TaskHub::clearTasks(Constants::TASK_CATEGORY_DEBUGGER_RUNTIME);
|
2015-06-24 08:26:35 +02:00
|
|
|
|
2017-10-19 14:23:43 +02:00
|
|
|
if (d->portsGatherer) {
|
2017-12-19 13:01:02 +01:00
|
|
|
setRemoteChannel(d->portsGatherer->gdbServer());
|
2017-10-19 14:23:43 +02:00
|
|
|
setQmlServer(d->portsGatherer->qmlServer());
|
|
|
|
if (d->addQmlServerInferiorCommandLineArgumentIfNeeded
|
|
|
|
&& m_runParameters.isQmlDebugging
|
2018-07-25 14:07:08 +02:00
|
|
|
&& m_runParameters.isCppDebugging()) {
|
2019-08-22 12:50:55 +02:00
|
|
|
|
2017-10-19 14:23:43 +02:00
|
|
|
int qmlServerPort = m_runParameters.qmlServer.port();
|
|
|
|
QTC_ASSERT(qmlServerPort > 0, reportFailure(); return);
|
|
|
|
QString mode = QString("port:%1").arg(qmlServerPort);
|
2019-08-22 12:50:55 +02:00
|
|
|
|
2021-08-10 09:19:30 +02:00
|
|
|
CommandLine cmd{m_runParameters.inferior.command.executable()};
|
2019-08-22 12:50:55 +02:00
|
|
|
cmd.addArg(qmlDebugCommandLineArguments(QmlDebug::QmlDebuggerServices, mode, true));
|
2021-08-10 09:19:30 +02:00
|
|
|
cmd.addArgs(m_runParameters.inferior.command.arguments(), CommandLine::Raw);
|
2019-08-22 12:50:55 +02:00
|
|
|
|
2021-08-10 09:19:30 +02:00
|
|
|
m_runParameters.inferior.command = cmd;
|
2017-10-19 14:23:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-18 13:01:12 +02:00
|
|
|
// User canceled input dialog asking for executable when working on library project.
|
2017-09-12 10:06:10 +02:00
|
|
|
if (m_runParameters.startMode == StartInternal
|
2021-08-10 09:19:30 +02:00
|
|
|
&& m_runParameters.inferior.command.isEmpty()
|
2017-09-12 10:06:10 +02:00
|
|
|
&& m_runParameters.interpreter.isEmpty()) {
|
2022-07-05 15:37:08 +02:00
|
|
|
reportFailure(Tr::tr("No executable specified."));
|
2011-04-18 13:01:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-12 10:06:10 +02:00
|
|
|
// QML and/or mixed are not prepared for it.
|
2022-11-16 10:09:06 +01:00
|
|
|
// setSupportsReRunning(!m_runParameters.isQmlDebugging);
|
|
|
|
setSupportsReRunning(false); // FIXME: Broken in general.
|
2017-09-12 10:06:10 +02:00
|
|
|
|
|
|
|
// FIXME: Disabled due to Android. Make Android device report available ports instead.
|
|
|
|
// int portsUsed = portsUsedByDebugger();
|
|
|
|
// if (portsUsed > device()->freePorts().count()) {
|
2022-07-05 15:37:08 +02:00
|
|
|
// reportFailure(Tr::tr("Cannot debug: Not enough free ports available."));
|
2017-09-12 10:06:10 +02:00
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
2017-09-27 15:30:02 +02:00
|
|
|
if (d->coreUnpacker)
|
|
|
|
m_runParameters.coreFile = d->coreUnpacker->coreFileName();
|
|
|
|
|
2017-09-18 14:47:39 +02:00
|
|
|
if (!fixupParameters())
|
2017-09-12 10:06:10 +02:00
|
|
|
return;
|
|
|
|
|
2019-03-01 14:30:02 +01:00
|
|
|
if (m_runParameters.cppEngineType == CdbEngineType
|
2021-11-09 18:45:07 +01:00
|
|
|
&& Utils::is64BitWindowsBinary(m_runParameters.inferior.command.executable())
|
|
|
|
&& !Utils::is64BitWindowsBinary(m_runParameters.debugger.command.executable())) {
|
2019-03-01 14:30:02 +01:00
|
|
|
reportFailure(
|
2022-07-05 15:37:08 +02:00
|
|
|
Tr::tr(
|
2019-03-01 14:30:02 +01:00
|
|
|
"%1 is a 64 bit executable which can not be debugged by a 32 bit Debugger.\n"
|
|
|
|
"Please select a 64 bit Debugger in the kit settings for this kit.")
|
2021-08-10 09:19:30 +02:00
|
|
|
.arg(m_runParameters.inferior.command.executable().toUserOutput()));
|
2019-03-01 14:30:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-12 10:06:10 +02:00
|
|
|
Utils::globalMacroExpander()->registerFileVariables(
|
2022-07-05 15:37:08 +02:00
|
|
|
"DebuggedExecutable", Tr::tr("Debugged executable"),
|
2021-08-10 09:19:30 +02:00
|
|
|
[this] { return m_runParameters.inferior.command.executable(); }
|
2017-09-12 10:06:10 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
runControl()->setDisplayName(m_runParameters.displayName);
|
|
|
|
|
2017-09-28 11:27:43 +02:00
|
|
|
if (!m_engine) {
|
2018-07-25 14:07:08 +02:00
|
|
|
if (m_runParameters.isCppDebugging()) {
|
|
|
|
switch (m_runParameters.cppEngineType) {
|
2017-09-28 11:27:43 +02:00
|
|
|
case GdbEngineType:
|
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
|
|
|
m_engine = createGdbEngine();
|
2017-09-28 11:27:43 +02:00
|
|
|
break;
|
|
|
|
case CdbEngineType:
|
|
|
|
if (!HostOsInfo::isWindowsHost()) {
|
2022-07-05 15:37:08 +02:00
|
|
|
reportFailure(Tr::tr("Unsupported CDB host system."));
|
2017-09-28 11:27:43 +02:00
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
m_engine = createCdbEngine();
|
2017-09-28 11:27:43 +02:00
|
|
|
break;
|
|
|
|
case LldbEngineType:
|
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
|
|
|
m_engine = createLldbEngine();
|
2017-09-28 11:27:43 +02:00
|
|
|
break;
|
|
|
|
case PdbEngineType: // FIXME: Yes, Python counts as C++...
|
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
|
|
|
QTC_CHECK(false); // Called from DebuggerRunTool constructor already.
|
|
|
|
// m_engine = createPdbEngine();
|
2017-09-28 11:27:43 +02:00
|
|
|
break;
|
2020-01-24 17:08:27 +03:00
|
|
|
case UvscEngineType:
|
|
|
|
m_engine = createUvscEngine();
|
|
|
|
break;
|
2023-01-03 15:12:43 +01:00
|
|
|
case DapEngineType:
|
|
|
|
m_engine = createDapEngine();
|
|
|
|
break;
|
2017-09-28 11:27:43 +02:00
|
|
|
default:
|
2017-11-07 12:39:46 +01:00
|
|
|
if (!m_runParameters.isQmlDebugging) {
|
2021-08-20 12:36:41 +02:00
|
|
|
reportFailure(noEngineMessage() + '\n' +
|
2022-07-05 15:37:08 +02:00
|
|
|
Tr::tr("Specify Debugger settings in Projects > Run."));
|
2017-11-07 12:39:46 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-10-05 08:16:34 +02:00
|
|
|
// Can happen for pure Qml.
|
2017-09-28 11:27:43 +02:00
|
|
|
break;
|
2018-07-25 14:07:08 +02:00
|
|
|
}
|
2017-09-28 11:27:43 +02:00
|
|
|
}
|
2017-09-18 14:47:39 +02:00
|
|
|
|
2017-09-26 11:02:12 +02:00
|
|
|
if (m_runParameters.isQmlDebugging) {
|
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
|
|
|
if (m_engine) {
|
|
|
|
m_engine2 = createQmlEngine();
|
|
|
|
} else {
|
2017-09-26 11:02:12 +02:00
|
|
|
m_engine = createQmlEngine();
|
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
|
|
|
}
|
2017-09-26 11:02:12 +02:00
|
|
|
}
|
2017-09-12 10:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_engine) {
|
2021-08-20 12:36:41 +02:00
|
|
|
QString msg = noEngineMessage();
|
|
|
|
if (!DebuggerKitAspect::debugger(runControl()->kit()))
|
|
|
|
msg += '\n' + noDebuggerInKitMessage();
|
|
|
|
reportFailure(msg);
|
2017-09-12 10:06:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
m_engine->setRunParameters(m_runParameters);
|
2018-09-04 13:29:15 +02:00
|
|
|
m_engine->setRunId(d->runId);
|
2018-08-22 13:08:49 +02:00
|
|
|
m_engine->setRunTool(this);
|
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
|
|
|
m_engine->setCompanionEngine(m_engine2);
|
|
|
|
connect(m_engine, &DebuggerEngine::requestRunControlFinish,
|
|
|
|
runControl(), &RunControl::initiateFinish);
|
|
|
|
connect(m_engine, &DebuggerEngine::requestRunControlStop,
|
|
|
|
runControl(), &RunControl::initiateStop);
|
|
|
|
connect(m_engine, &DebuggerEngine::engineStarted,
|
|
|
|
this, [this] { handleEngineStarted(m_engine); });
|
|
|
|
connect(m_engine, &DebuggerEngine::engineFinished,
|
|
|
|
this, [this] { handleEngineFinished(m_engine); });
|
|
|
|
connect(m_engine, &DebuggerEngine::appendMessageRequested,
|
|
|
|
this, &DebuggerRunTool::appendMessage);
|
|
|
|
++d->engineStartsNeeded;
|
|
|
|
++d->engineStopsNeeded;
|
|
|
|
|
|
|
|
connect(m_engine, &DebuggerEngine::attachToCoreRequested, this, [this](const QString &coreFile) {
|
2019-03-12 15:53:54 +01:00
|
|
|
auto rc = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
2022-04-13 17:57:11 +02:00
|
|
|
rc->copyDataFromRunControl(runControl());
|
2022-07-05 15:37:08 +02:00
|
|
|
auto name = QString(Tr::tr("%1 - Snapshot %2").arg(runControl()->displayName()).arg(++d->snapshotCounter));
|
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
|
|
|
auto debugger = new DebuggerRunTool(rc);
|
2021-01-06 16:56:36 +01:00
|
|
|
debugger->setStartMode(AttachToCore);
|
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
|
|
|
debugger->setRunControlName(name);
|
2021-09-27 15:52:05 +02:00
|
|
|
debugger->setCoreFilePath(FilePath::fromString(coreFile), true);
|
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
|
|
|
debugger->startRunControl();
|
|
|
|
});
|
|
|
|
|
|
|
|
if (m_engine2) {
|
|
|
|
m_engine2->setRunParameters(m_runParameters);
|
2018-09-04 13:29:15 +02:00
|
|
|
m_engine2->setRunId(d->runId);
|
2018-08-22 13:08:49 +02:00
|
|
|
m_engine2->setRunTool(this);
|
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
|
|
|
m_engine2->setCompanionEngine(m_engine);
|
|
|
|
m_engine2->setSecondaryEngine();
|
|
|
|
connect(m_engine2, &DebuggerEngine::requestRunControlFinish,
|
|
|
|
runControl(), &RunControl::initiateFinish);
|
|
|
|
connect(m_engine2, &DebuggerEngine::requestRunControlStop,
|
|
|
|
runControl(), &RunControl::initiateStop);
|
|
|
|
connect(m_engine2, &DebuggerEngine::engineStarted,
|
|
|
|
this, [this] { handleEngineStarted(m_engine2); });
|
|
|
|
connect(m_engine2, &DebuggerEngine::engineFinished,
|
|
|
|
this, [this] { handleEngineFinished(m_engine2); });
|
|
|
|
connect(m_engine2, &DebuggerEngine::appendMessageRequested,
|
|
|
|
this, &DebuggerRunTool::appendMessage);
|
|
|
|
++d->engineStartsNeeded;
|
|
|
|
++d->engineStopsNeeded;
|
|
|
|
}
|
2017-09-12 10:06:10 +02:00
|
|
|
|
2022-08-25 10:31:11 +02:00
|
|
|
if (m_runParameters.startMode != AttachToCore) {
|
2014-03-17 18:27:26 +01:00
|
|
|
QStringList unhandledIds;
|
2020-12-16 16:18:54 +01:00
|
|
|
bool hasQmlBreakpoints = false;
|
|
|
|
for (const GlobalBreakpoint &gbp : BreakpointManager::globalBreakpoints()) {
|
|
|
|
if (gbp->isEnabled()) {
|
|
|
|
const BreakpointParameters &bp = gbp->requestedParameters();
|
|
|
|
hasQmlBreakpoints = hasQmlBreakpoints || bp.isQmlFileAndLineBreakpoint();
|
|
|
|
if (!m_engine->acceptsBreakpoint(bp)) {
|
|
|
|
if (!m_engine2 || !m_engine2->acceptsBreakpoint(bp))
|
|
|
|
unhandledIds.append(gbp->displayName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-17 18:27:26 +01:00
|
|
|
if (!unhandledIds.isEmpty()) {
|
2022-08-25 10:31:11 +02:00
|
|
|
QString warningMessage = Tr::tr("Some breakpoints cannot be handled by the debugger "
|
|
|
|
"languages currently active, and will be ignored.<p>"
|
|
|
|
"Affected are breakpoints %1")
|
|
|
|
.arg(unhandledIds.join(", "));
|
2011-08-08 15:38:05 +02:00
|
|
|
|
2020-12-16 16:18:54 +01:00
|
|
|
if (hasQmlBreakpoints) {
|
2022-08-25 10:31:11 +02:00
|
|
|
warningMessage += "<p>"
|
|
|
|
+ Tr::tr("QML debugging needs to be enabled both in the Build "
|
|
|
|
"and the Run settings.");
|
2020-12-16 16:18:54 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
showMessage(warningMessage, LogWarning);
|
2011-08-08 15:38:05 +02:00
|
|
|
|
2023-04-28 08:39:20 +02:00
|
|
|
static bool doNotShowAgain = false;
|
|
|
|
CheckableMessageBox::information(Core::ICore::dialogParent(),
|
|
|
|
Tr::tr("Debugger"),
|
|
|
|
warningMessage,
|
2023-05-19 10:09:59 +02:00
|
|
|
&doNotShowAgain,
|
2023-04-28 08:39:20 +02:00
|
|
|
QMessageBox::Ok);
|
2011-04-28 14:05:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-05 15:37:08 +02:00
|
|
|
appendMessage(Tr::tr("Debugging %1 ...").arg(m_runParameters.inferior.command.toUserOutput()),
|
2021-03-15 15:14:08 +01:00
|
|
|
NormalMessageFormat);
|
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
|
|
|
QString debuggerName = m_engine->objectName();
|
|
|
|
if (m_engine2)
|
|
|
|
debuggerName += ' ' + m_engine2->objectName();
|
2019-09-19 16:55:21 +02:00
|
|
|
|
2022-07-05 15:37:08 +02:00
|
|
|
const QString message = Tr::tr("Starting debugger \"%1\" for ABI \"%2\"...")
|
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
|
|
|
.arg(debuggerName).arg(m_runParameters.toolChainAbi.toString());
|
2019-09-19 16:55:21 +02:00
|
|
|
DebuggerMainWindow::showStatusMessage(message, 10000);
|
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
|
|
|
|
|
|
|
showMessage(m_engine->formatStartParameters(), LogDebug);
|
|
|
|
showMessage(DebuggerSettings::dump(), LogDebug);
|
|
|
|
|
|
|
|
if (m_engine2)
|
|
|
|
m_engine2->start();
|
2017-09-12 10:06:10 +02:00
|
|
|
m_engine->start();
|
2010-06-15 11:42:49 +02:00
|
|
|
}
|
|
|
|
|
2017-04-27 09:53:07 +02:00
|
|
|
void DebuggerRunTool::stop()
|
2010-06-15 11:42:49 +02:00
|
|
|
{
|
2017-05-19 14:40:49 +02:00
|
|
|
QTC_ASSERT(m_engine, reportStopped(); return);
|
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
|
|
|
if (m_engine2)
|
|
|
|
m_engine2->quitDebugger();
|
2017-05-19 11:54:13 +02:00
|
|
|
m_engine->quitDebugger();
|
2010-06-15 11:42:49 +02:00
|
|
|
}
|
|
|
|
|
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 DebuggerRunTool::handleEngineStarted(DebuggerEngine *engine)
|
2014-12-12 15:33:16 +01:00
|
|
|
{
|
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
|
|
|
// Correct:
|
|
|
|
// if (--d->engineStartsNeeded == 0) {
|
|
|
|
// EngineManager::activateDebugMode();
|
|
|
|
// reportStarted();
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Feels better, as the QML Engine might attach late or not at all.
|
|
|
|
if (engine == m_engine) {
|
|
|
|
EngineManager::activateDebugMode();
|
|
|
|
reportStarted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunTool::handleEngineFinished(DebuggerEngine *engine)
|
|
|
|
{
|
|
|
|
engine->prepareForRestart();
|
|
|
|
if (--d->engineStopsNeeded == 0) {
|
2021-08-10 09:19:30 +02:00
|
|
|
QString cmd = m_runParameters.inferior.command.toUserOutput();
|
2021-03-15 15:14:08 +01:00
|
|
|
QString msg = engine->runParameters().exitCode // Main engine.
|
2022-07-05 15:37:08 +02:00
|
|
|
? Tr::tr("Debugging of %1 has finished with exit code %2.")
|
2021-03-15 15:14:08 +01:00
|
|
|
.arg(cmd).arg(engine->runParameters().exitCode.value())
|
2022-07-05 15:37:08 +02:00
|
|
|
: Tr::tr("Debugging of %1 has finished.").arg(cmd);
|
2021-03-15 15:14:08 +01:00
|
|
|
appendMessage(msg, NormalMessageFormat);
|
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
|
|
|
reportStopped();
|
|
|
|
}
|
2014-12-12 15:33:16 +01:00
|
|
|
}
|
|
|
|
|
2017-09-20 16:34:54 +02:00
|
|
|
bool DebuggerRunTool::isCppDebugging() const
|
|
|
|
{
|
2018-07-25 14:07:08 +02:00
|
|
|
return m_runParameters.isCppDebugging();
|
2017-09-20 16:34:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DebuggerRunTool::isQmlDebugging() const
|
|
|
|
{
|
|
|
|
return m_runParameters.isQmlDebugging;
|
|
|
|
}
|
|
|
|
|
2017-05-04 12:12:27 +02:00
|
|
|
int DebuggerRunTool::portsUsedByDebugger() const
|
|
|
|
{
|
|
|
|
return isCppDebugging() + isQmlDebugging();
|
|
|
|
}
|
|
|
|
|
2017-10-19 14:23:43 +02:00
|
|
|
void DebuggerRunTool::setUsePortsGatherer(bool useCpp, bool useQml)
|
|
|
|
{
|
|
|
|
QTC_ASSERT(!d->portsGatherer, reportFailure(); return);
|
2019-12-13 10:30:30 +01:00
|
|
|
d->portsGatherer = new DebugServerPortsGatherer(runControl());
|
2017-10-19 14:23:43 +02:00
|
|
|
d->portsGatherer->setUseGdbServer(useCpp);
|
|
|
|
d->portsGatherer->setUseQmlServer(useQml);
|
|
|
|
addStartDependency(d->portsGatherer);
|
|
|
|
}
|
|
|
|
|
2019-12-13 10:30:30 +01:00
|
|
|
DebugServerPortsGatherer *DebuggerRunTool::portsGatherer() const
|
2017-10-19 14:23:43 +02:00
|
|
|
{
|
|
|
|
return d->portsGatherer;
|
|
|
|
}
|
2017-05-04 12:12:27 +02:00
|
|
|
|
2022-11-16 14:33:11 +01:00
|
|
|
void DebuggerRunTool::setSolibSearchPath(const Utils::FilePaths &list)
|
2017-08-24 16:53:31 +02:00
|
|
|
{
|
|
|
|
m_runParameters.solibSearchPath = list;
|
|
|
|
}
|
|
|
|
|
2017-09-18 14:47:39 +02:00
|
|
|
bool DebuggerRunTool::fixupParameters()
|
2012-08-15 13:21:37 +02:00
|
|
|
{
|
2017-09-18 14:47:39 +02:00
|
|
|
DebuggerRunParameters &rp = m_runParameters;
|
2016-05-03 11:49:01 +02:00
|
|
|
if (rp.symbolFile.isEmpty())
|
2021-08-10 09:19:30 +02:00
|
|
|
rp.symbolFile = rp.inferior.command.executable();
|
2016-03-22 10:47:03 +01:00
|
|
|
|
2017-09-18 14:47:39 +02:00
|
|
|
// Copy over DYLD_IMAGE_SUFFIX etc
|
2019-01-16 14:47:24 +01:00
|
|
|
for (const auto &var :
|
|
|
|
QStringList({"DYLD_IMAGE_SUFFIX", "DYLD_LIBRARY_PATH", "DYLD_FRAMEWORK_PATH"}))
|
2017-09-18 14:47:39 +02:00
|
|
|
if (rp.inferior.environment.hasKey(var))
|
2019-08-19 14:29:14 +02:00
|
|
|
rp.debugger.environment.set(var, rp.inferior.environment.expandedValueForKey(var));
|
2016-03-22 15:36:08 +01:00
|
|
|
|
|
|
|
// validate debugger if C++ debugging is enabled
|
2021-08-20 12:36:41 +02:00
|
|
|
if (!rp.validationErrors.isEmpty()) {
|
2017-09-18 14:47:39 +02:00
|
|
|
reportFailure(rp.validationErrors.join('\n'));
|
|
|
|
return false;
|
2016-03-22 15:36:08 +01:00
|
|
|
}
|
|
|
|
|
2017-09-20 16:34:54 +02:00
|
|
|
if (rp.isQmlDebugging) {
|
2017-09-18 14:47:39 +02:00
|
|
|
if (device() && device()->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
|
|
|
if (rp.qmlServer.port() <= 0) {
|
2017-09-29 12:41:53 +02:00
|
|
|
rp.qmlServer = Utils::urlFromLocalHostAndFreePort();
|
2017-09-18 14:47:39 +02:00
|
|
|
if (rp.qmlServer.port() <= 0) {
|
2022-07-05 15:37:08 +02:00
|
|
|
reportFailure(Tr::tr("Not enough free ports for QML debugging."));
|
2017-04-06 20:03:18 +02:00
|
|
|
return false;
|
2016-08-03 16:27:22 +02:00
|
|
|
}
|
2014-10-20 14:03:47 +02:00
|
|
|
}
|
2016-03-22 15:36:08 +01:00
|
|
|
// Makes sure that all bindings go through the JavaScript engine, so that
|
|
|
|
// breakpoints are actually hit!
|
2016-04-12 16:42:15 +02:00
|
|
|
const QString optimizerKey = "QML_DISABLE_OPTIMIZER";
|
|
|
|
if (!rp.inferior.environment.hasKey(optimizerKey))
|
|
|
|
rp.inferior.environment.set(optimizerKey, "1");
|
2014-10-20 14:03:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-01 08:59:44 +01:00
|
|
|
if (!debuggerSettings()->autoEnrichParameters.value()) {
|
2021-09-27 11:11:18 +02:00
|
|
|
const FilePath sysroot = rp.sysRoot;
|
2016-04-12 16:42:15 +02:00
|
|
|
if (rp.debugInfoLocation.isEmpty())
|
2021-09-27 11:11:18 +02:00
|
|
|
rp.debugInfoLocation = sysroot / "/usr/lib/debug";
|
2016-04-12 16:42:15 +02:00
|
|
|
if (rp.debugSourceLocation.isEmpty()) {
|
2021-09-27 11:11:18 +02:00
|
|
|
QString base = sysroot.toString() + "/usr/src/debug/";
|
2016-04-12 16:42:15 +02:00
|
|
|
rp.debugSourceLocation.append(base + "qt5base/src/corelib");
|
|
|
|
rp.debugSourceLocation.append(base + "qt5base/src/gui");
|
|
|
|
rp.debugSourceLocation.append(base + "qt5base/src/network");
|
2015-06-24 08:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-26 11:02:12 +02:00
|
|
|
if (rp.isQmlDebugging) {
|
|
|
|
QmlDebug::QmlDebugServicesPreset service;
|
2018-07-25 14:07:08 +02:00
|
|
|
if (rp.isCppDebugging()) {
|
2017-09-26 11:02:12 +02:00
|
|
|
if (rp.nativeMixedEnabled) {
|
|
|
|
service = QmlDebug::QmlNativeDebuggerServices;
|
2015-10-08 16:19:57 +02:00
|
|
|
} else {
|
2015-11-12 08:07:46 +01:00
|
|
|
service = QmlDebug::QmlDebuggerServices;
|
2015-10-08 16:19:57 +02:00
|
|
|
}
|
2017-09-26 11:02:12 +02:00
|
|
|
} else {
|
|
|
|
service = QmlDebug::QmlDebuggerServices;
|
|
|
|
}
|
2021-01-06 16:56:36 +01:00
|
|
|
if (rp.startMode != AttachToLocalProcess && rp.startMode != AttachToCrashedProcess) {
|
2018-07-25 14:07:08 +02:00
|
|
|
QString qmlarg = rp.isCppDebugging() && rp.nativeMixedEnabled
|
2017-09-26 11:02:12 +02:00
|
|
|
? QmlDebug::qmlDebugNativeArguments(service, false)
|
2019-08-23 11:13:29 +02:00
|
|
|
: QmlDebug::qmlDebugTcpArguments(service, rp.qmlServer);
|
2021-08-10 09:19:30 +02:00
|
|
|
rp.inferior.command.addArg(qmlarg);
|
2015-06-24 08:26:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 16:42:15 +02:00
|
|
|
if (rp.startMode == NoStartMode)
|
|
|
|
rp.startMode = StartInternal;
|
2014-10-20 14:03:47 +02:00
|
|
|
|
2017-07-07 19:11:32 +02:00
|
|
|
if (breakOnMainNextTime) {
|
2016-04-12 16:42:15 +02:00
|
|
|
rp.breakOnMain = true;
|
2017-07-07 19:11:32 +02:00
|
|
|
breakOnMainNextTime = false;
|
|
|
|
}
|
2015-06-24 08:26:35 +02:00
|
|
|
|
2017-09-05 15:32:25 +02:00
|
|
|
if (HostOsInfo::isWindowsHost()) {
|
2023-02-07 14:25:47 +01:00
|
|
|
// Otherwise command lines with '> tmp.log' hang.
|
2021-05-06 13:07:36 +02:00
|
|
|
ProcessArgs::SplitError perr;
|
2023-02-07 14:25:47 +01:00
|
|
|
ProcessArgs::prepareArgs(rp.inferior.command.arguments(), &perr,
|
|
|
|
HostOsInfo::hostOs(), nullptr,
|
|
|
|
&rp.inferior.workingDirectory).toWindowsArgs();
|
2021-05-06 13:07:36 +02:00
|
|
|
if (perr != ProcessArgs::SplitOk) {
|
2017-09-05 15:32:25 +02:00
|
|
|
// perr == BadQuoting is never returned on Windows
|
|
|
|
// FIXME? QTCREATORBUG-2809
|
2022-07-05 15:37:08 +02:00
|
|
|
reportFailure(Tr::tr("Debugging complex command lines "
|
|
|
|
"is currently not supported on Windows."));
|
2017-09-05 15:32:25 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-19 17:36:12 +02:00
|
|
|
if (rp.isNativeMixedDebugging())
|
|
|
|
rp.inferior.environment.set("QV4_FORCE_INTERPRETER", "1");
|
|
|
|
|
2021-03-09 11:53:09 +01:00
|
|
|
if (debuggerSettings()->forceLoggingToConsole.value())
|
|
|
|
rp.inferior.environment.set("QT_LOGGING_TO_CONSOLE", "1");
|
|
|
|
|
2017-04-06 20:03:18 +02:00
|
|
|
return true;
|
2015-06-24 08:26:35 +02:00
|
|
|
}
|
|
|
|
|
2017-09-27 08:22:02 +02:00
|
|
|
Internal::TerminalRunner *DebuggerRunTool::terminalRunner() const
|
|
|
|
{
|
|
|
|
return d->terminalRunner;
|
|
|
|
}
|
|
|
|
|
2020-05-13 08:39:37 +02:00
|
|
|
DebuggerEngineType DebuggerRunTool::cppEngineType() const
|
|
|
|
{
|
|
|
|
return m_runParameters.cppEngineType;
|
|
|
|
}
|
|
|
|
|
2019-03-12 17:04:08 +01:00
|
|
|
DebuggerRunTool::DebuggerRunTool(RunControl *runControl, AllowTerminal allowTerminal)
|
2017-09-27 08:22:02 +02:00
|
|
|
: RunWorker(runControl), d(new DebuggerRunToolPrivate)
|
2017-05-03 12:35:00 +02:00
|
|
|
{
|
2018-08-21 08:28:27 +02:00
|
|
|
setId("DebuggerRunTool");
|
2017-09-20 16:34:54 +02:00
|
|
|
|
2018-09-04 13:29:15 +02:00
|
|
|
static int toolRunCount = 0;
|
|
|
|
|
|
|
|
// Reset once all are gone.
|
|
|
|
if (EngineManager::engines().isEmpty())
|
|
|
|
toolRunCount = 0;
|
|
|
|
|
|
|
|
d->runId = QString::number(++toolRunCount);
|
|
|
|
|
2017-07-05 15:17:38 +02:00
|
|
|
runControl->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL_TOOLBAR);
|
|
|
|
runControl->setPromptToStop([](bool *optionalPrompt) {
|
|
|
|
return RunControl::showPromptToStopDialog(
|
2022-07-05 15:37:08 +02:00
|
|
|
Tr::tr("Close Debugging Session"),
|
|
|
|
Tr::tr("A debugging session is still in progress. "
|
2017-07-05 15:17:38 +02:00
|
|
|
"Terminating the session in the current"
|
|
|
|
" state can leave the target in an inconsistent state."
|
|
|
|
" Would you still like to terminate it?"),
|
|
|
|
QString(), QString(), optionalPrompt);
|
|
|
|
});
|
2017-08-24 15:46:23 +02:00
|
|
|
|
2019-03-13 18:28:29 +01:00
|
|
|
m_runParameters.displayName = runControl->displayName();
|
2017-09-27 08:22:02 +02:00
|
|
|
|
2019-03-12 17:04:08 +01:00
|
|
|
if (auto symbolsAspect = runControl->aspect<SymbolFileAspect>())
|
2022-04-08 11:35:54 +02:00
|
|
|
m_runParameters.symbolFile = symbolsAspect->filePath;
|
2019-03-12 17:04:08 +01:00
|
|
|
if (auto terminalAspect = runControl->aspect<TerminalAspect>())
|
2022-04-08 11:35:54 +02:00
|
|
|
m_runParameters.useTerminal = terminalAspect->useTerminal;
|
2021-02-15 16:55:28 +01:00
|
|
|
if (auto runAsRootAspect = runControl->aspect<RunAsRootAspect>())
|
2022-04-08 11:35:54 +02:00
|
|
|
m_runParameters.runAsRoot = runAsRootAspect->value;
|
2019-03-12 17:04:08 +01:00
|
|
|
|
|
|
|
Kit *kit = runControl->kit();
|
2017-09-27 08:22:02 +02:00
|
|
|
QTC_ASSERT(kit, return);
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
m_runParameters.sysRoot = SysRootKitAspect::sysRoot(kit);
|
2021-10-07 16:58:25 +02:00
|
|
|
m_runParameters.macroExpander = runControl->macroExpander();
|
2019-02-06 12:50:51 +01:00
|
|
|
m_runParameters.debugger = DebuggerKitAspect::runnable(kit);
|
|
|
|
m_runParameters.cppEngineType = DebuggerKitAspect::engineType(kit);
|
2017-09-27 08:22:02 +02:00
|
|
|
|
2022-01-21 16:06:36 +01:00
|
|
|
if (QtSupport::QtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit))
|
2017-12-08 13:55:15 +01:00
|
|
|
m_runParameters.qtPackageSourceLocation = qtVersion->qtPackageSourcePath().toString();
|
|
|
|
|
2019-03-12 17:04:08 +01:00
|
|
|
if (auto aspect = runControl->aspect<DebuggerRunConfigurationAspect>()) {
|
2022-04-08 11:35:54 +02:00
|
|
|
if (!aspect->useCppDebugger)
|
2018-08-16 16:17:18 +02:00
|
|
|
m_runParameters.cppEngineType = NoEngineType;
|
2022-04-08 11:35:54 +02:00
|
|
|
m_runParameters.isQmlDebugging = aspect->useQmlDebugger;
|
|
|
|
m_runParameters.multiProcess = aspect->useMultiProcess;
|
|
|
|
m_runParameters.additionalStartupCommands = aspect->overrideStartup;
|
2021-08-20 12:36:41 +02:00
|
|
|
|
2022-04-08 11:35:54 +02:00
|
|
|
if (aspect->useCppDebugger) {
|
2021-08-20 12:36:41 +02:00
|
|
|
if (DebuggerKitAspect::debugger(kit)) {
|
|
|
|
const Tasks tasks = DebuggerKitAspect::validateDebugger(kit);
|
|
|
|
for (const Task &t : tasks) {
|
|
|
|
if (t.type != Task::Warning)
|
|
|
|
m_runParameters.validationErrors.append(t.description());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
m_runParameters.validationErrors.append(noDebuggerInKitMessage());
|
|
|
|
}
|
|
|
|
}
|
2018-07-25 14:07:08 +02:00
|
|
|
}
|
2017-10-05 08:16:34 +02:00
|
|
|
|
2022-05-30 17:18:15 +02:00
|
|
|
Runnable inferior = runControl->runnable();
|
2021-10-26 10:26:17 +02:00
|
|
|
const FilePath &debuggerExecutable = m_runParameters.debugger.command.executable();
|
2023-03-29 13:45:42 +02:00
|
|
|
inferior.command.setExecutable(debuggerExecutable.withNewMappedPath(inferior.command.executable()));
|
|
|
|
inferior.workingDirectory = debuggerExecutable.withNewMappedPath(inferior.workingDirectory);
|
2018-05-16 15:42:03 +02:00
|
|
|
// Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...)
|
2021-10-26 10:26:17 +02:00
|
|
|
inferior.workingDirectory = inferior.workingDirectory.normalizedPathName();
|
|
|
|
m_runParameters.inferior = inferior;
|
|
|
|
|
2019-03-12 17:04:08 +01:00
|
|
|
setUseTerminal(allowTerminal == DoAllowTerminal && m_runParameters.useTerminal);
|
2017-10-09 15:36:14 +03:00
|
|
|
|
2022-08-24 14:55:12 +02:00
|
|
|
const QString envBinary = qtcEnvironmentVariable("QTC_DEBUGGER_PATH");
|
2017-09-18 14:47:39 +02:00
|
|
|
if (!envBinary.isEmpty())
|
2022-08-24 14:55:12 +02:00
|
|
|
m_runParameters.debugger.command.setExecutable(FilePath::fromString(envBinary));
|
2017-09-18 14:47:39 +02:00
|
|
|
|
2019-03-13 18:28:29 +01:00
|
|
|
if (Project *project = runControl->project()) {
|
2018-08-21 17:15:53 +02:00
|
|
|
m_runParameters.projectSourceDirectory = project->projectDirectory();
|
2018-05-24 11:17:04 +02:00
|
|
|
m_runParameters.projectSourceFiles = project->files(Project::SourceFiles);
|
2023-03-14 18:18:39 +01:00
|
|
|
} else {
|
|
|
|
m_runParameters.projectSourceDirectory = m_runParameters.debugger.command.executable().parentDir();
|
|
|
|
m_runParameters.projectSourceFiles.clear();
|
2017-09-18 14:47:39 +02:00
|
|
|
}
|
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
m_runParameters.toolChainAbi = ToolChainKitAspect::targetAbi(kit);
|
2017-09-18 14:47:39 +02:00
|
|
|
|
|
|
|
bool ok = false;
|
2022-08-24 14:55:12 +02:00
|
|
|
const int nativeMixedOverride = qtcEnvironmentVariableIntValue("QTC_DEBUGGER_NATIVE_MIXED", &ok);
|
2017-09-18 14:47:39 +02:00
|
|
|
if (ok)
|
|
|
|
m_runParameters.nativeMixedEnabled = bool(nativeMixedOverride);
|
|
|
|
|
|
|
|
|
2022-04-13 12:26:54 +02:00
|
|
|
if (auto interpreterAspect = runControl->aspect<InterpreterAspect>()) {
|
|
|
|
if (auto mainScriptAspect = runControl->aspect<MainScriptAspect>()) {
|
|
|
|
const FilePath mainScript = mainScriptAspect->filePath;
|
|
|
|
const FilePath interpreter = interpreterAspect->interpreter.command;
|
|
|
|
if (!interpreter.isEmpty() && mainScript.endsWith(".py")) {
|
|
|
|
m_runParameters.mainScript = mainScript;
|
|
|
|
m_runParameters.interpreter = interpreter;
|
|
|
|
if (auto args = runControl->aspect<ArgumentsAspect>())
|
|
|
|
m_runParameters.inferior.command.addArgs(args->arguments, CommandLine::Raw);
|
|
|
|
m_engine = createPdbEngine();
|
|
|
|
}
|
2017-09-18 14:47:39 +02:00
|
|
|
}
|
|
|
|
}
|
2021-10-18 09:44:10 +02:00
|
|
|
|
2022-01-21 16:06:36 +01:00
|
|
|
if (QtSupport::QtVersion *baseQtVersion = QtSupport::QtKitAspect::qtVersion(kit)) {
|
2022-07-04 18:36:40 +02:00
|
|
|
const QVersionNumber qtVersion = baseQtVersion->qtVersion();
|
|
|
|
m_runParameters.fallbackQtVersion = 0x10000 * qtVersion.majorVersion()
|
|
|
|
+ 0x100 * qtVersion.minorVersion()
|
|
|
|
+ qtVersion.microVersion();
|
2021-10-25 12:03:34 +02:00
|
|
|
}
|
2017-05-03 12:35:00 +02:00
|
|
|
}
|
|
|
|
|
2017-08-24 18:40:37 +02:00
|
|
|
void DebuggerRunTool::startRunControl()
|
|
|
|
{
|
|
|
|
ProjectExplorerPlugin::startRunControl(runControl());
|
|
|
|
}
|
|
|
|
|
2017-08-24 16:53:31 +02:00
|
|
|
void DebuggerRunTool::addSolibSearchDir(const QString &str)
|
2017-05-04 12:12:27 +02:00
|
|
|
{
|
|
|
|
QString path = str;
|
2018-08-21 17:46:47 +02:00
|
|
|
path.replace("%{sysroot}", m_runParameters.sysRoot.toString());
|
2022-11-16 14:33:11 +01:00
|
|
|
m_runParameters.solibSearchPath.append(FilePath::fromString(path));
|
2017-05-04 12:12:27 +02:00
|
|
|
}
|
|
|
|
|
2017-04-10 13:57:05 +02:00
|
|
|
DebuggerRunTool::~DebuggerRunTool()
|
|
|
|
{
|
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
|
|
|
if (m_runParameters.isSnapshot && !m_runParameters.coreFile.isEmpty())
|
2021-09-27 15:52:05 +02:00
|
|
|
m_runParameters.coreFile.removeFile();
|
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
|
|
|
|
|
|
|
delete m_engine2;
|
|
|
|
m_engine2 = nullptr;
|
|
|
|
delete m_engine;
|
|
|
|
m_engine = nullptr;
|
|
|
|
|
2017-09-27 08:22:02 +02:00
|
|
|
delete d;
|
2017-04-10 13:57:05 +02:00
|
|
|
}
|
2017-04-07 10:21:27 +02:00
|
|
|
|
2017-04-10 13:57:05 +02:00
|
|
|
void DebuggerRunTool::showMessage(const QString &msg, int channel, int timeout)
|
|
|
|
{
|
|
|
|
if (channel == ConsoleOutput)
|
|
|
|
debuggerConsole()->printItem(ConsoleItem::DefaultType, msg);
|
|
|
|
|
2019-06-11 07:37:41 +02:00
|
|
|
QTC_ASSERT(m_engine, qDebug() << msg; return);
|
|
|
|
|
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
|
|
|
m_engine->showMessage(msg, channel, timeout);
|
|
|
|
if (m_engine2)
|
|
|
|
m_engine->showMessage(msg, channel, timeout);
|
2017-04-10 13:57:05 +02:00
|
|
|
switch (channel) {
|
|
|
|
case AppOutput:
|
2020-03-17 15:18:06 +01:00
|
|
|
appendMessage(msg, StdOutFormat);
|
2017-04-10 13:57:05 +02:00
|
|
|
break;
|
|
|
|
case AppError:
|
2020-03-17 15:18:06 +01:00
|
|
|
appendMessage(msg, StdErrFormat);
|
2017-04-10 13:57:05 +02:00
|
|
|
break;
|
|
|
|
case AppStuff:
|
|
|
|
appendMessage(msg, DebugFormat);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 10:21:27 +02:00
|
|
|
|
2015-06-24 08:26:35 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Externally visible helper.
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-05-09 10:25:11 +02:00
|
|
|
// GdbServerPortGatherer
|
|
|
|
|
2019-12-13 10:30:30 +01:00
|
|
|
DebugServerPortsGatherer::DebugServerPortsGatherer(RunControl *runControl)
|
2017-11-08 19:20:18 +01:00
|
|
|
: ChannelProvider(runControl, 2)
|
2017-05-09 10:25:11 +02:00
|
|
|
{
|
2019-12-13 10:30:30 +01:00
|
|
|
setId("DebugServerPortsGatherer");
|
2017-05-09 10:25:11 +02:00
|
|
|
}
|
|
|
|
|
2019-12-13 10:30:30 +01:00
|
|
|
DebugServerPortsGatherer::~DebugServerPortsGatherer() = default;
|
2017-05-09 10:25:11 +02:00
|
|
|
|
2019-12-13 10:30:30 +01:00
|
|
|
QUrl DebugServerPortsGatherer::gdbServer() const
|
2017-08-24 15:46:23 +02:00
|
|
|
{
|
2017-12-19 13:01:02 +01:00
|
|
|
return channel(0);
|
2017-08-24 15:46:23 +02:00
|
|
|
}
|
|
|
|
|
2019-12-13 10:30:30 +01:00
|
|
|
QUrl DebugServerPortsGatherer::qmlServer() const
|
2017-05-09 10:25:11 +02:00
|
|
|
{
|
2017-11-08 19:20:18 +01:00
|
|
|
return channel(1);
|
2017-05-09 10:25:11 +02:00
|
|
|
}
|
|
|
|
|
2019-12-13 10:30:30 +01:00
|
|
|
// DebugServerRunner
|
2017-05-09 10:25:11 +02:00
|
|
|
|
2019-12-13 10:30:30 +01:00
|
|
|
DebugServerRunner::DebugServerRunner(RunControl *runControl, DebugServerPortsGatherer *portsGatherer)
|
2019-09-02 18:22:35 +02:00
|
|
|
: SimpleTargetRunner(runControl)
|
2017-05-09 10:25:11 +02:00
|
|
|
{
|
2019-12-13 10:30:30 +01:00
|
|
|
setId("DebugServerRunner");
|
2019-09-02 18:22:35 +02:00
|
|
|
addStartDependency(portsGatherer);
|
2017-05-09 10:25:11 +02:00
|
|
|
|
2019-09-02 18:22:35 +02:00
|
|
|
QTC_ASSERT(portsGatherer, reportFailure(); return);
|
2017-05-09 10:25:11 +02:00
|
|
|
|
2022-05-23 16:09:43 +02:00
|
|
|
setStartModifier([this, runControl, portsGatherer] {
|
2019-09-02 18:22:35 +02:00
|
|
|
QTC_ASSERT(portsGatherer, reportFailure(); return);
|
|
|
|
|
|
|
|
const bool isQmlDebugging = portsGatherer->useQmlServer();
|
|
|
|
const bool isCppDebugging = portsGatherer->useGdbServer();
|
|
|
|
|
2022-05-23 16:09:43 +02:00
|
|
|
CommandLine cmd;
|
|
|
|
|
|
|
|
QStringList args = ProcessArgs::splitArgs(commandLine().arguments(), OsTypeLinux);
|
2019-09-02 18:22:35 +02:00
|
|
|
if (isQmlDebugging) {
|
|
|
|
args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
|
|
|
|
portsGatherer->qmlServer()));
|
|
|
|
}
|
|
|
|
if (isQmlDebugging && !isCppDebugging) {
|
2022-05-23 16:09:43 +02:00
|
|
|
cmd.setExecutable(commandLine().executable()); // FIXME: Case should not happen?
|
2019-09-02 18:22:35 +02:00
|
|
|
} else {
|
2022-05-23 16:09:43 +02:00
|
|
|
cmd.setExecutable(runControl->device()->debugServerPath());
|
2023-04-06 06:58:39 +02:00
|
|
|
|
|
|
|
if (cmd.isEmpty()) {
|
|
|
|
if (runControl->device()->osType() == Utils::OsTypeMac) {
|
|
|
|
const FilePath debugServerLocation = runControl->device()->filePath(
|
|
|
|
"/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/"
|
|
|
|
"Resources/debugserver");
|
|
|
|
|
|
|
|
if (debugServerLocation.isExecutableFile()) {
|
|
|
|
cmd.setExecutable(debugServerLocation);
|
|
|
|
} else {
|
|
|
|
// TODO: In the future it is expected that the debugserver will be
|
|
|
|
// replaced by lldb-server. Remove the check for debug server at that point.
|
|
|
|
const FilePath lldbserver
|
|
|
|
= runControl->device()->filePath("lldb-server").searchInPath();
|
|
|
|
if (lldbserver.isExecutableFile())
|
|
|
|
cmd.setExecutable(lldbserver);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cmd.setExecutable(runControl->device()->filePath("gdbserver"));
|
|
|
|
}
|
|
|
|
}
|
2019-09-02 18:22:35 +02:00
|
|
|
args.clear();
|
2023-04-06 06:58:39 +02:00
|
|
|
if (cmd.executable().baseName().contains("lldb-server")) {
|
2020-04-02 12:09:45 +02:00
|
|
|
args.append("platform");
|
|
|
|
args.append("--listen");
|
|
|
|
args.append(QString("*:%1").arg(portsGatherer->gdbServer().port()));
|
|
|
|
args.append("--server");
|
2023-04-06 06:58:39 +02:00
|
|
|
} else if (cmd.executable().baseName() == "debugserver") {
|
|
|
|
args.append(QString("*:%1").arg(portsGatherer->gdbServer().port()));
|
|
|
|
args.append("--attach");
|
|
|
|
args.append(QString::number(m_pid.pid()));
|
2020-04-02 12:09:45 +02:00
|
|
|
} else {
|
|
|
|
// Something resembling gdbserver
|
|
|
|
if (m_useMulti)
|
|
|
|
args.append("--multi");
|
|
|
|
if (m_pid.isValid())
|
|
|
|
args.append("--attach");
|
|
|
|
args.append(QString(":%1").arg(portsGatherer->gdbServer().port()));
|
|
|
|
if (m_pid.isValid())
|
|
|
|
args.append(QString::number(m_pid.pid()));
|
|
|
|
}
|
2019-09-02 18:22:35 +02:00
|
|
|
}
|
2022-05-23 16:09:43 +02:00
|
|
|
cmd.setArguments(ProcessArgs::joinArgs(args, OsTypeLinux));
|
|
|
|
|
|
|
|
setCommandLine(cmd);
|
2019-09-02 18:22:35 +02:00
|
|
|
});
|
2017-10-19 08:29:20 +02:00
|
|
|
}
|
|
|
|
|
2019-12-13 10:30:30 +01:00
|
|
|
DebugServerRunner::~DebugServerRunner() = default;
|
2019-09-02 18:22:35 +02:00
|
|
|
|
2019-12-13 10:30:30 +01:00
|
|
|
void DebugServerRunner::setUseMulti(bool on)
|
2017-10-19 08:29:20 +02:00
|
|
|
{
|
|
|
|
m_useMulti = on;
|
|
|
|
}
|
|
|
|
|
2019-12-13 10:30:30 +01:00
|
|
|
void DebugServerRunner::setAttachPid(ProcessHandle pid)
|
2017-10-19 08:29:20 +02:00
|
|
|
{
|
|
|
|
m_pid = pid;
|
|
|
|
}
|
|
|
|
|
2023-01-05 08:50:37 +01:00
|
|
|
// DebuggerRunWorkerFactory
|
|
|
|
|
|
|
|
DebuggerRunWorkerFactory::DebuggerRunWorkerFactory()
|
|
|
|
{
|
|
|
|
setProduct<DebuggerRunTool>();
|
|
|
|
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
|
|
|
addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
|
|
|
addSupportedDeviceType("DockerDeviceType");
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Debugger
|