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
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "debuggerplugin.h"
|
|
|
|
|
|
2011-01-10 10:14:23 +01:00
|
|
|
#include "debuggerstartparameters.h"
|
2009-03-17 17:00:06 +01:00
|
|
|
#include "debuggeractions.h"
|
2011-04-21 15:52:51 +02:00
|
|
|
#include "debuggerinternalconstants.h"
|
2010-11-10 11:39:01 +01:00
|
|
|
#include "debuggercore.h"
|
2013-08-14 18:30:40 +02:00
|
|
|
#include "debuggerkitconfigwidget.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerdialogs.h"
|
|
|
|
|
#include "debuggerengine.h"
|
2015-11-23 16:41:54 +01:00
|
|
|
#include "debuggericons.h"
|
2013-10-25 13:47:08 +02:00
|
|
|
#include "debuggeritemmanager.h"
|
2010-12-02 17:43:14 +01:00
|
|
|
#include "debuggermainwindow.h"
|
2013-03-27 13:03:15 +01:00
|
|
|
#include "debuggerrunconfigurationaspect.h"
|
2014-10-17 13:40:04 +02:00
|
|
|
#include "debuggerruncontrol.h"
|
2009-09-25 15:02:16 +02:00
|
|
|
#include "debuggerstringutils.h"
|
2013-10-25 13:47:08 +02:00
|
|
|
#include "debuggeroptionspage.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "debuggerkitinformation.h"
|
2011-04-19 12:17:48 +02:00
|
|
|
#include "memoryagent.h"
|
2010-11-04 09:54:23 +01:00
|
|
|
#include "breakhandler.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "breakwindow.h"
|
2011-04-12 17:32:41 +02:00
|
|
|
#include "disassemblerlines.h"
|
2010-09-22 16:20:08 +02:00
|
|
|
#include "logwindow.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "moduleswindow.h"
|
2011-01-10 10:14:23 +01:00
|
|
|
#include "moduleshandler.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "registerwindow.h"
|
|
|
|
|
#include "snapshotwindow.h"
|
2010-11-08 15:19:13 +01:00
|
|
|
#include "stackhandler.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "stackwindow.h"
|
|
|
|
|
#include "sourcefileswindow.h"
|
|
|
|
|
#include "threadswindow.h"
|
2010-11-04 18:11:09 +01:00
|
|
|
#include "watchhandler.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "watchwindow.h"
|
2010-11-08 15:19:13 +01:00
|
|
|
#include "watchutils.h"
|
2013-09-20 16:48:01 +02:00
|
|
|
#include "unstartedappwatcherdialog.h"
|
2011-02-11 15:00:13 +01:00
|
|
|
#include "debuggertooltipmanager.h"
|
2012-05-14 16:09:12 +02:00
|
|
|
#include "localsandexpressionswindow.h"
|
2012-07-24 17:02:42 +02:00
|
|
|
#include "loadcoredialog.h"
|
2013-01-24 16:33:17 +01:00
|
|
|
#include "sourceutils.h"
|
2015-11-10 16:59:02 +01:00
|
|
|
#include "shared/hostutils.h"
|
|
|
|
|
#include "console/console.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-07-21 13:11:03 +02:00
|
|
|
#include "snapshothandler.h"
|
|
|
|
|
#include "threadshandler.h"
|
2011-02-22 12:28:46 +01:00
|
|
|
#include "commonoptionspage.h"
|
2012-07-27 00:17:12 +02:00
|
|
|
#include "gdb/startgdbserverdialog.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-02-24 14:42:52 +01:00
|
|
|
#include "analyzer/analyzerconstants.h"
|
|
|
|
|
#include "analyzer/analyzermanager.h"
|
|
|
|
|
|
2009-01-13 13:39:31 +01:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2014-07-31 18:15:19 +02:00
|
|
|
#include <coreplugin/find/itemviewfind.h>
|
2010-12-02 13:34:23 +01:00
|
|
|
#include <coreplugin/imode.h>
|
2015-11-23 16:41:54 +01:00
|
|
|
#include <coreplugin/coreicons.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2014-11-25 13:08:18 +01:00
|
|
|
#include <coreplugin/messagebox.h>
|
2013-03-05 11:10:33 +01:00
|
|
|
#include <coreplugin/messagemanager.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/modemanager.h>
|
2015-02-26 13:22:35 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/documentmodel.h>
|
2008-12-09 16:18:28 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <cppeditor/cppeditorconstants.h>
|
2014-09-15 00:12:27 +02:00
|
|
|
#include <cpptools/cppmodelmanager.h>
|
2008-12-09 16:18:28 +01:00
|
|
|
|
2012-01-25 17:28:06 +01:00
|
|
|
#include <extensionsystem/invoker.h>
|
2009-01-20 11:52:04 +01:00
|
|
|
|
2012-10-31 18:14:17 +01:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2013-08-15 12:14:46 +02:00
|
|
|
#include <projectexplorer/taskhub.h>
|
2013-03-25 17:13:18 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2013-03-21 17:10:19 +01:00
|
|
|
#include <projectexplorer/devicesupport/deviceprocesslist.h>
|
2012-08-08 12:03:07 +02:00
|
|
|
#include <projectexplorer/devicesupport/deviceprocessesdialog.h>
|
2011-10-25 18:23:37 +08:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2015-11-23 16:41:54 +01:00
|
|
|
#include <projectexplorer/projectexplorericons.h>
|
2014-11-19 17:58:33 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2011-10-25 18:23:37 +08:00
|
|
|
#include <projectexplorer/projectexplorersettings.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
2016-01-25 15:00:20 +01:00
|
|
|
#include <projectexplorer/runnables.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <projectexplorer/session.h>
|
2016-02-24 14:42:52 +01:00
|
|
|
#include <projectexplorer/taskhub.h>
|
2010-07-21 17:06:22 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2010-11-08 16:17:59 +01:00
|
|
|
|
2014-09-26 09:14:03 +02:00
|
|
|
#include <texteditor/texteditor.h>
|
2015-02-26 13:22:35 +01:00
|
|
|
#include <texteditor/textdocument.h>
|
2010-06-16 11:08:54 +02:00
|
|
|
#include <texteditor/fontsettings.h>
|
2010-04-19 16:42:02 +02:00
|
|
|
#include <texteditor/texteditorsettings.h>
|
2008-12-09 16:18:28 +01:00
|
|
|
|
2014-06-04 14:45:10 +02:00
|
|
|
#include <utils/basetreeview.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2015-02-04 09:32:46 +01:00
|
|
|
#include <utils/mimetypes/mimedatabase.h>
|
2011-01-12 16:36:29 +01:00
|
|
|
#include <utils/proxyaction.h>
|
2014-06-04 14:45:10 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
#include <utils/savedaction.h>
|
2011-03-16 13:49:28 +01:00
|
|
|
#include <utils/statuslabel.h>
|
2014-06-04 14:45:10 +02:00
|
|
|
#include <utils/styledbar.h>
|
2014-02-19 15:35:58 +01:00
|
|
|
#include <utils/winutils.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-18 15:43:20 +10:00
|
|
|
#include <QApplication>
|
2014-05-16 17:32:07 +02:00
|
|
|
#include <QCheckBox>
|
2013-06-07 17:57:25 +02:00
|
|
|
#include <QComboBox>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDockWidget>
|
|
|
|
|
#include <QFileDialog>
|
2014-05-16 17:32:07 +02:00
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QHeaderView>
|
2012-06-05 10:25:48 +02:00
|
|
|
#include <QInputDialog>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QTextBlock>
|
|
|
|
|
#include <QToolButton>
|
2012-06-05 10:25:48 +02:00
|
|
|
#include <QtPlugin>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTreeWidget>
|
2014-06-04 14:45:10 +02:00
|
|
|
#include <QVBoxLayout>
|
2015-02-26 13:22:35 +01:00
|
|
|
#include <QMenu>
|
2014-06-04 14:45:10 +02:00
|
|
|
|
2012-01-23 16:45:00 +01:00
|
|
|
#ifdef WITH_TESTS
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTest>
|
|
|
|
|
#include <QSignalSpy>
|
|
|
|
|
#include <QTestEventLoop>
|
2012-01-26 13:14:00 +01:00
|
|
|
|
|
|
|
|
//#define WITH_BENCHMARK
|
|
|
|
|
#ifdef WITH_BENCHMARK
|
|
|
|
|
#include <valgrind/callgrind.h>
|
2012-01-23 16:45:00 +01:00
|
|
|
#endif
|
|
|
|
|
|
2012-01-26 13:14:00 +01:00
|
|
|
#endif // WITH_TESTS
|
|
|
|
|
|
2009-08-12 10:51:25 +02:00
|
|
|
#include <climits>
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
#define DEBUG_STATE 1
|
|
|
|
|
#ifdef DEBUG_STATE
|
|
|
|
|
//# define STATE_DEBUG(s)
|
|
|
|
|
// do { QString msg; QTextStream ts(&msg); ts << s;
|
|
|
|
|
// showMessage(msg, LogDebug); } while (0)
|
2012-11-28 20:44:03 +02:00
|
|
|
# define STATE_DEBUG(s) do { qDebug() << s; } while (0)
|
2010-06-16 11:08:54 +02:00
|
|
|
#else
|
|
|
|
|
# define STATE_DEBUG(s)
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-01-26 17:22:25 +01:00
|
|
|
/*!
|
|
|
|
|
\namespace Debugger
|
|
|
|
|
Debugger plugin namespace
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\namespace Debugger::Internal
|
|
|
|
|
Internal namespace of the Debugger plugin
|
2011-02-04 15:08:31 +01:00
|
|
|
\internal
|
2011-01-26 17:22:25 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\class Debugger::DebuggerEngine
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The DebuggerEngine class is the base class of a debugger engine.
|
2011-01-26 17:22:25 +01:00
|
|
|
|
2013-09-06 17:16:18 +02:00
|
|
|
\note The Debugger process itself and any helper processes like
|
2012-08-22 13:27:25 +02:00
|
|
|
gdbserver are referred to as 'Engine', whereas the debugged process
|
|
|
|
|
is referred to as 'Inferior'.
|
2011-01-26 17:22:25 +01:00
|
|
|
|
|
|
|
|
Transitions marked by '---' are done in the individual engines.
|
|
|
|
|
Transitions marked by '+-+' are done in the base DebuggerEngine.
|
|
|
|
|
Transitions marked by '*' are done asynchronously.
|
|
|
|
|
|
|
|
|
|
The GdbEngine->setupEngine() function is described in more detail below.
|
|
|
|
|
|
|
|
|
|
The engines are responsible for local roll-back to the last
|
|
|
|
|
acknowledged state before calling notify*Failed. I.e. before calling
|
|
|
|
|
notifyEngineSetupFailed() any process started during setupEngine()
|
|
|
|
|
so far must be terminated.
|
|
|
|
|
\code
|
|
|
|
|
|
|
|
|
|
DebuggerNotReady
|
|
|
|
|
progressmanager/progressmanager.cpp +
|
|
|
|
|
EngineSetupRequested
|
|
|
|
|
+
|
|
|
|
|
(calls *Engine->setupEngine())
|
|
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
{notify- {notify-
|
|
|
|
|
Engine- Engine-
|
|
|
|
|
SetupOk} SetupFailed}
|
|
|
|
|
+ +
|
|
|
|
|
+ `+-+-+> EngineSetupFailed
|
|
|
|
|
+ +
|
|
|
|
|
+ [calls RunControl->startFailed]
|
|
|
|
|
+ +
|
|
|
|
|
+ DebuggerFinished
|
|
|
|
|
v
|
|
|
|
|
EngineSetupOk
|
|
|
|
|
+
|
|
|
|
|
[calls RunControl->StartSuccessful]
|
|
|
|
|
+
|
|
|
|
|
InferiorSetupRequested
|
|
|
|
|
+
|
|
|
|
|
(calls *Engine->setupInferior())
|
|
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
{notify- {notify-
|
|
|
|
|
Inferior- Inferior-
|
|
|
|
|
SetupOk} SetupFailed}
|
|
|
|
|
+ +
|
|
|
|
|
+ ` +-+-> InferiorSetupFailed +-+-+-+-+-+->.
|
|
|
|
|
+ +
|
|
|
|
|
InferiorSetupOk +
|
|
|
|
|
+ +
|
|
|
|
|
EngineRunRequested +
|
|
|
|
|
+ +
|
|
|
|
|
(calls *Engine->runEngine()) +
|
|
|
|
|
/ | | \ +
|
|
|
|
|
/ | | \ +
|
|
|
|
|
| (core) | (attach) | | +
|
|
|
|
|
| | | | +
|
|
|
|
|
{notify- {notifyER&- {notifyER&- {notify- +
|
|
|
|
|
Inferior- Inferior- Inferior- EngineRun- +
|
|
|
|
|
Unrunnable} StopOk} RunOk} Failed} +
|
|
|
|
|
+ + + + +
|
|
|
|
|
InferiorUnrunnable + InferiorRunOk + +
|
|
|
|
|
+ + +
|
|
|
|
|
InferiorStopOk EngineRunFailed +
|
|
|
|
|
+ v
|
|
|
|
|
`-+-+-+-+-+-+-+-+-+-+-+>-+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
#Interrupt@InferiorRunOk# +
|
|
|
|
|
+ +
|
|
|
|
|
InferiorStopRequested +
|
|
|
|
|
#SpontaneousStop + +
|
|
|
|
|
@InferiorRunOk# (calls *Engine-> +
|
|
|
|
|
+ interruptInferior()) +
|
|
|
|
|
{notify- | | +
|
|
|
|
|
Spontaneous- {notify- {notify- +
|
|
|
|
|
Inferior- Inferior- Inferior- +
|
|
|
|
|
StopOk} StopOk} StopFailed} +
|
|
|
|
|
+ + + +
|
|
|
|
|
+ + + +
|
|
|
|
|
InferiorStopOk + +
|
|
|
|
|
+ + +
|
|
|
|
|
+ + +
|
|
|
|
|
+ + +
|
|
|
|
|
#Stop@InferiorUnrunnable# + +
|
|
|
|
|
#Creator Close Event# + +
|
|
|
|
|
+ + +
|
|
|
|
|
InferiorShutdownRequested +
|
|
|
|
|
+ +
|
|
|
|
|
(calls *Engine->shutdownInferior()) +
|
|
|
|
|
| | +
|
|
|
|
|
{notify- {notify- +
|
|
|
|
|
Inferior- Inferior- +
|
|
|
|
|
ShutdownOk} ShutdownFailed} +
|
|
|
|
|
+ + +
|
|
|
|
|
+ + +
|
|
|
|
|
#Inferior exited# + + +
|
|
|
|
|
| + + +
|
|
|
|
|
{notifyInferior- + + +
|
|
|
|
|
Exited} + + +
|
|
|
|
|
+ + + +
|
2015-06-16 15:01:46 +02:00
|
|
|
+ + + +
|
2011-01-26 17:22:25 +01:00
|
|
|
+ + + +
|
|
|
|
|
InferiorShutdownOk InferiorShutdownFailed +
|
|
|
|
|
* * +
|
|
|
|
|
EngineShutdownRequested +
|
|
|
|
|
+ +
|
|
|
|
|
(calls *Engine->shutdownEngine()) <+-+-+-+-+-+-+-+-+-+-+-+-+-+'
|
|
|
|
|
| |
|
|
|
|
|
| |
|
|
|
|
|
{notify- {notify-
|
|
|
|
|
Engine- Engine-
|
|
|
|
|
ShutdownOk} ShutdownFailed}
|
|
|
|
|
+ +
|
|
|
|
|
EngineShutdownOk EngineShutdownFailed
|
|
|
|
|
* *
|
|
|
|
|
DebuggerFinished
|
|
|
|
|
|
|
|
|
|
\endcode */
|
2010-11-08 15:19:13 +01:00
|
|
|
|
2010-08-31 12:49:51 +02:00
|
|
|
/* Here is a matching graph as a GraphViz graph. View it using
|
|
|
|
|
* \code
|
|
|
|
|
grep "^sg1:" debuggerplugin.cpp | cut -c5- | dot -osg1.ps -Tps && gv sg1.ps
|
2010-07-08 11:44:00 +02:00
|
|
|
|
2010-08-31 12:49:51 +02:00
|
|
|
sg1: digraph DebuggerStates {
|
|
|
|
|
sg1: DebuggerNotReady -> EngineSetupRequested
|
|
|
|
|
sg1: EngineSetupRequested -> EngineSetupOk [ label="notifyEngineSetupOk", style="dashed" ];
|
|
|
|
|
sg1: EngineSetupRequested -> EngineSetupFailed [ label= "notifyEngineSetupFailed", style="dashed"];
|
|
|
|
|
sg1: EngineSetupFailed -> DebuggerFinished [ label= "RunControl::StartFailed" ];
|
|
|
|
|
sg1: EngineSetupOk -> InferiorSetupRequested [ label= "RunControl::StartSuccessful" ];
|
2011-01-17 10:36:13 +01:00
|
|
|
sg1: InferiorSetupRequested -> InferiorSetupOk [ label="notifyInferiorSetupOk", style="dashed" ];
|
2010-08-31 12:49:51 +02:00
|
|
|
sg1: InferiorSetupRequested -> InferiorSetupFailed [ label="notifyInferiorFailed", style="dashed" ];
|
2011-01-17 10:36:13 +01:00
|
|
|
sg1: InferiorSetupOk -> EngineRunRequested
|
2010-08-31 12:49:51 +02:00
|
|
|
sg1: InferiorSetupFailed -> EngineShutdownRequested
|
|
|
|
|
sg1: EngineRunRequested -> InferiorUnrunnable [ label="notifyInferiorUnrunnable", style="dashed" ];
|
|
|
|
|
sg1: EngineRunRequested -> InferiorStopOk [ label="notifyEngineRunAndInferiorStopOk", style="dashed" ];
|
|
|
|
|
sg1: EngineRunRequested -> InferiorRunOk [ label="notifyEngineRunAndInferiorRunOk", style="dashed" ];
|
|
|
|
|
sg1: EngineRunRequested -> EngineRunFailed [ label="notifyEngineRunFailed", style="dashed" ];
|
|
|
|
|
sg1: EngineRunFailed -> EngineShutdownRequested
|
|
|
|
|
sg1: InferiorRunOk -> InferiorStopOk [ label="SpontaneousStop\nnotifyInferiorSpontaneousStop", style="dashed" ];
|
|
|
|
|
sg1: InferiorRunOk -> InferiorStopRequested [ label="User stop\nEngine::interruptInferior", style="dashed"];
|
|
|
|
|
sg1: InferiorStopRequested -> InferiorStopOk [ label="notifyInferiorStopOk", style="dashed" ];
|
|
|
|
|
sg1: InferiorStopRequested -> InferiorShutdownRequested [ label="notifyInferiorStopFailed", style="dashed" ];
|
|
|
|
|
sg1: InferiorStopOk -> InferiorRunRequested [ label="User\nEngine::continueInferior" ];
|
|
|
|
|
sg1: InferiorRunRequested -> InferiorRunOk [ label="notifyInferiorRunOk", style="dashed"];
|
|
|
|
|
sg1: InferiorRunRequested -> InferiorRunFailed [ label="notifyInferiorRunFailed", style="dashed"];
|
|
|
|
|
sg1: InferiorRunFailed -> InferiorStopOk
|
2011-01-17 10:36:13 +01:00
|
|
|
sg1: InferiorStopOk -> InferiorShutdownRequested [ label="Close event" ];
|
|
|
|
|
sg1: InferiorUnrunnable -> InferiorShutdownRequested [ label="Close event" ];
|
2010-08-31 12:49:51 +02:00
|
|
|
sg1: InferiorShutdownRequested -> InferiorShutdownOk [ label= "Engine::shutdownInferior\nnotifyInferiorShutdownOk", style="dashed" ];
|
|
|
|
|
sg1: InferiorShutdownRequested -> InferiorShutdownFailed [ label="Engine::shutdownInferior\nnotifyInferiorShutdownFailed", style="dashed" ];
|
2011-01-17 10:36:13 +01:00
|
|
|
sg1: InferiorExited -> InferiorExitOk [ label="notifyInferiorExited", style="dashed"];
|
|
|
|
|
sg1: InferiorExitOk -> InferiorShutdownOk
|
2010-08-31 12:49:51 +02:00
|
|
|
sg1: InferiorShutdownOk -> EngineShutdownRequested
|
|
|
|
|
sg1: InferiorShutdownFailed -> EngineShutdownRequested
|
|
|
|
|
sg1: EngineShutdownRequested -> EngineShutdownOk [ label="Engine::shutdownEngine\nnotifyEngineShutdownOk", style="dashed" ];
|
|
|
|
|
sg1: EngineShutdownRequested -> EngineShutdownFailed [ label="Engine::shutdownEngine\nnotifyEngineShutdownFailed", style="dashed" ];
|
|
|
|
|
sg1: EngineShutdownOk -> DebuggerFinished [ style = "dotted" ];
|
|
|
|
|
sg1: EngineShutdownFailed -> DebuggerFinished [ style = "dotted" ];
|
|
|
|
|
sg1: }
|
|
|
|
|
* \endcode */
|
2010-07-15 09:41:11 +02:00
|
|
|
// Additional signalling: {notifyInferiorIll} {notifyEngineIll}
|
2010-07-09 17:07:59 +02:00
|
|
|
|
|
|
|
|
|
2011-01-26 17:22:25 +01:00
|
|
|
/*!
|
|
|
|
|
\class Debugger::Internal::GdbEngine
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The GdbEngine class implements Debugger::Engine driving a GDB
|
|
|
|
|
executable.
|
2011-01-26 17:22:25 +01:00
|
|
|
|
|
|
|
|
GdbEngine specific startup. All happens in EngineSetupRequested state:
|
|
|
|
|
|
2013-09-06 17:16:18 +02:00
|
|
|
\list
|
|
|
|
|
\li Transitions marked by '---' are done in the individual adapters.
|
2011-01-26 17:22:25 +01:00
|
|
|
|
2013-09-06 17:16:18 +02:00
|
|
|
\li Transitions marked by '+-+' are done in the GdbEngine.
|
|
|
|
|
\endlist
|
2011-01-26 17:22:25 +01:00
|
|
|
|
|
|
|
|
\code
|
|
|
|
|
GdbEngine::setupEngine()
|
|
|
|
|
+
|
|
|
|
|
(calls *Adapter->startAdapter())
|
|
|
|
|
| |
|
|
|
|
|
| `---> handleAdapterStartFailed()
|
|
|
|
|
| +
|
|
|
|
|
| {notifyEngineSetupFailed}
|
|
|
|
|
|
|
|
|
|
|
handleAdapterStarted()
|
|
|
|
|
+
|
|
|
|
|
{notifyEngineSetupOk}
|
2010-07-08 11:44:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-26 17:22:25 +01:00
|
|
|
GdbEngine::setupInferior()
|
|
|
|
|
+
|
|
|
|
|
(calls *Adapter->prepareInferior())
|
|
|
|
|
| |
|
|
|
|
|
| `---> handlePrepareInferiorFailed()
|
|
|
|
|
| +
|
|
|
|
|
| {notifyInferiorSetupFailed}
|
|
|
|
|
|
|
|
|
|
|
handleInferiorPrepared()
|
|
|
|
|
+
|
|
|
|
|
{notifyInferiorSetupOk}
|
2010-07-08 11:44:00 +02:00
|
|
|
|
2011-01-26 17:22:25 +01:00
|
|
|
\endcode */
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Core;
|
2009-01-13 18:15:24 +01:00
|
|
|
using namespace Debugger::Constants;
|
2014-10-22 13:04:47 +02:00
|
|
|
using namespace Debugger::Internal;
|
2012-08-15 16:19:15 +02:00
|
|
|
using namespace ExtensionSystem;
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace ProjectExplorer;
|
2009-01-13 18:15:24 +01:00
|
|
|
using namespace TextEditor;
|
2012-08-15 16:19:15 +02:00
|
|
|
using namespace Utils;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-02-24 14:42:52 +01:00
|
|
|
using namespace Analyzer;
|
|
|
|
|
//using namespace Analyzer::Internal;
|
|
|
|
|
|
2010-03-11 12:22:24 +01:00
|
|
|
namespace CC = Core::Constants;
|
|
|
|
|
namespace PE = ProjectExplorer::Constants;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace Debugger {
|
2010-11-24 11:44:43 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2012-01-25 17:28:06 +01:00
|
|
|
struct TestCallBack
|
|
|
|
|
{
|
|
|
|
|
TestCallBack() : receiver(0), slot(0) {}
|
|
|
|
|
TestCallBack(QObject *ob, const char *s) : receiver(ob), slot(s) {}
|
|
|
|
|
|
|
|
|
|
QObject *receiver;
|
|
|
|
|
const char *slot;
|
|
|
|
|
QVariant cookie;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2011-06-27 10:37:57 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
2012-01-25 17:28:06 +01:00
|
|
|
Q_DECLARE_METATYPE(Debugger::Internal::TestCallBack)
|
|
|
|
|
|
2011-06-27 10:37:57 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2011-01-12 12:10:12 +01:00
|
|
|
void addCdbOptionPages(QList<IOptionsPage*> *opts);
|
2010-11-24 11:44:43 +01:00
|
|
|
void addGdbOptionPages(QList<IOptionsPage*> *opts);
|
2015-05-27 16:09:43 +02:00
|
|
|
QObject *createDebuggerRunControlFactory(QObject *parent);
|
2010-11-26 15:10:10 +01:00
|
|
|
|
2009-07-16 15:57:59 +02:00
|
|
|
static QToolButton *toolButton(QAction *action)
|
|
|
|
|
{
|
|
|
|
|
QToolButton *button = new QToolButton;
|
|
|
|
|
button->setDefaultAction(action);
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:58:49 +02:00
|
|
|
static void setProxyAction(ProxyAction *proxy, Id id)
|
2012-05-24 10:19:50 +02:00
|
|
|
{
|
2012-07-18 16:20:19 +02:00
|
|
|
proxy->setAction(ActionManager::command(id)->action());
|
2012-05-24 10:19:50 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:58:49 +02:00
|
|
|
static QToolButton *toolButton(Id id)
|
2012-05-24 10:19:50 +02:00
|
|
|
{
|
2012-07-18 16:20:19 +02:00
|
|
|
return toolButton(ActionManager::command(id)->action());
|
2012-05-24 10:19:50 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-23 13:44:37 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// DummyEngine
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class DummyEngine : public DebuggerEngine
|
|
|
|
|
{
|
|
|
|
|
public:
|
2015-05-27 13:59:56 +02:00
|
|
|
DummyEngine() : DebuggerEngine(DebuggerRunParameters()) {}
|
2010-11-26 10:20:50 +01:00
|
|
|
~DummyEngine() {}
|
|
|
|
|
|
|
|
|
|
void setupEngine() {}
|
|
|
|
|
void setupInferior() {}
|
|
|
|
|
void runEngine() {}
|
|
|
|
|
void shutdownEngine() {}
|
|
|
|
|
void shutdownInferior() {}
|
2012-01-12 20:28:17 +01:00
|
|
|
bool hasCapability(unsigned cap) const;
|
2015-01-10 01:07:01 +01:00
|
|
|
bool acceptsBreakpoint(Breakpoint) const { return false; }
|
2011-02-16 12:41:06 +01:00
|
|
|
bool acceptsDebuggerCommands() const { return false; }
|
2012-10-19 16:37:57 +02:00
|
|
|
void selectThread(ThreadId) {}
|
2010-11-23 13:44:37 +01:00
|
|
|
};
|
|
|
|
|
|
2012-01-12 20:28:17 +01:00
|
|
|
bool DummyEngine::hasCapability(unsigned cap) const
|
2012-01-12 19:32:25 +01:00
|
|
|
{
|
|
|
|
|
// This can only be a first approximation of what to expect when running.
|
2014-11-19 17:58:33 +01:00
|
|
|
Project *project = ProjectTree::currentProject();
|
2012-01-12 19:32:25 +01:00
|
|
|
if (!project)
|
|
|
|
|
return 0;
|
|
|
|
|
Target *target = project->activeTarget();
|
|
|
|
|
QTC_ASSERT(target, return 0);
|
|
|
|
|
RunConfiguration *activeRc = target->activeRunConfiguration();
|
|
|
|
|
QTC_ASSERT(activeRc, return 0);
|
|
|
|
|
|
|
|
|
|
// This is a non-started Cdb or Gdb engine:
|
2013-03-27 13:03:15 +01:00
|
|
|
if (activeRc->extraAspect<Debugger::DebuggerRunConfigurationAspect>()->useCppDebugger())
|
2012-01-12 20:28:17 +01:00
|
|
|
return cap & (WatchpointByAddressCapability
|
2012-01-12 19:32:25 +01:00
|
|
|
| BreakConditionCapability
|
|
|
|
|
| TracePointCapability
|
2012-01-12 20:28:17 +01:00
|
|
|
| OperateByInstructionCapability);
|
2012-01-12 19:32:25 +01:00
|
|
|
|
|
|
|
|
// This is a Qml or unknown engine.
|
2012-01-12 20:28:17 +01:00
|
|
|
return cap & AddWatcherCapability;
|
2012-01-12 19:32:25 +01:00
|
|
|
}
|
|
|
|
|
|
2009-01-14 18:09:02 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// DebugMode
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-12-02 13:34:23 +01:00
|
|
|
class DebugMode : public IMode
|
2009-01-13 18:15:24 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2011-04-13 13:00:30 +02:00
|
|
|
DebugMode()
|
|
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("DebugMode"));
|
2014-07-01 13:20:53 +02:00
|
|
|
setContext(Context(C_DEBUGMODE, CC::C_NAVIGATION_PANE));
|
2011-04-13 16:09:04 +02:00
|
|
|
setDisplayName(DebuggerPlugin::tr("Debug"));
|
2015-11-11 19:26:58 +01:00
|
|
|
setIcon(Utils::Icon::modeIcon(Icons::MODE_DEBUGGER_CLASSIC,
|
|
|
|
|
Icons::MODE_DEBUGGER_FLAT, Icons::MODE_DEBUGGER_FLAT_ACTIVE));
|
2011-07-15 10:55:39 +02:00
|
|
|
setPriority(85);
|
2012-05-07 18:28:03 +02:00
|
|
|
setId(MODE_DEBUG);
|
2011-04-13 13:00:30 +02:00
|
|
|
}
|
2009-01-13 18:15:24 +01:00
|
|
|
|
2010-12-08 17:54:16 +01:00
|
|
|
~DebugMode()
|
|
|
|
|
{
|
|
|
|
|
delete m_widget;
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
};
|
2009-01-13 18:15:24 +01:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Misc
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2014-06-06 00:53:31 +02:00
|
|
|
static QWidget *addSearch(BaseTreeView *treeView, const QString &title,
|
2014-06-26 12:49:14 +02:00
|
|
|
const char *objectName)
|
2014-06-04 14:45:10 +02:00
|
|
|
{
|
2014-07-28 14:23:52 +02:00
|
|
|
QAction *act = action(UseAlternatingRowColors);
|
2014-06-04 14:45:10 +02:00
|
|
|
treeView->setAlternatingRowColors(act->isChecked());
|
2014-10-22 13:04:47 +02:00
|
|
|
QObject::connect(act, &QAction::toggled,
|
|
|
|
|
treeView, &BaseTreeView::setAlternatingRowColorsHelper);
|
2014-06-04 14:45:10 +02:00
|
|
|
|
2014-07-31 18:15:19 +02:00
|
|
|
QWidget *widget = ItemViewFind::createSearchableWrapper(treeView);
|
2014-06-04 14:45:10 +02:00
|
|
|
widget->setObjectName(QLatin1String(objectName));
|
|
|
|
|
widget->setWindowTitle(title);
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-23 09:09:20 +02:00
|
|
|
static std::function<bool(const Kit *)> cdbMatcher(char wordWidth = 0)
|
2012-08-23 15:23:37 +02:00
|
|
|
{
|
2014-07-23 09:09:20 +02:00
|
|
|
return [wordWidth](const Kit *k) -> bool {
|
2012-09-05 14:56:08 +02:00
|
|
|
if (DebuggerKitInformation::engineType(k) != CdbEngineType
|
|
|
|
|
|| !DebuggerKitInformation::isValidDebugger(k)) {
|
2012-08-23 15:23:37 +02:00
|
|
|
return false;
|
2012-09-05 14:56:08 +02:00
|
|
|
}
|
2014-07-23 09:09:20 +02:00
|
|
|
if (wordWidth) {
|
2012-09-05 14:56:08 +02:00
|
|
|
const ToolChain *tc = ToolChainKitInformation::toolChain(k);
|
2014-07-23 09:09:20 +02:00
|
|
|
return tc && wordWidth == tc->targetAbi().wordWidth();
|
2012-09-05 14:56:08 +02:00
|
|
|
}
|
2012-08-23 15:23:37 +02:00
|
|
|
return true;
|
2014-07-23 09:09:20 +02:00
|
|
|
};
|
|
|
|
|
}
|
2012-08-23 15:23:37 +02:00
|
|
|
|
2014-07-23 09:09:20 +02:00
|
|
|
// Find a CDB kit for debugging unknown processes.
|
|
|
|
|
// On a 64bit OS, prefer a 64bit debugger.
|
|
|
|
|
static Kit *findUniversalCdbKit()
|
|
|
|
|
{
|
|
|
|
|
if (Utils::is64BitWindowsSystem()) {
|
2016-02-02 18:26:51 +01:00
|
|
|
if (Kit *cdb64Kit = KitManager::find(KitMatcher(cdbMatcher(64))))
|
2014-07-23 09:09:20 +02:00
|
|
|
return cdb64Kit;
|
2012-08-23 15:23:37 +02:00
|
|
|
}
|
2016-02-02 18:26:51 +01:00
|
|
|
return KitManager::find(KitMatcher(cdbMatcher()));
|
2014-07-23 09:09:20 +02:00
|
|
|
}
|
2012-08-23 15:23:37 +02:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2011-02-03 14:08:01 +01:00
|
|
|
// DebuggerPluginPrivate
|
2010-06-16 11:08:54 +02:00
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
static DebuggerPluginPrivate *dd = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-02-04 15:08:31 +01:00
|
|
|
/*!
|
|
|
|
|
\class Debugger::Internal::DebuggerCore
|
|
|
|
|
|
|
|
|
|
This is the "internal" interface of the debugger plugin that's
|
|
|
|
|
used by debugger views and debugger engines. The interface is
|
|
|
|
|
implemented in DebuggerPluginPrivate.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\class Debugger::Internal::DebuggerPluginPrivate
|
|
|
|
|
|
|
|
|
|
Implementation of DebuggerCore.
|
|
|
|
|
*/
|
|
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
class DebuggerPluginPrivate : public QObject
|
2010-06-16 11:08:54 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2010-03-19 13:58:26 +01:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
public:
|
|
|
|
|
explicit DebuggerPluginPrivate(DebuggerPlugin *plugin);
|
2010-11-10 11:39:01 +01:00
|
|
|
~DebuggerPluginPrivate();
|
2010-03-10 13:46:05 +01:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
bool initialize(const QStringList &arguments, QString *errorMessage);
|
2010-12-06 08:25:29 +01:00
|
|
|
void extensionsInitialized();
|
|
|
|
|
void aboutToShutdown();
|
|
|
|
|
|
2010-11-18 17:35:22 +01:00
|
|
|
void connectEngine(DebuggerEngine *engine);
|
2010-11-04 18:11:09 +01:00
|
|
|
void disconnectEngine() { connectEngine(0); }
|
2011-03-02 14:05:32 +01:00
|
|
|
DebuggerEngine *dummyEngine();
|
2010-02-09 20:44:40 +01:00
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
void setThreadBoxContents(const QStringList &list, int index)
|
2011-09-01 16:36:27 +02:00
|
|
|
{
|
|
|
|
|
const bool state = m_threadBox->blockSignals(true);
|
|
|
|
|
m_threadBox->clear();
|
|
|
|
|
foreach (const QString &item, list)
|
|
|
|
|
m_threadBox->addItem(item);
|
|
|
|
|
m_threadBox->setCurrentIndex(index);
|
|
|
|
|
m_threadBox->blockSignals(state);
|
|
|
|
|
}
|
2015-02-25 16:30:23 +01:00
|
|
|
|
|
|
|
|
DebuggerRunControl *attachToRunningProcess(Kit *kit, DeviceProcessItem process, bool contAfterAttach);
|
2011-09-01 16:36:27 +02:00
|
|
|
|
2011-02-22 12:05:25 +01:00
|
|
|
void writeSettings()
|
|
|
|
|
{
|
|
|
|
|
m_debuggerSettings->writeSettings();
|
|
|
|
|
m_mainWindow->writeSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-08 15:50:13 +01:00
|
|
|
void selectThread(int index)
|
|
|
|
|
{
|
2012-10-19 16:37:57 +02:00
|
|
|
ThreadId id = m_currentEngine->threadsHandler()->threadAt(index);
|
|
|
|
|
m_currentEngine->selectThread(id);
|
2010-11-08 15:50:13 +01:00
|
|
|
}
|
2010-11-08 15:41:44 +01:00
|
|
|
|
2015-01-10 01:07:01 +01:00
|
|
|
void breakpointSetMarginActionTriggered(bool isMessageOnly, const ContextData &data)
|
2010-11-08 15:41:44 +01:00
|
|
|
{
|
2011-06-27 10:37:57 +02:00
|
|
|
QString message;
|
2015-01-10 01:07:01 +01:00
|
|
|
if (isMessageOnly) {
|
2015-07-20 09:37:54 +02:00
|
|
|
if (data.type == LocationByAddress) {
|
2011-06-27 10:37:57 +02:00
|
|
|
//: Message tracepoint: Address hit.
|
|
|
|
|
message = tr("0x%1 hit").arg(data.address, 0, 16);
|
|
|
|
|
} else {
|
|
|
|
|
//: Message tracepoint: %1 file, %2 line %3 function hit.
|
2015-01-10 23:40:32 +02:00
|
|
|
message = tr("%1:%2 %3() hit").arg(FileName::fromString(data.fileName).fileName()).
|
2011-06-27 10:37:57 +02:00
|
|
|
arg(data.lineNumber).
|
|
|
|
|
arg(cppFunctionAt(data.fileName, data.lineNumber));
|
|
|
|
|
}
|
|
|
|
|
QInputDialog dialog; // Create wide input dialog.
|
|
|
|
|
dialog.setWindowFlags(dialog.windowFlags()
|
2011-06-28 19:20:09 +02:00
|
|
|
& ~(Qt::WindowContextHelpButtonHint|Qt::MSWindowsFixedSizeDialogHint));
|
2011-06-27 10:37:57 +02:00
|
|
|
dialog.resize(600, dialog.height());
|
|
|
|
|
dialog.setWindowTitle(tr("Add Message Tracepoint"));
|
|
|
|
|
dialog.setLabelText (tr("Message:"));
|
|
|
|
|
dialog.setTextValue(message);
|
|
|
|
|
if (dialog.exec() != QDialog::Accepted || dialog.textValue().isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
message = dialog.textValue();
|
|
|
|
|
}
|
2015-07-20 09:37:54 +02:00
|
|
|
toggleBreakpoint(data, message);
|
2010-11-24 11:44:43 +01:00
|
|
|
}
|
2010-11-08 15:41:44 +01:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
void updateWatchersHeader(int section, int, int newSize)
|
2010-11-05 19:38:40 +01:00
|
|
|
{
|
2014-06-04 14:45:10 +02:00
|
|
|
m_watchersView->header()->resizeSection(section, newSize);
|
|
|
|
|
m_returnView->header()->resizeSection(section, newSize);
|
2010-11-05 19:38:40 +01:00
|
|
|
}
|
2010-02-09 20:44:40 +01:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
void sourceFilesDockToggled(bool on)
|
2010-11-05 19:38:40 +01:00
|
|
|
{
|
2010-11-15 12:06:38 +01:00
|
|
|
if (on && m_currentEngine->state() == InferiorStopOk)
|
2010-11-05 19:38:40 +01:00
|
|
|
m_currentEngine->reloadSourceFiles();
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
void modulesDockToggled(bool on)
|
2010-11-05 19:38:40 +01:00
|
|
|
{
|
2010-11-15 12:06:38 +01:00
|
|
|
if (on && m_currentEngine->state() == InferiorStopOk)
|
2010-11-05 19:38:40 +01:00
|
|
|
m_currentEngine->reloadModules();
|
|
|
|
|
}
|
2010-11-05 13:35:31 +01:00
|
|
|
|
2010-06-22 12:02:24 +02:00
|
|
|
void registerDockToggled(bool on)
|
2010-11-05 13:35:31 +01:00
|
|
|
{
|
2010-11-15 12:06:38 +01:00
|
|
|
if (on && m_currentEngine->state() == InferiorStopOk)
|
2010-11-05 13:35:31 +01:00
|
|
|
m_currentEngine->reloadRegisters();
|
|
|
|
|
}
|
2009-05-05 17:48:54 +02:00
|
|
|
|
2010-11-04 09:54:23 +01:00
|
|
|
void synchronizeBreakpoints()
|
|
|
|
|
{
|
2011-12-21 14:02:52 +01:00
|
|
|
showMessage(QLatin1String("ATTEMPT SYNC"), LogDebug);
|
2010-11-04 09:54:23 +01:00
|
|
|
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
|
2010-12-10 10:01:29 +01:00
|
|
|
if (DebuggerEngine *engine = m_snapshotHandler->at(i))
|
2010-11-04 09:54:23 +01:00
|
|
|
engine->attemptBreakpointSynchronization();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:58:49 +02:00
|
|
|
void editorOpened(IEditor *editor);
|
|
|
|
|
void updateBreakMenuItem(IEditor *editor);
|
2010-06-16 11:08:54 +02:00
|
|
|
void setBusyCursor(bool busy);
|
2015-02-03 23:58:49 +02:00
|
|
|
void requestMark(TextEditorWidget *widget, int lineNumber,
|
|
|
|
|
TextMarkRequestKind kind);
|
|
|
|
|
void requestContextMenu(TextEditorWidget *widget,
|
2014-09-30 16:54:26 +02:00
|
|
|
int lineNumber, QMenu *menu);
|
2009-05-07 15:20:44 +02:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
void activatePreviousMode();
|
|
|
|
|
void activateDebugMode();
|
2015-07-20 09:37:54 +02:00
|
|
|
void toggleBreakpointHelper();
|
|
|
|
|
void toggleBreakpoint(const ContextData &location, const QString &tracePointMessage = QString());
|
2015-02-03 23:58:49 +02:00
|
|
|
void onModeChanged(IMode *mode);
|
2011-01-31 15:17:53 +01:00
|
|
|
void onCoreAboutToOpen();
|
2011-10-25 18:23:37 +08:00
|
|
|
void updateDebugWithoutDeployMenu();
|
2010-02-09 20:44:40 +01:00
|
|
|
|
2012-08-08 13:09:31 +02:00
|
|
|
void startAndDebugApplication();
|
2010-11-19 16:13:22 +01:00
|
|
|
void startRemoteCdbSession();
|
2015-02-25 16:30:23 +01:00
|
|
|
void startRemoteServerAndAttachToProcess();
|
2011-12-05 17:21:48 +01:00
|
|
|
void attachToRemoteServer();
|
2012-08-06 12:22:35 +02:00
|
|
|
void attachToRunningApplication();
|
2013-09-20 16:48:01 +02:00
|
|
|
void attachToUnstartedApplicationDialog();
|
2011-09-13 17:26:02 +02:00
|
|
|
void attachToQmlPort();
|
2014-12-12 15:50:32 +01:00
|
|
|
Q_SLOT void runScheduled();
|
2010-06-16 11:08:54 +02:00
|
|
|
void attachCore();
|
2009-06-08 19:28:28 +02:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
void enableReverseDebuggingTriggered(const QVariant &value);
|
2010-06-22 17:46:20 +02:00
|
|
|
void showStatusMessage(const QString &msg, int timeout = -1);
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2010-12-10 10:01:29 +01:00
|
|
|
void runControlStarted(DebuggerEngine *engine);
|
|
|
|
|
void runControlFinished(DebuggerEngine *engine);
|
2015-03-09 10:59:58 +02:00
|
|
|
void remoteCommand(const QStringList &options);
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2010-08-18 13:54:12 +02:00
|
|
|
void displayDebugger(DebuggerEngine *engine, bool updateEngine = true);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
|
|
|
|
void dumpLog();
|
|
|
|
|
void cleanupViews();
|
2010-07-05 17:08:30 +02:00
|
|
|
void setInitialState();
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-02-03 23:58:49 +02:00
|
|
|
void fontSettingsChanged(const FontSettings &settings);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
|
|
|
|
void updateState(DebuggerEngine *engine);
|
2015-02-03 23:58:49 +02:00
|
|
|
void onCurrentProjectChanged(Project *project);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
|
|
|
|
void sessionLoaded();
|
|
|
|
|
void aboutToUnloadSession();
|
|
|
|
|
void aboutToSaveSession();
|
2010-06-22 12:41:02 +02:00
|
|
|
|
2010-10-22 12:26:13 +02:00
|
|
|
void coreShutdown();
|
2010-08-26 16:02:41 +02:00
|
|
|
|
2012-01-23 16:45:00 +01:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
public slots:
|
2012-01-25 17:28:06 +01:00
|
|
|
void testLoadProject(const QString &proFile, const TestCallBack &cb);
|
2015-02-03 23:58:49 +02:00
|
|
|
void testProjectLoaded(Project *project);
|
2012-10-31 18:14:17 +01:00
|
|
|
void testProjectEvaluated();
|
|
|
|
|
void testProjectBuilt(bool success);
|
2012-01-25 17:28:06 +01:00
|
|
|
void testUnloadProject();
|
|
|
|
|
void testFinished();
|
|
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
void testRunProject(const DebuggerRunParameters &sp, const TestCallBack &cb);
|
2012-01-23 16:45:00 +01:00
|
|
|
void testRunControlFinished();
|
2012-01-25 17:28:06 +01:00
|
|
|
|
2013-09-10 13:37:31 +02:00
|
|
|
// void testStateMachine1();
|
|
|
|
|
// void testStateMachine2();
|
|
|
|
|
// void testStateMachine3();
|
2012-01-25 17:28:06 +01:00
|
|
|
|
2012-01-26 13:14:00 +01:00
|
|
|
void testBenchmark1();
|
|
|
|
|
|
2012-01-25 17:28:06 +01:00
|
|
|
public:
|
2012-12-30 11:37:50 +01:00
|
|
|
Project *m_testProject;
|
2012-01-25 17:28:06 +01:00
|
|
|
bool m_testSuccess;
|
|
|
|
|
QList<TestCallBack> m_testCallbacks;
|
|
|
|
|
|
2012-01-23 16:45:00 +01:00
|
|
|
#endif
|
|
|
|
|
|
2010-11-08 15:19:13 +01:00
|
|
|
public slots:
|
2010-11-12 20:18:29 +01:00
|
|
|
void updateDebugActions();
|
2010-11-23 16:42:46 +01:00
|
|
|
|
|
|
|
|
void handleExecDetach()
|
|
|
|
|
{
|
2010-12-14 12:21:29 +01:00
|
|
|
currentEngine()->resetLocation();
|
2010-11-23 16:42:46 +01:00
|
|
|
currentEngine()->detachDebugger();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleExecContinue()
|
|
|
|
|
{
|
2010-12-14 12:21:29 +01:00
|
|
|
currentEngine()->resetLocation();
|
2010-11-23 16:42:46 +01:00
|
|
|
currentEngine()->continueInferior();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleExecInterrupt()
|
|
|
|
|
{
|
2010-12-14 12:21:29 +01:00
|
|
|
currentEngine()->resetLocation();
|
2010-11-23 16:42:46 +01:00
|
|
|
currentEngine()->requestInterruptInferior();
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-31 16:15:48 +01:00
|
|
|
void handleAbort()
|
2010-11-23 16:42:46 +01:00
|
|
|
{
|
2010-12-14 12:21:29 +01:00
|
|
|
currentEngine()->resetLocation();
|
2011-10-31 16:15:48 +01:00
|
|
|
currentEngine()->abortDebugger();
|
2010-11-23 16:42:46 +01:00
|
|
|
}
|
2010-11-08 15:19:13 +01:00
|
|
|
|
2014-06-05 17:22:51 +02:00
|
|
|
void handleReset()
|
|
|
|
|
{
|
|
|
|
|
currentEngine()->resetLocation();
|
|
|
|
|
currentEngine()->resetInferior();
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-08 15:19:13 +01:00
|
|
|
void handleExecStep()
|
|
|
|
|
{
|
2011-05-02 18:22:32 +02:00
|
|
|
if (currentEngine()->state() == DebuggerNotReady) {
|
2015-06-29 10:36:29 +03:00
|
|
|
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
|
2011-05-02 18:22:32 +02:00
|
|
|
} else {
|
|
|
|
|
currentEngine()->resetLocation();
|
|
|
|
|
if (boolSetting(OperateByInstruction))
|
|
|
|
|
currentEngine()->executeStepI();
|
|
|
|
|
else
|
|
|
|
|
currentEngine()->executeStep();
|
|
|
|
|
}
|
2010-11-08 15:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleExecNext()
|
|
|
|
|
{
|
2011-05-02 18:22:32 +02:00
|
|
|
if (currentEngine()->state() == DebuggerNotReady) {
|
2015-06-29 10:36:29 +03:00
|
|
|
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
|
2011-05-02 18:22:32 +02:00
|
|
|
} else {
|
|
|
|
|
currentEngine()->resetLocation();
|
|
|
|
|
if (boolSetting(OperateByInstruction))
|
|
|
|
|
currentEngine()->executeNextI();
|
|
|
|
|
else
|
|
|
|
|
currentEngine()->executeNext();
|
|
|
|
|
}
|
2010-11-08 15:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-11-08 15:41:44 +01:00
|
|
|
void handleExecStepOut()
|
|
|
|
|
{
|
2010-12-14 12:21:29 +01:00
|
|
|
currentEngine()->resetLocation();
|
2010-11-08 15:41:44 +01:00
|
|
|
currentEngine()->executeStepOut();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleExecReturn()
|
|
|
|
|
{
|
2010-12-14 12:21:29 +01:00
|
|
|
currentEngine()->resetLocation();
|
2010-11-08 15:41:44 +01:00
|
|
|
currentEngine()->executeReturn();
|
|
|
|
|
}
|
2010-11-08 15:19:13 +01:00
|
|
|
|
|
|
|
|
void handleExecJumpToLine()
|
|
|
|
|
{
|
2010-12-14 12:21:29 +01:00
|
|
|
currentEngine()->resetLocation();
|
2015-07-20 09:37:54 +02:00
|
|
|
if (BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor()) {
|
|
|
|
|
ContextData location = getLocationContext(textEditor->textDocument(),
|
|
|
|
|
textEditor->currentLine());
|
|
|
|
|
if (location.isValid())
|
|
|
|
|
currentEngine()->executeJumpToLine(location);
|
|
|
|
|
}
|
2010-11-08 15:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleExecRunToLine()
|
|
|
|
|
{
|
2010-12-14 12:21:29 +01:00
|
|
|
currentEngine()->resetLocation();
|
2015-07-20 09:37:54 +02:00
|
|
|
if (BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor()) {
|
|
|
|
|
ContextData location = getLocationContext(textEditor->textDocument(),
|
|
|
|
|
textEditor->currentLine());
|
|
|
|
|
if (location.isValid())
|
|
|
|
|
currentEngine()->executeRunToLine(location);
|
|
|
|
|
}
|
2010-11-08 15:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-02 11:52:39 +01:00
|
|
|
void handleExecRunToSelectedFunction()
|
2010-11-08 15:19:13 +01:00
|
|
|
{
|
2014-07-23 19:10:38 +02:00
|
|
|
BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor();
|
2010-11-08 16:17:59 +01:00
|
|
|
QTC_ASSERT(textEditor, return);
|
2014-08-27 11:57:32 +02:00
|
|
|
QTextCursor cursor = textEditor->textCursor();
|
2010-11-08 16:17:59 +01:00
|
|
|
QString functionName = cursor.selectedText();
|
|
|
|
|
if (functionName.isEmpty()) {
|
|
|
|
|
const QTextBlock block = cursor.block();
|
|
|
|
|
const QString line = block.text();
|
2011-12-21 14:02:52 +01:00
|
|
|
foreach (const QString &str, line.trimmed().split(QLatin1Char('('))) {
|
2010-11-08 16:17:59 +01:00
|
|
|
QString a;
|
|
|
|
|
for (int i = str.size(); --i >= 0; ) {
|
|
|
|
|
if (!str.at(i).isLetterOrNumber())
|
|
|
|
|
break;
|
|
|
|
|
a = str.at(i) + a;
|
|
|
|
|
}
|
|
|
|
|
if (!a.isEmpty()) {
|
|
|
|
|
functionName = a;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-02 11:52:39 +01:00
|
|
|
if (functionName.isEmpty()) {
|
|
|
|
|
showStatusMessage(tr("No function selected."));
|
|
|
|
|
} else {
|
|
|
|
|
showStatusMessage(tr("Running to function \"%1\".")
|
|
|
|
|
.arg(functionName));
|
|
|
|
|
currentEngine()->resetLocation();
|
2010-11-08 16:17:59 +01:00
|
|
|
currentEngine()->executeRunToFunction(functionName);
|
2011-02-02 11:52:39 +01:00
|
|
|
}
|
2010-11-08 15:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleAddToWatchWindow()
|
|
|
|
|
{
|
|
|
|
|
// Requires a selection, but that's the only case we want anyway.
|
2014-08-27 11:57:32 +02:00
|
|
|
BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor();
|
2010-11-08 15:19:13 +01:00
|
|
|
if (!textEditor)
|
|
|
|
|
return;
|
2014-08-27 11:57:32 +02:00
|
|
|
QTextCursor tc = textEditor->textCursor();
|
2010-11-08 15:19:13 +01:00
|
|
|
QString exp;
|
|
|
|
|
if (tc.hasSelection()) {
|
|
|
|
|
exp = tc.selectedText();
|
|
|
|
|
} else {
|
|
|
|
|
int line, column;
|
2014-09-19 15:26:41 +02:00
|
|
|
exp = cppExpressionAt(textEditor->editorWidget(), tc.position(), &line, &column);
|
2010-11-08 15:19:13 +01:00
|
|
|
}
|
2013-01-09 14:51:49 +01:00
|
|
|
if (currentEngine()->hasCapability(WatchComplexExpressionsCapability))
|
|
|
|
|
exp = removeObviousSideEffects(exp);
|
|
|
|
|
else
|
|
|
|
|
exp = fixCppExpression(exp);
|
2015-03-19 22:35:39 +02:00
|
|
|
exp = exp.trimmed();
|
2010-11-08 15:19:13 +01:00
|
|
|
if (exp.isEmpty())
|
|
|
|
|
return;
|
2012-10-29 12:59:53 +01:00
|
|
|
currentEngine()->watchHandler()->watchVariable(exp);
|
2010-11-08 15:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleExecExit()
|
|
|
|
|
{
|
2010-11-08 17:43:31 +01:00
|
|
|
currentEngine()->exitDebugger();
|
2010-11-08 15:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleFrameDown()
|
|
|
|
|
{
|
|
|
|
|
currentEngine()->frameDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleFrameUp()
|
|
|
|
|
{
|
|
|
|
|
currentEngine()->frameUp();
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-22 12:21:56 +01:00
|
|
|
void handleOperateByInstructionTriggered(bool operateByInstructionTriggered)
|
2010-11-08 15:19:13 +01:00
|
|
|
{
|
2010-11-22 12:21:56 +01:00
|
|
|
// Go to source only if we have the file.
|
2015-03-04 17:43:59 +01:00
|
|
|
if (DebuggerEngine *cppEngine = currentEngine()->cppEngine()) {
|
|
|
|
|
if (cppEngine->stackHandler()->currentIndex() >= 0) {
|
|
|
|
|
const StackFrame frame = cppEngine->stackHandler()->currentFrame();
|
|
|
|
|
if (operateByInstructionTriggered || frame.isUsable())
|
|
|
|
|
cppEngine->gotoLocation(Location(frame, true));
|
|
|
|
|
}
|
2010-11-22 12:21:56 +01:00
|
|
|
}
|
2010-11-08 15:19:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
void showMessage(const QString &msg, int channel, int timeout = -1);
|
|
|
|
|
|
2011-02-08 13:48:04 +01:00
|
|
|
bool parseArgument(QStringList::const_iterator &it,
|
2012-08-09 01:50:26 +02:00
|
|
|
const QStringList::const_iterator &cend, QString *errorMessage);
|
|
|
|
|
bool parseArguments(const QStringList &args, QString *errorMessage);
|
2013-03-05 11:10:33 +01:00
|
|
|
void parseCommandLineArguments();
|
2011-02-08 13:48:04 +01:00
|
|
|
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
public:
|
2010-12-02 17:33:39 +01:00
|
|
|
DebuggerMainWindow *m_mainWindow;
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2012-05-07 18:28:03 +02:00
|
|
|
Id m_previousMode;
|
2015-06-24 08:26:35 +02:00
|
|
|
QVector<QPair<DebuggerRunParameters, Kit *>> m_scheduledStarts;
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2012-08-15 16:19:15 +02:00
|
|
|
ProxyAction *m_visibleStartAction;
|
|
|
|
|
ProxyAction *m_hiddenStopAction;
|
2011-08-03 18:57:37 +02:00
|
|
|
QAction *m_startAction;
|
2011-10-25 18:23:37 +08:00
|
|
|
QAction *m_debugWithoutDeployAction;
|
2012-08-08 13:09:31 +02:00
|
|
|
QAction *m_startAndDebugApplicationAction;
|
2011-12-06 15:39:25 +01:00
|
|
|
QAction *m_startRemoteServerAction;
|
2012-08-06 12:22:35 +02:00
|
|
|
QAction *m_attachToRunningApplication;
|
2013-09-20 16:48:01 +02:00
|
|
|
QAction *m_attachToUnstartedApplication;
|
2011-09-13 17:26:02 +02:00
|
|
|
QAction *m_attachToQmlPortAction;
|
2011-12-05 17:21:48 +01:00
|
|
|
QAction *m_attachToRemoteServerAction;
|
2010-11-19 16:13:22 +01:00
|
|
|
QAction *m_startRemoteCdbAction;
|
2011-12-05 17:21:48 +01:00
|
|
|
QAction *m_attachToCoreAction;
|
2010-06-16 11:08:54 +02:00
|
|
|
QAction *m_detachAction;
|
2011-02-03 14:08:01 +01:00
|
|
|
QAction *m_continueAction;
|
|
|
|
|
QAction *m_exitAction; // On application output button if "Stop" is possible
|
|
|
|
|
QAction *m_interruptAction; // On the fat debug button if "Pause" is possible
|
|
|
|
|
QAction *m_undisturbableAction; // On the fat debug button if nothing can be done
|
2011-10-31 16:15:48 +01:00
|
|
|
QAction *m_abortAction;
|
2011-02-03 14:08:01 +01:00
|
|
|
QAction *m_stepAction;
|
|
|
|
|
QAction *m_stepOutAction;
|
|
|
|
|
QAction *m_runToLineAction; // In the debug menu
|
|
|
|
|
QAction *m_runToSelectedFunctionAction;
|
|
|
|
|
QAction *m_jumpToLineAction; // In the Debug menu.
|
|
|
|
|
QAction *m_returnFromFunctionAction;
|
|
|
|
|
QAction *m_nextAction;
|
|
|
|
|
QAction *m_watchAction1; // In the Debug menu.
|
|
|
|
|
QAction *m_watchAction2; // In the text editor context menu.
|
|
|
|
|
QAction *m_breakAction;
|
|
|
|
|
QAction *m_reverseDirectionAction;
|
|
|
|
|
QAction *m_frameUpAction;
|
|
|
|
|
QAction *m_frameDownAction;
|
2014-06-05 17:22:51 +02:00
|
|
|
QAction *m_resetAction;
|
2011-02-03 14:08:01 +01:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
QToolButton *m_reverseToolButton;
|
|
|
|
|
|
2010-10-05 12:47:23 +02:00
|
|
|
QIcon m_startIcon;
|
2010-11-08 17:43:31 +01:00
|
|
|
QIcon m_exitIcon;
|
2010-10-05 12:47:23 +02:00
|
|
|
QIcon m_continueIcon;
|
2010-06-16 11:08:54 +02:00
|
|
|
QIcon m_interruptIcon;
|
|
|
|
|
QIcon m_locationMarkIcon;
|
2014-06-05 17:22:51 +02:00
|
|
|
QIcon m_resetIcon;
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2012-08-15 16:19:15 +02:00
|
|
|
StatusLabel *m_statusLabel;
|
2010-06-16 11:08:54 +02:00
|
|
|
QComboBox *m_threadBox;
|
|
|
|
|
|
2014-06-04 14:45:10 +02:00
|
|
|
BaseTreeView *m_breakView;
|
|
|
|
|
BaseTreeView *m_returnView;
|
|
|
|
|
BaseTreeView *m_localsView;
|
|
|
|
|
BaseTreeView *m_watchersView;
|
|
|
|
|
BaseTreeView *m_inspectorView;
|
|
|
|
|
BaseTreeView *m_registerView;
|
|
|
|
|
BaseTreeView *m_modulesView;
|
|
|
|
|
BaseTreeView *m_snapshotView;
|
|
|
|
|
BaseTreeView *m_sourceFilesView;
|
|
|
|
|
BaseTreeView *m_stackView;
|
|
|
|
|
BaseTreeView *m_threadsView;
|
|
|
|
|
|
|
|
|
|
QWidget *m_breakWindow;
|
2010-11-04 09:54:23 +01:00
|
|
|
BreakHandler *m_breakHandler;
|
2014-06-04 14:45:10 +02:00
|
|
|
QWidget *m_returnWindow;
|
|
|
|
|
QWidget *m_localsWindow;
|
|
|
|
|
QWidget *m_watchersWindow;
|
|
|
|
|
QWidget *m_inspectorWindow;
|
|
|
|
|
QWidget *m_registerWindow;
|
|
|
|
|
QWidget *m_modulesWindow;
|
|
|
|
|
QWidget *m_snapshotWindow;
|
|
|
|
|
QWidget *m_sourceFilesWindow;
|
|
|
|
|
QWidget *m_stackWindow;
|
|
|
|
|
QWidget *m_threadsWindow;
|
2010-09-22 16:20:08 +02:00
|
|
|
LogWindow *m_logWindow;
|
2012-05-14 16:09:12 +02:00
|
|
|
LocalsAndExpressionsWindow *m_localsAndExpressionsWindow;
|
2010-06-16 11:08:54 +02:00
|
|
|
|
|
|
|
|
bool m_busy;
|
|
|
|
|
QString m_lastPermanentStatusMessage;
|
|
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
mutable CPlusPlus::Snapshot m_codeModelSnapshot;
|
2010-06-16 11:08:54 +02:00
|
|
|
DebuggerPlugin *m_plugin;
|
|
|
|
|
|
2010-07-20 17:36:20 +02:00
|
|
|
SnapshotHandler *m_snapshotHandler;
|
2010-10-22 12:26:13 +02:00
|
|
|
bool m_shuttingDown;
|
2010-11-04 18:11:09 +01:00
|
|
|
DebuggerEngine *m_currentEngine;
|
2010-11-10 16:33:11 +01:00
|
|
|
DebuggerSettings *m_debuggerSettings;
|
2011-02-22 11:21:08 +01:00
|
|
|
QStringList m_arguments;
|
2014-11-07 13:50:09 +01:00
|
|
|
DebuggerToolTipManager m_toolTipManager;
|
2011-02-22 12:58:32 +01:00
|
|
|
CommonOptionsPage *m_commonOptionsPage;
|
2011-03-02 14:05:32 +01:00
|
|
|
DummyEngine *m_dummyEngine;
|
2011-03-04 16:21:57 +01:00
|
|
|
const QSharedPointer<GlobalDebuggerOptions> m_globalDebuggerOptions;
|
2010-06-16 11:08:54 +02:00
|
|
|
};
|
|
|
|
|
|
2011-02-11 15:00:13 +01:00
|
|
|
DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) :
|
2011-03-04 16:21:57 +01:00
|
|
|
m_dummyEngine(0),
|
|
|
|
|
m_globalDebuggerOptions(new GlobalDebuggerOptions)
|
2010-06-16 11:08:54 +02:00
|
|
|
{
|
2011-01-04 15:54:36 +01:00
|
|
|
qRegisterMetaType<ContextData>("ContextData");
|
2015-05-27 13:59:56 +02:00
|
|
|
qRegisterMetaType<DebuggerRunParameters>("DebuggerRunParameters");
|
2011-01-04 15:54:36 +01:00
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
QTC_CHECK(!dd);
|
|
|
|
|
dd = this;
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
m_plugin = plugin;
|
|
|
|
|
|
2010-11-23 16:42:46 +01:00
|
|
|
m_startRemoteCdbAction = 0;
|
2010-11-04 18:11:09 +01:00
|
|
|
m_shuttingDown = false;
|
2010-06-16 11:08:54 +02:00
|
|
|
m_statusLabel = 0;
|
|
|
|
|
m_threadBox = 0;
|
|
|
|
|
|
|
|
|
|
m_breakWindow = 0;
|
2010-11-04 09:54:23 +01:00
|
|
|
m_breakHandler = 0;
|
2010-06-16 11:08:54 +02:00
|
|
|
m_returnWindow = 0;
|
|
|
|
|
m_localsWindow = 0;
|
|
|
|
|
m_watchersWindow = 0;
|
2012-04-18 14:20:54 +02:00
|
|
|
m_inspectorWindow = 0;
|
2010-06-16 11:08:54 +02:00
|
|
|
m_registerWindow = 0;
|
|
|
|
|
m_modulesWindow = 0;
|
|
|
|
|
m_snapshotWindow = 0;
|
|
|
|
|
m_sourceFilesWindow = 0;
|
|
|
|
|
m_stackWindow = 0;
|
|
|
|
|
m_threadsWindow = 0;
|
2010-09-22 16:20:08 +02:00
|
|
|
m_logWindow = 0;
|
2012-05-14 16:09:12 +02:00
|
|
|
m_localsAndExpressionsWindow = 0;
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-02 17:33:39 +01:00
|
|
|
m_mainWindow = 0;
|
2010-07-20 17:36:20 +02:00
|
|
|
m_snapshotHandler = 0;
|
2010-11-04 18:11:09 +01:00
|
|
|
m_currentEngine = 0;
|
2010-11-10 16:33:11 +01:00
|
|
|
m_debuggerSettings = 0;
|
|
|
|
|
|
2010-12-06 08:04:43 +01:00
|
|
|
m_reverseToolButton = 0;
|
2011-08-03 18:57:37 +02:00
|
|
|
m_startAction = 0;
|
2011-10-25 18:23:37 +08:00
|
|
|
m_debugWithoutDeployAction = 0;
|
2012-08-08 13:09:31 +02:00
|
|
|
m_startAndDebugApplicationAction = 0;
|
2011-12-05 17:21:48 +01:00
|
|
|
m_attachToRemoteServerAction = 0;
|
2012-08-06 12:22:35 +02:00
|
|
|
m_attachToRunningApplication = 0;
|
2013-09-20 16:48:01 +02:00
|
|
|
m_attachToUnstartedApplication = 0;
|
2011-09-13 17:26:02 +02:00
|
|
|
m_attachToQmlPortAction = 0;
|
2010-12-06 08:04:43 +01:00
|
|
|
m_startRemoteCdbAction = 0;
|
2011-12-05 17:21:48 +01:00
|
|
|
m_attachToCoreAction = 0;
|
2010-12-06 08:04:43 +01:00
|
|
|
m_detachAction = 0;
|
2011-02-22 12:58:32 +01:00
|
|
|
|
|
|
|
|
m_commonOptionsPage = 0;
|
2010-06-16 11:08:54 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
DebuggerPluginPrivate::~DebuggerPluginPrivate()
|
|
|
|
|
{
|
2010-11-10 16:33:11 +01:00
|
|
|
delete m_debuggerSettings;
|
|
|
|
|
m_debuggerSettings = 0;
|
|
|
|
|
|
2011-03-15 14:52:35 +01:00
|
|
|
// Mainwindow will be deleted by debug mode.
|
2010-11-10 11:39:01 +01:00
|
|
|
|
|
|
|
|
delete m_snapshotHandler;
|
|
|
|
|
m_snapshotHandler = 0;
|
2011-02-24 13:25:30 +01:00
|
|
|
|
|
|
|
|
delete m_breakHandler;
|
|
|
|
|
m_breakHandler = 0;
|
2010-11-10 11:39:01 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-02 14:05:32 +01:00
|
|
|
DebuggerEngine *DebuggerPluginPrivate::dummyEngine()
|
|
|
|
|
{
|
|
|
|
|
if (!m_dummyEngine) {
|
|
|
|
|
m_dummyEngine = new DummyEngine;
|
|
|
|
|
m_dummyEngine->setParent(this);
|
|
|
|
|
m_dummyEngine->setObjectName(_("DummyEngine"));
|
|
|
|
|
}
|
|
|
|
|
return m_dummyEngine;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-08 13:48:04 +01:00
|
|
|
static QString msgParameterMissing(const QString &a)
|
|
|
|
|
{
|
2014-04-17 14:09:47 +02:00
|
|
|
return DebuggerPlugin::tr("Option \"%1\" is missing the parameter.").arg(a);
|
2011-02-08 13:48:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
2012-08-09 01:50:26 +02:00
|
|
|
const QStringList::const_iterator &cend, QString *errorMessage)
|
2011-02-08 13:48:04 +01:00
|
|
|
{
|
|
|
|
|
const QString &option = *it;
|
|
|
|
|
// '-debug <pid>'
|
2015-09-04 11:32:42 +02:00
|
|
|
// '-debug <exe>[,server=<server:port>][,core=<core>][,kit=<kit>][,terminal={0,1}]'
|
2011-02-08 13:48:04 +01:00
|
|
|
if (*it == _("-debug")) {
|
|
|
|
|
++it;
|
|
|
|
|
if (it == cend) {
|
|
|
|
|
*errorMessage = msgParameterMissing(*it);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *kit = 0;
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerRunParameters rp;
|
2011-02-08 13:48:04 +01:00
|
|
|
qulonglong pid = it->toULongLong();
|
|
|
|
|
if (pid) {
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.startMode = AttachExternal;
|
|
|
|
|
rp.closeMode = DetachAtClose;
|
|
|
|
|
rp.attachPID = pid;
|
|
|
|
|
rp.displayName = tr("Process %1").arg(rp.attachPID);
|
|
|
|
|
rp.startMessage = tr("Attaching to local process %1.").arg(rp.attachPID);
|
2011-02-08 13:48:04 +01:00
|
|
|
} else {
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.startMode = StartExternal;
|
2012-06-28 10:00:04 +02:00
|
|
|
QStringList args = it->split(QLatin1Char(','));
|
2012-02-17 12:32:57 +02:00
|
|
|
foreach (const QString &arg, args) {
|
|
|
|
|
QString key = arg.section(QLatin1Char('='), 0, 0);
|
|
|
|
|
QString val = arg.section(QLatin1Char('='), 1, 1);
|
|
|
|
|
if (val.isEmpty()) {
|
2013-07-17 00:01:45 +03:00
|
|
|
if (key.isEmpty()) {
|
2012-02-17 12:32:57 +02:00
|
|
|
continue;
|
2016-01-28 10:31:24 +01:00
|
|
|
} else if (rp.inferior.executable.isEmpty()) {
|
|
|
|
|
rp.inferior.executable = key;
|
2013-07-17 00:01:45 +03:00
|
|
|
} else {
|
2014-08-22 13:26:36 +02:00
|
|
|
*errorMessage = DebuggerPlugin::tr("Only one executable allowed.");
|
2012-02-17 12:32:57 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (key == QLatin1String("server")) {
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.startMode = AttachToRemoteServer;
|
|
|
|
|
rp.remoteChannel = val;
|
|
|
|
|
rp.displayName = tr("Remote: \"%1\"").arg(rp.remoteChannel);
|
|
|
|
|
rp.startMessage = tr("Attaching to remote server %1.").arg(rp.remoteChannel);
|
2013-07-17 00:01:45 +03:00
|
|
|
} else if (key == QLatin1String("core")) {
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.startMode = AttachCore;
|
|
|
|
|
rp.closeMode = DetachAtClose;
|
|
|
|
|
rp.coreFile = val;
|
|
|
|
|
rp.displayName = tr("Core file \"%1\"").arg(rp.coreFile);
|
|
|
|
|
rp.startMessage = tr("Attaching to core file %1.").arg(rp.coreFile);
|
2015-09-04 11:32:42 +02:00
|
|
|
} else if (key == QLatin1String("terminal")) {
|
|
|
|
|
rp.useTerminal = bool(val.toInt());
|
2013-07-17 00:01:45 +03:00
|
|
|
} else if (key == QLatin1String("kit")) {
|
2013-08-21 12:48:46 +02:00
|
|
|
kit = KitManager::find(Id::fromString(val));
|
2012-08-15 15:42:53 +02:00
|
|
|
}
|
2011-04-19 14:30:13 +02:00
|
|
|
}
|
2012-02-17 12:32:57 +02:00
|
|
|
}
|
2015-05-27 13:59:56 +02:00
|
|
|
if (rp.startMode == StartExternal) {
|
2016-01-28 10:31:24 +01:00
|
|
|
rp.displayName = tr("Executable file \"%1\"").arg(rp.inferior.executable);
|
|
|
|
|
rp.startMessage = tr("Debugging file %1.").arg(rp.inferior.executable);
|
2011-02-08 13:48:04 +01:00
|
|
|
}
|
2016-01-28 10:31:24 +01:00
|
|
|
rp.inferior.environment = Utils::Environment::systemEnvironment();
|
2015-12-08 12:39:10 +01:00
|
|
|
rp.stubEnvironment = Utils::Environment::systemEnvironment();
|
|
|
|
|
rp.debuggerEnvironment = Utils::Environment::systemEnvironment();
|
2015-06-24 08:26:35 +02:00
|
|
|
m_scheduledStarts.append(QPair<DebuggerRunParameters, Kit *>(rp, kit));
|
2011-02-08 13:48:04 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// -wincrashevent <event-handle>:<pid>. A handle used for
|
|
|
|
|
// a handshake when attaching to a crashed Windows process.
|
|
|
|
|
// This is created by $QTC/src/tools/qtcdebugger/main.cpp:
|
|
|
|
|
// args << QLatin1String("-wincrashevent")
|
2012-11-26 20:43:43 +02:00
|
|
|
// << QString::fromLatin1("%1:%2").arg(argWinCrashEvent).arg(argProcessId);
|
2011-02-08 13:48:04 +01:00
|
|
|
if (*it == _("-wincrashevent")) {
|
|
|
|
|
++it;
|
|
|
|
|
if (it == cend) {
|
|
|
|
|
*errorMessage = msgParameterMissing(*it);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerRunParameters rp;
|
|
|
|
|
rp.startMode = AttachCrashedExternal;
|
|
|
|
|
rp.crashParameter = it->section(QLatin1Char(':'), 0, 0);
|
|
|
|
|
rp.attachPID = it->section(QLatin1Char(':'), 1, 1).toULongLong();
|
|
|
|
|
rp.displayName = tr("Crashed process %1").arg(rp.attachPID);
|
|
|
|
|
rp.startMessage = tr("Attaching to crashed process %1").arg(rp.attachPID);
|
|
|
|
|
if (!rp.attachPID) {
|
2014-04-17 14:09:47 +02:00
|
|
|
*errorMessage = DebuggerPlugin::tr("The parameter \"%1\" of option \"%2\" "
|
2011-02-08 13:48:04 +01:00
|
|
|
"does not match the pattern <handle>:<pid>.").arg(*it, option);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-06-24 08:26:35 +02:00
|
|
|
m_scheduledStarts.append(QPair<DebuggerRunParameters, Kit *>(rp, findUniversalCdbKit()));
|
2011-02-08 13:48:04 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*errorMessage = DebuggerPlugin::tr("Invalid debugger option: %1").arg(option);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DebuggerPluginPrivate::parseArguments(const QStringList &args,
|
2012-08-09 01:50:26 +02:00
|
|
|
QString *errorMessage)
|
2011-02-08 13:48:04 +01:00
|
|
|
{
|
|
|
|
|
const QStringList::const_iterator cend = args.constEnd();
|
|
|
|
|
for (QStringList::const_iterator it = args.constBegin(); it != cend; ++it)
|
2012-08-09 01:50:26 +02:00
|
|
|
if (!parseArgument(it, cend, errorMessage))
|
2011-02-08 13:48:04 +01:00
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-05 11:10:33 +01:00
|
|
|
void DebuggerPluginPrivate::parseCommandLineArguments()
|
|
|
|
|
{
|
|
|
|
|
QString errorMessage;
|
|
|
|
|
if (!parseArguments(m_arguments, &errorMessage)) {
|
|
|
|
|
errorMessage = tr("Error evaluating command line arguments: %1")
|
|
|
|
|
.arg(errorMessage);
|
|
|
|
|
qWarning("%s\n", qPrintable(errorMessage));
|
2013-09-05 01:52:17 +02:00
|
|
|
MessageManager::write(errorMessage);
|
2013-03-05 11:10:33 +01:00
|
|
|
}
|
|
|
|
|
if (!m_scheduledStarts.isEmpty())
|
|
|
|
|
QTimer::singleShot(0, this, SLOT(runScheduled()));
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|
|
|
|
QString *errorMessage)
|
2010-06-16 11:08:54 +02:00
|
|
|
{
|
2011-02-22 11:21:08 +01:00
|
|
|
Q_UNUSED(errorMessage);
|
2015-02-04 09:32:46 +01:00
|
|
|
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/debugger/Debugger.mimetypes.xml"));
|
|
|
|
|
|
2011-02-22 11:21:08 +01:00
|
|
|
m_arguments = arguments;
|
2013-03-05 11:10:33 +01:00
|
|
|
if (!m_arguments.isEmpty())
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(KitManager::instance(), &KitManager::kitsLoaded,
|
|
|
|
|
this, &DebuggerPluginPrivate::parseCommandLineArguments);
|
2015-11-10 16:59:02 +01:00
|
|
|
|
2010-12-03 10:45:51 +01:00
|
|
|
m_mainWindow = new DebuggerMainWindow;
|
2015-11-10 16:59:02 +01:00
|
|
|
m_plugin->addAutoReleasedObject(debuggerConsole());
|
2010-12-03 10:45:51 +01:00
|
|
|
|
2015-02-03 23:58:49 +02:00
|
|
|
TaskHub::addCategory(TASK_CATEGORY_DEBUGGER_DEBUGINFO,
|
2013-08-15 12:14:46 +02:00
|
|
|
tr("Debug Information"));
|
2015-02-03 23:58:49 +02:00
|
|
|
TaskHub::addCategory(TASK_CATEGORY_DEBUGGER_RUNTIME,
|
2013-08-15 12:14:46 +02:00
|
|
|
tr("Debugger Runtime"));
|
|
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2014-07-28 14:23:52 +02:00
|
|
|
void setConfigValue(const QByteArray &name, const QVariant &value)
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2013-09-04 18:39:43 +02:00
|
|
|
ICore::settings()->setValue(_("DebugMode/" + name), value);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2014-07-28 14:23:52 +02:00
|
|
|
QVariant configValue(const QByteArray &name)
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2013-09-04 18:39:43 +02:00
|
|
|
return ICore::settings()->value(_("DebugMode/" + name));
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
|
|
|
|
|
{
|
|
|
|
|
RunConfiguration *activeRc = 0;
|
|
|
|
|
if (project) {
|
|
|
|
|
Target *target = project->activeTarget();
|
2011-10-28 10:15:04 +00:00
|
|
|
if (target)
|
|
|
|
|
activeRc = target->activeRunConfiguration();
|
|
|
|
|
if (!activeRc)
|
|
|
|
|
return;
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
|
|
|
|
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
|
|
|
|
|
// Run controls might be deleted during exit.
|
2010-12-10 10:01:29 +01:00
|
|
|
if (DebuggerEngine *engine = m_snapshotHandler->at(i)) {
|
|
|
|
|
DebuggerRunControl *runControl = engine->runControl();
|
2010-12-02 13:20:06 +01:00
|
|
|
RunConfiguration *rc = runControl->runConfiguration();
|
|
|
|
|
if (rc == activeRc) {
|
|
|
|
|
m_snapshotHandler->setCurrentIndex(i);
|
|
|
|
|
updateState(engine);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-07 12:52:24 +02:00
|
|
|
|
|
|
|
|
// If we have a running debugger, don't touch it.
|
|
|
|
|
if (m_snapshotHandler->size())
|
|
|
|
|
return;
|
|
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// No corresponding debugger found. So we are ready to start one.
|
2011-02-03 14:08:01 +01:00
|
|
|
m_interruptAction->setEnabled(false);
|
|
|
|
|
m_continueAction->setEnabled(false);
|
|
|
|
|
m_exitAction->setEnabled(false);
|
2014-09-04 13:48:44 +02:00
|
|
|
QString whyNot;
|
2015-06-29 10:36:29 +03:00
|
|
|
const bool canRun = ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE, &whyNot);
|
2013-03-12 16:52:29 +01:00
|
|
|
m_startAction->setEnabled(canRun);
|
2014-09-04 13:48:44 +02:00
|
|
|
m_startAction->setToolTip(whyNot);
|
2013-03-12 16:52:29 +01:00
|
|
|
m_debugWithoutDeployAction->setEnabled(canRun);
|
2015-02-03 23:58:49 +02:00
|
|
|
setProxyAction(m_visibleStartAction, Id(Constants::DEBUG));
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2012-08-08 13:09:31 +02:00
|
|
|
void DebuggerPluginPrivate::startAndDebugApplication()
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerRunParameters rp;
|
2015-06-24 08:26:35 +02:00
|
|
|
Kit *kit;
|
|
|
|
|
if (StartApplicationDialog::run(ICore::dialogParent(), &rp, &kit))
|
|
|
|
|
createAndScheduleRun(rp, kit);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-11-08 15:19:13 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::attachCore()
|
|
|
|
|
{
|
2014-02-12 14:11:52 +01:00
|
|
|
AttachCoreDialog dlg(ICore::dialogParent());
|
2012-07-24 17:02:42 +02:00
|
|
|
|
2013-09-04 18:39:43 +02:00
|
|
|
const QString lastExternalKit = configValue("LastExternalKit").toString();
|
2013-03-18 17:28:29 +01:00
|
|
|
if (!lastExternalKit.isEmpty())
|
2013-03-26 13:09:43 +01:00
|
|
|
dlg.setKitId(Id::fromString(lastExternalKit));
|
2013-09-04 18:39:43 +02:00
|
|
|
dlg.setLocalExecutableFile(configValue("LastExternalExecutableFile").toString());
|
|
|
|
|
dlg.setLocalCoreFile(configValue("LastLocalCoreFile").toString());
|
|
|
|
|
dlg.setRemoteCoreFile(configValue("LastRemoteCoreFile").toString());
|
|
|
|
|
dlg.setOverrideStartScript(configValue("LastExternalStartScript").toString());
|
|
|
|
|
dlg.setForceLocalCoreFile(configValue("LastForceLocalCoreFile").toBool());
|
2011-02-24 16:50:15 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
if (dlg.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
2011-02-24 16:50:15 +01:00
|
|
|
|
2013-09-04 18:39:43 +02:00
|
|
|
setConfigValue("LastExternalExecutableFile", dlg.localExecutableFile());
|
|
|
|
|
setConfigValue("LastLocalCoreFile", dlg.localCoreFile());
|
|
|
|
|
setConfigValue("LastRemoteCoreFile", dlg.remoteCoreFile());
|
|
|
|
|
setConfigValue("LastExternalKit", dlg.kit()->id().toSetting());
|
|
|
|
|
setConfigValue("LastExternalStartScript", dlg.overrideStartScript());
|
|
|
|
|
setConfigValue("LastForceLocalCoreFile", dlg.forcesLocalCoreFile());
|
2010-07-22 10:23:27 +02:00
|
|
|
|
2012-10-22 11:14:18 +02:00
|
|
|
QString display = dlg.useLocalCoreFile() ? dlg.localCoreFile() : dlg.remoteCoreFile();
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerRunParameters rp;
|
|
|
|
|
rp.masterEngineType = DebuggerKitInformation::engineType(dlg.kit());
|
2016-01-28 10:31:24 +01:00
|
|
|
rp.inferior.executable = dlg.localExecutableFile();
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.coreFile = dlg.localCoreFile();
|
|
|
|
|
rp.displayName = tr("Core file \"%1\"").arg(display);
|
|
|
|
|
rp.startMode = AttachCore;
|
|
|
|
|
rp.closeMode = DetachAtClose;
|
|
|
|
|
rp.overrideStartScript = dlg.overrideStartScript();
|
2015-06-24 08:26:35 +02:00
|
|
|
createAndScheduleRun(rp, dlg.kit());
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::startRemoteCdbSession()
|
|
|
|
|
{
|
2013-09-04 18:39:43 +02:00
|
|
|
const QByteArray connectionKey = "CdbRemoteConnection";
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerRunParameters rp;
|
2014-07-23 09:09:20 +02:00
|
|
|
Kit *kit = findUniversalCdbKit();
|
2014-10-20 14:03:47 +02:00
|
|
|
QTC_ASSERT(kit, return);
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.startMode = AttachToRemoteServer;
|
|
|
|
|
rp.closeMode = KillAtClose;
|
2014-02-12 14:11:52 +01:00
|
|
|
StartRemoteCdbDialog dlg(ICore::dialogParent());
|
2010-12-02 13:20:06 +01:00
|
|
|
QString previousConnection = configValue(connectionKey).toString();
|
|
|
|
|
if (previousConnection.isEmpty())
|
|
|
|
|
previousConnection = QLatin1String("localhost:1234");
|
|
|
|
|
dlg.setConnection(previousConnection);
|
|
|
|
|
if (dlg.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.remoteChannel = dlg.connection();
|
|
|
|
|
setConfigValue(connectionKey, rp.remoteChannel);
|
2015-06-24 08:26:35 +02:00
|
|
|
createAndScheduleRun(rp, kit);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2011-12-05 17:21:48 +01:00
|
|
|
void DebuggerPluginPrivate::attachToRemoteServer()
|
2011-09-14 15:22:08 +02:00
|
|
|
{
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerRunParameters rp;
|
2015-06-24 08:26:35 +02:00
|
|
|
Kit *kit;
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.startMode = AttachToRemoteServer;
|
2015-06-24 08:26:35 +02:00
|
|
|
if (StartApplicationDialog::run(ICore::dialogParent(), &rp, &kit)) {
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.closeMode = KillAtClose;
|
2015-06-24 08:26:35 +02:00
|
|
|
createAndScheduleRun(rp, kit);
|
2012-02-06 15:15:57 +01:00
|
|
|
}
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-02-25 16:30:23 +01:00
|
|
|
void DebuggerPluginPrivate::startRemoteServerAndAttachToProcess()
|
2011-12-06 15:39:25 +01:00
|
|
|
{
|
2015-02-25 16:30:23 +01:00
|
|
|
auto kitChooser = new DebuggerKitChooser(DebuggerKitChooser::AnyDebugging);
|
|
|
|
|
auto dlg = new DeviceProcessesDialog(kitChooser, ICore::dialogParent());
|
|
|
|
|
dlg->addAcceptButton(DeviceProcessesDialog::tr("&Attach to Process"));
|
|
|
|
|
dlg->showAllDevices();
|
|
|
|
|
if (dlg->exec() == QDialog::Rejected) {
|
|
|
|
|
delete dlg;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
|
Kit *kit = kitChooser->currentKit();
|
|
|
|
|
QTC_ASSERT(kit, return);
|
|
|
|
|
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
|
|
|
|
QTC_ASSERT(device, return);
|
|
|
|
|
|
|
|
|
|
GdbServerStarter *starter = new GdbServerStarter(dlg, true);
|
|
|
|
|
starter->run();
|
2012-03-21 17:54:56 +01:00
|
|
|
}
|
|
|
|
|
|
2012-08-06 12:22:35 +02:00
|
|
|
void DebuggerPluginPrivate::attachToRunningApplication()
|
2012-03-21 17:54:56 +01:00
|
|
|
{
|
2015-02-25 16:30:23 +01:00
|
|
|
auto kitChooser = new DebuggerKitChooser(DebuggerKitChooser::LocalDebugging);
|
2012-08-08 12:03:07 +02:00
|
|
|
|
2015-02-25 16:30:23 +01:00
|
|
|
auto dlg = new DeviceProcessesDialog(kitChooser, ICore::dialogParent());
|
2015-02-03 23:58:49 +02:00
|
|
|
dlg->addAcceptButton(DeviceProcessesDialog::tr("&Attach to Process"));
|
2012-08-08 12:03:07 +02:00
|
|
|
dlg->showAllDevices();
|
|
|
|
|
if (dlg->exec() == QDialog::Rejected) {
|
|
|
|
|
delete dlg;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *kit = kitChooser->currentKit();
|
|
|
|
|
QTC_ASSERT(kit, return);
|
|
|
|
|
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
2012-08-08 12:03:07 +02:00
|
|
|
QTC_ASSERT(device, return);
|
2013-09-20 16:48:01 +02:00
|
|
|
|
2015-02-25 16:30:23 +01:00
|
|
|
if (device->type() == PE::DESKTOP_DEVICE_TYPE) {
|
|
|
|
|
attachToRunningProcess(kit, dlg->currentProcess(), false);
|
2013-09-20 16:48:01 +02:00
|
|
|
} else {
|
2015-02-25 16:30:23 +01:00
|
|
|
GdbServerStarter *starter = new GdbServerStarter(dlg, true);
|
|
|
|
|
starter->run();
|
2013-09-20 16:48:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPluginPrivate::attachToUnstartedApplicationDialog()
|
|
|
|
|
{
|
2015-02-25 16:30:23 +01:00
|
|
|
auto dlg = new UnstartedAppWatcherDialog(ICore::dialogParent());
|
2013-09-20 16:48:01 +02:00
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(dlg, &QDialog::finished, dlg, &QObject::deleteLater);
|
2015-02-25 16:30:23 +01:00
|
|
|
connect(dlg, &UnstartedAppWatcherDialog::processFound, this, [this, dlg] {
|
|
|
|
|
DebuggerRunControl *rc = attachToRunningProcess(dlg->currentKit(),
|
|
|
|
|
dlg->currentProcess(),
|
|
|
|
|
dlg->continueOnAttach());
|
|
|
|
|
if (!rc)
|
|
|
|
|
return;
|
2013-09-20 16:48:01 +02:00
|
|
|
|
2015-02-25 16:30:23 +01:00
|
|
|
if (dlg->hideOnAttach())
|
|
|
|
|
connect(rc, &RunControl::finished, dlg, &UnstartedAppWatcherDialog::startWatching);
|
|
|
|
|
});
|
2013-09-20 16:48:01 +02:00
|
|
|
|
2015-02-25 16:30:23 +01:00
|
|
|
dlg->show();
|
2013-09-20 16:48:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DebuggerRunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit,
|
2015-02-25 16:30:23 +01:00
|
|
|
DeviceProcessItem process, bool contAfterAttach)
|
2013-09-20 16:48:01 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(kit, return 0);
|
|
|
|
|
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
|
|
|
|
QTC_ASSERT(device, return 0);
|
2012-08-08 12:03:07 +02:00
|
|
|
if (process.pid == 0) {
|
2015-02-25 16:30:23 +01:00
|
|
|
AsynchronousMessageBox::warning(tr("Warning"), tr("Cannot attach to process with PID 0"));
|
2013-09-20 16:48:01 +02:00
|
|
|
return 0;
|
2012-08-08 12:03:07 +02:00
|
|
|
}
|
|
|
|
|
|
2012-11-02 15:33:06 +01:00
|
|
|
bool isWindows = false;
|
2012-12-30 11:37:50 +01:00
|
|
|
if (const ToolChain *tc = ToolChainKitInformation::toolChain(kit))
|
|
|
|
|
isWindows = tc->targetAbi().os() == Abi::WindowsOS;
|
2012-11-02 15:33:06 +01:00
|
|
|
if (isWindows && isWinProcessBeingDebugged(process.pid)) {
|
2015-02-03 23:58:49 +02:00
|
|
|
AsynchronousMessageBox::warning(tr("Process Already Under Debugger Control"),
|
2012-08-08 12:03:07 +02:00
|
|
|
tr("The process %1 is already under the control of a debugger.\n"
|
|
|
|
|
"Qt Creator cannot attach to it.").arg(process.pid));
|
2013-09-20 16:48:01 +02:00
|
|
|
return 0;
|
2012-08-08 12:03:07 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-20 16:48:01 +02:00
|
|
|
if (device->type() != PE::DESKTOP_DEVICE_TYPE) {
|
2015-02-03 23:58:49 +02:00
|
|
|
AsynchronousMessageBox::warning(tr("Not a Desktop Device Type"),
|
2014-03-13 08:39:22 +01:00
|
|
|
tr("It is only possible to attach to a locally running process."));
|
2013-09-20 16:48:01 +02:00
|
|
|
return 0;
|
2012-08-08 12:03:07 +02:00
|
|
|
}
|
2013-09-20 16:48:01 +02:00
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerRunParameters rp;
|
|
|
|
|
rp.attachPID = process.pid;
|
|
|
|
|
rp.displayName = tr("Process %1").arg(process.pid);
|
2016-01-28 10:31:24 +01:00
|
|
|
rp.inferior.executable = process.exe;
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.startMode = AttachExternal;
|
|
|
|
|
rp.closeMode = DetachAtClose;
|
|
|
|
|
rp.continueAfterAttach = contAfterAttach;
|
2015-06-24 08:26:35 +02:00
|
|
|
return createAndScheduleRun(rp, kit);
|
2011-12-05 17:21:48 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
void DebuggerPlugin::attachExternalApplication(RunControl *rc)
|
2012-08-30 10:26:09 +02:00
|
|
|
{
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerRunParameters rp;
|
|
|
|
|
rp.attachPID = rc->applicationProcessHandle().pid();
|
|
|
|
|
rp.displayName = tr("Process %1").arg(rp.attachPID);
|
|
|
|
|
rp.startMode = AttachExternal;
|
|
|
|
|
rp.closeMode = DetachAtClose;
|
|
|
|
|
rp.toolChainAbi = rc->abi();
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *kit = 0;
|
2012-08-31 15:06:07 +02:00
|
|
|
if (const RunConfiguration *runConfiguration = rc->runConfiguration())
|
|
|
|
|
if (const Target *target = runConfiguration->target())
|
2012-09-03 18:31:44 +02:00
|
|
|
kit = target->kit();
|
2015-06-24 08:26:35 +02:00
|
|
|
createAndScheduleRun(rp, kit);
|
2012-08-30 10:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-13 17:26:02 +02:00
|
|
|
void DebuggerPluginPrivate::attachToQmlPort()
|
|
|
|
|
{
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerRunParameters rp;
|
2013-10-16 17:11:39 +02:00
|
|
|
AttachToQmlPortDialog dlg(ICore::mainWindow());
|
2011-09-13 17:26:02 +02:00
|
|
|
|
2013-09-04 18:39:43 +02:00
|
|
|
const QVariant qmlServerPort = configValue("LastQmlServerPort");
|
2012-08-15 16:20:11 +02:00
|
|
|
if (qmlServerPort.isValid())
|
2011-09-13 17:26:02 +02:00
|
|
|
dlg.setPort(qmlServerPort.toInt());
|
2012-08-15 16:20:11 +02:00
|
|
|
else
|
2015-05-27 13:59:56 +02:00
|
|
|
dlg.setPort(rp.qmlServerPort);
|
2011-09-13 17:26:02 +02:00
|
|
|
|
2013-09-04 18:39:43 +02:00
|
|
|
const Id kitId = Id::fromSetting(configValue("LastProfile"));
|
2012-09-03 18:31:44 +02:00
|
|
|
if (kitId.isValid())
|
2013-03-19 12:44:33 +01:00
|
|
|
dlg.setKitId(kitId);
|
2011-10-11 15:21:00 +02:00
|
|
|
|
2011-09-13 17:26:02 +02:00
|
|
|
if (dlg.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *kit = dlg.kit();
|
2014-10-20 14:03:47 +02:00
|
|
|
QTC_ASSERT(kit, return);
|
2013-09-04 18:39:43 +02:00
|
|
|
setConfigValue("LastQmlServerPort", dlg.port());
|
|
|
|
|
setConfigValue("LastProfile", kit->id().toSetting());
|
2011-09-13 17:26:02 +02:00
|
|
|
|
2013-04-26 10:28:26 +02:00
|
|
|
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
|
|
|
|
|
if (device) {
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.connParams = device->sshParameters();
|
|
|
|
|
rp.qmlServerAddress = device->qmlProfilerHost();
|
2013-04-26 10:28:26 +02:00
|
|
|
}
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.qmlServerPort = dlg.port();
|
|
|
|
|
rp.startMode = AttachToRemoteProcess;
|
|
|
|
|
rp.closeMode = KillAtClose;
|
|
|
|
|
rp.languages = QmlLanguage;
|
|
|
|
|
rp.masterEngineType = QmlEngineType;
|
2011-10-28 13:25:58 +02:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// get files from all the projects in the session
|
|
|
|
|
//
|
2013-09-05 11:46:07 +02:00
|
|
|
QList<Project *> projects = SessionManager::projects();
|
|
|
|
|
if (Project *startupProject = SessionManager::startupProject()) {
|
2011-10-28 13:25:58 +02:00
|
|
|
// startup project first
|
2013-09-05 11:46:07 +02:00
|
|
|
projects.removeOne(startupProject);
|
2011-10-28 13:25:58 +02:00
|
|
|
projects.insert(0, startupProject);
|
|
|
|
|
}
|
|
|
|
|
QStringList sourceFiles;
|
|
|
|
|
foreach (Project *project, projects)
|
2016-01-08 16:56:35 +01:00
|
|
|
sourceFiles << project->files(Project::SourceFiles);
|
2011-10-28 13:25:58 +02:00
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.projectSourceDirectory =
|
2014-05-02 12:53:36 +02:00
|
|
|
!projects.isEmpty() ? projects.first()->projectDirectory().toString() : QString();
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.projectSourceFiles = sourceFiles;
|
2015-06-24 08:26:35 +02:00
|
|
|
createAndScheduleRun(rp, kit);
|
2011-09-13 17:26:02 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::enableReverseDebuggingTriggered(const QVariant &value)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_reverseToolButton, return);
|
|
|
|
|
m_reverseToolButton->setVisible(value.toBool());
|
2011-02-03 14:08:01 +01:00
|
|
|
m_reverseDirectionAction->setChecked(false);
|
|
|
|
|
m_reverseDirectionAction->setEnabled(value.toBool());
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-09-22 12:25:42 +02:00
|
|
|
|
2011-02-08 13:48:04 +01:00
|
|
|
void DebuggerPluginPrivate::runScheduled()
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2015-06-24 08:26:35 +02:00
|
|
|
for (int i = 0, n = m_scheduledStarts.size(); i != n; ++i)
|
|
|
|
|
createAndScheduleRun(m_scheduledStarts.at(i).first, m_scheduledStarts.at(i).second);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2011-01-04 15:37:17 +01:00
|
|
|
void DebuggerPluginPrivate::editorOpened(IEditor *editor)
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2014-09-30 16:54:26 +02:00
|
|
|
if (auto widget = qobject_cast<TextEditorWidget *>(editor->widget())) {
|
|
|
|
|
connect(widget, &TextEditorWidget::markRequested,
|
|
|
|
|
this, &DebuggerPluginPrivate::requestMark);
|
|
|
|
|
|
|
|
|
|
connect(widget, &TextEditorWidget::markContextMenuRequested,
|
|
|
|
|
this, &DebuggerPluginPrivate::requestContextMenu);
|
|
|
|
|
}
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-09-22 12:25:42 +02:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
void DebuggerPluginPrivate::updateBreakMenuItem(IEditor *editor)
|
2011-02-04 14:36:50 +01:00
|
|
|
{
|
2014-07-23 19:10:38 +02:00
|
|
|
BaseTextEditor *textEditor = qobject_cast<BaseTextEditor *>(editor);
|
2011-02-04 14:36:50 +01:00
|
|
|
m_breakAction->setEnabled(textEditor != 0);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-30 16:54:26 +02:00
|
|
|
void DebuggerPluginPrivate::requestContextMenu(TextEditorWidget *widget,
|
2010-12-02 13:20:06 +01:00
|
|
|
int lineNumber, QMenu *menu)
|
|
|
|
|
{
|
2015-01-10 01:07:01 +01:00
|
|
|
Breakpoint bp;
|
2014-09-30 16:54:26 +02:00
|
|
|
TextDocument *document = widget->textDocument();
|
2015-07-20 09:37:54 +02:00
|
|
|
|
|
|
|
|
ContextData args = getLocationContext(document, lineNumber);
|
|
|
|
|
if (args.type == LocationByAddress) {
|
2010-12-02 13:20:06 +01:00
|
|
|
BreakpointResponse needle;
|
|
|
|
|
needle.type = BreakpointByAddress;
|
2015-07-20 09:37:54 +02:00
|
|
|
needle.address = args.address;
|
2010-12-02 13:20:06 +01:00
|
|
|
needle.lineNumber = -1;
|
2015-01-10 01:07:01 +01:00
|
|
|
bp = breakHandler()->findSimilarBreakpoint(needle);
|
2015-07-20 09:37:54 +02:00
|
|
|
} else if (args.type == LocationByFile) {
|
|
|
|
|
bp = breakHandler()->findBreakpointByFileAndLine(args.fileName, lineNumber);
|
2015-01-10 01:07:01 +01:00
|
|
|
if (!bp)
|
|
|
|
|
bp = breakHandler()->findBreakpointByFileAndLine(args.fileName, lineNumber, false);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-01-10 01:07:01 +01:00
|
|
|
if (bp) {
|
|
|
|
|
QString id = bp.id().toString();
|
|
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// Remove existing breakpoint.
|
2015-01-10 01:07:01 +01:00
|
|
|
auto act = menu->addAction(tr("Remove Breakpoint %1").arg(id));
|
|
|
|
|
connect(act, &QAction::triggered, [bp] { bp.removeBreakpoint(); });
|
2010-08-18 13:54:12 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// Enable/disable existing breakpoint.
|
2015-01-10 01:07:01 +01:00
|
|
|
if (bp.isEnabled()) {
|
|
|
|
|
act = menu->addAction(tr("Disable Breakpoint %1").arg(id));
|
|
|
|
|
connect(act, &QAction::triggered, [bp] { bp.setEnabled(false); });
|
2010-12-02 13:20:06 +01:00
|
|
|
} else {
|
2015-01-10 01:07:01 +01:00
|
|
|
act = menu->addAction(tr("Enable Breakpoint %1").arg(id));
|
|
|
|
|
connect(act, &QAction::triggered, [bp] { bp.setEnabled(true); });
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-08-26 16:02:41 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// Edit existing breakpoint.
|
2015-01-10 01:07:01 +01:00
|
|
|
act = menu->addAction(tr("Edit Breakpoint %1...").arg(id));
|
|
|
|
|
connect(act, &QAction::triggered, [bp] {
|
|
|
|
|
BreakTreeView::editBreakpoint(bp, ICore::dialogParent());
|
|
|
|
|
});
|
|
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
} else {
|
|
|
|
|
// Handle non-existing breakpoint.
|
2011-02-23 10:16:11 +01:00
|
|
|
const QString text = args.address
|
|
|
|
|
? tr("Set Breakpoint at 0x%1").arg(args.address, 0, 16)
|
2012-03-20 18:05:12 +01:00
|
|
|
: tr("Set Breakpoint at Line %1").arg(lineNumber);
|
2015-01-10 01:07:01 +01:00
|
|
|
auto act = menu->addAction(text);
|
2015-07-20 09:37:54 +02:00
|
|
|
act->setEnabled(args.isValid());
|
2015-01-10 01:07:01 +01:00
|
|
|
connect(act, &QAction::triggered, [this, args] {
|
|
|
|
|
breakpointSetMarginActionTriggered(false, args);
|
|
|
|
|
});
|
|
|
|
|
|
2011-06-27 10:37:57 +02:00
|
|
|
// Message trace point
|
|
|
|
|
const QString tracePointText = args.address
|
|
|
|
|
? tr("Set Message Tracepoint at 0x%1...").arg(args.address, 0, 16)
|
2012-03-20 18:05:12 +01:00
|
|
|
: tr("Set Message Tracepoint at Line %1...").arg(lineNumber);
|
2015-01-10 01:07:01 +01:00
|
|
|
act = menu->addAction(tracePointText);
|
2015-07-20 09:37:54 +02:00
|
|
|
act->setEnabled(args.isValid());
|
2015-01-10 01:07:01 +01:00
|
|
|
connect(act, &QAction::triggered, [this, args] {
|
|
|
|
|
breakpointSetMarginActionTriggered(true, args);
|
|
|
|
|
});
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2015-01-10 01:07:01 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// Run to, jump to line below in stopped state.
|
2015-07-20 09:37:54 +02:00
|
|
|
if (currentEngine()->state() == InferiorStopOk && args.isValid()) {
|
2010-12-02 13:20:06 +01:00
|
|
|
menu->addSeparator();
|
2012-01-12 20:28:17 +01:00
|
|
|
if (currentEngine()->hasCapability(RunToLineCapability)) {
|
2015-01-10 01:07:01 +01:00
|
|
|
auto act = menu->addAction(args.address
|
2011-04-01 19:47:39 +02:00
|
|
|
? DebuggerEngine::tr("Run to Address 0x%1").arg(args.address, 0, 16)
|
2015-01-10 01:07:01 +01:00
|
|
|
: DebuggerEngine::tr("Run to Line %1").arg(args.lineNumber));
|
|
|
|
|
connect(act, &QAction::triggered, [this, args] {
|
|
|
|
|
currentEngine()->executeRunToLine(args);
|
|
|
|
|
});
|
2011-04-01 19:47:39 +02:00
|
|
|
}
|
2012-01-12 20:28:17 +01:00
|
|
|
if (currentEngine()->hasCapability(JumpToLineCapability)) {
|
2015-01-10 01:07:01 +01:00
|
|
|
auto act = menu->addAction(args.address
|
2011-02-23 10:16:11 +01:00
|
|
|
? DebuggerEngine::tr("Jump to Address 0x%1").arg(args.address, 0, 16)
|
2015-01-10 01:07:01 +01:00
|
|
|
: DebuggerEngine::tr("Jump to Line %1").arg(args.lineNumber));
|
|
|
|
|
connect(act, &QAction::triggered, [this, args] {
|
|
|
|
|
currentEngine()->executeJumpToLine(args);
|
|
|
|
|
});
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2012-02-01 17:44:07 +01:00
|
|
|
// Disassemble current function in stopped state.
|
2015-02-18 17:07:40 +01:00
|
|
|
if (currentEngine()->hasCapability(DisassemblerCapability)) {
|
2012-02-01 17:44:07 +01:00
|
|
|
StackFrame frame;
|
2015-02-18 17:07:40 +01:00
|
|
|
frame.function = cppFunctionAt(args.fileName, lineNumber, 1);
|
2012-02-01 17:44:07 +01:00
|
|
|
frame.line = 42; // trick gdb into mixed mode.
|
|
|
|
|
if (!frame.function.isEmpty()) {
|
2012-03-20 18:05:12 +01:00
|
|
|
const QString text = tr("Disassemble Function \"%1\"")
|
|
|
|
|
.arg(frame.function);
|
2015-02-18 17:07:40 +01:00
|
|
|
auto act = new QAction(text, menu);
|
|
|
|
|
connect(act, &QAction::triggered, [this, frame] {
|
|
|
|
|
currentEngine()->openDisassemblerView(Location(frame));
|
|
|
|
|
});
|
|
|
|
|
menu->addAction(act);
|
2012-02-01 17:44:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
}
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-07-20 09:37:54 +02:00
|
|
|
void DebuggerPluginPrivate::toggleBreakpoint(const ContextData &location, const QString &tracePointMessage)
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2015-07-20 09:37:54 +02:00
|
|
|
QTC_ASSERT(location.isValid(), return);
|
2010-12-02 13:20:06 +01:00
|
|
|
BreakHandler *handler = m_breakHandler;
|
2015-07-20 09:37:54 +02:00
|
|
|
Breakpoint bp;
|
|
|
|
|
if (location.type == LocationByFile) {
|
|
|
|
|
bp = handler->findBreakpointByFileAndLine(location.fileName, location.lineNumber, true);
|
|
|
|
|
if (!bp)
|
|
|
|
|
bp = handler->findBreakpointByFileAndLine(location.fileName, location.lineNumber, false);
|
|
|
|
|
} else if (location.type == LocationByAddress) {
|
|
|
|
|
bp = handler->findBreakpointByAddress(location.address);
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-01-10 01:07:01 +01:00
|
|
|
if (bp) {
|
|
|
|
|
bp.removeBreakpoint();
|
2010-12-02 13:20:06 +01:00
|
|
|
} else {
|
2015-07-20 09:37:54 +02:00
|
|
|
BreakpointParameters data;
|
|
|
|
|
if (location.type == LocationByFile) {
|
|
|
|
|
data.type = BreakpointByFileAndLine;
|
|
|
|
|
if (boolSetting(BreakpointsFullPathByDefault))
|
|
|
|
|
data.pathUsage = BreakpointUseFullPath;
|
|
|
|
|
data.tracepoint = !tracePointMessage.isEmpty();
|
|
|
|
|
data.message = tracePointMessage;
|
|
|
|
|
data.fileName = location.fileName;
|
|
|
|
|
data.lineNumber = location.lineNumber;
|
|
|
|
|
} else if (location.type == LocationByAddress) {
|
|
|
|
|
data.type = BreakpointByAddress;
|
|
|
|
|
data.tracepoint = !tracePointMessage.isEmpty();
|
|
|
|
|
data.message = tracePointMessage;
|
|
|
|
|
data.address = location.address;
|
|
|
|
|
}
|
2010-12-02 13:20:06 +01:00
|
|
|
handler->appendBreakpoint(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-07-20 09:37:54 +02:00
|
|
|
void DebuggerPluginPrivate::toggleBreakpointHelper()
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2015-07-20 09:37:54 +02:00
|
|
|
BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor();
|
|
|
|
|
QTC_ASSERT(textEditor, return);
|
|
|
|
|
const int lineNumber = textEditor->currentLine();
|
|
|
|
|
ContextData location = getLocationContext(textEditor->textDocument(), lineNumber);
|
|
|
|
|
if (location.isValid())
|
|
|
|
|
toggleBreakpoint(location);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-11-09 10:23:10 +01:00
|
|
|
|
2014-09-30 16:54:26 +02:00
|
|
|
void DebuggerPluginPrivate::requestMark(TextEditorWidget *widget, int lineNumber,
|
2014-09-30 17:45:48 +02:00
|
|
|
TextMarkRequestKind kind)
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2015-07-20 09:37:54 +02:00
|
|
|
if (kind == BreakpointRequest) {
|
|
|
|
|
ContextData location = getLocationContext(widget->textDocument(), lineNumber);
|
|
|
|
|
if (location.isValid())
|
|
|
|
|
toggleBreakpoint(location);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
2010-12-01 15:41:08 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// If updateEngine is set, the engine will update its threads/modules and so forth.
|
|
|
|
|
void DebuggerPluginPrivate::displayDebugger(DebuggerEngine *engine, bool updateEngine)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(engine, return);
|
|
|
|
|
disconnectEngine();
|
|
|
|
|
connectEngine(engine);
|
|
|
|
|
if (updateEngine)
|
|
|
|
|
engine->updateAll();
|
|
|
|
|
engine->updateViews();
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
|
|
|
|
|
{
|
|
|
|
|
if (!engine)
|
|
|
|
|
engine = dummyEngine();
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
if (m_currentEngine == engine)
|
|
|
|
|
return;
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-14 12:21:29 +01:00
|
|
|
if (m_currentEngine)
|
|
|
|
|
m_currentEngine->resetLocation();
|
2010-12-02 13:20:06 +01:00
|
|
|
m_currentEngine = engine;
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2014-06-04 14:45:10 +02:00
|
|
|
m_localsView->setModel(engine->watchModel());
|
|
|
|
|
m_modulesView->setModel(engine->modulesModel());
|
|
|
|
|
m_registerView->setModel(engine->registerModel());
|
|
|
|
|
m_returnView->setModel(engine->watchModel());
|
|
|
|
|
m_sourceFilesView->setModel(engine->sourceFilesModel());
|
|
|
|
|
m_stackView->setModel(engine->stackModel());
|
|
|
|
|
m_threadsView->setModel(engine->threadsModel());
|
|
|
|
|
m_watchersView->setModel(engine->watchModel());
|
|
|
|
|
m_inspectorView->setModel(engine->watchModel());
|
2011-10-06 17:38:28 +02:00
|
|
|
|
2015-03-18 13:28:45 +01:00
|
|
|
engine->watchHandler()->resetWatchers();
|
2015-08-17 13:13:08 +02:00
|
|
|
m_localsView->hideProgressIndicator();
|
2015-03-18 13:28:45 +01:00
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
m_mainWindow->setEngineDebugLanguages(engine->runParameters().languages);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-11-12 20:18:29 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
static void changeFontSize(QWidget *widget, qreal size)
|
|
|
|
|
{
|
|
|
|
|
QFont font = widget->font();
|
|
|
|
|
font.setPointSizeF(size);
|
|
|
|
|
widget->setFont(font);
|
|
|
|
|
}
|
2009-06-04 16:06:12 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::fontSettingsChanged
|
2015-02-03 23:58:49 +02:00
|
|
|
(const FontSettings &settings)
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2011-04-01 12:01:14 +02:00
|
|
|
if (!boolSetting(FontSizeFollowsEditor))
|
|
|
|
|
return;
|
2010-12-02 13:20:06 +01:00
|
|
|
qreal size = settings.fontZoom() * settings.fontSize() / 100.;
|
|
|
|
|
changeFontSize(m_breakWindow, size);
|
|
|
|
|
changeFontSize(m_logWindow, size);
|
|
|
|
|
changeFontSize(m_localsWindow, size);
|
|
|
|
|
changeFontSize(m_modulesWindow, size);
|
|
|
|
|
//changeFontSize(m_consoleWindow, size);
|
|
|
|
|
changeFontSize(m_registerWindow, size);
|
|
|
|
|
changeFontSize(m_returnWindow, size);
|
|
|
|
|
changeFontSize(m_sourceFilesWindow, size);
|
|
|
|
|
changeFontSize(m_stackWindow, size);
|
|
|
|
|
changeFontSize(m_threadsWindow, size);
|
|
|
|
|
changeFontSize(m_watchersWindow, size);
|
2012-04-18 14:20:54 +02:00
|
|
|
changeFontSize(m_inspectorWindow, size);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::cleanupViews()
|
|
|
|
|
{
|
2011-02-03 14:08:01 +01:00
|
|
|
m_reverseDirectionAction->setChecked(false);
|
|
|
|
|
m_reverseDirectionAction->setEnabled(false);
|
2010-12-01 15:41:08 +01:00
|
|
|
|
2014-11-17 10:19:18 +01:00
|
|
|
const bool closeSource = boolSetting(CloseSourceBuffersOnExit);
|
|
|
|
|
const bool closeMemory = boolSetting(CloseMemoryBuffersOnExit);
|
2009-03-02 15:14:12 +01:00
|
|
|
|
2013-07-09 12:14:33 +02:00
|
|
|
QList<IDocument *> toClose;
|
2014-05-07 16:25:04 +02:00
|
|
|
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
2014-11-17 10:19:18 +01:00
|
|
|
const bool isMemory = document->property(Constants::OPENED_WITH_DISASSEMBLY).toBool();
|
2013-07-09 12:14:33 +02:00
|
|
|
if (document->property(Constants::OPENED_BY_DEBUGGER).toBool()) {
|
2012-06-12 13:29:37 +02:00
|
|
|
bool keepIt = true;
|
2014-11-17 10:19:18 +01:00
|
|
|
if (document->isModified())
|
2012-06-12 13:29:37 +02:00
|
|
|
keepIt = true;
|
2014-12-21 21:54:30 +02:00
|
|
|
else if (document->filePath().toString().contains(_("qeventdispatcher")))
|
2012-06-12 13:29:37 +02:00
|
|
|
keepIt = false;
|
2014-11-17 10:19:18 +01:00
|
|
|
else if (isMemory)
|
|
|
|
|
keepIt = !closeMemory;
|
2012-06-12 13:29:37 +02:00
|
|
|
else
|
2014-11-17 10:19:18 +01:00
|
|
|
keepIt = !closeSource;
|
2012-06-12 13:29:37 +02:00
|
|
|
|
|
|
|
|
if (keepIt)
|
2013-07-09 12:14:33 +02:00
|
|
|
document->setProperty(Constants::OPENED_BY_DEBUGGER, false);
|
2012-06-12 13:29:37 +02:00
|
|
|
else
|
2013-07-09 12:14:33 +02:00
|
|
|
toClose.append(document);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
2013-07-09 12:14:33 +02:00
|
|
|
EditorManager::closeDocuments(toClose);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-05-05 12:41:52 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::setBusyCursor(bool busy)
|
|
|
|
|
{
|
|
|
|
|
//STATE_DEBUG("BUSY FROM: " << m_busy << " TO: " << busy);
|
|
|
|
|
if (busy == m_busy)
|
|
|
|
|
return;
|
|
|
|
|
m_busy = busy;
|
|
|
|
|
QCursor cursor(busy ? Qt::BusyCursor : Qt::ArrowCursor);
|
|
|
|
|
m_breakWindow->setCursor(cursor);
|
|
|
|
|
//m_consoleWindow->setCursor(cursor);
|
|
|
|
|
m_localsWindow->setCursor(cursor);
|
|
|
|
|
m_modulesWindow->setCursor(cursor);
|
|
|
|
|
m_logWindow->setCursor(cursor);
|
|
|
|
|
m_registerWindow->setCursor(cursor);
|
|
|
|
|
m_returnWindow->setCursor(cursor);
|
|
|
|
|
m_sourceFilesWindow->setCursor(cursor);
|
|
|
|
|
m_stackWindow->setCursor(cursor);
|
|
|
|
|
m_threadsWindow->setCursor(cursor);
|
|
|
|
|
m_watchersWindow->setCursor(cursor);
|
|
|
|
|
m_snapshotWindow->setCursor(cursor);
|
|
|
|
|
}
|
2009-05-07 17:11:19 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::setInitialState()
|
|
|
|
|
{
|
|
|
|
|
m_watchersWindow->setVisible(false);
|
|
|
|
|
m_returnWindow->setVisible(false);
|
|
|
|
|
setBusyCursor(false);
|
2011-02-03 14:08:01 +01:00
|
|
|
m_reverseDirectionAction->setChecked(false);
|
|
|
|
|
m_reverseDirectionAction->setEnabled(false);
|
2014-11-07 13:50:09 +01:00
|
|
|
m_toolTipManager.closeAllToolTips();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-08-08 13:09:31 +02:00
|
|
|
m_startAndDebugApplicationAction->setEnabled(true);
|
2011-09-13 17:26:02 +02:00
|
|
|
m_attachToQmlPortAction->setEnabled(true);
|
2011-12-05 17:21:48 +01:00
|
|
|
m_attachToCoreAction->setEnabled(true);
|
|
|
|
|
m_attachToRemoteServerAction->setEnabled(true);
|
2012-08-06 12:22:35 +02:00
|
|
|
m_attachToRunningApplication->setEnabled(true);
|
2013-09-20 16:48:01 +02:00
|
|
|
m_attachToUnstartedApplication->setEnabled(true);
|
2010-12-02 13:20:06 +01:00
|
|
|
m_detachAction->setEnabled(false);
|
2010-07-22 10:23:27 +02:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
m_watchAction1->setEnabled(true);
|
|
|
|
|
m_watchAction2->setEnabled(true);
|
2011-02-04 14:36:50 +01:00
|
|
|
m_breakAction->setEnabled(false);
|
2011-02-03 14:08:01 +01:00
|
|
|
//m_snapshotAction->setEnabled(false);
|
2010-12-02 13:20:06 +01:00
|
|
|
action(OperateByInstruction)->setEnabled(false);
|
2010-10-05 12:47:23 +02:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
m_exitAction->setEnabled(false);
|
2011-10-31 16:15:48 +01:00
|
|
|
m_abortAction->setEnabled(false);
|
2014-06-05 17:22:51 +02:00
|
|
|
m_resetAction->setEnabled(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-02-04 14:36:50 +01:00
|
|
|
m_interruptAction->setEnabled(false);
|
|
|
|
|
m_continueAction->setEnabled(false);
|
|
|
|
|
|
2011-05-02 18:22:32 +02:00
|
|
|
m_stepAction->setEnabled(true);
|
2011-02-03 14:08:01 +01:00
|
|
|
m_stepOutAction->setEnabled(false);
|
|
|
|
|
m_runToLineAction->setEnabled(false);
|
|
|
|
|
m_runToSelectedFunctionAction->setEnabled(true);
|
|
|
|
|
m_returnFromFunctionAction->setEnabled(false);
|
|
|
|
|
m_jumpToLineAction->setEnabled(false);
|
2011-05-02 18:22:32 +02:00
|
|
|
m_nextAction->setEnabled(true);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
action(AutoDerefPointers)->setEnabled(true);
|
|
|
|
|
action(ExpandStack)->setEnabled(false);
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(engine, return);
|
2014-06-04 14:45:10 +02:00
|
|
|
QTC_ASSERT(m_watchersView->model(), return);
|
|
|
|
|
QTC_ASSERT(m_returnView->model(), return);
|
2010-12-02 13:20:06 +01:00
|
|
|
QTC_ASSERT(!engine->isSlaveEngine(), return);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-10-19 16:37:57 +02:00
|
|
|
m_threadBox->setCurrentIndex(engine->threadsHandler()->currentThreadIndex());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-01-04 16:05:53 +01:00
|
|
|
const DebuggerState state = engine->state();
|
2012-11-26 20:43:43 +02:00
|
|
|
//showMessage(QString::fromLatin1("PLUGIN SET STATE: ")
|
2011-01-04 16:05:53 +01:00
|
|
|
// + DebuggerEngine::stateName(state), LogStatus);
|
|
|
|
|
//qDebug() << "PLUGIN SET STATE: " << state;
|
2010-03-18 10:56:25 +01:00
|
|
|
|
2011-01-04 16:05:53 +01:00
|
|
|
static DebuggerState previousState = DebuggerNotReady;
|
|
|
|
|
if (state == previousState)
|
2010-12-02 13:20:06 +01:00
|
|
|
return;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-01-04 16:05:53 +01:00
|
|
|
bool actionsEnabled = DebuggerEngine::debuggerActionsEnabled(state);
|
2010-12-02 13:20:06 +01:00
|
|
|
|
2011-01-04 16:05:53 +01:00
|
|
|
if (state == DebuggerNotReady) {
|
2011-08-03 18:57:37 +02:00
|
|
|
QTC_ASSERT(false, /* We use the Core's m_debugAction here */);
|
2010-12-02 13:20:06 +01:00
|
|
|
// F5 starts debugging. It is "startable".
|
2011-02-03 14:08:01 +01:00
|
|
|
m_interruptAction->setEnabled(false);
|
|
|
|
|
m_continueAction->setEnabled(false);
|
|
|
|
|
m_exitAction->setEnabled(false);
|
2011-08-03 18:57:37 +02:00
|
|
|
m_startAction->setEnabled(true);
|
2011-10-25 18:23:37 +08:00
|
|
|
m_debugWithoutDeployAction->setEnabled(true);
|
2015-02-03 23:58:49 +02:00
|
|
|
setProxyAction(m_visibleStartAction, Id(Constants::DEBUG));
|
2011-08-03 18:57:37 +02:00
|
|
|
m_hiddenStopAction->setAction(m_undisturbableAction);
|
2011-01-04 16:05:53 +01:00
|
|
|
} else if (state == InferiorStopOk) {
|
2010-12-02 13:20:06 +01:00
|
|
|
// F5 continues, Shift-F5 kills. It is "continuable".
|
2011-02-03 14:08:01 +01:00
|
|
|
m_interruptAction->setEnabled(false);
|
|
|
|
|
m_continueAction->setEnabled(true);
|
|
|
|
|
m_exitAction->setEnabled(true);
|
2011-08-03 18:57:37 +02:00
|
|
|
m_startAction->setEnabled(false);
|
2011-10-25 18:23:37 +08:00
|
|
|
m_debugWithoutDeployAction->setEnabled(false);
|
2015-02-03 23:58:49 +02:00
|
|
|
setProxyAction(m_visibleStartAction, Id(Constants::CONTINUE));
|
2011-08-03 18:57:37 +02:00
|
|
|
m_hiddenStopAction->setAction(m_exitAction);
|
2012-05-14 16:09:12 +02:00
|
|
|
m_localsAndExpressionsWindow->setShowLocals(true);
|
2011-01-04 16:05:53 +01:00
|
|
|
} else if (state == InferiorRunOk) {
|
2010-12-02 13:20:06 +01:00
|
|
|
// Shift-F5 interrupts. It is also "interruptible".
|
2011-02-03 14:08:01 +01:00
|
|
|
m_interruptAction->setEnabled(true);
|
|
|
|
|
m_continueAction->setEnabled(false);
|
2011-08-03 18:57:37 +02:00
|
|
|
m_exitAction->setEnabled(true);
|
|
|
|
|
m_startAction->setEnabled(false);
|
2011-10-25 18:23:37 +08:00
|
|
|
m_debugWithoutDeployAction->setEnabled(false);
|
2015-02-03 23:58:49 +02:00
|
|
|
setProxyAction(m_visibleStartAction, Id(Constants::INTERRUPT));
|
2011-08-03 18:57:37 +02:00
|
|
|
m_hiddenStopAction->setAction(m_interruptAction);
|
2012-05-14 16:09:12 +02:00
|
|
|
m_localsAndExpressionsWindow->setShowLocals(false);
|
2015-12-12 23:02:43 +02:00
|
|
|
activateDebugMode();
|
2011-01-04 16:05:53 +01:00
|
|
|
} else if (state == DebuggerFinished) {
|
2014-07-02 09:53:22 +02:00
|
|
|
Project *project = SessionManager::startupProject();
|
2015-06-29 10:36:29 +03:00
|
|
|
const bool canRun = ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
2010-12-02 13:20:06 +01:00
|
|
|
// We don't want to do anything anymore.
|
2011-02-03 14:08:01 +01:00
|
|
|
m_interruptAction->setEnabled(false);
|
|
|
|
|
m_continueAction->setEnabled(false);
|
|
|
|
|
m_exitAction->setEnabled(false);
|
2014-07-02 09:53:22 +02:00
|
|
|
m_startAction->setEnabled(canRun);
|
|
|
|
|
m_debugWithoutDeployAction->setEnabled(canRun);
|
2015-02-03 23:58:49 +02:00
|
|
|
setProxyAction(m_visibleStartAction, Id(Constants::DEBUG));
|
2011-08-03 18:57:37 +02:00
|
|
|
m_hiddenStopAction->setAction(m_undisturbableAction);
|
2010-12-02 13:20:06 +01:00
|
|
|
m_codeModelSnapshot = CPlusPlus::Snapshot();
|
|
|
|
|
setBusyCursor(false);
|
|
|
|
|
cleanupViews();
|
2011-01-04 16:05:53 +01:00
|
|
|
} else if (state == InferiorUnrunnable) {
|
2010-12-02 13:20:06 +01:00
|
|
|
// We don't want to do anything anymore.
|
2011-02-03 14:08:01 +01:00
|
|
|
m_interruptAction->setEnabled(false);
|
|
|
|
|
m_continueAction->setEnabled(false);
|
|
|
|
|
m_exitAction->setEnabled(true);
|
2011-08-03 18:57:37 +02:00
|
|
|
m_startAction->setEnabled(false);
|
2011-10-25 18:23:37 +08:00
|
|
|
m_debugWithoutDeployAction->setEnabled(false);
|
2012-01-11 19:29:01 +01:00
|
|
|
m_visibleStartAction->setAction(m_undisturbableAction);
|
|
|
|
|
m_hiddenStopAction->setAction(m_exitAction);
|
2012-05-14 16:03:44 +02:00
|
|
|
// show locals in core dumps
|
2012-05-14 16:09:12 +02:00
|
|
|
m_localsAndExpressionsWindow->setShowLocals(true);
|
2015-12-12 23:02:43 +02:00
|
|
|
activateDebugMode();
|
2010-12-02 13:20:06 +01:00
|
|
|
} else {
|
|
|
|
|
// Everything else is "undisturbable".
|
2011-02-03 14:08:01 +01:00
|
|
|
m_interruptAction->setEnabled(false);
|
|
|
|
|
m_continueAction->setEnabled(false);
|
|
|
|
|
m_exitAction->setEnabled(false);
|
2011-08-03 18:57:37 +02:00
|
|
|
m_startAction->setEnabled(false);
|
2011-10-25 18:23:37 +08:00
|
|
|
m_debugWithoutDeployAction->setEnabled(false);
|
2011-08-03 18:57:37 +02:00
|
|
|
m_visibleStartAction->setAction(m_undisturbableAction);
|
|
|
|
|
m_hiddenStopAction->setAction(m_undisturbableAction);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-03-18 10:56:25 +01:00
|
|
|
|
2012-08-08 13:09:31 +02:00
|
|
|
m_startAndDebugApplicationAction->setEnabled(true);
|
2011-09-13 17:26:02 +02:00
|
|
|
m_attachToQmlPortAction->setEnabled(true);
|
2011-12-05 17:21:48 +01:00
|
|
|
m_attachToCoreAction->setEnabled(true);
|
|
|
|
|
m_attachToRemoteServerAction->setEnabled(true);
|
2012-08-06 12:22:35 +02:00
|
|
|
m_attachToRunningApplication->setEnabled(true);
|
2013-09-20 16:48:01 +02:00
|
|
|
m_attachToUnstartedApplication->setEnabled(true);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-04-11 17:56:25 +02:00
|
|
|
m_threadBox->setEnabled(state == InferiorStopOk || state == InferiorUnrunnable);
|
2012-03-26 17:30:57 +02:00
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
const bool isCore = engine->runParameters().startMode == AttachCore;
|
2011-01-04 16:05:53 +01:00
|
|
|
const bool stopped = state == InferiorStopOk;
|
2010-12-02 13:20:06 +01:00
|
|
|
const bool detachable = stopped && !isCore;
|
|
|
|
|
m_detachAction->setEnabled(detachable);
|
2010-03-18 10:56:25 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
if (stopped)
|
2015-03-20 12:10:35 +01:00
|
|
|
QApplication::alert(m_mainWindow, 3000);
|
2010-02-15 16:02:41 +01:00
|
|
|
|
2012-01-12 20:28:17 +01:00
|
|
|
const bool canReverse = engine->hasCapability(ReverseSteppingCapability)
|
2010-12-02 13:20:06 +01:00
|
|
|
&& boolSetting(EnableReverseDebugging);
|
2011-02-03 14:08:01 +01:00
|
|
|
m_reverseDirectionAction->setEnabled(canReverse);
|
2010-03-18 10:56:25 +01:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
m_watchAction1->setEnabled(true);
|
|
|
|
|
m_watchAction2->setEnabled(true);
|
|
|
|
|
m_breakAction->setEnabled(true);
|
2009-05-25 17:19:42 +02:00
|
|
|
|
2012-01-12 20:28:17 +01:00
|
|
|
const bool canOperateByInstruction = engine->hasCapability(OperateByInstructionCapability)
|
2011-04-01 19:47:39 +02:00
|
|
|
&& (stopped || isCore);
|
|
|
|
|
action(OperateByInstruction)->setEnabled(canOperateByInstruction);
|
2010-03-18 10:56:25 +01:00
|
|
|
|
2011-10-31 16:15:48 +01:00
|
|
|
m_abortAction->setEnabled(state != DebuggerNotReady
|
2011-01-04 16:05:53 +01:00
|
|
|
&& state != DebuggerFinished);
|
2014-06-05 17:22:51 +02:00
|
|
|
m_resetAction->setEnabled((stopped || state == DebuggerNotReady)
|
|
|
|
|
&& engine->hasCapability(ResetInferiorCapability));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-05-02 18:22:32 +02:00
|
|
|
m_stepAction->setEnabled(stopped || state == DebuggerNotReady);
|
|
|
|
|
m_nextAction->setEnabled(stopped || state == DebuggerNotReady);
|
2011-07-18 17:23:42 +02:00
|
|
|
m_stepAction->setToolTip(QString());
|
|
|
|
|
m_nextAction->setToolTip(QString());
|
2011-05-02 18:22:32 +02:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
m_stepOutAction->setEnabled(stopped);
|
2012-01-12 20:28:17 +01:00
|
|
|
m_runToLineAction->setEnabled(stopped && engine->hasCapability(RunToLineCapability));
|
2011-02-03 14:08:01 +01:00
|
|
|
m_runToSelectedFunctionAction->setEnabled(stopped);
|
|
|
|
|
m_returnFromFunctionAction->
|
2012-01-12 20:28:17 +01:00
|
|
|
setEnabled(stopped && engine->hasCapability(ReturnFromFunctionCapability));
|
2010-03-18 10:56:25 +01:00
|
|
|
|
2012-01-12 20:28:17 +01:00
|
|
|
const bool canJump = stopped && engine->hasCapability(JumpToLineCapability);
|
2011-02-03 14:08:01 +01:00
|
|
|
m_jumpToLineAction->setEnabled(canJump);
|
2010-06-07 13:17:19 +02:00
|
|
|
|
2012-01-12 20:28:17 +01:00
|
|
|
const bool canDeref = actionsEnabled && engine->hasCapability(AutoDerefPointersCapability);
|
2010-12-02 13:20:06 +01:00
|
|
|
action(AutoDerefPointers)->setEnabled(canDeref);
|
|
|
|
|
action(AutoDerefPointers)->setEnabled(true);
|
|
|
|
|
action(ExpandStack)->setEnabled(actionsEnabled);
|
2010-03-18 10:56:25 +01:00
|
|
|
|
2011-01-04 16:05:53 +01:00
|
|
|
const bool notbusy = state == InferiorStopOk
|
|
|
|
|
|| state == DebuggerNotReady
|
|
|
|
|
|| state == DebuggerFinished
|
|
|
|
|
|| state == InferiorUnrunnable;
|
2010-12-02 13:20:06 +01:00
|
|
|
setBusyCursor(!notbusy);
|
|
|
|
|
}
|
2010-03-18 10:56:25 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::updateDebugActions()
|
|
|
|
|
{
|
2011-10-13 13:22:26 +02:00
|
|
|
//if we're currently debugging the actions are controlled by engine
|
|
|
|
|
if (m_currentEngine->state() != DebuggerNotReady)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
Project *project = SessionManager::startupProject();
|
2014-09-04 13:48:44 +02:00
|
|
|
QString whyNot;
|
2015-06-29 10:36:29 +03:00
|
|
|
const bool canRun = ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE, &whyNot);
|
2011-08-03 18:57:37 +02:00
|
|
|
m_startAction->setEnabled(canRun);
|
2014-09-04 13:48:44 +02:00
|
|
|
m_startAction->setToolTip(whyNot);
|
2011-10-25 18:23:37 +08:00
|
|
|
m_debugWithoutDeployAction->setEnabled(canRun);
|
2011-07-18 17:23:42 +02:00
|
|
|
|
|
|
|
|
// Step into/next: Start and break at 'main' unless a debugger is running.
|
|
|
|
|
if (m_snapshotHandler->currentIndex() < 0) {
|
2014-09-04 13:48:44 +02:00
|
|
|
QString toolTip;
|
|
|
|
|
const bool canRunAndBreakMain
|
2015-06-29 10:36:29 +03:00
|
|
|
= ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, &toolTip);
|
2011-07-18 17:23:42 +02:00
|
|
|
m_stepAction->setEnabled(canRunAndBreakMain);
|
|
|
|
|
m_nextAction->setEnabled(canRunAndBreakMain);
|
|
|
|
|
if (canRunAndBreakMain) {
|
|
|
|
|
QTC_ASSERT(project, return ; );
|
2014-04-17 14:09:47 +02:00
|
|
|
toolTip = tr("Start \"%1\" and break at function \"main()\"")
|
2011-07-18 17:23:42 +02:00
|
|
|
.arg(project->displayName());
|
|
|
|
|
}
|
|
|
|
|
m_stepAction->setToolTip(toolTip);
|
|
|
|
|
m_nextAction->setToolTip(toolTip);
|
|
|
|
|
}
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-01-31 15:17:53 +01:00
|
|
|
void DebuggerPluginPrivate::onCoreAboutToOpen()
|
|
|
|
|
{
|
2012-01-26 01:18:02 +01:00
|
|
|
m_mainWindow->onModeChanged(ModeManager::currentMode());
|
2011-01-31 15:17:53 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::onModeChanged(IMode *mode)
|
|
|
|
|
{
|
|
|
|
|
// FIXME: This one gets always called, even if switching between modes
|
|
|
|
|
// different then the debugger mode. E.g. Welcome and Help mode and
|
|
|
|
|
// also on shutdown.
|
2009-12-11 18:19:51 +01:00
|
|
|
|
2010-12-02 17:33:39 +01:00
|
|
|
m_mainWindow->onModeChanged(mode);
|
2010-02-08 09:13:21 +01:00
|
|
|
|
2012-05-07 18:28:03 +02:00
|
|
|
if (mode->id() != Constants::MODE_DEBUG) {
|
2014-11-07 13:50:09 +01:00
|
|
|
m_toolTipManager.leavingDebugMode();
|
2010-12-02 13:20:06 +01:00
|
|
|
return;
|
2011-02-11 15:00:13 +01:00
|
|
|
}
|
2010-02-08 09:13:21 +01:00
|
|
|
|
2012-05-08 09:43:14 +02:00
|
|
|
if (IEditor *editor = EditorManager::currentEditor())
|
|
|
|
|
editor->widget()->setFocus();
|
|
|
|
|
|
2014-11-07 13:50:09 +01:00
|
|
|
m_toolTipManager.debugModeEntered();
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-11-26 15:10:10 +01:00
|
|
|
|
2011-10-25 18:23:37 +08:00
|
|
|
void DebuggerPluginPrivate::updateDebugWithoutDeployMenu()
|
|
|
|
|
{
|
2013-09-05 18:30:50 +02:00
|
|
|
const bool state = ProjectExplorerPlugin::projectExplorerSettings().deployBeforeRun;
|
2011-10-25 18:23:37 +08:00
|
|
|
m_debugWithoutDeployAction->setVisible(state);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::dumpLog()
|
|
|
|
|
{
|
2013-10-16 17:11:39 +02:00
|
|
|
QString fileName = QFileDialog::getSaveFileName(ICore::mainWindow(),
|
2010-12-02 13:20:06 +01:00
|
|
|
tr("Save Debugger Log"), QDir::tempPath());
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
return;
|
2012-08-15 16:19:15 +02:00
|
|
|
FileSaver saver(fileName);
|
2011-03-30 15:15:15 +02:00
|
|
|
if (!saver.hasError()) {
|
|
|
|
|
QTextStream ts(saver.file());
|
|
|
|
|
ts << m_logWindow->inputContents();
|
|
|
|
|
ts << "\n\n=======================================\n\n";
|
|
|
|
|
ts << m_logWindow->combinedContents();
|
|
|
|
|
saver.setResult(&ts);
|
|
|
|
|
}
|
2013-10-16 17:11:39 +02:00
|
|
|
saver.finalize(ICore::mainWindow());
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2009-01-13 18:15:24 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
/*! Activates the previous mode when the current mode is the debug mode. */
|
|
|
|
|
void DebuggerPluginPrivate::activatePreviousMode()
|
|
|
|
|
{
|
2012-05-07 18:28:03 +02:00
|
|
|
if (ModeManager::currentMode() == ModeManager::mode(MODE_DEBUG)
|
|
|
|
|
&& m_previousMode.isValid()) {
|
2015-12-09 15:33:22 +01:00
|
|
|
// If stopping the application also makes Qt Creator active (as the
|
|
|
|
|
// "previously active application"), doing the switch synchronously
|
|
|
|
|
// leads to funny effects with floating dock widgets
|
|
|
|
|
const Core::Id mode = m_previousMode;
|
|
|
|
|
QTimer::singleShot(0, this, [mode]() { ModeManager::activateMode(mode); });
|
2012-05-07 18:28:03 +02:00
|
|
|
m_previousMode = Id();
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
2009-01-13 18:15:24 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::activateDebugMode()
|
|
|
|
|
{
|
2011-02-03 14:08:01 +01:00
|
|
|
m_reverseDirectionAction->setChecked(false);
|
|
|
|
|
m_reverseDirectionAction->setEnabled(false);
|
2012-01-26 01:18:02 +01:00
|
|
|
m_previousMode = ModeManager::currentMode()->id();
|
2012-05-07 18:28:03 +02:00
|
|
|
ModeManager::activateMode(MODE_DEBUG);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-02-12 14:15:20 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::sessionLoaded()
|
|
|
|
|
{
|
|
|
|
|
m_breakHandler->loadSessionData();
|
|
|
|
|
dummyEngine()->watchHandler()->loadSessionData();
|
2014-07-10 18:10:56 +02:00
|
|
|
DebuggerToolTipManager::loadSessionData();
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::aboutToUnloadSession()
|
|
|
|
|
{
|
2014-11-07 13:50:09 +01:00
|
|
|
m_toolTipManager.sessionAboutToChange();
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::aboutToSaveSession()
|
|
|
|
|
{
|
2011-02-28 18:48:06 +01:00
|
|
|
dummyEngine()->watchHandler()->saveSessionData();
|
2010-12-02 13:20:06 +01:00
|
|
|
m_breakHandler->saveSessionData();
|
2014-07-10 18:10:56 +02:00
|
|
|
DebuggerToolTipManager::saveSessionData();
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2009-02-27 11:41:19 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout)
|
|
|
|
|
{
|
|
|
|
|
showMessage(msg0, LogStatus);
|
|
|
|
|
QString msg = msg0;
|
2016-01-06 21:59:19 +02:00
|
|
|
msg.replace(QChar::LineFeed, QLatin1String("; "));
|
2011-03-16 13:49:28 +01:00
|
|
|
m_statusLabel->showStatusMessage(msg, timeout);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-03-11 11:07:16 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::coreShutdown()
|
|
|
|
|
{
|
|
|
|
|
m_shuttingDown = true;
|
|
|
|
|
}
|
2010-03-10 13:46:05 +01:00
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
const CPlusPlus::Snapshot &cppCodeModelSnapshot()
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
if (dd->m_codeModelSnapshot.isEmpty() && action(UseCodeModel)->isChecked())
|
|
|
|
|
dd->m_codeModelSnapshot = CppTools::CppModelManager::instance()->snapshot();
|
|
|
|
|
return dd->m_codeModelSnapshot;
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-03-11 11:07:16 +01:00
|
|
|
|
2014-07-28 14:23:52 +02:00
|
|
|
void setSessionValue(const QByteArray &key, const QVariant &value)
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2013-09-05 11:46:07 +02:00
|
|
|
SessionManager::setValue(QString::fromUtf8(key), value);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-11-23 16:42:46 +01:00
|
|
|
|
2014-07-28 14:23:52 +02:00
|
|
|
QVariant sessionValue(const QByteArray &key)
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2013-09-05 11:46:07 +02:00
|
|
|
return SessionManager::value(QString::fromUtf8(key));
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
QTreeView *inspectorView()
|
2014-06-04 14:45:10 +02:00
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
return dd->m_inspectorView;
|
2010-09-27 12:23:34 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::showMessage(const QString &msg, int channel, int timeout)
|
2010-07-21 17:06:22 +02:00
|
|
|
{
|
2010-12-02 13:20:06 +01:00
|
|
|
//qDebug() << "PLUGIN OUTPUT: " << channel << msg;
|
|
|
|
|
//ConsoleWindow *cw = m_consoleWindow;
|
|
|
|
|
QTC_ASSERT(m_logWindow, return);
|
|
|
|
|
switch (channel) {
|
|
|
|
|
case StatusBar:
|
|
|
|
|
// This will append to m_logWindow's output pane, too.
|
|
|
|
|
showStatusMessage(msg, timeout);
|
|
|
|
|
break;
|
|
|
|
|
case LogMiscInput:
|
|
|
|
|
m_logWindow->showInput(LogMisc, msg);
|
|
|
|
|
m_logWindow->showOutput(LogMisc, msg);
|
|
|
|
|
break;
|
|
|
|
|
case LogInput:
|
|
|
|
|
m_logWindow->showInput(LogInput, msg);
|
|
|
|
|
m_logWindow->showOutput(LogInput, msg);
|
|
|
|
|
break;
|
2012-02-22 12:46:47 +01:00
|
|
|
case LogError:
|
|
|
|
|
m_logWindow->showInput(LogError, QLatin1String("ERROR: ") + msg);
|
|
|
|
|
m_logWindow->showOutput(LogError, QLatin1String("ERROR: ") + msg);
|
2010-12-02 13:20:06 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
m_logWindow->showOutput(channel, msg);
|
|
|
|
|
break;
|
2010-07-21 17:06:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
void createNewDock(QWidget *widget)
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
QDockWidget *dockWidget = dd->m_mainWindow->createDockWidget(CppLanguage, widget);
|
2014-09-29 17:03:25 +02:00
|
|
|
dockWidget->setWindowTitle(widget->windowTitle());
|
2010-12-02 13:20:06 +01:00
|
|
|
dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
|
|
|
|
|
dockWidget->show();
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
static QString formatStartParameters(DebuggerRunParameters &sp)
|
2011-02-25 13:43:06 +01:00
|
|
|
{
|
|
|
|
|
QString rc;
|
|
|
|
|
QTextStream str(&rc);
|
|
|
|
|
str << "Start parameters: '" << sp.displayName << "' mode: " << sp.startMode
|
|
|
|
|
<< "\nABI: " << sp.toolChainAbi.toString() << '\n';
|
2012-02-01 09:03:05 +01:00
|
|
|
str << "Languages: ";
|
|
|
|
|
if (sp.languages == AnyLanguage)
|
|
|
|
|
str << "any";
|
|
|
|
|
if (sp.languages & CppLanguage)
|
|
|
|
|
str << "c++ ";
|
|
|
|
|
if (sp.languages & QmlLanguage)
|
|
|
|
|
str << "qml";
|
|
|
|
|
str << '\n';
|
2016-01-28 10:31:24 +01:00
|
|
|
if (!sp.inferior.executable.isEmpty()) {
|
|
|
|
|
str << "Executable: " << QDir::toNativeSeparators(sp.inferior.executable)
|
|
|
|
|
<< ' ' << sp.inferior.commandLineArguments;
|
2011-02-25 13:43:06 +01:00
|
|
|
if (sp.useTerminal)
|
|
|
|
|
str << " [terminal]";
|
|
|
|
|
str << '\n';
|
2016-01-28 10:31:24 +01:00
|
|
|
if (!sp.inferior.workingDirectory.isEmpty())
|
|
|
|
|
str << "Directory: " << QDir::toNativeSeparators(sp.inferior.workingDirectory)
|
2011-09-26 12:38:17 +02:00
|
|
|
<< '\n';
|
2011-02-25 13:43:06 +01:00
|
|
|
}
|
2012-06-28 10:00:04 +02:00
|
|
|
QString cmd = sp.debuggerCommand;
|
|
|
|
|
if (!cmd.isEmpty())
|
|
|
|
|
str << "Debugger: " << QDir::toNativeSeparators(cmd) << '\n';
|
2011-02-25 13:43:06 +01:00
|
|
|
if (!sp.coreFile.isEmpty())
|
|
|
|
|
str << "Core: " << QDir::toNativeSeparators(sp.coreFile) << '\n';
|
|
|
|
|
if (sp.attachPID > 0)
|
|
|
|
|
str << "PID: " << sp.attachPID << ' ' << sp.crashParameter << '\n';
|
2011-04-26 09:46:05 +02:00
|
|
|
if (!sp.projectSourceDirectory.isEmpty()) {
|
|
|
|
|
str << "Project: " << QDir::toNativeSeparators(sp.projectSourceDirectory);
|
2015-04-23 19:05:56 +02:00
|
|
|
str << "Addtional Search Directories:"
|
|
|
|
|
<< sp.additionalSearchDirectories.join(QLatin1Char(' ')) << '\n';
|
2011-02-25 13:43:06 +01:00
|
|
|
}
|
|
|
|
|
if (!sp.qmlServerAddress.isEmpty())
|
2011-09-26 12:38:17 +02:00
|
|
|
str << "QML server: " << sp.qmlServerAddress << ':'
|
|
|
|
|
<< sp.qmlServerPort << '\n';
|
2015-06-26 13:06:08 +02:00
|
|
|
if (!sp.remoteChannel.isEmpty())
|
2012-07-25 03:38:19 +02:00
|
|
|
str << "Remote: " << sp.remoteChannel << '\n';
|
2012-06-28 10:00:04 +02:00
|
|
|
str << "Sysroot: " << sp.sysRoot << '\n';
|
2014-08-23 01:19:53 +02:00
|
|
|
str << "Debug Source Location: " << sp.debugSourceLocation.join(QLatin1Char(':')) << '\n';
|
2011-02-25 13:43:06 +01:00
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 10:01:29 +01:00
|
|
|
void DebuggerPluginPrivate::runControlStarted(DebuggerEngine *engine)
|
2010-12-02 13:20:06 +01:00
|
|
|
{
|
|
|
|
|
activateDebugMode();
|
2012-03-07 16:40:54 +01:00
|
|
|
const QString message = tr("Starting debugger \"%1\" for ABI \"%2\"...")
|
2011-02-01 18:36:00 +01:00
|
|
|
.arg(engine->objectName())
|
2015-05-27 13:59:56 +02:00
|
|
|
.arg(engine->runParameters().toolChainAbi.toString());
|
2012-03-07 16:40:54 +01:00
|
|
|
showStatusMessage(message);
|
2015-05-27 13:59:56 +02:00
|
|
|
showMessage(formatStartParameters(engine->runParameters()), LogDebug);
|
2010-12-02 13:20:06 +01:00
|
|
|
showMessage(m_debuggerSettings->dump(), LogDebug);
|
2010-12-10 10:01:29 +01:00
|
|
|
m_snapshotHandler->appendSnapshot(engine);
|
2010-12-10 09:37:31 +01:00
|
|
|
connectEngine(engine);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-10 10:01:29 +01:00
|
|
|
void DebuggerPluginPrivate::runControlFinished(DebuggerEngine *engine)
|
2010-04-06 17:58:11 +02:00
|
|
|
{
|
2011-02-22 18:45:52 +01:00
|
|
|
showStatusMessage(tr("Debugger finished."));
|
2010-12-10 10:01:29 +01:00
|
|
|
m_snapshotHandler->removeSnapshot(engine);
|
2010-12-02 13:20:06 +01:00
|
|
|
if (m_snapshotHandler->size() == 0) {
|
|
|
|
|
// Last engine quits.
|
|
|
|
|
disconnectEngine();
|
|
|
|
|
if (boolSetting(SwitchModeOnExit))
|
|
|
|
|
activatePreviousMode();
|
|
|
|
|
} else {
|
|
|
|
|
// Connect to some existing engine.
|
|
|
|
|
m_snapshotHandler->activateSnapshot(0);
|
|
|
|
|
}
|
2011-05-02 15:05:16 +02:00
|
|
|
action(OperateByInstruction)->setValue(QVariant(false));
|
2013-07-31 20:46:37 +03:00
|
|
|
m_logWindow->clearUndoRedoStacks();
|
2010-04-06 17:58:11 +02:00
|
|
|
}
|
|
|
|
|
|
2015-03-09 10:59:58 +02:00
|
|
|
void DebuggerPluginPrivate::remoteCommand(const QStringList &options)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-12-02 13:20:06 +01:00
|
|
|
if (options.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QString errorMessage;
|
|
|
|
|
|
2012-08-09 01:50:26 +02:00
|
|
|
if (!parseArguments(options, &errorMessage)) {
|
2010-12-02 13:20:06 +01:00
|
|
|
qWarning("%s", qPrintable(errorMessage));
|
2010-06-16 11:08:54 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2011-02-08 13:48:04 +01:00
|
|
|
runScheduled();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
QMessageBox *showMessageBox(int icon, const QString &title,
|
|
|
|
|
const QString &text, int buttons)
|
2010-11-19 16:13:22 +01:00
|
|
|
{
|
2010-12-02 13:20:06 +01:00
|
|
|
QMessageBox *mb = new QMessageBox(QMessageBox::Icon(icon),
|
|
|
|
|
title, text, QMessageBox::StandardButtons(buttons),
|
2013-10-16 17:11:39 +02:00
|
|
|
ICore::mainWindow());
|
2010-12-02 13:20:06 +01:00
|
|
|
mb->setAttribute(Qt::WA_DeleteOnClose);
|
2014-01-16 18:37:26 +01:00
|
|
|
mb->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
2010-12-02 13:20:06 +01:00
|
|
|
mb->show();
|
|
|
|
|
return mb;
|
2010-11-19 16:13:22 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-10 14:19:42 +02:00
|
|
|
bool isReverseDebuggingEnabled()
|
|
|
|
|
{
|
|
|
|
|
static bool enabled = qEnvironmentVariableIsSet("QTC_DEBUGGER_ENABLE_REVERSE");
|
|
|
|
|
return enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isReverseDebugging()
|
|
|
|
|
{
|
|
|
|
|
return isReverseDebuggingEnabled() && dd->m_reverseDirectionAction->isChecked();
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
void DebuggerPluginPrivate::extensionsInitialized()
|
2010-12-01 15:41:08 +01:00
|
|
|
{
|
2012-05-23 13:25:51 +02:00
|
|
|
const QKeySequence debugKey = QKeySequence(UseMacShortcuts ? tr("Ctrl+Y") : tr("F5"));
|
|
|
|
|
|
2015-02-03 23:58:49 +02:00
|
|
|
QSettings *settings = ICore::settings();
|
2014-07-16 16:32:11 +02:00
|
|
|
|
2013-09-04 18:39:43 +02:00
|
|
|
m_debuggerSettings = new DebuggerSettings;
|
2011-07-08 15:33:13 +02:00
|
|
|
m_debuggerSettings->readSettings();
|
2010-12-01 15:41:08 +01:00
|
|
|
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(ICore::instance(), &ICore::coreAboutToClose, this, &DebuggerPluginPrivate::coreShutdown);
|
2010-12-01 15:41:08 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
const Context cppDebuggercontext(C_CPPDEBUGGER);
|
2014-09-02 12:25:20 +02:00
|
|
|
const Context cppeditorcontext(CppEditor::Constants::CPPEDITOR_ID);
|
2010-05-12 16:48:04 +02:00
|
|
|
|
2015-11-23 16:41:54 +01:00
|
|
|
m_startIcon = Core::Icons::DEBUG_START_SMALL.icon();
|
|
|
|
|
m_exitIcon = Core::Icons::DEBUG_EXIT_SMALL.icon();
|
2015-11-11 19:26:58 +01:00
|
|
|
const QIcon continueSideBarIcon =
|
|
|
|
|
Icon::sideBarIcon(Icons::CONTINUE, Icons::CONTINUE_FLAT);
|
|
|
|
|
m_continueIcon = Icon::combinedIcon({Core::Icons::DEBUG_CONTINUE_SMALL.icon(), continueSideBarIcon});
|
|
|
|
|
const QIcon interruptSideBarIcon =
|
|
|
|
|
Icon::sideBarIcon(Icons::INTERRUPT, Icons::INTERRUPT_FLAT);
|
|
|
|
|
m_interruptIcon = Icon::combinedIcon({Core::Icons::DEBUG_INTERRUPT_SMALL.icon(), interruptSideBarIcon});
|
2015-11-23 16:41:54 +01:00
|
|
|
m_locationMarkIcon = Icons::LOCATION.icon();
|
|
|
|
|
m_resetIcon = Icons::RESTART.icon();
|
2010-12-02 13:20:06 +01:00
|
|
|
|
|
|
|
|
m_busy = false;
|
|
|
|
|
|
2012-08-15 16:19:15 +02:00
|
|
|
m_statusLabel = new StatusLabel;
|
2010-12-02 13:20:06 +01:00
|
|
|
|
|
|
|
|
m_logWindow = new LogWindow;
|
2011-12-21 14:02:52 +01:00
|
|
|
m_logWindow->setObjectName(QLatin1String(DOCKWIDGET_OUTPUT));
|
2014-06-04 14:45:10 +02:00
|
|
|
|
|
|
|
|
m_breakHandler = new BreakHandler;
|
|
|
|
|
m_breakView = new BreakTreeView;
|
2014-07-16 16:32:11 +02:00
|
|
|
m_breakView->setSettings(settings, "Debugger.BreakWindow");
|
2014-06-04 14:45:10 +02:00
|
|
|
m_breakView->setModel(m_breakHandler->model());
|
|
|
|
|
m_breakWindow = addSearch(m_breakView, tr("Breakpoints"), DOCKWIDGET_BREAK);
|
|
|
|
|
|
|
|
|
|
m_modulesView = new ModulesTreeView;
|
2014-07-16 16:32:11 +02:00
|
|
|
m_modulesView->setSettings(settings, "Debugger.ModulesView");
|
2014-06-04 14:45:10 +02:00
|
|
|
m_modulesWindow = addSearch(m_modulesView, tr("Modules"), DOCKWIDGET_MODULES);
|
|
|
|
|
|
|
|
|
|
m_registerView = new RegisterTreeView;
|
2014-07-16 16:32:11 +02:00
|
|
|
m_registerView->setSettings(settings, "Debugger.RegisterView");
|
2014-06-04 14:45:10 +02:00
|
|
|
m_registerWindow = addSearch(m_registerView, tr("Registers"), DOCKWIDGET_REGISTER);
|
|
|
|
|
|
|
|
|
|
m_stackView = new StackTreeView;
|
2014-07-16 16:32:11 +02:00
|
|
|
m_stackView->setSettings(settings, "Debugger.StackView");
|
2014-06-04 14:45:10 +02:00
|
|
|
m_stackWindow = addSearch(m_stackView, tr("Stack"), DOCKWIDGET_STACK);
|
|
|
|
|
|
|
|
|
|
m_sourceFilesView = new SourceFilesTreeView;
|
2014-07-16 16:32:11 +02:00
|
|
|
m_sourceFilesView->setSettings(settings, "Debugger.SourceFilesView");
|
2014-06-04 14:45:10 +02:00
|
|
|
m_sourceFilesWindow = addSearch(m_sourceFilesView, tr("Source Files"), DOCKWIDGET_SOURCE_FILES);
|
|
|
|
|
|
|
|
|
|
m_threadsView = new ThreadsTreeView;
|
2014-07-16 16:32:11 +02:00
|
|
|
m_threadsView->setSettings(settings, "Debugger.ThreadsView");
|
2014-06-04 14:45:10 +02:00
|
|
|
m_threadsWindow = addSearch(m_threadsView, tr("Threads"), DOCKWIDGET_THREADS);
|
|
|
|
|
|
2014-07-16 16:32:11 +02:00
|
|
|
m_returnView = new WatchTreeView(ReturnType); // No settings.
|
2014-06-26 12:49:14 +02:00
|
|
|
m_returnWindow = addSearch(m_returnView, tr("Locals and Expressions"), "CppDebugReturn");
|
2014-06-04 14:45:10 +02:00
|
|
|
|
|
|
|
|
m_localsView = new WatchTreeView(LocalsType);
|
2014-07-16 16:32:11 +02:00
|
|
|
m_localsView->setSettings(settings, "Debugger.LocalsView");
|
2014-06-26 12:49:14 +02:00
|
|
|
m_localsWindow = addSearch(m_localsView, tr("Locals and Expressions"), "CppDebugLocals");
|
2014-06-04 14:45:10 +02:00
|
|
|
|
2014-07-16 16:32:11 +02:00
|
|
|
m_watchersView = new WatchTreeView(WatchersType); // No settings.
|
2014-06-26 12:49:14 +02:00
|
|
|
m_watchersWindow = addSearch(m_watchersView, tr("Locals and Expressions"), "CppDebugWatchers");
|
2014-06-04 14:45:10 +02:00
|
|
|
|
|
|
|
|
m_inspectorView = new WatchTreeView(InspectType);
|
2014-07-16 16:32:11 +02:00
|
|
|
m_inspectorView->setSettings(settings, "Debugger.LocalsView"); // sic! same as locals view.
|
2014-06-26 12:49:14 +02:00
|
|
|
m_inspectorWindow = addSearch(m_inspectorView, tr("Locals and Expressions"), "Inspector");
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// Snapshot
|
|
|
|
|
m_snapshotHandler = new SnapshotHandler;
|
2014-06-04 14:45:10 +02:00
|
|
|
m_snapshotView = new SnapshotTreeView(m_snapshotHandler);
|
2014-07-16 16:32:11 +02:00
|
|
|
m_snapshotView->setSettings(settings, "Debugger.SnapshotView");
|
2014-06-04 14:45:10 +02:00
|
|
|
m_snapshotView->setModel(m_snapshotHandler->model());
|
|
|
|
|
m_snapshotWindow = addSearch(m_snapshotView, tr("Snapshots"), DOCKWIDGET_SNAPSHOTS);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// Watchers
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(m_localsView->header(), &QHeaderView::sectionResized,
|
|
|
|
|
this, &DebuggerPluginPrivate::updateWatchersHeader, Qt::QueuedConnection);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
QAction *act = 0;
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_continueAction = new QAction(tr("Continue"), this);
|
2010-12-02 13:20:06 +01:00
|
|
|
act->setIcon(m_continueIcon);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecContinue);
|
2010-11-08 15:19:13 +01:00
|
|
|
|
2012-05-24 10:19:50 +02:00
|
|
|
act = m_exitAction = new QAction(tr("Stop Debugger"), this);
|
2010-12-02 13:20:06 +01:00
|
|
|
act->setIcon(m_exitIcon);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecExit);
|
2010-11-08 15:19:13 +01:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_interruptAction = new QAction(tr("Interrupt"), this);
|
2010-12-02 13:20:06 +01:00
|
|
|
act->setIcon(m_interruptIcon);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecInterrupt);
|
2010-11-08 15:19:13 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// A "disabled pause" seems to be a good choice.
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_undisturbableAction = new QAction(tr("Debugger is Busy"), this);
|
2010-12-02 13:20:06 +01:00
|
|
|
act->setIcon(m_interruptIcon);
|
|
|
|
|
act->setEnabled(false);
|
2010-11-08 15:19:13 +01:00
|
|
|
|
2011-10-31 16:15:48 +01:00
|
|
|
act = m_abortAction = new QAction(tr("Abort Debugging"), this);
|
2010-12-02 13:20:06 +01:00
|
|
|
act->setToolTip(tr("Aborts debugging and "
|
|
|
|
|
"resets the debugger to the initial state."));
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleAbort);
|
2010-11-10 16:33:11 +01:00
|
|
|
|
2014-06-05 17:22:51 +02:00
|
|
|
act = m_resetAction = new QAction(tr("Restart Debugging"),this);
|
|
|
|
|
act->setToolTip(tr("Restart the debugging session."));
|
|
|
|
|
act->setIcon(m_resetIcon);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleReset);
|
2014-06-05 17:22:51 +02:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_nextAction = new QAction(tr("Step Over"), this);
|
2015-11-23 16:41:54 +01:00
|
|
|
act->setIcon(Icons::STEP_OVER.icon());
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecNext);
|
2009-04-28 15:08:52 +02:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_stepAction = new QAction(tr("Step Into"), this);
|
2015-11-23 16:41:54 +01:00
|
|
|
act->setIcon(Icons::STEP_INTO.icon());
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecStep);
|
2010-11-24 18:36:17 +01:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_stepOutAction = new QAction(tr("Step Out"), this);
|
2015-11-23 16:41:54 +01:00
|
|
|
act->setIcon(Icons::STEP_OUT.icon());
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecStepOut);
|
2010-11-24 18:36:17 +01:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_runToLineAction = new QAction(tr("Run to Line"), this);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecRunToLine);
|
2010-06-11 12:38:54 +02:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_runToSelectedFunctionAction =
|
2011-02-02 11:52:39 +01:00
|
|
|
new QAction(tr("Run to Selected Function"), this);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecRunToSelectedFunction);
|
2010-11-24 18:36:17 +01:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_returnFromFunctionAction =
|
2010-12-02 13:20:06 +01:00
|
|
|
new QAction(tr("Immediately Return From Inner Function"), this);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecReturn);
|
2010-12-02 13:20:06 +01:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_jumpToLineAction = new QAction(tr("Jump to Line"), this);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecJumpToLine);
|
2010-12-02 13:20:06 +01:00
|
|
|
|
2014-09-11 10:53:47 +02:00
|
|
|
m_breakAction = new QAction(tr("Toggle Breakpoint"), this);
|
2010-12-02 13:20:06 +01:00
|
|
|
|
2012-05-14 11:21:01 +02:00
|
|
|
act = m_watchAction1 = new QAction(tr("Add Expression Evaluator"), this);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleAddToWatchWindow);
|
2010-12-02 13:20:06 +01:00
|
|
|
|
2012-05-14 11:21:01 +02:00
|
|
|
act = m_watchAction2 = new QAction(tr("Add Expression Evaluator"), this);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleAddToWatchWindow);
|
2010-12-02 13:20:06 +01:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
//m_snapshotAction = new QAction(tr("Create Snapshot"), this);
|
|
|
|
|
//m_snapshotAction->setProperty(Role, RequestCreateSnapshotRole);
|
2015-11-23 16:41:54 +01:00
|
|
|
//m_snapshotAction->setIcon(Icons::SNAPSHOT.icon());
|
2010-12-02 13:20:06 +01:00
|
|
|
|
2015-06-10 14:19:42 +02:00
|
|
|
act = m_reverseDirectionAction = new QAction(tr("Reverse Direction"), this);
|
2010-12-02 13:20:06 +01:00
|
|
|
act->setCheckable(true);
|
|
|
|
|
act->setChecked(false);
|
|
|
|
|
act->setCheckable(false);
|
2015-11-23 16:41:54 +01:00
|
|
|
act->setIcon(Icons::REVERSE_MODE.icon());
|
2010-12-02 13:20:06 +01:00
|
|
|
act->setIconVisibleInMenu(false);
|
2010-06-11 12:38:54 +02:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_frameDownAction = new QAction(tr("Move to Called Frame"), this);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleFrameDown);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-02-03 14:08:01 +01:00
|
|
|
act = m_frameUpAction = new QAction(tr("Move to Calling Frame"), this);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleFrameUp);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-10-27 12:21:42 +01:00
|
|
|
connect(action(OperateByInstruction), &QAction::triggered,
|
|
|
|
|
this, &DebuggerPluginPrivate::handleOperateByInstructionTriggered);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-12-30 11:37:50 +01:00
|
|
|
ActionContainer *debugMenu = ActionManager::actionContainer(PE::M_DEBUG);
|
2010-12-02 18:19:05 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// Dock widgets
|
2010-12-03 15:03:51 +01:00
|
|
|
QDockWidget *dock = 0;
|
2010-12-03 15:55:17 +01:00
|
|
|
dock = m_mainWindow->createDockWidget(CppLanguage, m_modulesWindow);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(dock->toggleViewAction(), &QAction::toggled,
|
|
|
|
|
this, &DebuggerPluginPrivate::modulesDockToggled, Qt::QueuedConnection);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-03 15:55:17 +01:00
|
|
|
dock = m_mainWindow->createDockWidget(CppLanguage, m_registerWindow);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(dock->toggleViewAction(), &QAction::toggled,
|
|
|
|
|
this, &DebuggerPluginPrivate::registerDockToggled, Qt::QueuedConnection);
|
2009-05-25 16:22:11 +02:00
|
|
|
|
2010-12-03 15:55:17 +01:00
|
|
|
dock = m_mainWindow->createDockWidget(CppLanguage, m_sourceFilesWindow);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(dock->toggleViewAction(), &QAction::toggled,
|
|
|
|
|
this, &DebuggerPluginPrivate::sourceFilesDockToggled, Qt::QueuedConnection);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-06 10:25:33 +01:00
|
|
|
dock = m_mainWindow->createDockWidget(AnyLanguage, m_logWindow);
|
|
|
|
|
dock->setProperty(DOCKWIDGET_DEFAULT_AREA, Qt::TopDockWidgetArea);
|
|
|
|
|
|
2010-12-03 15:55:17 +01:00
|
|
|
m_mainWindow->createDockWidget(CppLanguage, m_breakWindow);
|
|
|
|
|
m_mainWindow->createDockWidget(CppLanguage, m_snapshotWindow);
|
|
|
|
|
m_mainWindow->createDockWidget(CppLanguage, m_stackWindow);
|
|
|
|
|
m_mainWindow->createDockWidget(CppLanguage, m_threadsWindow);
|
2010-03-29 18:44:02 +02:00
|
|
|
|
2012-05-14 16:09:12 +02:00
|
|
|
m_localsAndExpressionsWindow = new LocalsAndExpressionsWindow(
|
2012-04-18 14:20:54 +02:00
|
|
|
m_localsWindow, m_inspectorWindow, m_returnWindow,
|
|
|
|
|
m_watchersWindow);
|
2012-05-14 16:09:12 +02:00
|
|
|
m_localsAndExpressionsWindow->setObjectName(QLatin1String(DOCKWIDGET_WATCHERS));
|
|
|
|
|
m_localsAndExpressionsWindow->setWindowTitle(m_localsWindow->windowTitle());
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2012-05-14 16:09:12 +02:00
|
|
|
dock = m_mainWindow->createDockWidget(CppLanguage, m_localsAndExpressionsWindow);
|
2010-12-06 10:25:33 +01:00
|
|
|
dock->setProperty(DOCKWIDGET_DEFAULT_AREA, Qt::RightDockWidgetArea);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2012-01-12 17:04:14 +01:00
|
|
|
m_mainWindow->addStagedMenuEntries();
|
|
|
|
|
|
2015-05-27 16:09:43 +02:00
|
|
|
m_plugin->addAutoReleasedObject(createDebuggerRunControlFactory(m_plugin));
|
2010-08-18 13:54:12 +02:00
|
|
|
|
2010-12-06 08:04:43 +01:00
|
|
|
// The main "Start Debugging" action.
|
2011-08-03 18:57:37 +02:00
|
|
|
act = m_startAction = new QAction(this);
|
2015-11-11 19:26:58 +01:00
|
|
|
const QIcon sideBarIcon =
|
|
|
|
|
Icon::sideBarIcon(ProjectExplorer::Icons::DEBUG_START, ProjectExplorer::Icons::DEBUG_START_FLAT);
|
|
|
|
|
const QIcon debuggerIcon = Icon::combinedIcon({Core::Icons::DEBUG_START_SMALL.icon(), sideBarIcon});
|
2010-12-02 13:20:06 +01:00
|
|
|
act->setIcon(debuggerIcon);
|
|
|
|
|
act->setText(tr("Start Debugging"));
|
2015-06-29 10:36:29 +03:00
|
|
|
connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE); });
|
2010-07-05 17:08:30 +02:00
|
|
|
|
2011-10-25 18:23:37 +08:00
|
|
|
act = m_debugWithoutDeployAction = new QAction(this);
|
2011-12-08 16:31:21 +01:00
|
|
|
act->setText(tr("Start Debugging Without Deployment"));
|
2015-06-29 10:36:29 +03:00
|
|
|
connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, true); });
|
2011-10-25 18:23:37 +08:00
|
|
|
|
2012-08-08 13:09:31 +02:00
|
|
|
act = m_startAndDebugApplicationAction = new QAction(this);
|
2012-08-14 09:45:53 +02:00
|
|
|
act->setText(tr("Start and Debug External Application..."));
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::startAndDebugApplication);
|
2010-07-05 17:08:30 +02:00
|
|
|
|
2011-12-05 17:21:48 +01:00
|
|
|
act = m_attachToCoreAction = new QAction(this);
|
2011-12-08 16:31:21 +01:00
|
|
|
act->setText(tr("Load Core File..."));
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::attachCore);
|
2010-07-05 17:08:30 +02:00
|
|
|
|
2011-12-05 17:21:48 +01:00
|
|
|
act = m_attachToRemoteServerAction = new QAction(this);
|
2015-03-03 13:36:28 +01:00
|
|
|
act->setText(tr("Attach to Running Debug Server..."));
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::attachToRemoteServer);
|
2011-12-05 17:21:48 +01:00
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
act = m_startRemoteServerAction = new QAction(this);
|
2015-03-03 13:36:28 +01:00
|
|
|
act->setText(tr("Start Debug Server Attached to Process..."));
|
2015-02-25 16:30:23 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::startRemoteServerAndAttachToProcess);
|
2011-12-06 15:39:25 +01:00
|
|
|
|
2012-08-06 12:22:35 +02:00
|
|
|
act = m_attachToRunningApplication = new QAction(this);
|
|
|
|
|
act->setText(tr("Attach to Running Application..."));
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::attachToRunningApplication);
|
2011-09-14 15:22:08 +02:00
|
|
|
|
2013-09-20 16:48:01 +02:00
|
|
|
act = m_attachToUnstartedApplication = new QAction(this);
|
|
|
|
|
act->setText(tr("Attach to Unstarted Application..."));
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::attachToUnstartedApplicationDialog);
|
2013-09-20 16:48:01 +02:00
|
|
|
|
2011-09-13 17:26:02 +02:00
|
|
|
act = m_attachToQmlPortAction = new QAction(this);
|
|
|
|
|
act->setText(tr("Attach to QML Port..."));
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::attachToQmlPort);
|
2011-09-13 17:26:02 +02:00
|
|
|
|
2012-08-23 15:53:58 +02:00
|
|
|
if (HostOsInfo::isWindowsHost()) {
|
|
|
|
|
m_startRemoteCdbAction = new QAction(tr("Attach to Remote CDB Session..."), this);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(m_startRemoteCdbAction, &QAction::triggered,
|
|
|
|
|
this, &DebuggerPluginPrivate::startRemoteCdbSession);
|
2012-08-23 15:53:58 +02:00
|
|
|
}
|
2010-07-05 17:08:30 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
act = m_detachAction = new QAction(this);
|
|
|
|
|
act->setText(tr("Detach Debugger"));
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::handleExecDetach);
|
2010-11-23 13:28:18 +01:00
|
|
|
|
2011-10-10 13:38:58 +02:00
|
|
|
// "Start Debugging" sub-menu
|
|
|
|
|
// groups:
|
|
|
|
|
// G_DEFAULT_ONE
|
2011-10-19 11:51:51 +02:00
|
|
|
// G_START_LOCAL
|
|
|
|
|
// G_START_REMOTE
|
2011-10-10 13:38:58 +02:00
|
|
|
// G_START_QML
|
|
|
|
|
|
2010-12-02 18:19:05 +01:00
|
|
|
Command *cmd = 0;
|
2012-07-18 16:20:19 +02:00
|
|
|
ActionContainer *mstart = ActionManager::actionContainer(PE::M_DEBUG_STARTDEBUGGING);
|
2010-08-24 16:22:21 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_startAction, Constants::DEBUG);
|
2012-01-06 17:13:18 +01:00
|
|
|
cmd->setDescription(tr("Start Debugging"));
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(debugKey);
|
2011-05-26 19:57:07 +02:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
2011-10-10 13:38:58 +02:00
|
|
|
mstart->addAction(cmd, CC::G_DEFAULT_ONE);
|
2012-08-15 16:19:15 +02:00
|
|
|
m_visibleStartAction = new ProxyAction(this);
|
2012-05-24 10:19:50 +02:00
|
|
|
m_visibleStartAction->initialize(cmd->action());
|
2012-08-15 16:19:15 +02:00
|
|
|
m_visibleStartAction->setAttribute(ProxyAction::UpdateText);
|
|
|
|
|
m_visibleStartAction->setAttribute(ProxyAction::UpdateIcon);
|
2011-08-03 18:57:37 +02:00
|
|
|
m_visibleStartAction->setAction(cmd->action());
|
2011-02-03 14:17:23 +01:00
|
|
|
|
2012-01-26 01:18:02 +01:00
|
|
|
ModeManager::addAction(m_visibleStartAction, Constants::P_ACTION_DEBUG);
|
2010-10-28 08:55:50 +02:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_debugWithoutDeployAction,
|
2015-02-19 11:35:47 +01:00
|
|
|
"Debugger.DebugWithoutDeploy");
|
2011-10-25 18:23:37 +08:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
|
|
|
|
mstart->addAction(cmd, CC::G_DEFAULT_ONE);
|
|
|
|
|
|
2012-08-06 12:22:35 +02:00
|
|
|
cmd = ActionManager::registerAction(m_attachToRunningApplication,
|
2015-02-19 11:35:47 +01:00
|
|
|
"Debugger.AttachToRemoteProcess");
|
2012-08-06 12:22:35 +02:00
|
|
|
cmd->setDescription(tr("Attach to Running Application"));
|
2015-02-03 23:58:49 +02:00
|
|
|
mstart->addAction(cmd, G_GENERAL);
|
2011-10-19 11:51:51 +02:00
|
|
|
|
2013-09-20 16:48:01 +02:00
|
|
|
cmd = ActionManager::registerAction(m_attachToUnstartedApplication,
|
2015-02-19 11:35:47 +01:00
|
|
|
"Debugger.AttachToUnstartedProcess");
|
2013-09-20 16:48:01 +02:00
|
|
|
cmd->setDescription(tr("Attach to Unstarted Application"));
|
2015-02-03 23:58:49 +02:00
|
|
|
mstart->addAction(cmd, G_GENERAL);
|
2013-09-20 16:48:01 +02:00
|
|
|
|
2012-08-08 13:09:31 +02:00
|
|
|
cmd = ActionManager::registerAction(m_startAndDebugApplicationAction,
|
2015-02-19 11:35:47 +01:00
|
|
|
"Debugger.StartAndDebugApplication");
|
2011-10-19 11:51:51 +02:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2015-02-03 23:58:49 +02:00
|
|
|
mstart->addAction(cmd, G_GENERAL);
|
2012-01-07 17:18:52 +01:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_attachToCoreAction,
|
2015-02-19 11:35:47 +01:00
|
|
|
"Debugger.AttachCore");
|
2011-10-19 11:51:51 +02:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2012-08-15 16:19:15 +02:00
|
|
|
mstart->addAction(cmd, Constants::G_GENERAL);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_attachToRemoteServerAction,
|
2015-02-19 11:35:47 +01:00
|
|
|
"Debugger.AttachToRemoteServer");
|
2010-12-02 13:20:06 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2012-08-15 16:19:15 +02:00
|
|
|
mstart->addAction(cmd, Constants::G_SPECIAL);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_startRemoteServerAction,
|
2015-02-19 11:35:47 +01:00
|
|
|
"Debugger.StartRemoteServer");
|
2012-01-06 17:13:18 +01:00
|
|
|
cmd->setDescription(tr("Start Gdbserver"));
|
2012-08-15 16:19:15 +02:00
|
|
|
mstart->addAction(cmd, Constants::G_SPECIAL);
|
2011-12-06 15:39:25 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
if (m_startRemoteCdbAction) {
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_startRemoteCdbAction,
|
2015-02-19 11:35:47 +01:00
|
|
|
"Debugger.AttachRemoteCdb");
|
2010-12-02 13:20:06 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2012-08-15 16:19:15 +02:00
|
|
|
mstart->addAction(cmd, Constants::G_SPECIAL);
|
2010-12-02 13:20:06 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
mstart->addSeparator(Context(CC::C_GLOBAL), Constants::G_START_QML);
|
2011-10-10 13:38:58 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_attachToQmlPortAction, "Debugger.AttachToQmlPort");
|
2011-10-10 13:38:58 +02:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
|
|
|
|
mstart->addAction(cmd, Constants::G_START_QML);
|
2011-09-22 11:18:14 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_detachAction, "Debugger.Detach");
|
2010-12-02 13:20:06 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd, CC::G_DEFAULT_ONE);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_interruptAction, Constants::INTERRUPT);
|
2012-01-06 17:13:18 +01:00
|
|
|
cmd->setDescription(tr("Interrupt Debugger"));
|
2011-01-12 16:36:29 +01:00
|
|
|
debugMenu->addAction(cmd, CC::G_DEFAULT_ONE);
|
|
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_continueAction, Constants::CONTINUE);
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(debugKey);
|
2011-01-12 16:36:29 +01:00
|
|
|
debugMenu->addAction(cmd, CC::G_DEFAULT_ONE);
|
|
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_exitAction, Constants::STOP);
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd, CC::G_DEFAULT_ONE);
|
2012-08-15 16:19:15 +02:00
|
|
|
m_hiddenStopAction = new ProxyAction(this);
|
2012-05-24 10:19:50 +02:00
|
|
|
m_hiddenStopAction->initialize(cmd->action());
|
2012-08-15 16:19:15 +02:00
|
|
|
m_hiddenStopAction->setAttribute(ProxyAction::UpdateText);
|
|
|
|
|
m_hiddenStopAction->setAttribute(ProxyAction::UpdateIcon);
|
2011-08-03 18:57:37 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_hiddenStopAction, Constants::HIDDEN_STOP);
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Shift+Ctrl+Y") : tr("Shift+F5")));
|
2011-08-03 18:57:37 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_abortAction, Constants::ABORT);
|
2012-01-06 17:13:18 +01:00
|
|
|
cmd->setDescription(tr("Reset Debugger"));
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd, CC::G_DEFAULT_ONE);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_resetAction, Constants::RESET);
|
2014-06-05 17:22:51 +02:00
|
|
|
cmd->setDescription(tr("Restart Debugging"));
|
|
|
|
|
debugMenu->addAction(cmd, CC::G_DEFAULT_ONE);
|
|
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
debugMenu->addSeparator();
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_nextAction, Constants::NEXT);
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+O") : tr("F10")));
|
2010-12-02 13:20:06 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2011-07-18 17:23:42 +02:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd);
|
2010-09-24 16:55:22 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_stepAction, Constants::STEP);
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+I") : tr("F11")));
|
2010-12-02 13:20:06 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2011-07-18 17:23:42 +02:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd);
|
2010-11-12 20:18:29 +01:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_stepOutAction,
|
2010-12-02 13:20:06 +01:00
|
|
|
Constants::STEPOUT, cppDebuggercontext);
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+T") : tr("Shift+F11")));
|
2010-12-02 13:20:06 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd);
|
2010-11-23 16:42:46 +01:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_runToLineAction,
|
2011-08-04 10:31:15 +02:00
|
|
|
"Debugger.RunToLine", cppDebuggercontext);
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Shift+F8") : tr("Ctrl+F10")));
|
2010-12-02 13:20:06 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd);
|
2009-05-25 18:21:31 +02:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_runToSelectedFunctionAction,
|
2011-08-04 10:31:15 +02:00
|
|
|
"Debugger.RunToSelectedFunction", cppDebuggercontext);
|
2014-05-05 17:08:41 +03:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F6")));
|
2010-12-02 13:20:06 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2011-02-02 11:52:39 +01:00
|
|
|
// Don't add to menu by default as keeping its enabled state
|
|
|
|
|
// and text up-to-date is a lot of hassle.
|
|
|
|
|
// debugMenu->addAction(cmd);
|
2009-01-13 18:15:24 +01:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_jumpToLineAction,
|
2011-08-04 10:31:15 +02:00
|
|
|
"Debugger.JumpToLine", cppDebuggercontext);
|
2010-12-02 13:20:06 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd);
|
2009-02-27 11:41:19 +01:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_returnFromFunctionAction,
|
2011-08-04 10:31:15 +02:00
|
|
|
"Debugger.ReturnFromFunction", cppDebuggercontext);
|
2010-12-02 13:20:06 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd);
|
2009-06-16 13:44:45 +02:00
|
|
|
|
2015-06-10 14:19:42 +02:00
|
|
|
if (isReverseDebuggingEnabled()) {
|
|
|
|
|
cmd = ActionManager::registerAction(m_reverseDirectionAction,
|
|
|
|
|
Constants::REVERSE, cppDebuggercontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? QString() : tr("F12")));
|
|
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
|
|
|
|
debugMenu->addAction(cmd);
|
|
|
|
|
}
|
2009-05-05 17:48:54 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
debugMenu->addSeparator();
|
2009-05-05 17:48:54 +02:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
//cmd = ActionManager::registerAction(m_snapshotAction,
|
2011-08-04 10:31:15 +02:00
|
|
|
// "Debugger.Snapshot", cppDebuggercontext);
|
2012-05-23 13:25:51 +02:00
|
|
|
//cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+S")));
|
2010-12-02 13:20:06 +01:00
|
|
|
//cmd->setAttribute(Command::CA_Hide);
|
2010-12-02 18:21:39 +01:00
|
|
|
//debugMenu->addAction(cmd);
|
2009-09-30 12:27:03 +02:00
|
|
|
|
2015-03-08 21:41:57 +02:00
|
|
|
ActionManager::registerAction(m_frameDownAction,
|
2011-08-04 10:31:15 +02:00
|
|
|
"Debugger.FrameDown", cppDebuggercontext);
|
2014-09-11 10:53:47 +02:00
|
|
|
ActionManager::registerAction(m_frameUpAction,
|
2011-08-04 10:31:15 +02:00
|
|
|
"Debugger.FrameUp", cppDebuggercontext);
|
2009-05-05 17:48:54 +02:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(action(OperateByInstruction),
|
2010-12-02 13:20:06 +01:00
|
|
|
Constants::OPERATE_BY_INSTRUCTION, cppDebuggercontext);
|
|
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd);
|
2010-08-26 16:02:41 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_breakAction, "Debugger.ToggleBreak");
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("F8") : tr("F9")));
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd);
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(m_breakAction, &QAction::triggered,
|
2015-07-20 09:37:54 +02:00
|
|
|
this, &DebuggerPluginPrivate::toggleBreakpointHelper);
|
2010-08-26 16:02:41 +02:00
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
debugMenu->addSeparator();
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2014-07-17 12:14:14 +02:00
|
|
|
// currently broken
|
|
|
|
|
// QAction *qmlUpdateOnSaveDummyAction = new QAction(tr("Apply Changes on Save"), this);
|
|
|
|
|
// qmlUpdateOnSaveDummyAction->setCheckable(true);
|
2015-11-23 16:41:54 +01:00
|
|
|
// qmlUpdateOnSaveDummyAction->setIcon(Icons::APPLY_ON_SAVE.icon());
|
2014-07-17 12:14:14 +02:00
|
|
|
// qmlUpdateOnSaveDummyAction->setEnabled(false);
|
2015-02-19 11:35:47 +01:00
|
|
|
// cmd = ActionManager::registerAction(qmlUpdateOnSaveDummyAction, Constants::QML_UPDATE_ON_SAVE);
|
2014-07-17 12:14:14 +02:00
|
|
|
// debugMenu->addAction(cmd);
|
2012-11-27 15:33:20 +01:00
|
|
|
|
2013-02-08 17:21:49 +01:00
|
|
|
QAction *qmlShowAppOnTopDummyAction = new QAction(tr("Show Application on Top"), this);
|
2012-11-27 15:33:20 +01:00
|
|
|
qmlShowAppOnTopDummyAction->setCheckable(true);
|
2015-11-23 16:41:54 +01:00
|
|
|
qmlShowAppOnTopDummyAction->setIcon(Icons::APP_ON_TOP.icon());
|
2012-11-27 15:33:20 +01:00
|
|
|
qmlShowAppOnTopDummyAction->setEnabled(false);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(qmlShowAppOnTopDummyAction, Constants::QML_SHOW_APP_ON_TOP);
|
2012-11-27 15:33:20 +01:00
|
|
|
debugMenu->addAction(cmd);
|
|
|
|
|
|
|
|
|
|
QAction *qmlSelectDummyAction = new QAction(tr("Select"), this);
|
|
|
|
|
qmlSelectDummyAction->setCheckable(true);
|
2015-11-23 16:41:54 +01:00
|
|
|
qmlSelectDummyAction->setIcon(Icons::SELECT.icon());
|
2012-11-27 15:33:20 +01:00
|
|
|
qmlSelectDummyAction->setEnabled(false);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(qmlSelectDummyAction, Constants::QML_SELECTTOOL);
|
2012-11-27 15:33:20 +01:00
|
|
|
debugMenu->addAction(cmd);
|
|
|
|
|
|
|
|
|
|
QAction *qmlZoomDummyAction = new QAction(tr("Zoom"), this);
|
|
|
|
|
qmlZoomDummyAction->setCheckable(true);
|
2015-11-23 16:41:54 +01:00
|
|
|
qmlZoomDummyAction->setIcon(Core::Icons::ZOOM.icon());
|
2012-11-27 15:33:20 +01:00
|
|
|
qmlZoomDummyAction->setEnabled(false);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(qmlZoomDummyAction, Constants::QML_ZOOMTOOL);
|
2012-11-27 15:33:20 +01:00
|
|
|
debugMenu->addAction(cmd);
|
|
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
debugMenu->addSeparator();
|
2012-11-27 15:33:20 +01:00
|
|
|
|
2011-08-04 10:31:15 +02:00
|
|
|
// Don't add '1' to the string as it shows up in the shortcut dialog.
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_watchAction1,
|
2011-08-04 10:31:15 +02:00
|
|
|
"Debugger.AddToWatch", cppeditorcontext);
|
2010-12-02 13:20:06 +01:00
|
|
|
//cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+W")));
|
2010-12-02 18:21:39 +01:00
|
|
|
debugMenu->addAction(cmd);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2011-01-06 14:57:21 +01:00
|
|
|
// If the CppEditor plugin is there, we want to add something to
|
|
|
|
|
// the editor context menu.
|
|
|
|
|
if (ActionContainer *editorContextMenu =
|
2012-07-18 16:20:19 +02:00
|
|
|
ActionManager::actionContainer(CppEditor::Constants::M_CONTEXT)) {
|
2012-06-05 14:22:20 +02:00
|
|
|
cmd = editorContextMenu->addSeparator(cppDebuggercontext);
|
2011-01-06 14:57:21 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-11-10 12:38:29 +01:00
|
|
|
|
2012-07-18 16:20:19 +02:00
|
|
|
cmd = ActionManager::registerAction(m_watchAction2,
|
2011-08-04 10:31:15 +02:00
|
|
|
"Debugger.AddToWatch2", cppDebuggercontext);
|
2011-01-06 14:57:21 +01:00
|
|
|
cmd->action()->setEnabled(true);
|
|
|
|
|
editorContextMenu->addAction(cmd);
|
|
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2011-08-04 10:31:15 +02:00
|
|
|
cmd->setAttribute(Command::CA_NonConfigurable);
|
|
|
|
|
// Debugger.AddToWatch is enough.
|
2011-01-06 14:57:21 +01:00
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
QList<IOptionsPage *> engineOptionPages;
|
2012-08-09 01:50:26 +02:00
|
|
|
addGdbOptionPages(&engineOptionPages);
|
|
|
|
|
addCdbOptionPages(&engineOptionPages);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
foreach (IOptionsPage *op, engineOptionPages)
|
2010-12-02 13:20:06 +01:00
|
|
|
m_plugin->addAutoReleasedObject(op);
|
2012-05-14 15:11:11 +02:00
|
|
|
m_plugin->addAutoReleasedObject(new LocalsAndExpressionsOptionsPage);
|
2013-08-14 18:30:40 +02:00
|
|
|
m_plugin->addAutoReleasedObject(new DebuggerOptionsPage);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2014-12-08 12:43:20 +01:00
|
|
|
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
|
|
|
|
|
this, &DebuggerPluginPrivate::onModeChanged);
|
|
|
|
|
connect(ICore::instance(), &ICore::coreAboutToOpen,
|
|
|
|
|
this, &DebuggerPluginPrivate::onCoreAboutToOpen);
|
|
|
|
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
|
|
|
|
this, &DebuggerPluginPrivate::updateDebugWithoutDeployMenu);
|
2010-12-03 15:23:23 +01:00
|
|
|
|
|
|
|
|
// Debug mode setup
|
2011-04-13 13:00:30 +02:00
|
|
|
DebugMode *debugMode = new DebugMode;
|
|
|
|
|
QWidget *widget = m_mainWindow->createContents(debugMode);
|
2015-02-03 23:58:49 +02:00
|
|
|
IContext *modeContextObject = new IContext(this);
|
|
|
|
|
modeContextObject->setContext(Context(CC::C_EDITORMANAGER));
|
2014-07-01 13:20:53 +02:00
|
|
|
modeContextObject->setWidget(widget);
|
2015-02-03 23:58:49 +02:00
|
|
|
ICore::addContextObject(modeContextObject);
|
2011-04-13 13:00:30 +02:00
|
|
|
debugMode->setWidget(widget);
|
|
|
|
|
|
|
|
|
|
m_plugin->addAutoReleasedObject(debugMode);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
//
|
|
|
|
|
// Connections
|
|
|
|
|
//
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2011-02-22 12:05:25 +01:00
|
|
|
// Core
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(ICore::instance(), &ICore::saveSettingsRequested,
|
|
|
|
|
this, &DebuggerPluginPrivate::writeSettings);
|
2011-02-22 12:05:25 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// TextEditor
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged,
|
|
|
|
|
this, &DebuggerPluginPrivate::fontSettingsChanged);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// ProjectExplorer
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(SessionManager::instance(), &SessionManager::sessionLoaded,
|
|
|
|
|
this, &DebuggerPluginPrivate::sessionLoaded);
|
|
|
|
|
connect(SessionManager::instance(), &SessionManager::aboutToSaveSession,
|
|
|
|
|
this, &DebuggerPluginPrivate::aboutToSaveSession);
|
|
|
|
|
connect(SessionManager::instance(), &SessionManager::aboutToUnloadSession,
|
|
|
|
|
this, &DebuggerPluginPrivate::aboutToUnloadSession);
|
|
|
|
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
|
|
|
|
this, &DebuggerPluginPrivate::updateDebugActions);
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// EditorManager
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(EditorManager::instance(), &EditorManager::editorOpened,
|
|
|
|
|
this, &DebuggerPluginPrivate::editorOpened);
|
|
|
|
|
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
|
|
|
|
|
this, &DebuggerPluginPrivate::updateBreakMenuItem);
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// Application interaction
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(action(SettingsDialog), &QAction::triggered,
|
2015-02-23 11:07:38 +01:00
|
|
|
[] { ICore::showOptionsDialog(DEBUGGER_COMMON_SETTINGS_ID); });
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
// Toolbar
|
|
|
|
|
QWidget *toolbarContainer = new QWidget;
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
QHBoxLayout *hbox = new QHBoxLayout(toolbarContainer);
|
|
|
|
|
hbox->setMargin(0);
|
|
|
|
|
hbox->setSpacing(0);
|
2011-08-03 18:57:37 +02:00
|
|
|
hbox->addWidget(toolButton(m_visibleStartAction));
|
2012-05-24 10:19:50 +02:00
|
|
|
hbox->addWidget(toolButton(Constants::STOP));
|
|
|
|
|
hbox->addWidget(toolButton(Constants::NEXT));
|
|
|
|
|
hbox->addWidget(toolButton(Constants::STEP));
|
|
|
|
|
hbox->addWidget(toolButton(Constants::STEPOUT));
|
2014-06-05 17:22:51 +02:00
|
|
|
hbox->addWidget(toolButton(Constants::RESET));
|
2012-05-24 10:19:50 +02:00
|
|
|
hbox->addWidget(toolButton(Constants::OPERATE_BY_INSTRUCTION));
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2015-06-10 14:19:42 +02:00
|
|
|
if (isReverseDebuggingEnabled()) {
|
|
|
|
|
m_reverseToolButton = toolButton(Constants::REVERSE);
|
|
|
|
|
hbox->addWidget(m_reverseToolButton);
|
|
|
|
|
}
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2012-08-15 16:19:15 +02:00
|
|
|
hbox->addWidget(new StyledSeparator);
|
2010-12-02 13:20:06 +01:00
|
|
|
hbox->addWidget(new QLabel(tr("Threads:")));
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
m_threadBox = new QComboBox;
|
2011-09-01 16:36:27 +02:00
|
|
|
m_threadBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(m_threadBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
|
|
|
|
|
this, &DebuggerPluginPrivate::selectThread);
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
hbox->addWidget(m_threadBox);
|
|
|
|
|
hbox->addSpacerItem(new QSpacerItem(4, 0));
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2011-02-16 10:02:30 +01:00
|
|
|
m_mainWindow->setToolBar(CppLanguage, toolbarContainer);
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2013-07-10 11:56:13 +02:00
|
|
|
QWidget *qmlToolbar = new QWidget(m_mainWindow);
|
2012-04-18 14:20:54 +02:00
|
|
|
hbox = new QHBoxLayout(qmlToolbar);
|
|
|
|
|
hbox->setMargin(0);
|
|
|
|
|
hbox->setSpacing(0);
|
2014-07-17 12:14:14 +02:00
|
|
|
// currently broken
|
|
|
|
|
//hbox->addWidget(toolButton(Constants::QML_UPDATE_ON_SAVE));
|
2012-11-27 15:15:27 +01:00
|
|
|
hbox->addWidget(toolButton(Constants::QML_SHOW_APP_ON_TOP));
|
2012-08-15 16:19:15 +02:00
|
|
|
hbox->addWidget(new StyledSeparator);
|
2012-05-24 10:19:50 +02:00
|
|
|
hbox->addWidget(toolButton(Constants::QML_SELECTTOOL));
|
|
|
|
|
hbox->addWidget(toolButton(Constants::QML_ZOOMTOOL));
|
2012-08-15 16:19:15 +02:00
|
|
|
hbox->addWidget(new StyledSeparator);
|
2012-04-18 14:20:54 +02:00
|
|
|
m_mainWindow->setToolBar(QmlLanguage, qmlToolbar);
|
|
|
|
|
|
2012-03-26 17:30:57 +02:00
|
|
|
m_mainWindow->setToolBar(AnyLanguage, m_statusLabel);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(action(EnableReverseDebugging), &SavedAction::valueChanged,
|
|
|
|
|
this, &DebuggerPluginPrivate::enableReverseDebuggingTriggered);
|
2010-11-10 16:33:11 +01:00
|
|
|
|
2010-12-02 13:20:06 +01:00
|
|
|
setInitialState();
|
|
|
|
|
connectEngine(0);
|
2010-11-10 11:39:01 +01:00
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(SessionManager::instance(), &SessionManager::startupProjectChanged,
|
|
|
|
|
this, &DebuggerPluginPrivate::onCurrentProjectChanged);
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
m_commonOptionsPage = new CommonOptionsPage(m_globalDebuggerOptions);
|
|
|
|
|
m_plugin->addAutoReleasedObject(m_commonOptionsPage);
|
|
|
|
|
|
2013-09-04 18:39:43 +02:00
|
|
|
m_globalDebuggerOptions->fromSettings();
|
2010-11-10 11:39:01 +01:00
|
|
|
m_watchersWindow->setVisible(false);
|
|
|
|
|
m_returnWindow->setVisible(false);
|
2010-06-29 18:12:22 +02:00
|
|
|
|
2011-02-08 13:48:04 +01:00
|
|
|
// time gdb -i mi -ex 'b debuggerplugin.cpp:800' -ex r -ex q bin/qtcreator.bin
|
2010-06-16 11:08:54 +02:00
|
|
|
}
|
2010-05-05 12:41:52 +02:00
|
|
|
|
2014-07-28 14:23:52 +02:00
|
|
|
DebuggerEngine *currentEngine()
|
|
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
return dd->m_currentEngine;
|
2014-07-28 14:23:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SavedAction *action(int code)
|
2010-11-10 16:33:11 +01:00
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
return dd->m_debuggerSettings->item(code);
|
2010-11-10 16:33:11 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-28 14:23:52 +02:00
|
|
|
bool boolSetting(int code)
|
2010-11-10 16:33:11 +01:00
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
return dd->m_debuggerSettings->item(code)->value().toBool();
|
2010-11-10 16:33:11 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-28 14:23:52 +02:00
|
|
|
QString stringSetting(int code)
|
2010-11-10 16:33:11 +01:00
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
QString raw = dd->m_debuggerSettings->item(code)->value().toString();
|
2014-10-15 14:45:31 +02:00
|
|
|
return globalMacroExpander()->expand(raw);
|
2010-11-10 16:33:11 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-28 14:23:52 +02:00
|
|
|
QStringList stringListSetting(int code)
|
|
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
return dd->m_debuggerSettings->item(code)->value().toStringList();
|
2014-07-28 14:23:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BreakHandler *breakHandler()
|
2013-05-27 10:20:20 +02:00
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
return dd->m_breakHandler;
|
2013-05-27 10:20:20 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
void showModuleSymbols(const QString &moduleName, const Symbols &symbols)
|
2010-11-26 09:58:34 +01:00
|
|
|
{
|
|
|
|
|
QTreeWidget *w = new QTreeWidget;
|
2011-12-19 17:18:58 +01:00
|
|
|
w->setUniformRowHeights(true);
|
2010-11-26 09:58:34 +01:00
|
|
|
w->setColumnCount(5);
|
|
|
|
|
w->setRootIsDecorated(false);
|
|
|
|
|
w->setAlternatingRowColors(true);
|
|
|
|
|
w->setSortingEnabled(true);
|
2011-12-21 14:02:52 +01:00
|
|
|
w->setObjectName(QLatin1String("Symbols.") + moduleName);
|
2010-11-26 09:58:34 +01:00
|
|
|
QStringList header;
|
2014-10-22 13:04:47 +02:00
|
|
|
header.append(DebuggerPlugin::tr("Symbol"));
|
|
|
|
|
header.append(DebuggerPlugin::tr("Address"));
|
|
|
|
|
header.append(DebuggerPlugin::tr("Code"));
|
|
|
|
|
header.append(DebuggerPlugin::tr("Section"));
|
|
|
|
|
header.append(DebuggerPlugin::tr("Name"));
|
2010-11-26 09:58:34 +01:00
|
|
|
w->setHeaderLabels(header);
|
2014-10-22 13:04:47 +02:00
|
|
|
w->setWindowTitle(DebuggerPlugin::tr("Symbols in \"%1\"").arg(moduleName));
|
2010-11-26 09:58:34 +01:00
|
|
|
foreach (const Symbol &s, symbols) {
|
|
|
|
|
QTreeWidgetItem *it = new QTreeWidgetItem;
|
|
|
|
|
it->setData(0, Qt::DisplayRole, s.name);
|
|
|
|
|
it->setData(1, Qt::DisplayRole, s.address);
|
|
|
|
|
it->setData(2, Qt::DisplayRole, s.state);
|
|
|
|
|
it->setData(3, Qt::DisplayRole, s.section);
|
|
|
|
|
it->setData(4, Qt::DisplayRole, s.demangled);
|
|
|
|
|
w->addTopLevelItem(it);
|
|
|
|
|
}
|
2010-12-03 15:55:17 +01:00
|
|
|
createNewDock(w);
|
2010-11-26 09:58:34 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
void showModuleSections(const QString &moduleName, const Sections §ions)
|
2012-11-07 18:31:17 +01:00
|
|
|
{
|
|
|
|
|
QTreeWidget *w = new QTreeWidget;
|
|
|
|
|
w->setUniformRowHeights(true);
|
|
|
|
|
w->setColumnCount(5);
|
|
|
|
|
w->setRootIsDecorated(false);
|
|
|
|
|
w->setAlternatingRowColors(true);
|
|
|
|
|
w->setSortingEnabled(true);
|
|
|
|
|
w->setObjectName(QLatin1String("Sections.") + moduleName);
|
|
|
|
|
QStringList header;
|
2014-10-22 13:04:47 +02:00
|
|
|
header.append(DebuggerPlugin::tr("Name"));
|
|
|
|
|
header.append(DebuggerPlugin::tr("From"));
|
|
|
|
|
header.append(DebuggerPlugin::tr("To"));
|
|
|
|
|
header.append(DebuggerPlugin::tr("Address"));
|
|
|
|
|
header.append(DebuggerPlugin::tr("Flags"));
|
2012-11-07 18:31:17 +01:00
|
|
|
w->setHeaderLabels(header);
|
2014-10-22 13:04:47 +02:00
|
|
|
w->setWindowTitle(DebuggerPlugin::tr("Sections in \"%1\"").arg(moduleName));
|
2012-11-07 18:31:17 +01:00
|
|
|
foreach (const Section &s, sections) {
|
|
|
|
|
QTreeWidgetItem *it = new QTreeWidgetItem;
|
|
|
|
|
it->setData(0, Qt::DisplayRole, s.name);
|
|
|
|
|
it->setData(1, Qt::DisplayRole, s.from);
|
|
|
|
|
it->setData(2, Qt::DisplayRole, s.to);
|
|
|
|
|
it->setData(3, Qt::DisplayRole, s.address);
|
|
|
|
|
it->setData(4, Qt::DisplayRole, s.flags);
|
|
|
|
|
w->addTopLevelItem(it);
|
|
|
|
|
}
|
|
|
|
|
createNewDock(w);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 08:25:29 +01:00
|
|
|
void DebuggerPluginPrivate::aboutToShutdown()
|
|
|
|
|
{
|
2013-09-05 11:46:07 +02:00
|
|
|
disconnect(SessionManager::instance(),
|
2010-12-06 08:25:29 +01:00
|
|
|
SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
|
|
|
|
this, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
void updateState(DebuggerEngine *engine)
|
|
|
|
|
{
|
|
|
|
|
dd->updateState(engine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateWatchersWindow(bool showWatch, bool showReturn)
|
|
|
|
|
{
|
2015-03-16 13:21:02 +01:00
|
|
|
dd->m_watchersWindow->setVisible(showWatch);
|
|
|
|
|
dd->m_returnWindow->setVisible(showReturn);
|
2014-10-22 13:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QIcon locationMarkIcon()
|
|
|
|
|
{
|
|
|
|
|
return dd->m_locationMarkIcon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool hasSnapshots()
|
|
|
|
|
{
|
|
|
|
|
return dd->m_snapshotHandler->size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void openTextEditor(const QString &titlePattern0, const QString &contents)
|
|
|
|
|
{
|
|
|
|
|
if (dd->m_shuttingDown)
|
|
|
|
|
return;
|
|
|
|
|
QString titlePattern = titlePattern0;
|
|
|
|
|
IEditor *editor = EditorManager::openEditorWithContents(
|
2015-02-26 20:50:28 +03:00
|
|
|
CC::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern, contents.toUtf8(), QString(),
|
2014-10-22 13:04:47 +02:00
|
|
|
EditorManager::IgnoreNavigationHistory);
|
2015-07-20 17:07:28 +02:00
|
|
|
if (auto textEditor = qobject_cast<BaseTextEditor *>(editor)) {
|
|
|
|
|
QString suggestion = titlePattern;
|
|
|
|
|
if (!suggestion.contains(QLatin1Char('.')))
|
|
|
|
|
suggestion.append(QLatin1String(".txt"));
|
2016-01-14 14:45:01 +01:00
|
|
|
textEditor->textDocument()->setFallbackSaveAsFileName(suggestion);
|
2015-07-20 17:07:28 +02:00
|
|
|
}
|
2014-10-22 13:04:47 +02:00
|
|
|
QTC_ASSERT(editor, return);
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
bool isActiveDebugLanguage(int language)
|
|
|
|
|
{
|
|
|
|
|
return dd->m_mainWindow->activeDebugLanguages() & language;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// void runTest(const QString &fileName);
|
|
|
|
|
void showMessage(const QString &msg, int channel, int timeout)
|
|
|
|
|
{
|
|
|
|
|
dd->showMessage(msg, channel, timeout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void runControlStarted(DebuggerEngine *engine)
|
|
|
|
|
{
|
|
|
|
|
dd->runControlStarted(engine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void runControlFinished(DebuggerEngine *engine)
|
|
|
|
|
{
|
|
|
|
|
dd->runControlFinished(engine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void displayDebugger(DebuggerEngine *engine, bool updateEngine)
|
|
|
|
|
{
|
|
|
|
|
dd->displayDebugger(engine, updateEngine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DebuggerLanguages activeLanguages()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(dd->m_mainWindow, return AnyLanguage);
|
|
|
|
|
return dd->m_mainWindow->activeDebugLanguages();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void synchronizeBreakpoints()
|
|
|
|
|
{
|
|
|
|
|
dd->synchronizeBreakpoints();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *mainWindow()
|
|
|
|
|
{
|
2015-03-20 12:10:35 +01:00
|
|
|
return dd->m_mainWindow;
|
2014-10-22 13:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isDockVisible(const QString &objectName)
|
|
|
|
|
{
|
2015-03-20 12:10:35 +01:00
|
|
|
QDockWidget *dock = dd->m_mainWindow->findChild<QDockWidget *>(objectName);
|
|
|
|
|
return dock && dock->toggleViewAction()->isChecked();
|
2014-10-22 13:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void openMemoryEditor()
|
|
|
|
|
{
|
|
|
|
|
AddressDialog dialog;
|
2014-12-17 13:14:29 +01:00
|
|
|
if (dialog.exec() == QDialog::Accepted) {
|
|
|
|
|
MemoryViewSetupData data;
|
|
|
|
|
data.startAddress = dialog.address();
|
|
|
|
|
currentEngine()->openMemoryView(data);
|
|
|
|
|
}
|
2014-10-22 13:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-12 11:55:57 +02:00
|
|
|
void setThreadBoxContents(const QStringList &list, int index)
|
2014-10-22 13:04:47 +02:00
|
|
|
{
|
2015-06-12 11:55:57 +02:00
|
|
|
dd->setThreadBoxContents(list, index);
|
2014-10-22 13:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSharedPointer<Internal::GlobalDebuggerOptions> globalDebuggerOptions()
|
|
|
|
|
{
|
|
|
|
|
return dd->m_globalDebuggerOptions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// DebuggerPlugin
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2011-02-04 15:08:31 +01:00
|
|
|
/*!
|
|
|
|
|
\class Debugger::DebuggerPlugin
|
|
|
|
|
|
|
|
|
|
This is the "external" interface of the debugger plugin that's visible
|
|
|
|
|
from Qt Creator core. The internal interface to global debugger
|
|
|
|
|
functionality that is used by debugger views and debugger engines
|
2012-12-30 11:37:50 +01:00
|
|
|
is DebuggerCore, implemented in DebuggerPluginPrivate.
|
|
|
|
|
*/
|
2011-02-04 15:08:31 +01:00
|
|
|
|
2016-02-24 14:42:52 +01:00
|
|
|
static DebuggerPlugin *m_instance = 0;
|
|
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
DebuggerPlugin::DebuggerPlugin()
|
2010-07-13 15:57:34 +02:00
|
|
|
{
|
2014-10-28 08:26:25 +01:00
|
|
|
setObjectName(QLatin1String("DebuggerPlugin"));
|
2014-10-22 13:04:47 +02:00
|
|
|
dd = new DebuggerPluginPrivate(this);
|
2016-02-24 14:42:52 +01:00
|
|
|
m_instance = this;
|
2010-08-18 13:54:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
DebuggerPlugin::~DebuggerPlugin()
|
2010-08-18 13:54:12 +02:00
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
delete dd;
|
|
|
|
|
dd = 0;
|
2016-02-24 14:42:52 +01:00
|
|
|
m_instance = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DebuggerPlugin *DebuggerPlugin::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
2010-07-13 15:57:34 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
2010-06-16 11:08:54 +02:00
|
|
|
{
|
2015-06-16 15:24:42 +02:00
|
|
|
addObject(this);
|
2011-10-10 13:38:58 +02:00
|
|
|
// Menu groups
|
2012-07-18 16:20:19 +02:00
|
|
|
ActionContainer *mstart = ActionManager::actionContainer(PE::M_DEBUG_STARTDEBUGGING);
|
2012-08-15 16:19:15 +02:00
|
|
|
mstart->appendGroup(Constants::G_GENERAL);
|
|
|
|
|
mstart->appendGroup(Constants::G_SPECIAL);
|
2011-10-10 13:38:58 +02:00
|
|
|
mstart->appendGroup(Constants::G_START_QML);
|
|
|
|
|
|
2011-10-19 11:51:51 +02:00
|
|
|
// Separators
|
2015-02-26 13:58:00 +01:00
|
|
|
mstart->addSeparator(Constants::G_GENERAL);
|
|
|
|
|
mstart->addSeparator(Constants::G_SPECIAL);
|
2011-10-10 13:38:58 +02:00
|
|
|
|
2013-10-09 12:42:00 +02:00
|
|
|
addAutoReleasedObject(new DebuggerItemManager);
|
2013-08-14 18:30:40 +02:00
|
|
|
DebuggerItemManager::restoreDebuggers();
|
|
|
|
|
|
2013-08-21 12:48:46 +02:00
|
|
|
KitManager::registerKitInformation(new DebuggerKitInformation);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2016-02-24 14:42:52 +01:00
|
|
|
// Ex-Analyzer stuff
|
|
|
|
|
(void) new AnalyzerManager(this);
|
|
|
|
|
|
|
|
|
|
// Task integration.
|
|
|
|
|
//: Category under which Analyzer tasks are listed in Issues view
|
|
|
|
|
ProjectExplorer::TaskHub::addCategory(Analyzer::Constants::ANALYZERTASK_ID, tr("Analyzer"));
|
|
|
|
|
|
2014-10-22 13:04:47 +02:00
|
|
|
return dd->initialize(arguments, errorMessage);
|
2010-06-16 11:08:54 +02:00
|
|
|
}
|
|
|
|
|
|
2011-12-06 15:39:25 +01:00
|
|
|
IPlugin::ShutdownFlag DebuggerPlugin::aboutToShutdown()
|
2010-06-16 11:08:54 +02:00
|
|
|
{
|
2014-10-28 10:01:19 +01:00
|
|
|
removeObject(this);
|
2014-10-22 13:04:47 +02:00
|
|
|
dd->aboutToShutdown();
|
2016-02-24 14:42:52 +01:00
|
|
|
AnalyzerManager::shutdown();
|
2010-11-10 11:39:01 +01:00
|
|
|
return SynchronousShutdown;
|
2010-06-16 11:08:54 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-11 18:15:49 +02:00
|
|
|
QObject *DebuggerPlugin::remoteCommand(const QStringList &options,
|
2015-03-09 10:59:58 +02:00
|
|
|
const QString &workingDirectory,
|
|
|
|
|
const QStringList &list)
|
2010-06-16 11:08:54 +02:00
|
|
|
{
|
2015-03-09 10:59:58 +02:00
|
|
|
Q_UNUSED(workingDirectory);
|
|
|
|
|
Q_UNUSED(list);
|
|
|
|
|
dd->remoteCommand(options);
|
2013-03-11 18:15:49 +02:00
|
|
|
return 0;
|
2010-06-16 11:08:54 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
void DebuggerPlugin::extensionsInitialized()
|
2010-11-05 13:35:31 +01:00
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
dd->extensionsInitialized();
|
2010-11-05 13:35:31 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-23 16:45:00 +01:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
|
2012-01-25 17:28:06 +01:00
|
|
|
void DebuggerPluginPrivate::testLoadProject(const QString &proFile, const TestCallBack &cb)
|
2012-01-23 16:45:00 +01:00
|
|
|
{
|
2014-11-19 17:58:33 +01:00
|
|
|
connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged,
|
2014-09-12 01:08:28 +02:00
|
|
|
this, &DebuggerPluginPrivate::testProjectLoaded);
|
2012-01-23 16:45:00 +01:00
|
|
|
|
2012-01-25 17:28:06 +01:00
|
|
|
m_testCallbacks.append(cb);
|
2015-08-20 14:47:02 +02:00
|
|
|
ProjectExplorerPlugin::OpenProjectResult result = ProjectExplorerPlugin::openProject(proFile);
|
|
|
|
|
if (result) {
|
2012-10-31 18:14:17 +01:00
|
|
|
// Will end up in callback below due to the connections to
|
|
|
|
|
// signal currentProjectChanged().
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-01-23 16:45:00 +01:00
|
|
|
|
2012-10-31 18:14:17 +01:00
|
|
|
// Project opening failed. Eat the unused callback.
|
2015-08-20 14:47:02 +02:00
|
|
|
qWarning("Cannot open %s: %s", qPrintable(proFile), qPrintable(result.errorMessage()));
|
2012-01-25 17:28:06 +01:00
|
|
|
QVERIFY(false);
|
|
|
|
|
m_testCallbacks.pop_back();
|
2012-01-23 16:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPluginPrivate::testProjectLoaded(Project *project)
|
|
|
|
|
{
|
|
|
|
|
if (!project) {
|
|
|
|
|
qWarning("Changed to null project.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-10-31 18:14:17 +01:00
|
|
|
m_testProject = project;
|
|
|
|
|
connect(project, SIGNAL(proFilesEvaluated()), SLOT(testProjectEvaluated()));
|
2015-11-27 16:14:14 +01:00
|
|
|
project->configureAsExampleProject({ });
|
2012-10-31 18:14:17 +01:00
|
|
|
}
|
2012-01-25 17:28:06 +01:00
|
|
|
|
2012-10-31 18:14:17 +01:00
|
|
|
void DebuggerPluginPrivate::testProjectEvaluated()
|
|
|
|
|
{
|
2014-05-02 12:22:58 +02:00
|
|
|
QString fileName = m_testProject->projectFilePath().toUserOutput();
|
2012-01-23 16:45:00 +01:00
|
|
|
QVERIFY(!fileName.isEmpty());
|
|
|
|
|
qWarning("Project %s loaded", qPrintable(fileName));
|
2013-09-05 14:36:20 +02:00
|
|
|
connect(BuildManager::instance(), SIGNAL(buildQueueFinished(bool)),
|
2015-02-12 13:50:54 +01:00
|
|
|
this, SLOT(testProjectBuilt(bool)));
|
2014-09-12 01:08:28 +02:00
|
|
|
ProjectExplorerPlugin::buildProject(m_testProject);
|
2012-10-31 18:14:17 +01:00
|
|
|
}
|
2012-01-23 16:45:00 +01:00
|
|
|
|
2012-10-31 18:14:17 +01:00
|
|
|
void DebuggerPluginPrivate::testProjectBuilt(bool success)
|
|
|
|
|
{
|
|
|
|
|
QVERIFY(success);
|
2012-01-25 17:28:06 +01:00
|
|
|
QVERIFY(!m_testCallbacks.isEmpty());
|
|
|
|
|
TestCallBack cb = m_testCallbacks.takeLast();
|
|
|
|
|
invoke<void>(cb.receiver, cb.slot);
|
|
|
|
|
}
|
2012-01-23 16:45:00 +01:00
|
|
|
|
2012-01-25 17:28:06 +01:00
|
|
|
void DebuggerPluginPrivate::testUnloadProject()
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
|
|
|
|
|
invoke<void>(pe, "unloadProject");
|
|
|
|
|
}
|
2012-01-23 16:45:00 +01:00
|
|
|
|
2013-09-10 16:30:13 +02:00
|
|
|
//static Target *activeTarget()
|
|
|
|
|
//{
|
|
|
|
|
// Project *project = ProjectExplorerPlugin::instance()->currentProject();
|
|
|
|
|
// return project->activeTarget();
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//static Kit *currentKit()
|
|
|
|
|
//{
|
|
|
|
|
// Target *t = activeTarget();
|
|
|
|
|
// if (!t || !t->isEnabled())
|
|
|
|
|
// return 0;
|
|
|
|
|
// return t->kit();
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//static LocalApplicationRunConfiguration *activeLocalRunConfiguration()
|
|
|
|
|
//{
|
|
|
|
|
// Target *t = activeTarget();
|
|
|
|
|
// return t ? qobject_cast<LocalApplicationRunConfiguration *>(t->activeRunConfiguration()) : 0;
|
|
|
|
|
//}
|
2012-01-25 17:28:06 +01:00
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
void DebuggerPluginPrivate::testRunProject(const DebuggerRunParameters &rp, const TestCallBack &cb)
|
2012-01-25 17:28:06 +01:00
|
|
|
{
|
|
|
|
|
m_testCallbacks.append(cb);
|
2015-06-24 08:26:35 +02:00
|
|
|
RunControl *rc = createAndScheduleRun(rp, 0);
|
2014-10-22 13:04:47 +02:00
|
|
|
connect(rc, &RunControl::finished, this, &DebuggerPluginPrivate::testRunControlFinished);
|
2012-01-23 16:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPluginPrivate::testRunControlFinished()
|
|
|
|
|
{
|
2012-01-25 17:28:06 +01:00
|
|
|
QVERIFY(!m_testCallbacks.isEmpty());
|
|
|
|
|
TestCallBack cb = m_testCallbacks.takeLast();
|
|
|
|
|
ExtensionSystem::invoke<void>(cb.receiver, cb.slot);
|
|
|
|
|
}
|
2012-01-23 16:45:00 +01:00
|
|
|
|
2012-01-25 17:28:06 +01:00
|
|
|
void DebuggerPluginPrivate::testFinished()
|
|
|
|
|
{
|
2012-01-23 16:45:00 +01:00
|
|
|
QTestEventLoop::instance().exitLoop();
|
2012-01-25 17:28:06 +01:00
|
|
|
QVERIFY(m_testSuccess);
|
2012-01-23 16:45:00 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-25 17:28:06 +01:00
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2013-09-10 13:37:31 +02:00
|
|
|
//void DebuggerPlugin::testStateMachine()
|
|
|
|
|
//{
|
2014-10-22 13:04:47 +02:00
|
|
|
// dd->testStateMachine1();
|
2013-09-10 13:37:31 +02:00
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//void DebuggerPluginPrivate::testStateMachine1()
|
|
|
|
|
//{
|
|
|
|
|
// m_testSuccess = true;
|
|
|
|
|
// QString proFile = ICore::resourcePath();
|
|
|
|
|
// if (Utils::HostOsInfo::isMacHost())
|
|
|
|
|
// proFile += QLatin1String("/../..");
|
|
|
|
|
// proFile += QLatin1String("/../../tests/manual/debugger/simple/simple.pro");
|
|
|
|
|
// testLoadProject(proFile, TestCallBack(this, "testStateMachine2"));
|
|
|
|
|
// QVERIFY(m_testSuccess);
|
|
|
|
|
// QTestEventLoop::instance().enterLoop(20);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//void DebuggerPluginPrivate::testStateMachine2()
|
|
|
|
|
//{
|
2015-05-27 13:59:56 +02:00
|
|
|
// DebuggerRunParameters sp;
|
2013-09-10 13:37:31 +02:00
|
|
|
// fillParameters(&sp, currentKit());
|
|
|
|
|
// sp.executable = activeLocalRunConfiguration()->executable();
|
|
|
|
|
// sp.testCase = TestNoBoundsOfCurrentFunction;
|
|
|
|
|
// testRunProject(sp, TestCallBack(this, "testStateMachine3"));
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//void DebuggerPluginPrivate::testStateMachine3()
|
|
|
|
|
//{
|
|
|
|
|
// testUnloadProject();
|
|
|
|
|
// testFinished();
|
|
|
|
|
//}
|
2012-01-26 13:14:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::testBenchmark()
|
|
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
dd->testBenchmark1();
|
2012-01-26 13:14:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum FakeEnum { FakeDebuggerCommonSettingsId };
|
|
|
|
|
|
|
|
|
|
void DebuggerPluginPrivate::testBenchmark1()
|
|
|
|
|
{
|
|
|
|
|
#ifdef WITH_BENCHMARK
|
|
|
|
|
CALLGRIND_START_INSTRUMENTATION;
|
2015-02-03 23:58:49 +02:00
|
|
|
volatile Id id1 = Id(DEBUGGER_COMMON_SETTINGS_ID);
|
2012-01-26 13:14:00 +01:00
|
|
|
CALLGRIND_STOP_INSTRUMENTATION;
|
|
|
|
|
CALLGRIND_DUMP_STATS;
|
|
|
|
|
|
|
|
|
|
CALLGRIND_START_INSTRUMENTATION;
|
|
|
|
|
volatile FakeEnum id2 = FakeDebuggerCommonSettingsId;
|
|
|
|
|
CALLGRIND_STOP_INSTRUMENTATION;
|
|
|
|
|
CALLGRIND_DUMP_STATS;
|
2012-01-23 16:45:00 +01:00
|
|
|
#endif
|
2012-01-26 13:14:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // if WITH_TESTS
|
2012-01-23 16:45:00 +01:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
} // namespace Debugger
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "debuggerplugin.moc"
|