2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2014-10-17 13:40:04 +02:00
|
|
|
#include "debuggerruncontrol.h"
|
2017-09-27 08:22:02 +02:00
|
|
|
#include "terminal.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-03-02 13:57:37 +01:00
|
|
|
#include "analyzer/analyzermanager.h"
|
2017-04-10 13:57:05 +02:00
|
|
|
#include "console/console.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggeractions.h"
|
2010-11-10 11:39:01 +01:00
|
|
|
#include "debuggercore.h"
|
2013-03-22 10:28:49 +01:00
|
|
|
#include "debuggerengine.h"
|
|
|
|
#include "debuggerkitinformation.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerplugin.h"
|
2013-03-27 13:03:15 +01:00
|
|
|
#include "debuggerrunconfigurationaspect.h"
|
2013-03-22 10:28:49 +01:00
|
|
|
#include "breakhandler.h"
|
2014-02-19 15:35:58 +01:00
|
|
|
#include "shared/peutils.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
|
|
|
#include "snapshothandler.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>
|
|
|
|
#include <projectexplorer/devicesupport/deviceprocesslist.h>
|
|
|
|
#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>
|
2018-04-23 15:38:53 +02:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2017-04-11 13:45:37 +02:00
|
|
|
#include <projectexplorer/session.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>
|
2013-10-23 22:07:46 +03:00
|
|
|
#include <utils/fileutils.h>
|
2017-05-04 12:12:27 +02:00
|
|
|
#include <utils/portlist.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2010-12-15 13:06:39 +01:00
|
|
|
#include <utils/qtcprocess.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>
|
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>
|
|
|
|
|
2017-09-12 10:53:56 +02:00
|
|
|
#include <ssh/sshconnection.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();
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2017-08-21 14:32:15 +02:00
|
|
|
class LocalProcessRunner : public RunWorker
|
|
|
|
{
|
2017-10-23 13:45:47 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::LocalProcessRunner)
|
|
|
|
|
2017-08-21 14:32:15 +02:00
|
|
|
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
|
|
|
LocalProcessRunner(DebuggerRunTool *runTool, const Runnable &runnable)
|
|
|
|
: RunWorker(runTool->runControl()), m_runTool(runTool), m_runnable(runnable)
|
2017-08-21 14:32:15 +02:00
|
|
|
{
|
|
|
|
connect(&m_proc, &QProcess::errorOccurred,
|
|
|
|
this, &LocalProcessRunner::handleError);
|
|
|
|
connect(&m_proc, &QProcess::readyReadStandardOutput,
|
|
|
|
this, &LocalProcessRunner::handleStandardOutput);
|
|
|
|
connect(&m_proc, &QProcess::readyReadStandardError,
|
|
|
|
this, &LocalProcessRunner::handleStandardError);
|
|
|
|
connect(&m_proc, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
|
|
|
|
this, &LocalProcessRunner::handleFinished);
|
|
|
|
}
|
|
|
|
|
|
|
|
void start() override
|
|
|
|
{
|
|
|
|
m_proc.setCommand(m_runnable.executable, m_runnable.commandLineArguments);
|
|
|
|
m_proc.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void stop() override
|
|
|
|
{
|
|
|
|
m_proc.terminate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void handleStandardOutput()
|
|
|
|
{
|
|
|
|
const QByteArray ba = m_proc.readAllStandardOutput();
|
|
|
|
const QString msg = QString::fromLocal8Bit(ba, ba.length());
|
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_runTool->appendMessage(msg, StdOutFormatSameLine);
|
2017-08-21 14:32:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void handleStandardError()
|
|
|
|
{
|
|
|
|
const QByteArray ba = m_proc.readAllStandardError();
|
|
|
|
const QString msg = QString::fromLocal8Bit(ba, ba.length());
|
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_runTool->appendMessage(msg, StdErrFormatSameLine);
|
2017-08-21 14:32:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void handleFinished()
|
|
|
|
{
|
|
|
|
if (m_proc.exitStatus() == QProcess::NormalExit && m_proc.exitCode() == 0) {
|
|
|
|
// all good.
|
|
|
|
reportDone();
|
|
|
|
} else {
|
|
|
|
reportFailure(tr("Upload failed: %1").arg(m_proc.errorString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void handleError(QProcess::ProcessError error)
|
|
|
|
{
|
|
|
|
QString msg;
|
|
|
|
switch (error) {
|
|
|
|
case QProcess::FailedToStart:
|
|
|
|
msg = tr("The upload process failed to start. Shell missing?");
|
|
|
|
break;
|
|
|
|
case QProcess::Crashed:
|
|
|
|
msg = tr("The upload process crashed some time after starting "
|
|
|
|
"successfully.");
|
|
|
|
break;
|
|
|
|
case QProcess::Timedout:
|
|
|
|
msg = tr("The last waitFor...() function timed out. "
|
|
|
|
"The state of QProcess is unchanged, and you can try calling "
|
|
|
|
"waitFor...() again.");
|
|
|
|
break;
|
|
|
|
case QProcess::WriteError:
|
|
|
|
msg = tr("An error occurred when attempting to write "
|
|
|
|
"to the upload process. For example, the process may not be running, "
|
|
|
|
"or it may have closed its input channel.");
|
|
|
|
break;
|
|
|
|
case QProcess::ReadError:
|
|
|
|
msg = tr("An error occurred when attempting to read from "
|
|
|
|
"the upload process. For example, the process may not be running.");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
msg = tr("An unknown error in the upload process occurred. "
|
|
|
|
"This is the default return value of error().");
|
|
|
|
}
|
|
|
|
|
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_runTool->showMessage(msg, StatusBar);
|
2017-08-21 14:32:15 +02:00
|
|
|
Core::AsynchronousMessageBox::critical(tr("Error"), msg);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
QPointer<DebuggerRunTool> m_runTool;
|
2018-05-16 15:42:03 +02:00
|
|
|
Runnable m_runnable;
|
2017-08-21 14:32:15 +02:00
|
|
|
Utils::QtcProcess m_proc;
|
|
|
|
};
|
|
|
|
|
2017-09-27 15:30:02 +02:00
|
|
|
class CoreUnpacker : public RunWorker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CoreUnpacker(RunControl *runControl, const QString &coreFileName)
|
|
|
|
: RunWorker(runControl), m_coreFileName(coreFileName)
|
|
|
|
{}
|
|
|
|
|
|
|
|
QString coreFileName() const { return m_tempCoreFileName; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
~CoreUnpacker() final
|
|
|
|
{
|
|
|
|
m_coreUnpackProcess.blockSignals(true);
|
|
|
|
m_coreUnpackProcess.terminate();
|
|
|
|
m_coreUnpackProcess.deleteLater();
|
|
|
|
if (m_tempCoreFile.isOpen())
|
|
|
|
m_tempCoreFile.close();
|
|
|
|
|
|
|
|
QFile::remove(m_tempCoreFileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void start() final
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Utils::TemporaryFile tmp("tmpcore-XXXXXX");
|
|
|
|
tmp.open();
|
|
|
|
m_tempCoreFileName = tmp.fileName();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_coreUnpackProcess.setWorkingDirectory(TemporaryDirectory::masterDirectoryPath());
|
|
|
|
connect(&m_coreUnpackProcess, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
|
|
|
|
this, &CoreUnpacker::reportStarted);
|
|
|
|
|
|
|
|
const QString msg = DebuggerRunTool::tr("Unpacking core file to %1");
|
|
|
|
appendMessage(msg.arg(m_tempCoreFileName), LogMessageFormat);
|
|
|
|
|
|
|
|
if (m_coreFileName.endsWith(".lzo")) {
|
|
|
|
m_coreUnpackProcess.start("lzop", {"-o", m_tempCoreFileName, "-x", m_coreFileName});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_coreFileName.endsWith(".gz")) {
|
|
|
|
appendMessage(msg.arg(m_tempCoreFileName), LogMessageFormat);
|
|
|
|
m_tempCoreFile.setFileName(m_tempCoreFileName);
|
|
|
|
m_tempCoreFile.open(QFile::WriteOnly);
|
|
|
|
connect(&m_coreUnpackProcess, &QProcess::readyRead, this, [this] {
|
|
|
|
m_tempCoreFile.write(m_coreUnpackProcess.readAll());
|
|
|
|
});
|
|
|
|
m_coreUnpackProcess.start("gzip", {"-c", "-d", m_coreFileName});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QTC_CHECK(false);
|
|
|
|
reportFailure("Unknown file extension in " + m_coreFileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
QFile m_tempCoreFile;
|
|
|
|
QString m_coreFileName;
|
|
|
|
QString m_tempCoreFileName;
|
|
|
|
QProcess m_coreUnpackProcess;
|
|
|
|
};
|
|
|
|
|
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;
|
2017-10-19 14:23:43 +02:00
|
|
|
QPointer<GdbServerPortsGatherer> portsGatherer;
|
|
|
|
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;
|
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
|
|
|
|
QList<Project *> projects = SessionManager::projects();
|
|
|
|
if (Project *startupProject = SessionManager::startupProject()) {
|
|
|
|
// startup project first
|
|
|
|
projects.removeOne(startupProject);
|
|
|
|
projects.insert(0, startupProject);
|
|
|
|
}
|
|
|
|
foreach (Project *project, 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())
|
|
|
|
m_runParameters.projectSourceDirectory = projects.first()->projectDirectory().toString();
|
|
|
|
|
|
|
|
} 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);
|
|
|
|
}
|
|
|
|
|
2017-08-24 16:53:31 +02:00
|
|
|
void DebuggerRunTool::setSysRoot(const QString &sysRoot)
|
|
|
|
{
|
|
|
|
m_runParameters.sysRoot = sysRoot;
|
|
|
|
}
|
|
|
|
|
2017-08-24 15:46:23 +02:00
|
|
|
void DebuggerRunTool::setSymbolFile(const QString &symbolFile)
|
|
|
|
{
|
|
|
|
if (symbolFile.isEmpty())
|
|
|
|
reportFailure(tr("Cannot debug: Local executable is not set."));
|
|
|
|
m_runParameters.symbolFile = symbolFile;
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
&& boolSetting(UseCdbConsole);
|
|
|
|
|
|
|
|
if (on && !d->terminalRunner && !useCdbConsole) {
|
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
|
|
|
d->terminalRunner = new TerminalRunner(runControl(), 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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-09-12 12:38:31 +02:00
|
|
|
void DebuggerRunTool::setServerStartScript(const QString &serverStartScript)
|
|
|
|
{
|
2017-09-12 13:50:45 +02:00
|
|
|
if (!serverStartScript.isEmpty()) {
|
|
|
|
// Provide script information about the environment
|
2018-05-16 15:42:03 +02:00
|
|
|
Runnable serverStarter;
|
2017-09-12 13:50:45 +02:00
|
|
|
serverStarter.executable = serverStartScript;
|
|
|
|
QtcProcess::addArg(&serverStarter.commandLineArguments, m_runParameters.inferior.executable);
|
|
|
|
QtcProcess::addArg(&serverStarter.commandLineArguments, m_runParameters.remoteChannel);
|
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
|
|
|
addStartDependency(new LocalProcessRunner(this, serverStarter));
|
2017-09-12 13:50:45 +02:00
|
|
|
}
|
2017-09-12 12:38:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunTool::setDebugInfoLocation(const QString &debugInfoLocation)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-09-12 12:38:31 +02:00
|
|
|
void DebuggerRunTool::setOverrideStartScript(const QString &script)
|
|
|
|
{
|
|
|
|
m_runParameters.overrideStartScript = script;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-08-24 17:38:06 +02:00
|
|
|
void DebuggerRunTool::setInferiorExecutable(const QString &executable)
|
|
|
|
{
|
|
|
|
m_runParameters.inferior.executable = executable;
|
|
|
|
}
|
|
|
|
|
2017-10-11 17:17:16 +02:00
|
|
|
void DebuggerRunTool::setInferiorEnvironment(const Utils::Environment &env)
|
|
|
|
{
|
|
|
|
m_runParameters.inferior.environment = env;
|
|
|
|
}
|
|
|
|
|
2017-11-13 11:11:43 +01:00
|
|
|
void DebuggerRunTool::setInferiorDevice(IDevice::ConstPtr device)
|
|
|
|
{
|
|
|
|
m_runParameters.inferior.device = device;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunTool::setCoreFileName(const QString &coreFile, bool isSnapshot)
|
|
|
|
{
|
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::appendInferiorCommandLineArgument(const QString &arg)
|
|
|
|
{
|
2018-04-16 13:42:43 +02:00
|
|
|
QtcProcess::addArg(&m_runParameters.inferior.commandLineArguments, arg,
|
|
|
|
device() ? device()->osType() : HostOsInfo::hostOs());
|
2017-08-24 15:46:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunTool::prependInferiorCommandLineArgument(const QString &arg)
|
|
|
|
{
|
|
|
|
if (!m_runParameters.inferior.commandLineArguments.isEmpty())
|
|
|
|
m_runParameters.inferior.commandLineArguments.prepend(' ');
|
2018-04-16 13:42:43 +02:00
|
|
|
m_runParameters.inferior.commandLineArguments.prepend(
|
|
|
|
QtcProcess::quoteArg(arg, device() ? device()->osType() : HostOsInfo::hostOs()));
|
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
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DebuggerRunTool::addSearchDirectory(const QString &dir)
|
|
|
|
{
|
|
|
|
m_runParameters.additionalSearchDirectories.append(dir);
|
|
|
|
}
|
|
|
|
|
2017-05-09 10:25:11 +02:00
|
|
|
void DebuggerRunTool::start()
|
2010-06-15 09:13:22 +02:00
|
|
|
{
|
2015-06-24 08:26:35 +02:00
|
|
|
TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO);
|
|
|
|
TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME);
|
|
|
|
|
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()) {
|
2017-10-19 14:23:43 +02:00
|
|
|
using namespace QmlDebug;
|
|
|
|
int qmlServerPort = m_runParameters.qmlServer.port();
|
|
|
|
QTC_ASSERT(qmlServerPort > 0, reportFailure(); return);
|
|
|
|
QString mode = QString("port:%1").arg(qmlServerPort);
|
|
|
|
QString qmlServerArg = qmlDebugCommandLineArguments(QmlDebuggerServices, mode, true);
|
|
|
|
prependInferiorCommandLineArgument(qmlServerArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
&& m_runParameters.inferior.executable.isEmpty()
|
|
|
|
&& m_runParameters.interpreter.isEmpty()) {
|
|
|
|
reportFailure(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.
|
2017-09-20 16:34:54 +02:00
|
|
|
setSupportsReRunning(!m_runParameters.isQmlDebugging);
|
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()) {
|
|
|
|
// reportFailure(tr("Cannot debug: Not enough free ports available."));
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
Utils::globalMacroExpander()->registerFileVariables(
|
|
|
|
"DebuggedExecutable", tr("Debugged executable"),
|
|
|
|
[this] { return m_runParameters.inferior.executable; }
|
|
|
|
);
|
|
|
|
|
|
|
|
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()) {
|
|
|
|
reportFailure(tr("Unsupported CDB host system."));
|
|
|
|
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;
|
|
|
|
default:
|
2017-11-07 12:39:46 +01:00
|
|
|
if (!m_runParameters.isQmlDebugging) {
|
|
|
|
reportFailure(DebuggerPlugin::tr("Unable to create a debugging engine. "
|
2018-07-25 14:07:08 +02:00
|
|
|
"Please select a Debugger Setting from the Run page of the project mode."));
|
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) {
|
2017-10-20 14:11:47 +02:00
|
|
|
reportFailure(DebuggerPlugin::tr("Unable to create a debugging engine."));
|
2017-09-12 10:06:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
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->setRunParameters(m_runParameters);
|
|
|
|
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) {
|
|
|
|
auto runConfig = runControl()->runConfiguration();
|
|
|
|
QTC_ASSERT(runConfig, return);
|
|
|
|
auto rc = new RunControl(runConfig, ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
|
|
|
auto name = QString(tr("%1 - Snapshot %2").arg(runControl()->displayName()).arg(++d->snapshotCounter));
|
|
|
|
auto debugger = new DebuggerRunTool(rc);
|
|
|
|
debugger->setStartMode(AttachCore);
|
|
|
|
debugger->setRunControlName(name);
|
|
|
|
debugger->setCoreFileName(coreFile, true);
|
|
|
|
debugger->startRunControl();
|
|
|
|
});
|
|
|
|
|
|
|
|
if (m_engine2) {
|
|
|
|
m_engine2->setRunTool(this);
|
|
|
|
m_engine2->setRunParameters(m_runParameters);
|
|
|
|
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
|
|
|
|
|
|
|
if (m_runParameters.startMode == StartInternal) {
|
2014-03-17 18:27:26 +01:00
|
|
|
QStringList unhandledIds;
|
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
|
|
|
for (const GlobalBreakpoint bp : BreakpointManager::globalBreakpoints()) {
|
|
|
|
// if (bp->isEnabled() && !m_engine->acceptsBreakpoint(bp))
|
|
|
|
// unhandledIds.append(bp.id().toString());
|
2014-03-17 18:27:26 +01:00
|
|
|
}
|
|
|
|
if (!unhandledIds.isEmpty()) {
|
|
|
|
QString warningMessage =
|
|
|
|
DebuggerPlugin::tr("Some breakpoints cannot be handled by the debugger "
|
|
|
|
"languages currently active, and will be ignored.\n"
|
|
|
|
"Affected are breakpoints %1")
|
|
|
|
.arg(unhandledIds.join(QLatin1String(", ")));
|
2011-08-08 15:38:05 +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
|
|
|
showMessage(warningMessage, LogWarning);
|
2011-08-08 15:38:05 +02:00
|
|
|
|
2014-03-17 18:27:26 +01:00
|
|
|
static bool checked = true;
|
|
|
|
if (checked)
|
2013-10-16 17:11:39 +02:00
|
|
|
CheckableMessageBox::information(Core::ICore::mainWindow(),
|
2013-09-13 16:12:04 +02:00
|
|
|
tr("Debugger"),
|
|
|
|
warningMessage,
|
|
|
|
tr("&Show this message again."),
|
|
|
|
&checked, QDialogButtonBox::Ok);
|
2011-04-28 14:05:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-23 16:40:49 +02:00
|
|
|
appendMessage(tr("Debugging starts"), 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();
|
|
|
|
const QString message = tr("Starting debugger \"%1\" for ABI \"%2\"...")
|
|
|
|
.arg(debuggerName).arg(m_runParameters.toolChainAbi.toString());
|
|
|
|
showStatusMessage(message);
|
|
|
|
|
|
|
|
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
|
|
|
EngineManager::activateEngine(engine);
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
appendMessage(tr("Debugging has finished"), NormalMessageFormat);
|
|
|
|
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);
|
|
|
|
d->portsGatherer = new GdbServerPortsGatherer(runControl());
|
|
|
|
d->portsGatherer->setUseGdbServer(useCpp);
|
|
|
|
d->portsGatherer->setUseQmlServer(useQml);
|
|
|
|
addStartDependency(d->portsGatherer);
|
|
|
|
}
|
|
|
|
|
|
|
|
GdbServerPortsGatherer *DebuggerRunTool::portsGatherer() const
|
|
|
|
{
|
|
|
|
return d->portsGatherer;
|
|
|
|
}
|
2017-05-04 12:12:27 +02:00
|
|
|
|
2017-08-24 16:53:31 +02:00
|
|
|
void DebuggerRunTool::setSolibSearchPath(const QStringList &list)
|
|
|
|
{
|
|
|
|
m_runParameters.solibSearchPath = list;
|
|
|
|
}
|
|
|
|
|
2017-04-21 17:20:57 +02:00
|
|
|
void DebuggerRunTool::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
|
|
|
initiateStop();
|
2010-06-15 11:42:49 +02:00
|
|
|
}
|
|
|
|
|
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())
|
|
|
|
rp.symbolFile = rp.inferior.executable;
|
2016-03-22 10:47:03 +01:00
|
|
|
|
2017-09-18 14:47:39 +02:00
|
|
|
// Copy over DYLD_IMAGE_SUFFIX etc
|
|
|
|
for (auto var : QStringList({"DYLD_IMAGE_SUFFIX", "DYLD_LIBRARY_PATH", "DYLD_FRAMEWORK_PATH"}))
|
|
|
|
if (rp.inferior.environment.hasKey(var))
|
|
|
|
rp.debugger.environment.set(var, rp.inferior.environment.value(var));
|
2016-03-22 15:36:08 +01:00
|
|
|
|
|
|
|
// validate debugger if C++ debugging is enabled
|
2018-07-25 14:07:08 +02:00
|
|
|
if (rp.isCppDebugging() && !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) {
|
|
|
|
reportFailure(DebuggerPlugin::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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-24 08:26:35 +02:00
|
|
|
if (!boolSetting(AutoEnrichParameters)) {
|
2016-04-12 16:42:15 +02:00
|
|
|
const QString sysroot = rp.sysRoot;
|
|
|
|
if (rp.debugInfoLocation.isEmpty())
|
|
|
|
rp.debugInfoLocation = sysroot + "/usr/lib/debug";
|
|
|
|
if (rp.debugSourceLocation.isEmpty()) {
|
|
|
|
QString base = sysroot + "/usr/src/debug/";
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if (rp.startMode != AttachExternal && rp.startMode != AttachCrashedExternal) {
|
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)
|
|
|
|
: QmlDebug::qmlDebugTcpArguments(service, Port(rp.qmlServer.port()));
|
|
|
|
QtcProcess::addArg(&rp.inferior.commandLineArguments, 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()) {
|
|
|
|
QtcProcess::SplitError perr;
|
|
|
|
rp.inferior.commandLineArguments =
|
|
|
|
QtcProcess::prepareArgs(rp.inferior.commandLineArguments, &perr,
|
|
|
|
HostOsInfo::hostOs(), nullptr,
|
|
|
|
&rp.inferior.workingDirectory).toWindowsArgs();
|
|
|
|
if (perr != QtcProcess::SplitOk) {
|
|
|
|
// perr == BadQuoting is never returned on Windows
|
|
|
|
// FIXME? QTCREATORBUG-2809
|
2017-09-18 14:47:39 +02:00
|
|
|
reportFailure(DebuggerPlugin::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");
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-11-16 12:29:25 +01:00
|
|
|
DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTerminal)
|
2017-09-27 08:22:02 +02:00
|
|
|
: RunWorker(runControl), d(new DebuggerRunToolPrivate)
|
2017-05-03 12:35:00 +02:00
|
|
|
{
|
2017-05-09 10:25:11 +02:00
|
|
|
setDisplayName("DebuggerRunTool");
|
2017-09-20 16:34:54 +02:00
|
|
|
|
|
|
|
RunConfiguration *runConfig = runControl->runConfiguration();
|
|
|
|
|
2017-07-05 15:17:38 +02:00
|
|
|
runControl->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL_TOOLBAR);
|
|
|
|
runControl->setPromptToStop([](bool *optionalPrompt) {
|
|
|
|
return RunControl::showPromptToStopDialog(
|
|
|
|
DebuggerRunTool::tr("Close Debugging Session"),
|
|
|
|
DebuggerRunTool::tr("A debugging session is still in progress. "
|
|
|
|
"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
|
|
|
|
2018-04-23 15:38:53 +02:00
|
|
|
if (runConfig) {
|
2017-09-27 08:22:02 +02:00
|
|
|
m_runParameters.displayName = runConfig->displayName();
|
2018-04-23 15:38:53 +02:00
|
|
|
if (auto symbolsAspect = runConfig->extraAspect<SymbolFileAspect>())
|
|
|
|
m_runParameters.symbolFile = symbolsAspect->value();
|
2018-05-03 18:15:49 +02:00
|
|
|
if (auto terminalAspect = runConfig->extraAspect<TerminalAspect>())
|
|
|
|
m_runParameters.useTerminal = terminalAspect->useTerminal();
|
2018-04-23 15:38:53 +02:00
|
|
|
}
|
2017-09-27 08:22:02 +02:00
|
|
|
|
|
|
|
if (runConfig && !kit)
|
|
|
|
kit = runConfig->target()->kit();
|
|
|
|
QTC_ASSERT(kit, return);
|
|
|
|
|
|
|
|
m_runParameters.sysRoot = SysRootKitInformation::sysRoot(kit).toString();
|
|
|
|
m_runParameters.macroExpander = kit->macroExpander();
|
|
|
|
m_runParameters.debugger = DebuggerKitInformation::runnable(kit);
|
2018-08-16 16:17:18 +02:00
|
|
|
m_runParameters.cppEngineType = DebuggerKitInformation::engineType(kit);
|
2017-09-27 08:22:02 +02:00
|
|
|
|
2017-12-08 13:55:15 +01:00
|
|
|
if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(kit))
|
|
|
|
m_runParameters.qtPackageSourceLocation = qtVersion->qtPackageSourcePath().toString();
|
|
|
|
|
2017-09-20 16:34:54 +02:00
|
|
|
if (auto aspect = runConfig ? runConfig->extraAspect<DebuggerRunConfigurationAspect>() : nullptr) {
|
2018-08-16 16:17:18 +02:00
|
|
|
if (!aspect->useCppDebugger())
|
|
|
|
m_runParameters.cppEngineType = NoEngineType;
|
2017-09-20 16:34:54 +02:00
|
|
|
m_runParameters.isQmlDebugging = aspect->useQmlDebugger();
|
|
|
|
m_runParameters.multiProcess = aspect->useMultiProcess();
|
2018-07-25 14:07:08 +02:00
|
|
|
}
|
2017-10-05 08:16:34 +02:00
|
|
|
|
2018-05-16 15:42:03 +02:00
|
|
|
m_runParameters.inferior = runnable();
|
|
|
|
// Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...)
|
|
|
|
m_runParameters.inferior.workingDirectory =
|
|
|
|
FileUtils::normalizePathName(m_runParameters.inferior.workingDirectory);
|
2018-05-03 18:15:49 +02:00
|
|
|
setUseTerminal(allowTerminal && m_runParameters.useTerminal);
|
2017-10-09 15:36:14 +03:00
|
|
|
|
2017-09-18 14:47:39 +02:00
|
|
|
const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH");
|
|
|
|
if (!envBinary.isEmpty())
|
|
|
|
m_runParameters.debugger.executable = QString::fromLocal8Bit(envBinary);
|
|
|
|
|
2017-09-20 16:34:54 +02:00
|
|
|
Project *project = runConfig ? runConfig->target()->project() : nullptr;
|
|
|
|
if (project) {
|
2017-09-18 14:47:39 +02:00
|
|
|
m_runParameters.projectSourceDirectory = project->projectDirectory().toString();
|
2018-05-24 11:17:04 +02:00
|
|
|
m_runParameters.projectSourceFiles = project->files(Project::SourceFiles);
|
2017-09-18 14:47:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
m_runParameters.toolChainAbi = ToolChainKitInformation::targetAbi(kit);
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
int nativeMixedOverride = qgetenv("QTC_DEBUGGER_NATIVE_MIXED").toInt(&ok);
|
|
|
|
if (ok)
|
|
|
|
m_runParameters.nativeMixedEnabled = bool(nativeMixedOverride);
|
|
|
|
|
|
|
|
// This will only be shown in some cases, but we don't want to access
|
|
|
|
// the kit at that time anymore.
|
|
|
|
const QList<Task> tasks = DebuggerKitInformation::validateDebugger(kit);
|
|
|
|
for (const Task &t : tasks) {
|
|
|
|
if (t.type != Task::Warning)
|
|
|
|
m_runParameters.validationErrors.append(t.description);
|
|
|
|
}
|
|
|
|
|
2017-09-19 17:51:53 +02:00
|
|
|
if (runConfig && runConfig->property("supportsDebugger").toBool()) {
|
2017-09-18 14:47:39 +02:00
|
|
|
const QString mainScript = runConfig->property("mainScript").toString();
|
|
|
|
const QString interpreter = runConfig->property("interpreter").toString();
|
|
|
|
if (!interpreter.isEmpty() && mainScript.endsWith(".py")) {
|
|
|
|
m_runParameters.mainScript = mainScript;
|
|
|
|
m_runParameters.interpreter = interpreter;
|
|
|
|
const QString args = runConfig->property("arguments").toString();
|
|
|
|
if (!args.isEmpty()) {
|
|
|
|
if (!m_runParameters.inferior.commandLineArguments.isEmpty())
|
|
|
|
m_runParameters.inferior.commandLineArguments.append(' ');
|
|
|
|
m_runParameters.inferior.commandLineArguments.append(args);
|
|
|
|
}
|
2017-09-26 11:02:12 +02:00
|
|
|
m_engine = createPdbEngine();
|
2017-09-18 14:47:39 +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;
|
2017-05-05 14:45:36 +02:00
|
|
|
path.replace("%{sysroot}", m_runParameters.sysRoot);
|
|
|
|
m_runParameters.solibSearchPath.append(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())
|
|
|
|
QFile::remove(m_runParameters.coreFile);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
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:
|
|
|
|
appendMessage(msg, StdOutFormatSameLine);
|
|
|
|
break;
|
|
|
|
case AppError:
|
|
|
|
appendMessage(msg, StdErrFormatSameLine);
|
|
|
|
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
|
|
|
|
|
|
|
|
GdbServerPortsGatherer::GdbServerPortsGatherer(RunControl *runControl)
|
2017-11-08 19:20:18 +01:00
|
|
|
: ChannelProvider(runControl, 2)
|
2017-05-09 10:25:11 +02:00
|
|
|
{
|
2017-06-14 10:30:03 +02:00
|
|
|
setDisplayName("GdbServerPortsGatherer");
|
2017-10-19 08:29:20 +02:00
|
|
|
m_device = runControl->device();
|
2017-05-09 10:25:11 +02:00
|
|
|
}
|
|
|
|
|
2018-07-23 22:28:49 +02:00
|
|
|
GdbServerPortsGatherer::~GdbServerPortsGatherer() = default;
|
2017-05-09 10:25:11 +02:00
|
|
|
|
2017-11-08 19:20:18 +01:00
|
|
|
Port GdbServerPortsGatherer::gdbServerPort() const
|
2017-08-24 15:46:23 +02:00
|
|
|
{
|
2017-11-08 19:20:18 +01:00
|
|
|
QUrl url = channel(0);
|
|
|
|
return Port(url.port());
|
2017-08-24 15:46:23 +02:00
|
|
|
}
|
|
|
|
|
2017-12-19 13:01:02 +01:00
|
|
|
QUrl GdbServerPortsGatherer::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
|
|
|
}
|
|
|
|
|
2017-11-08 19:20:18 +01:00
|
|
|
Port GdbServerPortsGatherer::qmlServerPort() const
|
2017-10-19 08:29:20 +02:00
|
|
|
{
|
2017-11-08 19:20:18 +01:00
|
|
|
QUrl url = channel(1);
|
|
|
|
return Port(url.port());
|
2017-10-19 08:29:20 +02:00
|
|
|
}
|
|
|
|
|
2017-11-08 19:20:18 +01:00
|
|
|
QUrl GdbServerPortsGatherer::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
|
|
|
}
|
|
|
|
|
2017-11-08 19:20:18 +01:00
|
|
|
void GdbServerPortsGatherer::setDevice(IDevice::ConstPtr device)
|
2017-07-07 16:40:10 +02:00
|
|
|
{
|
2017-11-08 19:20:18 +01:00
|
|
|
m_device = device;
|
2017-07-07 16:40:10 +02:00
|
|
|
}
|
2017-05-09 10:25:11 +02:00
|
|
|
|
|
|
|
// GdbServerRunner
|
|
|
|
|
2017-07-07 09:46:22 +02:00
|
|
|
GdbServerRunner::GdbServerRunner(RunControl *runControl, GdbServerPortsGatherer *portsGatherer)
|
2017-07-07 15:40:46 +02:00
|
|
|
: SimpleTargetRunner(runControl), m_portsGatherer(portsGatherer)
|
2017-05-09 10:25:11 +02:00
|
|
|
{
|
|
|
|
setDisplayName("GdbServerRunner");
|
2018-05-16 15:42:03 +02:00
|
|
|
m_runnable = runControl->runnable();
|
2017-10-20 13:42:47 +02:00
|
|
|
addStartDependency(m_portsGatherer);
|
2017-05-09 10:25:11 +02:00
|
|
|
}
|
|
|
|
|
2018-07-23 22:28:49 +02:00
|
|
|
GdbServerRunner::~GdbServerRunner() = default;
|
2017-05-09 10:25:11 +02:00
|
|
|
|
2018-05-16 15:42:03 +02:00
|
|
|
void GdbServerRunner::setRunnable(const Runnable &runnable)
|
2017-10-19 08:29:20 +02:00
|
|
|
{
|
|
|
|
m_runnable = runnable;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GdbServerRunner::setUseMulti(bool on)
|
|
|
|
{
|
|
|
|
m_useMulti = on;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GdbServerRunner::setAttachPid(ProcessHandle pid)
|
|
|
|
{
|
|
|
|
m_pid = pid;
|
|
|
|
}
|
|
|
|
|
2017-05-09 10:25:11 +02:00
|
|
|
void GdbServerRunner::start()
|
|
|
|
{
|
2017-07-07 09:46:22 +02:00
|
|
|
QTC_ASSERT(m_portsGatherer, reportFailure(); return);
|
2017-05-09 10:25:11 +02:00
|
|
|
|
2018-05-16 15:42:03 +02:00
|
|
|
Runnable gdbserver;
|
2017-10-19 08:29:20 +02:00
|
|
|
gdbserver.environment = m_runnable.environment;
|
|
|
|
gdbserver.workingDirectory = m_runnable.workingDirectory;
|
|
|
|
|
|
|
|
QStringList args = QtcProcess::splitArgs(m_runnable.commandLineArguments, OsTypeLinux);
|
2017-05-09 10:25:11 +02:00
|
|
|
|
2017-07-07 09:46:22 +02:00
|
|
|
const bool isQmlDebugging = m_portsGatherer->useQmlServer();
|
|
|
|
const bool isCppDebugging = m_portsGatherer->useGdbServer();
|
2017-05-09 10:25:11 +02:00
|
|
|
|
|
|
|
if (isQmlDebugging) {
|
|
|
|
args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices,
|
2017-07-07 09:46:22 +02:00
|
|
|
m_portsGatherer->qmlServerPort()));
|
2017-05-09 10:25:11 +02:00
|
|
|
}
|
|
|
|
if (isQmlDebugging && !isCppDebugging) {
|
2017-10-19 08:29:20 +02:00
|
|
|
gdbserver.executable = m_runnable.executable; // FIXME: Case should not happen?
|
2017-05-09 10:25:11 +02:00
|
|
|
} else {
|
2017-10-19 08:29:20 +02:00
|
|
|
gdbserver.executable = device()->debugServerPath();
|
|
|
|
if (gdbserver.executable.isEmpty())
|
|
|
|
gdbserver.executable = "gdbserver";
|
2017-05-09 10:25:11 +02:00
|
|
|
args.clear();
|
2017-10-19 08:29:20 +02:00
|
|
|
if (m_useMulti)
|
|
|
|
args.append("--multi");
|
|
|
|
if (m_pid.isValid())
|
|
|
|
args.append("--attach");
|
2017-07-07 09:46:22 +02:00
|
|
|
args.append(QString(":%1").arg(m_portsGatherer->gdbServerPort().number()));
|
2017-10-19 08:29:20 +02:00
|
|
|
if (m_pid.isValid())
|
|
|
|
args.append(QString::number(m_pid.pid()));
|
2017-05-09 10:25:11 +02:00
|
|
|
}
|
2017-10-19 08:29:20 +02:00
|
|
|
gdbserver.commandLineArguments = QtcProcess::joinArgs(args, OsTypeLinux);
|
2017-05-09 10:25:11 +02:00
|
|
|
|
2017-10-19 08:29:20 +02:00
|
|
|
SimpleTargetRunner::setRunnable(gdbserver);
|
2017-07-07 15:40:46 +02:00
|
|
|
SimpleTargetRunner::start();
|
2017-05-09 10:25:11 +02:00
|
|
|
}
|
|
|
|
|
2009-09-11 08:55:16 +02:00
|
|
|
} // namespace Debugger
|