2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "debuggerplugin.h"
|
|
|
|
|
|
2009-04-28 15:08:52 +02:00
|
|
|
#include "breakhandler.h"
|
2009-03-17 17:00:06 +01:00
|
|
|
#include "debuggeractions.h"
|
2009-05-25 16:22:11 +02:00
|
|
|
#include "debuggerdialogs.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "debuggerconstants.h"
|
|
|
|
|
#include "debuggermanager.h"
|
|
|
|
|
#include "debuggerrunner.h"
|
2009-09-25 15:02:16 +02:00
|
|
|
#include "debuggerstringutils.h"
|
2010-02-09 20:44:40 +01:00
|
|
|
#include "debuggeruiswitcher.h"
|
|
|
|
|
#include "debuggermainwindow.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-04-17 09:03:32 +02:00
|
|
|
#include "ui_commonoptionspage.h"
|
2009-03-23 12:28:02 +01:00
|
|
|
#include "ui_dumperoptionpage.h"
|
2009-01-14 18:09:02 +01:00
|
|
|
|
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>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2009-01-13 18:15:24 +01:00
|
|
|
#include <coreplugin/basemode.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2009-01-14 18:09:02 +01:00
|
|
|
#include <coreplugin/dialogs/ioptionspage.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2009-01-13 18:15:24 +01:00
|
|
|
#include <coreplugin/findplaceholder.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2009-10-26 18:05:11 +01:00
|
|
|
#include <coreplugin/icorelistener.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/messagemanager.h>
|
2009-01-13 18:15:24 +01:00
|
|
|
#include <coreplugin/minisplitter.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/modemanager.h>
|
2009-01-13 18:15:24 +01:00
|
|
|
#include <coreplugin/navigationwidget.h>
|
|
|
|
|
#include <coreplugin/outputpane.h>
|
|
|
|
|
#include <coreplugin/rightpane.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/uniqueidmanager.h>
|
2008-12-09 16:18:28 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <cplusplus/ExpressionUnderCursor.h>
|
2008-12-09 16:18:28 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <cppeditor/cppeditorconstants.h>
|
2008-12-09 16:18:28 +01:00
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
2009-11-24 15:05:02 +01:00
|
|
|
#include <coreplugin/manhattanstyle.h>
|
2009-01-28 14:29:54 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/session.h>
|
2009-09-29 11:39:55 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2008-12-09 16:18:28 +01:00
|
|
|
|
|
|
|
|
#include <texteditor/basetexteditor.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <texteditor/basetextmark.h>
|
|
|
|
|
#include <texteditor/itexteditor.h>
|
|
|
|
|
#include <texteditor/texteditorconstants.h>
|
2010-02-12 14:15:20 +01:00
|
|
|
#include <texteditor/texteditorplugin.h>
|
2008-12-09 16:18:28 +01:00
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
2009-07-16 15:57:59 +02:00
|
|
|
#include <utils/styledbar.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <utils/savedaction.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
|
#include <QtCore/QPoint>
|
|
|
|
|
#include <QtCore/QSettings>
|
2009-01-05 12:54:52 +01:00
|
|
|
#include <QtCore/QtPlugin>
|
2009-04-17 09:03:32 +02:00
|
|
|
#include <QtCore/QCoreApplication>
|
2009-05-25 16:22:11 +02:00
|
|
|
#include <QtCore/QTimer>
|
2010-03-10 13:46:05 +01:00
|
|
|
#include <QtCore/QVariant>
|
2008-12-09 16:18:28 +01:00
|
|
|
|
2009-01-14 18:09:02 +01:00
|
|
|
#include <QtGui/QLineEdit>
|
2009-01-13 17:41:23 +01:00
|
|
|
#include <QtGui/QDockWidget>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QPlainTextEdit>
|
|
|
|
|
#include <QtGui/QTextBlock>
|
|
|
|
|
#include <QtGui/QTextCursor>
|
2009-10-01 16:38:08 +02:00
|
|
|
#include <QtGui/QToolButton>
|
2009-05-25 16:22:11 +02:00
|
|
|
#include <QtGui/QMessageBox>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
#include <QtGui/QMenu>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-08-12 10:51:25 +02:00
|
|
|
#include <climits>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Core;
|
2010-02-09 20:44:40 +01:00
|
|
|
using namespace Debugger;
|
2009-01-13 18:15:24 +01:00
|
|
|
using namespace Debugger::Constants;
|
|
|
|
|
using namespace Debugger::Internal;
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace ProjectExplorer;
|
2009-01-13 18:15:24 +01:00
|
|
|
using namespace TextEditor;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
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 {
|
|
|
|
|
namespace Constants {
|
|
|
|
|
|
2009-06-08 19:28:28 +02:00
|
|
|
const char * const M_DEBUG_START_DEBUGGING = "QtCreator.Menu.Debug.StartDebugging";
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
const char * const STARTEXTERNAL = "Debugger.StartExternal";
|
|
|
|
|
const char * const ATTACHEXTERNAL = "Debugger.AttachExternal";
|
2009-03-02 15:14:12 +01:00
|
|
|
const char * const ATTACHCORE = "Debugger.AttachCore";
|
2009-05-04 14:47:45 +02:00
|
|
|
const char * const ATTACHREMOTE = "Debugger.AttachRemote";
|
2009-05-07 15:20:44 +02:00
|
|
|
const char * const DETACH = "Debugger.Detach";
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-08 09:13:21 +01:00
|
|
|
const char * const RUN_TO_LINE1 = "Debugger.RunToLine1";
|
|
|
|
|
const char * const RUN_TO_LINE2 = "Debugger.RunToLine2";
|
2008-12-02 12:01:29 +01:00
|
|
|
const char * const RUN_TO_FUNCTION = "Debugger.RunToFunction";
|
2010-02-08 09:13:21 +01:00
|
|
|
const char * const JUMP_TO_LINE1 = "Debugger.JumpToLine1";
|
|
|
|
|
const char * const JUMP_TO_LINE2 = "Debugger.JumpToLine2";
|
2010-02-15 16:02:41 +01:00
|
|
|
const char * const RETURN_FROM_FUNCTION = "Debugger.ReturnFromFunction";
|
2010-02-02 17:25:14 +01:00
|
|
|
const char * const SNAPSHOT = "Debugger.Snapshot";
|
2008-12-02 12:01:29 +01:00
|
|
|
const char * const TOGGLE_BREAK = "Debugger.ToggleBreak";
|
|
|
|
|
const char * const BREAK_BY_FUNCTION = "Debugger.BreakByFunction";
|
|
|
|
|
const char * const BREAK_AT_MAIN = "Debugger.BreakAtMain";
|
2009-12-11 18:19:51 +01:00
|
|
|
const char * const ADD_TO_WATCH1 = "Debugger.AddToWatch1";
|
|
|
|
|
const char * const ADD_TO_WATCH2 = "Debugger.AddToWatch2";
|
2009-09-29 11:13:19 +02:00
|
|
|
const char * const OPERATE_BY_INSTRUCTION = "Debugger.OperateByInstruction";
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-03 20:45:49 +02:00
|
|
|
#ifdef Q_WS_MAC
|
2008-12-02 12:01:29 +01:00
|
|
|
const char * const INTERRUPT_KEY = "Shift+F5";
|
|
|
|
|
const char * const RESET_KEY = "Ctrl+Shift+F5";
|
|
|
|
|
const char * const STEP_KEY = "F7";
|
|
|
|
|
const char * const STEPOUT_KEY = "Shift+F7";
|
|
|
|
|
const char * const NEXT_KEY = "F6";
|
2009-05-25 17:19:42 +02:00
|
|
|
const char * const REVERSE_KEY = "";
|
2008-12-02 12:01:29 +01:00
|
|
|
const char * const RUN_TO_LINE_KEY = "Shift+F8";
|
|
|
|
|
const char * const RUN_TO_FUNCTION_KEY = "Ctrl+F6";
|
|
|
|
|
const char * const JUMP_TO_LINE_KEY = "Alt+D,Alt+L";
|
|
|
|
|
const char * const TOGGLE_BREAK_KEY = "F8";
|
|
|
|
|
const char * const BREAK_BY_FUNCTION_KEY = "Alt+D,Alt+F";
|
|
|
|
|
const char * const BREAK_AT_MAIN_KEY = "Alt+D,Alt+M";
|
|
|
|
|
const char * const ADD_TO_WATCH_KEY = "Alt+D,Alt+W";
|
2010-02-02 17:25:14 +01:00
|
|
|
const char * const SNAPSHOT_KEY = "Alt+D,Alt+S";
|
2008-12-02 12:01:29 +01:00
|
|
|
#else
|
|
|
|
|
const char * const INTERRUPT_KEY = "Shift+F5";
|
|
|
|
|
const char * const RESET_KEY = "Ctrl+Shift+F5";
|
|
|
|
|
const char * const STEP_KEY = "F11";
|
|
|
|
|
const char * const STEPOUT_KEY = "Shift+F11";
|
|
|
|
|
const char * const NEXT_KEY = "F10";
|
2009-05-25 17:19:42 +02:00
|
|
|
const char * const REVERSE_KEY = "F12";
|
2008-12-02 12:01:29 +01:00
|
|
|
const char * const RUN_TO_LINE_KEY = "";
|
|
|
|
|
const char * const RUN_TO_FUNCTION_KEY = "";
|
|
|
|
|
const char * const JUMP_TO_LINE_KEY = "";
|
|
|
|
|
const char * const TOGGLE_BREAK_KEY = "F9";
|
|
|
|
|
const char * const BREAK_BY_FUNCTION_KEY = "";
|
|
|
|
|
const char * const BREAK_AT_MAIN_KEY = "";
|
|
|
|
|
const char * const ADD_TO_WATCH_KEY = "Ctrl+Alt+Q";
|
2010-02-02 17:25:14 +01:00
|
|
|
const char * const SNAPSHOT_KEY = "Alt+D,Alt+S";
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
} // namespace Constants
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
|
|
|
|
|
2009-01-28 14:29:54 +01:00
|
|
|
static ProjectExplorer::SessionManager *sessionManager()
|
|
|
|
|
{
|
|
|
|
|
return ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-28 15:08:52 +02:00
|
|
|
static QSettings *settings()
|
|
|
|
|
{
|
|
|
|
|
return ICore::instance()->settings();
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-16 15:57:59 +02:00
|
|
|
static QToolButton *toolButton(QAction *action)
|
|
|
|
|
{
|
|
|
|
|
QToolButton *button = new QToolButton;
|
|
|
|
|
button->setDefaultAction(action);
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-14 18:09:02 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// DebugMode
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2009-01-13 18:15:24 +01:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class DebugMode : public Core::BaseMode
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
DebugMode(QObject *parent = 0);
|
|
|
|
|
~DebugMode();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DebugMode::DebugMode(QObject *parent)
|
2009-01-14 12:00:22 +01:00
|
|
|
: BaseMode(parent)
|
2009-01-13 18:15:24 +01:00
|
|
|
{
|
2010-01-07 18:17:24 +01:00
|
|
|
setDisplayName(tr("Debug"));
|
2010-03-11 12:22:24 +01:00
|
|
|
setId(MODE_DEBUG);
|
2009-01-14 12:00:22 +01:00
|
|
|
setIcon(QIcon(":/fancyactionbar/images/mode_Debug.png"));
|
2010-03-11 12:22:24 +01:00
|
|
|
setPriority(P_MODE_DEBUG);
|
2009-01-13 18:15:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DebugMode::~DebugMode()
|
|
|
|
|
{
|
|
|
|
|
// Make sure the editor manager does not get deleted
|
|
|
|
|
EditorManager::instance()->setParent(0);
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-26 18:05:11 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// DebuggerListener: Close the debugging session if running.
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-03-11 11:07:16 +01:00
|
|
|
class DebuggerListener : public Core::ICoreListener
|
|
|
|
|
{
|
2009-10-26 18:05:11 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2010-03-11 12:22:24 +01:00
|
|
|
DebuggerListener() {}
|
2009-10-26 18:05:11 +01:00
|
|
|
virtual bool coreAboutToClose();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool DebuggerListener::coreAboutToClose()
|
|
|
|
|
{
|
|
|
|
|
DebuggerManager *mgr = DebuggerManager::instance();
|
|
|
|
|
if (!mgr)
|
|
|
|
|
return true;
|
|
|
|
|
// Ask to terminate the session.
|
|
|
|
|
bool cleanTermination = false;
|
|
|
|
|
switch (mgr->state()) {
|
|
|
|
|
case DebuggerNotReady:
|
|
|
|
|
return true;
|
|
|
|
|
case AdapterStarted: // Most importantly, terminating a running
|
|
|
|
|
case AdapterStartFailed: // debuggee can cause problems.
|
|
|
|
|
case InferiorUnrunnable:
|
|
|
|
|
case InferiorStartFailed:
|
|
|
|
|
case InferiorStopped:
|
|
|
|
|
case InferiorShutDown:
|
|
|
|
|
cleanTermination = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-03-11 12:22:24 +01:00
|
|
|
|
2009-10-26 18:05:11 +01:00
|
|
|
const QString question = cleanTermination ?
|
2010-03-11 12:22:24 +01:00
|
|
|
tr("A debugging session is still in progress.\n"
|
|
|
|
|
"Would you like to terminate it?") :
|
|
|
|
|
tr("A debugging session is still in progress. "
|
|
|
|
|
"Terminating the session in the current"
|
2009-10-26 18:05:11 +01:00
|
|
|
" state (%1) can leave the target in an inconsistent state."
|
2009-10-27 19:34:40 +01:00
|
|
|
" Would you still like to terminate it?")
|
2010-03-11 12:22:24 +01:00
|
|
|
.arg(_(DebuggerManager::stateName(mgr->state())));
|
|
|
|
|
|
|
|
|
|
QMessageBox::StandardButton answer =
|
|
|
|
|
QMessageBox::question(DebuggerUISwitcher::instance()->mainWindow(),
|
|
|
|
|
tr("Close Debugging Session"), question,
|
|
|
|
|
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
|
|
|
|
|
|
2009-10-27 19:34:40 +01:00
|
|
|
if (answer != QMessageBox::Yes)
|
2009-10-26 18:05:11 +01:00
|
|
|
return false;
|
2010-03-11 12:22:24 +01:00
|
|
|
|
2009-10-26 18:05:11 +01:00
|
|
|
mgr->exitDebugger();
|
2009-10-27 09:51:14 +01:00
|
|
|
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
2009-10-26 18:05:11 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-14 18:09:02 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
2009-01-13 18:15:24 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// LocationMark
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2009-01-14 18:09:02 +01:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-08-14 13:04:05 +02:00
|
|
|
// Used in "real" editors
|
2009-01-14 18:09:02 +01:00
|
|
|
class LocationMark : public TextEditor::BaseTextMark
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
LocationMark(const QString &fileName, int linenumber)
|
|
|
|
|
: BaseTextMark(fileName, linenumber)
|
2008-12-12 17:49:52 +01:00
|
|
|
{}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-10 10:47:34 +01:00
|
|
|
QIcon icon() const { return DebuggerManager::instance()->locationMarkIcon(); }
|
2008-12-02 12:01:29 +01:00
|
|
|
void updateLineNumber(int /*lineNumber*/) {}
|
|
|
|
|
void updateBlock(const QTextBlock & /*block*/) {}
|
2008-12-12 17:49:52 +01:00
|
|
|
void removedFromEditor() {}
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2009-01-14 18:09:02 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2009-04-17 09:03:32 +02:00
|
|
|
// CommonOptionsPage
|
2009-01-14 18:09:02 +01:00
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-04-17 09:03:32 +02:00
|
|
|
class CommonOptionsPage : public Core::IOptionsPage
|
2009-01-14 18:09:02 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2009-04-17 09:03:32 +02:00
|
|
|
CommonOptionsPage() {}
|
2009-01-14 18:09:02 +01:00
|
|
|
|
|
|
|
|
// IOptionsPage
|
2009-04-28 15:08:52 +02:00
|
|
|
QString id() const
|
2010-03-11 12:22:24 +01:00
|
|
|
{ return _(DEBUGGER_COMMON_SETTINGS_ID); }
|
2010-01-07 18:17:24 +01:00
|
|
|
QString displayName() const
|
2010-03-11 12:22:24 +01:00
|
|
|
{ return QCoreApplication::translate("Debugger", DEBUGGER_COMMON_SETTINGS_NAME); }
|
2009-04-28 15:08:52 +02:00
|
|
|
QString category() const
|
2010-03-11 12:22:24 +01:00
|
|
|
{ return _(DEBUGGER_SETTINGS_CATEGORY); }
|
2010-01-07 18:17:24 +01:00
|
|
|
QString displayCategory() const
|
2010-03-11 12:22:24 +01:00
|
|
|
{ return QCoreApplication::translate("Debugger", DEBUGGER_SETTINGS_TR_CATEGORY); }
|
2010-03-26 17:34:10 +01:00
|
|
|
QIcon categoryIcon() const
|
|
|
|
|
{ return QIcon(QLatin1String(DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON)); }
|
2009-01-14 18:09:02 +01:00
|
|
|
|
|
|
|
|
QWidget *createPage(QWidget *parent);
|
2009-04-28 15:08:52 +02:00
|
|
|
void apply() { m_group.apply(settings()); }
|
2009-03-26 15:56:16 +01:00
|
|
|
void finish() { m_group.finish(); }
|
2009-11-24 15:05:02 +01:00
|
|
|
virtual bool matches(const QString &s) const;
|
2009-01-14 18:09:02 +01:00
|
|
|
|
|
|
|
|
private:
|
2009-04-17 09:03:32 +02:00
|
|
|
Ui::CommonOptionsPage m_ui;
|
2009-10-05 11:06:05 +02:00
|
|
|
Utils::SavedActionSet m_group;
|
2009-11-24 15:05:02 +01:00
|
|
|
QString m_searchKeywords;
|
2009-01-14 18:09:02 +01:00
|
|
|
};
|
|
|
|
|
|
2009-04-17 09:03:32 +02:00
|
|
|
QWidget *CommonOptionsPage::createPage(QWidget *parent)
|
2009-01-14 18:09:02 +01:00
|
|
|
{
|
|
|
|
|
QWidget *w = new QWidget(parent);
|
|
|
|
|
m_ui.setupUi(w);
|
2009-03-26 17:27:44 +01:00
|
|
|
m_group.clear();
|
2009-03-26 15:56:16 +01:00
|
|
|
|
2010-03-18 10:56:25 +01:00
|
|
|
m_group.insert(theDebuggerAction(SwitchLanguageAutomatically),
|
|
|
|
|
m_ui.checkBoxChangeLanguageAutomatically);
|
|
|
|
|
|
2009-05-25 16:22:11 +02:00
|
|
|
m_group.insert(theDebuggerAction(ListSourceFiles),
|
2009-03-26 17:27:44 +01:00
|
|
|
m_ui.checkBoxListSourceFiles);
|
2009-05-25 16:22:11 +02:00
|
|
|
m_group.insert(theDebuggerAction(UseAlternatingRowColors),
|
2009-05-05 10:14:35 +02:00
|
|
|
m_ui.checkBoxUseAlternatingRowColors);
|
2009-08-13 14:33:02 +02:00
|
|
|
m_group.insert(theDebuggerAction(UseMessageBoxForSignals),
|
|
|
|
|
m_ui.checkBoxUseMessageBoxForSignals);
|
2009-05-25 16:22:11 +02:00
|
|
|
m_group.insert(theDebuggerAction(SkipKnownFrames),
|
2009-03-26 15:56:16 +01:00
|
|
|
m_ui.checkBoxSkipKnownFrames);
|
2010-01-29 21:33:57 +01:00
|
|
|
m_group.insert(theDebuggerAction(UseToolTipsInMainEditor),
|
2009-10-01 18:01:23 +02:00
|
|
|
m_ui.checkBoxUseToolTipsInMainEditor);
|
2009-10-06 10:54:08 +02:00
|
|
|
m_group.insert(theDebuggerAction(AutoDerefPointers), 0);
|
2009-10-01 11:22:44 +02:00
|
|
|
m_group.insert(theDebuggerAction(UseToolTipsInLocalsView), 0);
|
|
|
|
|
m_group.insert(theDebuggerAction(UseToolTipsInBreakpointsView), 0);
|
|
|
|
|
m_group.insert(theDebuggerAction(UseAddressInBreakpointsView), 0);
|
|
|
|
|
m_group.insert(theDebuggerAction(UseAddressInStackView), 0);
|
2010-01-29 21:33:57 +01:00
|
|
|
m_group.insert(theDebuggerAction(EnableReverseDebugging),
|
2009-05-25 17:19:42 +02:00
|
|
|
m_ui.checkBoxEnableReverseDebugging);
|
2010-01-29 21:33:57 +01:00
|
|
|
m_group.insert(theDebuggerAction(MaximalStackDepth),
|
2009-04-02 15:06:24 +02:00
|
|
|
m_ui.spinBoxMaximalStackDepth);
|
2009-12-09 15:23:49 +01:00
|
|
|
m_group.insert(theDebuggerAction(GdbWatchdogTimeout), 0);
|
2009-11-25 08:35:02 +01:00
|
|
|
m_group.insert(theDebuggerAction(ShowStdNamespace), 0);
|
|
|
|
|
m_group.insert(theDebuggerAction(ShowQtNamespace), 0);
|
2009-12-07 12:10:07 +01:00
|
|
|
m_group.insert(theDebuggerAction(LogTimeStamps), 0);
|
2010-01-15 12:01:26 +01:00
|
|
|
m_group.insert(theDebuggerAction(VerboseLog), 0);
|
2009-12-09 11:13:20 +01:00
|
|
|
m_group.insert(theDebuggerAction(UsePreciseBreakpoints), 0);
|
2010-02-11 17:29:10 +01:00
|
|
|
m_group.insert(theDebuggerAction(BreakOnThrow), 0);
|
|
|
|
|
m_group.insert(theDebuggerAction(BreakOnCatch), 0);
|
2010-03-25 16:54:23 +01:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
Utils::SavedAction *registerAction = theDebuggerAction(RegisterForPostMortem);
|
|
|
|
|
m_group.insert(registerAction,
|
|
|
|
|
m_ui.checkBoxRegisterForPostMortem);
|
|
|
|
|
connect(registerAction, SIGNAL(toggled(bool)),
|
|
|
|
|
m_ui.checkBoxRegisterForPostMortem, SLOT(setChecked(bool)));
|
|
|
|
|
#endif
|
2009-01-14 18:09:02 +01:00
|
|
|
|
2009-11-24 15:05:02 +01:00
|
|
|
if (m_searchKeywords.isEmpty()) {
|
2010-03-18 10:56:25 +01:00
|
|
|
QTextStream(&m_searchKeywords) << ' '
|
|
|
|
|
<< m_ui.checkBoxChangeLanguageAutomatically->text()
|
|
|
|
|
<< m_ui.checkBoxListSourceFiles->text()
|
2009-11-24 15:05:02 +01:00
|
|
|
<< ' ' << m_ui.checkBoxUseMessageBoxForSignals->text()
|
|
|
|
|
<< ' ' << m_ui.checkBoxUseAlternatingRowColors->text()
|
|
|
|
|
<< ' ' << m_ui.checkBoxUseToolTipsInMainEditor->text()
|
|
|
|
|
<< ' ' << m_ui.checkBoxSkipKnownFrames->text()
|
|
|
|
|
<< ' ' << m_ui.checkBoxEnableReverseDebugging->text()
|
2010-03-25 16:54:23 +01:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
<< ' ' << m_ui.checkBoxRegisterForPostMortem->text()
|
|
|
|
|
#endif
|
2009-11-24 15:05:02 +01:00
|
|
|
<< ' ' << m_ui.labelMaximalStackDepth->text();
|
|
|
|
|
m_searchKeywords.remove(QLatin1Char('&'));
|
|
|
|
|
}
|
2010-03-25 16:54:23 +01:00
|
|
|
#ifndef Q_OS_WIN
|
|
|
|
|
m_ui.checkBoxRegisterForPostMortem->setVisible(false);
|
|
|
|
|
#endif
|
2009-01-14 18:09:02 +01:00
|
|
|
return w;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 15:05:02 +01:00
|
|
|
bool CommonOptionsPage::matches(const QString &s) const
|
|
|
|
|
{
|
|
|
|
|
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-14 18:09:02 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
2009-01-13 18:15:24 +01:00
|
|
|
|
2009-03-23 12:28:02 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2009-04-07 16:39:17 +02:00
|
|
|
// DebuggingHelperOptionPage
|
2009-03-23 12:28:02 +01:00
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2009-11-24 15:05:02 +01:00
|
|
|
static inline bool oxygenStyle()
|
|
|
|
|
{
|
|
|
|
|
if (const ManhattanStyle *ms = qobject_cast<const ManhattanStyle *>(qApp->style()))
|
2010-02-23 12:42:04 +01:00
|
|
|
return !qstrcmp("OxygenStyle", ms->baseStyle()->metaObject()->className());
|
2009-11-24 15:05:02 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-23 12:28:02 +01:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-04-07 16:39:17 +02:00
|
|
|
class DebuggingHelperOptionPage : public Core::IOptionsPage
|
2009-03-23 12:28:02 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2009-04-07 16:39:17 +02:00
|
|
|
DebuggingHelperOptionPage() {}
|
2009-03-23 12:28:02 +01:00
|
|
|
|
|
|
|
|
// IOptionsPage
|
2010-03-11 12:22:24 +01:00
|
|
|
QString id() const { return _("B.DebuggingHelper"); }
|
2010-01-07 18:17:24 +01:00
|
|
|
QString displayName() const { return tr("Debugging Helper"); }
|
2010-03-11 12:22:24 +01:00
|
|
|
QString category() const { return _(DEBUGGER_SETTINGS_CATEGORY); }
|
|
|
|
|
QString displayCategory() const { return QCoreApplication::translate("Debugger", DEBUGGER_SETTINGS_TR_CATEGORY); }
|
2010-03-26 17:34:10 +01:00
|
|
|
QIcon categoryIcon() const { return QIcon(QLatin1String(DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON)); }
|
2009-03-23 12:28:02 +01:00
|
|
|
|
|
|
|
|
QWidget *createPage(QWidget *parent);
|
2009-04-28 15:08:52 +02:00
|
|
|
void apply() { m_group.apply(settings()); }
|
2009-03-26 15:56:16 +01:00
|
|
|
void finish() { m_group.finish(); }
|
2009-11-24 15:05:02 +01:00
|
|
|
virtual bool matches(const QString &s) const;
|
2009-03-23 12:28:02 +01:00
|
|
|
|
|
|
|
|
private:
|
2009-04-07 16:39:17 +02:00
|
|
|
Ui::DebuggingHelperOptionPage m_ui;
|
2009-10-05 11:06:05 +02:00
|
|
|
Utils::SavedActionSet m_group;
|
2009-11-24 15:05:02 +01:00
|
|
|
QString m_searchKeywords;
|
2009-03-23 12:28:02 +01:00
|
|
|
};
|
|
|
|
|
|
2009-04-07 16:39:17 +02:00
|
|
|
QWidget *DebuggingHelperOptionPage::createPage(QWidget *parent)
|
2009-03-23 12:28:02 +01:00
|
|
|
{
|
|
|
|
|
QWidget *w = new QWidget(parent);
|
|
|
|
|
m_ui.setupUi(w);
|
|
|
|
|
|
2009-10-05 11:06:05 +02:00
|
|
|
m_ui.dumperLocationChooser->setExpectedKind(Utils::PathChooser::Command);
|
2009-04-07 16:39:17 +02:00
|
|
|
m_ui.dumperLocationChooser->setPromptDialogTitle(tr("Choose DebuggingHelper Location"));
|
2009-03-23 13:02:50 +01:00
|
|
|
m_ui.dumperLocationChooser->setInitialBrowsePathBackup(
|
|
|
|
|
Core::ICore::instance()->resourcePath() + "../../lib");
|
2009-03-23 12:28:02 +01:00
|
|
|
|
2009-03-26 17:27:44 +01:00
|
|
|
m_group.clear();
|
2009-04-07 16:39:17 +02:00
|
|
|
m_group.insert(theDebuggerAction(UseDebuggingHelpers),
|
2009-11-24 15:05:02 +01:00
|
|
|
m_ui.debuggingHelperGroupBox);
|
2009-04-07 16:39:17 +02:00
|
|
|
m_group.insert(theDebuggerAction(UseCustomDebuggingHelperLocation),
|
2009-11-24 15:05:02 +01:00
|
|
|
m_ui.customLocationGroupBox);
|
2010-03-11 12:22:24 +01:00
|
|
|
// Suppress Oxygen style's giving flat group boxes bold titles.
|
2009-11-24 15:05:02 +01:00
|
|
|
if (oxygenStyle())
|
2010-03-11 12:22:24 +01:00
|
|
|
m_ui.customLocationGroupBox->setStyleSheet(_("QGroupBox::title { font: ; }"));
|
2009-11-24 15:05:02 +01:00
|
|
|
|
2009-04-07 16:39:17 +02:00
|
|
|
m_group.insert(theDebuggerAction(CustomDebuggingHelperLocation),
|
2009-03-26 15:56:16 +01:00
|
|
|
m_ui.dumperLocationChooser);
|
2009-03-23 12:28:02 +01:00
|
|
|
|
2009-10-16 16:26:28 +02:00
|
|
|
m_group.insert(theDebuggerAction(UseCodeModel),
|
|
|
|
|
m_ui.checkBoxUseCodeModel);
|
|
|
|
|
|
2009-07-10 14:38:36 +02:00
|
|
|
#ifdef QT_DEBUG
|
2009-04-07 16:39:17 +02:00
|
|
|
m_group.insert(theDebuggerAction(DebugDebuggingHelpers),
|
|
|
|
|
m_ui.checkBoxDebugDebuggingHelpers);
|
2009-07-10 14:38:36 +02:00
|
|
|
#else
|
|
|
|
|
m_ui.checkBoxDebugDebuggingHelpers->hide();
|
|
|
|
|
#endif
|
2009-03-23 12:28:02 +01:00
|
|
|
|
|
|
|
|
#ifndef QT_DEBUG
|
|
|
|
|
#if 0
|
|
|
|
|
cmd = am->registerAction(m_manager->m_dumpLogAction,
|
2010-03-11 12:22:24 +01:00
|
|
|
DUMP_LOG, globalcontext);
|
2009-03-23 12:28:02 +01:00
|
|
|
//cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+L")));
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F11")));
|
|
|
|
|
mdebug->addAction(cmd);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-11-24 15:05:02 +01:00
|
|
|
if (m_searchKeywords.isEmpty()) {
|
|
|
|
|
QTextStream(&m_searchKeywords)
|
|
|
|
|
<< ' ' << m_ui.debuggingHelperGroupBox->title()
|
|
|
|
|
<< ' ' << m_ui.customLocationGroupBox->title()
|
|
|
|
|
<< ' ' << m_ui.dumperLocationLabel->text()
|
|
|
|
|
<< ' ' << m_ui.checkBoxUseCodeModel->text()
|
|
|
|
|
<< ' ' << m_ui.checkBoxDebugDebuggingHelpers->text();
|
|
|
|
|
m_searchKeywords.remove(QLatin1Char('&'));
|
|
|
|
|
}
|
2009-03-23 12:28:02 +01:00
|
|
|
return w;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 15:05:02 +01:00
|
|
|
bool DebuggingHelperOptionPage::matches(const QString &s) const
|
2009-03-27 13:04:23 +01:00
|
|
|
{
|
2009-11-24 15:05:02 +01:00
|
|
|
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
|
2009-03-27 13:04:23 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-23 12:28:02 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
2009-08-12 10:51:25 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// DebuggerPlugin
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2009-12-14 18:01:39 +01:00
|
|
|
|
|
|
|
|
DebuggerPlugin::AttachRemoteParameters::AttachRemoteParameters() :
|
|
|
|
|
attachPid(0),
|
|
|
|
|
winCrashEvent(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-28 15:08:52 +02:00
|
|
|
DebuggerPlugin::DebuggerPlugin()
|
|
|
|
|
: m_manager(0),
|
2009-04-17 09:03:32 +02:00
|
|
|
m_debugMode(0),
|
|
|
|
|
m_locationMark(0),
|
|
|
|
|
m_gdbRunningContext(0),
|
2010-02-09 20:44:40 +01:00
|
|
|
m_cmdLineEnabledEngines(AllEngineTypes)
|
2009-04-28 15:08:52 +02:00
|
|
|
{}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
DebuggerPlugin::~DebuggerPlugin()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::shutdown()
|
|
|
|
|
{
|
2008-12-09 12:08:56 +01:00
|
|
|
QTC_ASSERT(m_manager, /**/);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (m_manager)
|
|
|
|
|
m_manager->shutdown();
|
|
|
|
|
|
2009-01-13 18:15:24 +01:00
|
|
|
writeSettings();
|
2010-02-09 20:44:40 +01:00
|
|
|
|
|
|
|
|
if (m_uiSwitcher)
|
|
|
|
|
m_uiSwitcher->shutdown();
|
|
|
|
|
|
2009-06-03 13:53:45 +02:00
|
|
|
delete DebuggerSettings::instance();
|
2009-01-13 18:15:24 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
removeObject(m_debugMode);
|
|
|
|
|
|
|
|
|
|
// FIXME: when using the line below, BreakWindow etc gets deleted twice.
|
|
|
|
|
// so better leak for now...
|
|
|
|
|
delete m_debugMode;
|
|
|
|
|
m_debugMode = 0;
|
|
|
|
|
|
|
|
|
|
delete m_locationMark;
|
|
|
|
|
m_locationMark = 0;
|
|
|
|
|
|
2009-10-16 17:33:12 +02:00
|
|
|
removeObject(m_manager);
|
2008-12-02 12:01:29 +01:00
|
|
|
delete m_manager;
|
|
|
|
|
m_manager = 0;
|
2010-02-09 20:44:40 +01:00
|
|
|
|
|
|
|
|
removeObject(m_uiSwitcher);
|
|
|
|
|
delete m_uiSwitcher;
|
|
|
|
|
m_uiSwitcher = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-09-24 10:08:17 +02:00
|
|
|
static QString msgParameterMissing(const QString &a)
|
2009-05-25 16:22:11 +02:00
|
|
|
{
|
|
|
|
|
return DebuggerPlugin::tr("Option '%1' is missing the parameter.").arg(a);
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-24 10:08:17 +02:00
|
|
|
static QString msgInvalidNumericParameter(const QString &a, const QString &number)
|
2009-05-25 16:22:11 +02:00
|
|
|
{
|
|
|
|
|
return DebuggerPlugin::tr("The parameter '%1' of option '%2' is not a number.").arg(number, a);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Parse arguments
|
2009-12-14 18:01:39 +01:00
|
|
|
static bool parseArgument(QStringList::const_iterator &it,
|
|
|
|
|
const QStringList::const_iterator &cend,
|
|
|
|
|
DebuggerPlugin::AttachRemoteParameters *attachRemoteParameters,
|
|
|
|
|
unsigned *enabledEngines, QString *errorMessage)
|
2009-05-25 16:22:11 +02:00
|
|
|
{
|
|
|
|
|
const QString &option = *it;
|
|
|
|
|
// '-debug <pid>'
|
2010-03-11 12:22:24 +01:00
|
|
|
if (*it == _("-debug")) {
|
2009-05-25 16:22:11 +02:00
|
|
|
++it;
|
|
|
|
|
if (it == cend) {
|
|
|
|
|
*errorMessage = msgParameterMissing(*it);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool ok;
|
2009-12-14 18:01:39 +01:00
|
|
|
attachRemoteParameters->attachPid = it->toULongLong(&ok);
|
2009-05-25 16:22:11 +02:00
|
|
|
if (!ok) {
|
2009-12-14 18:01:39 +01:00
|
|
|
attachRemoteParameters->attachPid = 0;
|
|
|
|
|
attachRemoteParameters->attachCore = *it;
|
2009-05-25 16:22:11 +02:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2009-05-26 16:27:24 +02:00
|
|
|
// -wincrashevent <event-handle>. A handle used for
|
|
|
|
|
// a handshake when attaching to a crashed Windows process.
|
2010-03-11 12:22:24 +01:00
|
|
|
if (*it == _("-wincrashevent")) {
|
2009-05-25 16:22:11 +02:00
|
|
|
++it;
|
|
|
|
|
if (it == cend) {
|
|
|
|
|
*errorMessage = msgParameterMissing(*it);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
bool ok;
|
2009-12-14 18:01:39 +01:00
|
|
|
attachRemoteParameters->winCrashEvent = it->toULongLong(&ok);
|
2009-05-25 16:22:11 +02:00
|
|
|
if (!ok) {
|
|
|
|
|
*errorMessage = msgInvalidNumericParameter(option, *it);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// engine disabling
|
2010-03-11 12:22:24 +01:00
|
|
|
if (option == _("-disable-cdb")) {
|
2009-12-14 18:01:39 +01:00
|
|
|
*enabledEngines &= ~Debugger::CdbEngineType;
|
2009-05-25 16:22:11 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-03-11 12:22:24 +01:00
|
|
|
if (option == _("-disable-gdb")) {
|
2009-12-14 18:01:39 +01:00
|
|
|
*enabledEngines &= ~Debugger::GdbEngineType;
|
2009-05-25 16:22:11 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-03-11 12:22:24 +01:00
|
|
|
if (option == _("-disable-sdb")) {
|
2009-12-14 18:01:39 +01:00
|
|
|
*enabledEngines &= ~Debugger::ScriptEngineType;
|
2009-05-25 16:22:11 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-14 18:01:39 +01:00
|
|
|
*errorMessage = DebuggerPlugin::tr("Invalid debugger option: %1").arg(option);
|
2009-05-25 16:22:11 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-14 18:01:39 +01:00
|
|
|
static bool parseArguments(const QStringList &args,
|
|
|
|
|
DebuggerPlugin::AttachRemoteParameters *attachRemoteParameters,
|
|
|
|
|
unsigned *enabledEngines, QString *errorMessage)
|
2009-05-25 16:22:11 +02:00
|
|
|
{
|
|
|
|
|
const QStringList::const_iterator cend = args.constEnd();
|
|
|
|
|
for (QStringList::const_iterator it = args.constBegin(); it != cend; ++it)
|
2009-12-14 18:01:39 +01:00
|
|
|
if (!parseArgument(it, cend, attachRemoteParameters, enabledEngines, errorMessage))
|
2009-05-25 16:22:11 +02:00
|
|
|
return false;
|
|
|
|
|
if (Debugger::Constants::Internal::debug)
|
2009-09-24 10:08:17 +02:00
|
|
|
qDebug().nospace() << args << "engines=0x"
|
2009-12-14 18:01:39 +01:00
|
|
|
<< QString::number(*enabledEngines, 16)
|
|
|
|
|
<< " pid" << attachRemoteParameters->attachPid
|
|
|
|
|
<< " core" << attachRemoteParameters->attachCore << '\n';
|
2009-05-25 16:22:11 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-14 18:01:39 +01:00
|
|
|
void DebuggerPlugin::remoteCommand(const QStringList &options, const QStringList &)
|
|
|
|
|
{
|
|
|
|
|
QString errorMessage;
|
|
|
|
|
AttachRemoteParameters parameters;
|
|
|
|
|
unsigned dummy = 0;
|
|
|
|
|
// Did we receive a request for debugging (unless it is ourselves)?
|
|
|
|
|
if (parseArguments(options, ¶meters, &dummy, &errorMessage)
|
|
|
|
|
&& parameters.attachPid != quint64(QCoreApplication::applicationPid())) {
|
|
|
|
|
m_attachRemoteParameters = parameters;
|
|
|
|
|
attachCmdLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-16 14:22:13 +01:00
|
|
|
bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-11 12:22:24 +01:00
|
|
|
// Do not fail the whole plugin if something goes wrong here.
|
2009-12-14 18:01:39 +01:00
|
|
|
if (!parseArguments(arguments, &m_attachRemoteParameters, &m_cmdLineEnabledEngines, errorMessage)) {
|
2009-09-24 10:08:17 +02:00
|
|
|
*errorMessage = tr("Error evaluating command line arguments: %1")
|
|
|
|
|
.arg(*errorMessage);
|
2009-05-26 16:27:24 +02:00
|
|
|
qWarning("%s\n", qPrintable(*errorMessage));
|
|
|
|
|
errorMessage->clear();
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-11 12:22:24 +01:00
|
|
|
// Debug mode setup.
|
2010-02-09 20:44:40 +01:00
|
|
|
m_debugMode = new DebugMode(this);
|
|
|
|
|
m_uiSwitcher = new DebuggerUISwitcher(m_debugMode, this);
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->addObject(m_uiSwitcher);
|
|
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
ICore *core = ICore::instance();
|
2008-12-09 12:08:56 +01:00
|
|
|
QTC_ASSERT(core, return false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-13 17:41:23 +01:00
|
|
|
Core::ActionManager *am = core->actionManager();
|
|
|
|
|
QTC_ASSERT(am, return false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
Core::UniqueIDManager *uidm = core->uniqueIDManager();
|
2008-12-09 12:08:56 +01:00
|
|
|
QTC_ASSERT(uidm, return false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QList<int> globalcontext;
|
2010-03-11 12:22:24 +01:00
|
|
|
globalcontext << CC::C_GLOBAL_ID;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QList<int> cppcontext;
|
2010-03-11 12:22:24 +01:00
|
|
|
cppcontext << uidm->uniqueIdentifier(PE::LANG_CXX);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-23 18:12:03 +01:00
|
|
|
QList<int> cppDebuggercontext;
|
|
|
|
|
cppDebuggercontext << uidm->uniqueIdentifier(C_CPPDEBUGGER);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QList<int> cppeditorcontext;
|
2010-01-11 16:52:38 +01:00
|
|
|
cppeditorcontext << uidm->uniqueIdentifier(CppEditor::Constants::C_CPPEDITOR);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QList<int> texteditorcontext;
|
|
|
|
|
texteditorcontext << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
|
|
|
|
|
|
|
|
|
|
m_gdbRunningContext = uidm->uniqueIdentifier(Constants::GDBRUNNING);
|
|
|
|
|
|
2010-03-23 18:12:03 +01:00
|
|
|
m_uiSwitcher->addLanguage(LANG_CPP, cppDebuggercontext);
|
2010-03-19 13:58:26 +01:00
|
|
|
|
2010-03-10 13:46:05 +01:00
|
|
|
DebuggerManager *manager = new DebuggerManager(this);
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->addObject(manager);
|
|
|
|
|
const QList<Core::IOptionsPage *> engineOptionPages =
|
|
|
|
|
manager->initializeEngines(m_cmdLineEnabledEngines);
|
|
|
|
|
|
2010-03-11 11:07:16 +01:00
|
|
|
// Register factory of DebuggerRunControl.
|
2010-03-10 13:46:05 +01:00
|
|
|
m_debuggerRunControlFactory = new DebuggerRunControlFactory(manager);
|
2010-02-09 20:44:40 +01:00
|
|
|
addAutoReleasedObject(m_debuggerRunControlFactory);
|
|
|
|
|
|
|
|
|
|
QList<int> context;
|
2010-03-11 12:22:24 +01:00
|
|
|
context.append(uidm->uniqueIdentifier(CC::C_EDITORMANAGER));
|
2010-03-23 18:12:03 +01:00
|
|
|
context.append(uidm->uniqueIdentifier(C_DEBUGMODE));
|
2010-03-11 12:22:24 +01:00
|
|
|
context.append(uidm->uniqueIdentifier(CC::C_NAVIGATION_PANE));
|
2010-02-09 20:44:40 +01:00
|
|
|
m_debugMode->setContext(context);
|
|
|
|
|
|
2010-03-11 11:07:16 +01:00
|
|
|
m_reverseToolButton = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-11 11:07:16 +01:00
|
|
|
// Handling of external applications.
|
2009-05-05 17:48:54 +02:00
|
|
|
m_startExternalAction = new QAction(this);
|
|
|
|
|
m_startExternalAction->setText(tr("Start and Debug External Application..."));
|
|
|
|
|
connect(m_startExternalAction, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(startExternalApplication()));
|
|
|
|
|
|
|
|
|
|
m_attachExternalAction = new QAction(this);
|
|
|
|
|
m_attachExternalAction->setText(tr("Attach to Running External Application..."));
|
|
|
|
|
connect(m_attachExternalAction, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(attachExternalApplication()));
|
|
|
|
|
|
|
|
|
|
m_attachCoreAction = new QAction(this);
|
|
|
|
|
m_attachCoreAction->setText(tr("Attach to Core..."));
|
|
|
|
|
connect(m_attachCoreAction, SIGNAL(triggered()), this, SLOT(attachCore()));
|
|
|
|
|
|
2009-05-06 13:27:11 +02:00
|
|
|
m_startRemoteAction = new QAction(this);
|
|
|
|
|
m_startRemoteAction->setText(tr("Start and Attach to Remote Application..."));
|
|
|
|
|
connect(m_startRemoteAction, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(startRemoteApplication()));
|
2009-05-05 17:48:54 +02:00
|
|
|
|
2009-05-07 15:20:44 +02:00
|
|
|
m_detachAction = new QAction(this);
|
2009-06-11 15:00:21 +02:00
|
|
|
m_detachAction->setText(tr("Detach Debugger"));
|
2009-05-07 15:20:44 +02:00
|
|
|
connect(m_detachAction, SIGNAL(triggered()),
|
2010-03-10 13:46:05 +01:00
|
|
|
manager, SLOT(detachDebugger()));
|
2009-05-07 15:20:44 +02:00
|
|
|
|
2010-02-09 20:44:40 +01:00
|
|
|
Core::Command *cmd = 0;
|
2010-03-10 13:46:05 +01:00
|
|
|
const DebuggerManagerActions actions = manager->debuggerManagerActions();
|
2010-02-09 20:44:40 +01:00
|
|
|
|
2009-06-08 19:28:28 +02:00
|
|
|
Core::ActionContainer *mstart =
|
2010-03-11 12:22:24 +01:00
|
|
|
am->actionContainer(PE::M_DEBUG_STARTDEBUGGING);
|
2009-06-08 19:28:28 +02:00
|
|
|
|
2009-09-25 15:02:16 +02:00
|
|
|
cmd = am->registerAction(actions.continueAction,
|
2010-03-11 12:22:24 +01:00
|
|
|
PE::DEBUG, QList<int>() << m_gdbRunningContext);
|
|
|
|
|
mstart->addAction(cmd, CC::G_DEFAULT_ONE);
|
2009-06-04 16:06:12 +02:00
|
|
|
|
2009-05-05 17:48:54 +02:00
|
|
|
cmd = am->registerAction(m_startExternalAction,
|
2008-12-02 12:01:29 +01:00
|
|
|
Constants::STARTEXTERNAL, globalcontext);
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-11 12:22:24 +01:00
|
|
|
mstart->addAction(cmd, CC::G_DEFAULT_ONE);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-05-05 17:48:54 +02:00
|
|
|
cmd = am->registerAction(m_attachExternalAction,
|
2008-12-02 12:01:29 +01:00
|
|
|
Constants::ATTACHEXTERNAL, globalcontext);
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-11 12:22:24 +01:00
|
|
|
mstart->addAction(cmd, CC::G_DEFAULT_ONE);
|
2009-03-02 15:14:12 +01:00
|
|
|
|
2009-05-05 17:48:54 +02:00
|
|
|
cmd = am->registerAction(m_attachCoreAction,
|
|
|
|
|
Constants::ATTACHCORE, globalcontext);
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-11 12:22:24 +01:00
|
|
|
mstart->addAction(cmd, CC::G_DEFAULT_ONE);
|
2009-05-07 17:11:19 +02:00
|
|
|
|
2009-05-06 13:27:11 +02:00
|
|
|
cmd = am->registerAction(m_startRemoteAction,
|
2009-05-05 17:48:54 +02:00
|
|
|
Constants::ATTACHREMOTE, globalcontext);
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-11 12:22:24 +01:00
|
|
|
mstart->addAction(cmd, CC::G_DEFAULT_ONE);
|
2009-05-04 14:47:45 +02:00
|
|
|
|
2009-05-07 15:20:44 +02:00
|
|
|
cmd = am->registerAction(m_detachAction,
|
|
|
|
|
Constants::DETACH, globalcontext);
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-11 12:22:24 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, CC::G_DEFAULT_ONE);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-25 15:02:16 +02:00
|
|
|
cmd = am->registerAction(actions.stopAction,
|
2008-12-02 12:01:29 +01:00
|
|
|
Constants::INTERRUPT, globalcontext);
|
2010-03-11 12:22:24 +01:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
|
|
|
|
cmd->setAttribute(Command::CA_UpdateIcon);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Constants::INTERRUPT_KEY));
|
|
|
|
|
cmd->setDefaultText(tr("Stop Debugger/Interrupt Debugger"));
|
2010-03-11 12:22:24 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, CC::G_DEFAULT_ONE);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-25 15:02:16 +02:00
|
|
|
cmd = am->registerAction(actions.resetAction,
|
2008-12-02 12:01:29 +01:00
|
|
|
Constants::RESET, globalcontext);
|
2009-01-14 13:17:53 +01:00
|
|
|
cmd->setAttribute(Core::Command::CA_UpdateText);
|
2010-02-11 11:26:08 +01:00
|
|
|
//cmd->setDefaultKeySequence(QKeySequence(Constants::RESET_KEY));
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultText(tr("Reset Debugger"));
|
2010-03-11 12:22:24 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, CC::G_DEFAULT_ONE);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QAction *sep = new QAction(this);
|
|
|
|
|
sep->setSeparator(true);
|
2010-03-11 12:22:24 +01:00
|
|
|
cmd = am->registerAction(sep, _("Debugger.Sep.Step"), globalcontext);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-25 15:02:16 +02:00
|
|
|
cmd = am->registerAction(actions.nextAction,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::NEXT, cppDebuggercontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Constants::NEXT_KEY));
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-25 15:02:16 +02:00
|
|
|
cmd = am->registerAction(actions.stepAction,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::STEP, cppDebuggercontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Constants::STEP_KEY));
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-25 15:02:16 +02:00
|
|
|
cmd = am->registerAction(actions.stepOutAction,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::STEPOUT, cppDebuggercontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Constants::STEPOUT_KEY));
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-08 09:13:21 +01:00
|
|
|
cmd = am->registerAction(actions.runToLineAction1,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::RUN_TO_LINE1, cppDebuggercontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Constants::RUN_TO_LINE_KEY));
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-25 15:02:16 +02:00
|
|
|
cmd = am->registerAction(actions.runToFunctionAction,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::RUN_TO_FUNCTION, cppDebuggercontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Constants::RUN_TO_FUNCTION_KEY));
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-08 09:13:21 +01:00
|
|
|
cmd = am->registerAction(actions.jumpToLineAction1,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::JUMP_TO_LINE1, cppDebuggercontext);
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-15 16:02:41 +01:00
|
|
|
cmd = am->registerAction(actions.returnFromFunctionAction,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::RETURN_FROM_FUNCTION, cppDebuggercontext);
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2010-02-15 16:02:41 +01:00
|
|
|
|
2009-09-25 15:02:16 +02:00
|
|
|
cmd = am->registerAction(actions.reverseDirectionAction,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::REVERSE, cppDebuggercontext);
|
2009-05-25 17:19:42 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Constants::REVERSE_KEY));
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2009-05-25 17:19:42 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
sep = new QAction(this);
|
|
|
|
|
sep->setSeparator(true);
|
2010-03-11 12:22:24 +01:00
|
|
|
cmd = am->registerAction(sep, _("Debugger.Sep.Break"), globalcontext);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-02 17:25:14 +01:00
|
|
|
cmd = am->registerAction(actions.snapshotAction,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::SNAPSHOT, cppDebuggercontext);
|
2010-02-02 17:25:14 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Constants::SNAPSHOT_KEY));
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2010-02-02 17:25:14 +01:00
|
|
|
|
2009-09-29 11:13:19 +02:00
|
|
|
cmd = am->registerAction(theDebuggerAction(OperateByInstruction),
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::OPERATE_BY_INSTRUCTION, cppDebuggercontext);
|
2010-03-19 13:58:26 +01:00
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2009-09-29 11:13:19 +02:00
|
|
|
|
2009-09-25 15:02:16 +02:00
|
|
|
cmd = am->registerAction(actions.breakAction,
|
2008-12-02 12:01:29 +01:00
|
|
|
Constants::TOGGLE_BREAK, cppeditorcontext);
|
|
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Constants::TOGGLE_BREAK_KEY));
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
//mcppcontext->addAction(cmd);
|
|
|
|
|
|
|
|
|
|
sep = new QAction(this);
|
|
|
|
|
sep->setSeparator(true);
|
2010-03-11 12:22:24 +01:00
|
|
|
cmd = am->registerAction(sep, _("Debugger.Sep.Watch"), globalcontext);
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-12-11 18:19:51 +01:00
|
|
|
cmd = am->registerAction(actions.watchAction1,
|
|
|
|
|
Constants::ADD_TO_WATCH1, cppeditorcontext);
|
2009-12-11 15:31:37 +01:00
|
|
|
cmd->action()->setEnabled(true);
|
2009-12-11 18:19:51 +01:00
|
|
|
//cmd->setDefaultKeySequence(QKeySequence(tr("ALT+D,ALT+W")));
|
2010-03-18 10:56:25 +01:00
|
|
|
m_uiSwitcher->addMenuAction(cmd, Constants::LANG_CPP);
|
|
|
|
|
|
2009-12-11 18:19:51 +01:00
|
|
|
|
2010-02-08 09:13:21 +01:00
|
|
|
// Editor context menu
|
2009-12-11 18:19:51 +01:00
|
|
|
ActionContainer *editorContextMenu =
|
|
|
|
|
am->actionContainer(CppEditor::Constants::M_CONTEXT);
|
2010-03-11 12:22:24 +01:00
|
|
|
cmd = am->registerAction(sep, _("Debugger.Sep.Views"),
|
2010-03-23 18:12:03 +01:00
|
|
|
cppDebuggercontext);
|
2009-12-11 18:19:51 +01:00
|
|
|
editorContextMenu->addAction(cmd);
|
|
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2010-02-08 09:13:21 +01:00
|
|
|
|
2009-12-11 18:19:51 +01:00
|
|
|
cmd = am->registerAction(actions.watchAction2,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::ADD_TO_WATCH2, cppDebuggercontext);
|
2009-12-11 18:19:51 +01:00
|
|
|
cmd->action()->setEnabled(true);
|
2010-02-08 09:13:21 +01:00
|
|
|
editorContextMenu->addAction(cmd);
|
|
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
|
|
|
|
|
|
|
|
|
cmd = am->registerAction(actions.runToLineAction2,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::RUN_TO_LINE2, cppDebuggercontext);
|
2010-02-08 09:13:21 +01:00
|
|
|
cmd->action()->setEnabled(true);
|
|
|
|
|
editorContextMenu->addAction(cmd);
|
|
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
|
|
|
|
|
|
|
|
|
cmd = am->registerAction(actions.jumpToLineAction2,
|
2010-03-23 18:12:03 +01:00
|
|
|
Constants::JUMP_TO_LINE2, cppDebuggercontext);
|
2010-02-08 09:13:21 +01:00
|
|
|
cmd->action()->setEnabled(true);
|
2009-12-11 18:19:51 +01:00
|
|
|
editorContextMenu->addAction(cmd);
|
|
|
|
|
cmd->setAttribute(Command::CA_Hide);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-08-13 16:16:19 +02:00
|
|
|
// FIXME:
|
2009-04-17 09:03:32 +02:00
|
|
|
addAutoReleasedObject(new CommonOptionsPage);
|
2009-05-25 16:22:11 +02:00
|
|
|
addAutoReleasedObject(new DebuggingHelperOptionPage);
|
2009-04-17 09:03:32 +02:00
|
|
|
foreach (Core::IOptionsPage* op, engineOptionPages)
|
|
|
|
|
addAutoReleasedObject(op);
|
2009-10-26 18:05:11 +01:00
|
|
|
addAutoReleasedObject(new DebuggerListener);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_locationMark = 0;
|
|
|
|
|
|
2010-03-10 13:46:05 +01:00
|
|
|
manager->setSimpleDockWidgetArrangement(LANG_CPP);
|
2009-01-13 18:15:24 +01:00
|
|
|
readSettings();
|
|
|
|
|
|
|
|
|
|
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
2009-05-15 16:54:54 +02:00
|
|
|
this, SLOT(onModeChanged(Core::IMode*)));
|
2009-01-13 18:15:24 +01:00
|
|
|
m_debugMode->widget()->setFocusProxy(EditorManager::instance());
|
|
|
|
|
addObject(m_debugMode);
|
|
|
|
|
|
2010-03-10 13:46:05 +01:00
|
|
|
m_manager = manager;
|
|
|
|
|
|
|
|
|
|
|
2009-01-13 18:15:24 +01:00
|
|
|
//
|
|
|
|
|
// Connections
|
|
|
|
|
//
|
|
|
|
|
|
2010-02-12 14:15:20 +01:00
|
|
|
// TextEditor
|
2010-03-10 13:46:05 +01:00
|
|
|
connect(TextEditorPlugin::instance(),
|
2010-02-12 14:15:20 +01:00
|
|
|
SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
|
2010-03-10 13:46:05 +01:00
|
|
|
manager, SLOT(fontSettingsChanged(TextEditor::FontSettings)));
|
2010-02-12 14:15:20 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// ProjectExplorer
|
2009-01-28 14:29:54 +01:00
|
|
|
connect(sessionManager(), SIGNAL(sessionLoaded()),
|
2010-03-10 13:46:05 +01:00
|
|
|
manager, SLOT(sessionLoaded()));
|
2009-01-28 14:29:54 +01:00
|
|
|
connect(sessionManager(), SIGNAL(aboutToSaveSession()),
|
2010-03-10 13:46:05 +01:00
|
|
|
manager, SLOT(aboutToSaveSession()));
|
2009-08-13 17:10:53 +02:00
|
|
|
connect(sessionManager(), SIGNAL(aboutToUnloadSession()),
|
2010-03-10 13:46:05 +01:00
|
|
|
manager, SLOT(aboutToUnloadSession()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// EditorManager
|
|
|
|
|
QObject *editorManager = core->editorManager();
|
|
|
|
|
connect(editorManager, SIGNAL(editorAboutToClose(Core::IEditor*)),
|
|
|
|
|
this, SLOT(editorAboutToClose(Core::IEditor*)));
|
|
|
|
|
connect(editorManager, SIGNAL(editorOpened(Core::IEditor*)),
|
|
|
|
|
this, SLOT(editorOpened(Core::IEditor*)));
|
|
|
|
|
|
|
|
|
|
// Application interaction
|
2009-03-19 15:54:52 +01:00
|
|
|
connect(theDebuggerAction(SettingsDialog), SIGNAL(triggered()),
|
2009-02-27 11:41:19 +01:00
|
|
|
this, SLOT(showSettingsDialog()));
|
|
|
|
|
|
2009-09-30 13:07:14 +02:00
|
|
|
handleStateChanged(DebuggerNotReady);
|
2010-03-10 13:46:05 +01:00
|
|
|
|
2010-03-11 11:07:16 +01:00
|
|
|
// Toolbar
|
2010-02-09 20:44:40 +01:00
|
|
|
QWidget *toolbarContainer = new QWidget;
|
2010-03-10 13:46:05 +01:00
|
|
|
|
|
|
|
|
QHBoxLayout *hbox = new QHBoxLayout(toolbarContainer);
|
|
|
|
|
hbox->setMargin(0);
|
|
|
|
|
hbox->setSpacing(0);
|
2010-03-11 12:22:24 +01:00
|
|
|
hbox->addWidget(toolButton(am->command(PE::DEBUG)->action()));
|
|
|
|
|
hbox->addWidget(toolButton(am->command(INTERRUPT)->action()));
|
|
|
|
|
hbox->addWidget(toolButton(am->command(NEXT)->action()));
|
|
|
|
|
hbox->addWidget(toolButton(am->command(STEP)->action()));
|
|
|
|
|
hbox->addWidget(toolButton(am->command(STEPOUT)->action()));
|
|
|
|
|
hbox->addWidget(toolButton(am->command(OPERATE_BY_INSTRUCTION)->action()));
|
2010-03-11 11:07:16 +01:00
|
|
|
|
|
|
|
|
//hbox->addWidget(new Utils::StyledSeparator);
|
2010-03-11 12:22:24 +01:00
|
|
|
m_reverseToolButton = toolButton(am->command(REVERSE)->action());
|
2010-03-11 11:07:16 +01:00
|
|
|
hbox->addWidget(m_reverseToolButton);
|
|
|
|
|
//m_reverseToolButton->hide();
|
|
|
|
|
|
2010-03-10 13:46:05 +01:00
|
|
|
hbox->addWidget(new Utils::StyledSeparator);
|
|
|
|
|
hbox->addWidget(new QLabel(tr("Threads:")));
|
2010-02-09 20:44:40 +01:00
|
|
|
|
|
|
|
|
QComboBox *threadBox = new QComboBox;
|
|
|
|
|
threadBox->setModel(m_manager->threadsModel());
|
|
|
|
|
connect(threadBox, SIGNAL(activated(int)),
|
|
|
|
|
m_manager->threadsWindow(), SIGNAL(threadSelected(int)));
|
2010-03-10 13:46:05 +01:00
|
|
|
|
|
|
|
|
hbox->addWidget(threadBox);
|
2010-03-23 14:49:02 +01:00
|
|
|
hbox->addSpacerItem(new QSpacerItem(4, 0));
|
2010-03-10 13:46:05 +01:00
|
|
|
hbox->addWidget(m_manager->statusLabel(), 10);
|
2010-02-09 20:44:40 +01:00
|
|
|
|
2010-03-11 11:07:16 +01:00
|
|
|
|
|
|
|
|
m_uiSwitcher->setToolbar(LANG_CPP, toolbarContainer);
|
|
|
|
|
connect(m_uiSwitcher, SIGNAL(dockArranged(QString)), manager,
|
|
|
|
|
SLOT(setSimpleDockWidgetArrangement(QString)));
|
|
|
|
|
|
|
|
|
|
connect(theDebuggerAction(EnableReverseDebugging), SIGNAL(valueChanged(QVariant)),
|
|
|
|
|
this, SLOT(enableReverseDebuggingTriggered(QVariant)));
|
|
|
|
|
|
2010-03-18 10:56:25 +01:00
|
|
|
// UI Switcher
|
|
|
|
|
connect(DebuggerUISwitcher::instance(), SIGNAL(languageChanged(QString)),
|
|
|
|
|
this, SLOT(languageChanged(QString)));
|
|
|
|
|
|
2010-03-11 11:07:16 +01:00
|
|
|
return true;
|
2010-02-09 20:44:40 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void DebuggerPlugin::extensionsInitialized()
|
|
|
|
|
{
|
2009-04-06 10:58:48 +02:00
|
|
|
// time gdb -i mi -ex 'debuggerplugin.cpp:800' -ex r -ex q bin/qtcreator.bin
|
2009-05-25 16:22:11 +02:00
|
|
|
const QByteArray env = qgetenv("QTC_DEBUGGER_TEST");
|
2009-04-07 09:40:56 +02:00
|
|
|
//qDebug() << "EXTENSIONS INITIALIZED:" << env;
|
2009-04-06 16:30:11 +02:00
|
|
|
if (!env.isEmpty())
|
|
|
|
|
m_manager->runTest(QString::fromLocal8Bit(env));
|
2009-12-14 18:01:39 +01:00
|
|
|
if (m_attachRemoteParameters.attachPid || !m_attachRemoteParameters.attachCore.isEmpty())
|
|
|
|
|
QTimer::singleShot(0, this, SLOT(attachCmdLine()));
|
2010-02-09 20:44:40 +01:00
|
|
|
|
|
|
|
|
readSettings();
|
|
|
|
|
m_uiSwitcher->initialize();
|
2009-05-25 16:22:11 +02:00
|
|
|
}
|
|
|
|
|
|
2009-12-14 18:01:39 +01:00
|
|
|
void DebuggerPlugin::attachCmdLine()
|
2009-05-25 16:22:11 +02:00
|
|
|
{
|
2009-12-14 18:01:39 +01:00
|
|
|
if (m_manager->state() != DebuggerNotReady)
|
|
|
|
|
return;
|
|
|
|
|
if (m_attachRemoteParameters.attachPid) {
|
|
|
|
|
m_manager->showStatusMessage(tr("Attaching to PID %1.").arg(m_attachRemoteParameters.attachPid));
|
|
|
|
|
const QString crashParameter =
|
|
|
|
|
m_attachRemoteParameters.winCrashEvent ? QString::number(m_attachRemoteParameters.winCrashEvent) : QString();
|
2010-03-17 10:57:19 +01:00
|
|
|
attachExternalApplication(m_attachRemoteParameters.attachPid, QString(), crashParameter);
|
2009-12-14 18:01:39 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!m_attachRemoteParameters.attachCore.isEmpty()) {
|
|
|
|
|
m_manager->showStatusMessage(tr("Attaching to core %1.").arg(m_attachRemoteParameters.attachCore));
|
|
|
|
|
attachCore(m_attachRemoteParameters.attachCore, QString());
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! Activates the previous mode when the current mode is the debug mode. */
|
|
|
|
|
void DebuggerPlugin::activatePreviousMode()
|
|
|
|
|
{
|
2009-01-20 11:52:04 +01:00
|
|
|
Core::ModeManager *const modeManager = ICore::instance()->modeManager();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-11 12:22:24 +01:00
|
|
|
if (modeManager->currentMode() == modeManager->mode(MODE_DEBUG)
|
2008-12-02 12:01:29 +01:00
|
|
|
&& !m_previousMode.isEmpty()) {
|
|
|
|
|
modeManager->activateMode(m_previousMode);
|
|
|
|
|
m_previousMode.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::activateDebugMode()
|
|
|
|
|
{
|
2009-01-21 15:52:34 +01:00
|
|
|
ModeManager *modeManager = ModeManager::instance();
|
2010-01-07 18:17:24 +01:00
|
|
|
m_previousMode = modeManager->currentMode()->id();
|
2010-03-11 12:22:24 +01:00
|
|
|
modeManager->activateMode(_(MODE_DEBUG));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-10 13:58:20 +01:00
|
|
|
TextEditor::ITextEditor *DebuggerPlugin::currentTextEditor()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-21 15:52:34 +01:00
|
|
|
EditorManager *editorManager = EditorManager::instance();
|
|
|
|
|
if (!editorManager)
|
2010-03-10 13:46:05 +01:00
|
|
|
return 0;
|
2009-01-21 15:52:34 +01:00
|
|
|
Core::IEditor *editor = editorManager->currentEditor();
|
2010-03-10 13:58:20 +01:00
|
|
|
return qobject_cast<ITextEditor*>(editor);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::editorOpened(Core::IEditor *editor)
|
|
|
|
|
{
|
|
|
|
|
if (ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor)) {
|
|
|
|
|
connect(textEditor, SIGNAL(markRequested(TextEditor::ITextEditor*,int)),
|
|
|
|
|
this, SLOT(requestMark(TextEditor::ITextEditor*,int)));
|
|
|
|
|
connect(editor, SIGNAL(tooltipRequested(TextEditor::ITextEditor*,QPoint,int)),
|
|
|
|
|
this, SLOT(showToolTip(TextEditor::ITextEditor*,QPoint,int)));
|
2008-12-05 16:39:33 +01:00
|
|
|
connect(textEditor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
|
|
|
|
|
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::editorAboutToClose(Core::IEditor *editor)
|
|
|
|
|
{
|
|
|
|
|
if (ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor)) {
|
|
|
|
|
disconnect(textEditor, SIGNAL(markRequested(TextEditor::ITextEditor*,int)),
|
|
|
|
|
this, SLOT(requestMark(TextEditor::ITextEditor*,int)));
|
|
|
|
|
disconnect(editor, SIGNAL(tooltipRequested(TextEditor::ITextEditor*,QPoint,int)),
|
|
|
|
|
this, SLOT(showToolTip(TextEditor::ITextEditor*,QPoint,int)));
|
2008-12-05 16:39:33 +01:00
|
|
|
disconnect(textEditor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
|
|
|
|
|
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-05 16:39:33 +01:00
|
|
|
void DebuggerPlugin::requestContextMenu(TextEditor::ITextEditor *editor,
|
|
|
|
|
int lineNumber, QMenu *menu)
|
|
|
|
|
{
|
2009-04-28 15:08:52 +02:00
|
|
|
QString fileName = editor->file()->fileName();
|
|
|
|
|
QString position = fileName + QString(":%1").arg(lineNumber);
|
|
|
|
|
BreakpointData *data = m_manager->findBreakpoint(fileName, lineNumber);
|
|
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
|
// existing breakpoint
|
|
|
|
|
QAction *act = new QAction(tr("Remove Breakpoint"), menu);
|
|
|
|
|
act->setData(position);
|
|
|
|
|
connect(act, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(breakpointSetRemoveMarginActionTriggered()));
|
|
|
|
|
menu->addAction(act);
|
|
|
|
|
|
|
|
|
|
QAction *act2;
|
|
|
|
|
if (data->enabled)
|
|
|
|
|
act2 = new QAction(tr("Disable Breakpoint"), menu);
|
|
|
|
|
else
|
|
|
|
|
act2 = new QAction(tr("Enable Breakpoint"), menu);
|
|
|
|
|
act2->setData(position);
|
|
|
|
|
connect(act2, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(breakpointEnableDisableMarginActionTriggered()));
|
|
|
|
|
menu->addAction(act2);
|
|
|
|
|
} else {
|
|
|
|
|
// non-existing
|
|
|
|
|
QAction *act = new QAction(tr("Set Breakpoint"), menu);
|
|
|
|
|
act->setData(position);
|
|
|
|
|
connect(act, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(breakpointSetRemoveMarginActionTriggered()));
|
|
|
|
|
menu->addAction(act);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::breakpointSetRemoveMarginActionTriggered()
|
|
|
|
|
{
|
|
|
|
|
if (QAction *act = qobject_cast<QAction *>(sender())) {
|
|
|
|
|
QString str = act->data().toString();
|
|
|
|
|
int pos = str.lastIndexOf(':');
|
|
|
|
|
m_manager->toggleBreakpoint(str.left(pos), str.mid(pos + 1).toInt());
|
|
|
|
|
}
|
2008-12-05 16:39:33 +01:00
|
|
|
}
|
|
|
|
|
|
2009-04-28 15:08:52 +02:00
|
|
|
void DebuggerPlugin::breakpointEnableDisableMarginActionTriggered()
|
2008-12-05 16:39:33 +01:00
|
|
|
{
|
2009-04-28 15:08:52 +02:00
|
|
|
if (QAction *act = qobject_cast<QAction *>(sender())) {
|
|
|
|
|
QString str = act->data().toString();
|
|
|
|
|
int pos = str.lastIndexOf(':');
|
|
|
|
|
m_manager->toggleBreakpointEnabled(str.left(pos), str.mid(pos + 1).toInt());
|
|
|
|
|
}
|
2008-12-05 16:39:33 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-10 13:46:05 +01:00
|
|
|
void DebuggerPlugin::requestMark(ITextEditor *editor, int lineNumber)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
m_manager->toggleBreakpoint(editor->file()->fileName(), lineNumber);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-10 13:46:05 +01:00
|
|
|
void DebuggerPlugin::showToolTip(ITextEditor *editor, const QPoint &point, int pos)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-09-23 16:11:25 +02:00
|
|
|
if (!theDebuggerBoolSetting(UseToolTipsInMainEditor)
|
2009-09-25 08:35:31 +02:00
|
|
|
|| m_manager->state() == DebuggerNotReady)
|
2008-12-08 19:26:00 +01:00
|
|
|
return;
|
|
|
|
|
|
2009-05-14 14:29:37 +02:00
|
|
|
m_manager->setToolTipExpression(point, editor, pos);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::setSessionValue(const QString &name, const QVariant &value)
|
|
|
|
|
{
|
2009-01-28 14:29:54 +01:00
|
|
|
QTC_ASSERT(sessionManager(), return);
|
|
|
|
|
sessionManager()->setValue(name, value);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-10 13:46:05 +01:00
|
|
|
QVariant DebuggerPlugin::sessionValue(const QString &name)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-10 13:46:05 +01:00
|
|
|
QTC_ASSERT(sessionManager(), return QVariant());
|
|
|
|
|
return sessionManager()->value(name);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::setConfigValue(const QString &name, const QVariant &value)
|
|
|
|
|
{
|
2008-12-09 12:08:56 +01:00
|
|
|
QTC_ASSERT(m_debugMode, return);
|
2009-01-13 18:15:24 +01:00
|
|
|
settings()->setValue(name, value);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-05-25 16:22:11 +02:00
|
|
|
QVariant DebuggerPlugin::configValue(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_debugMode, return QVariant());
|
|
|
|
|
return settings()->value(name);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void DebuggerPlugin::resetLocation()
|
|
|
|
|
{
|
|
|
|
|
//qDebug() << "RESET_LOCATION: current:" << currentTextEditor();
|
|
|
|
|
//qDebug() << "RESET_LOCATION: locations:" << m_locationMark;
|
|
|
|
|
//qDebug() << "RESET_LOCATION: stored:" << m_locationMark->editor();
|
|
|
|
|
delete m_locationMark;
|
|
|
|
|
m_locationMark = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-29 15:21:28 +02:00
|
|
|
void DebuggerPlugin::gotoLocation(const QString &file, int line, bool setMarker)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-10 12:48:53 +01:00
|
|
|
bool newEditor = false;
|
2010-03-10 13:46:05 +01:00
|
|
|
ITextEditor *editor =
|
|
|
|
|
BaseTextEditor::openEditorAt(file, line, 0, QString(), &newEditor);
|
|
|
|
|
if (!editor)
|
|
|
|
|
return;
|
|
|
|
|
if (newEditor)
|
|
|
|
|
editor->setProperty("OpenedByDebugger", true);
|
2009-09-29 15:21:28 +02:00
|
|
|
if (setMarker) {
|
|
|
|
|
resetLocation();
|
|
|
|
|
m_locationMark = new LocationMark(file, line);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-29 18:44:02 +02:00
|
|
|
void DebuggerPlugin::openTextEditor(const QString &titlePattern0,
|
|
|
|
|
const QString &contents)
|
|
|
|
|
{
|
|
|
|
|
QString titlePattern = titlePattern0;
|
|
|
|
|
EditorManager *editorManager = EditorManager::instance();
|
|
|
|
|
QTC_ASSERT(editorManager, return);
|
|
|
|
|
Core::IEditor *editor = editorManager->openEditorWithContents(
|
|
|
|
|
Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern, contents);
|
|
|
|
|
QTC_ASSERT(editor, return);
|
|
|
|
|
editorManager->activateEditor(editor);
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-25 08:35:31 +02:00
|
|
|
void DebuggerPlugin::handleStateChanged(int state)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-10 13:46:05 +01:00
|
|
|
// Prevent it from beeing triggered on setup.
|
|
|
|
|
if (!m_manager)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-09-25 08:35:31 +02:00
|
|
|
const bool startIsContinue = (state == InferiorStopped);
|
2009-01-20 11:52:04 +01:00
|
|
|
ICore *core = ICore::instance();
|
2010-03-22 18:05:22 +01:00
|
|
|
if (startIsContinue)
|
|
|
|
|
core->updateAdditionalContexts(QList<int>(), QList<int>() << m_gdbRunningContext);
|
|
|
|
|
else
|
|
|
|
|
core->updateAdditionalContexts(QList<int>() << m_gdbRunningContext, QList<int>());
|
2009-09-24 10:08:17 +02:00
|
|
|
|
2009-09-25 08:35:31 +02:00
|
|
|
const bool started = state == InferiorRunning
|
|
|
|
|
|| state == InferiorRunningRequested
|
|
|
|
|
|| state == InferiorStopping
|
|
|
|
|
|| state == InferiorStopped;
|
2009-09-24 10:08:17 +02:00
|
|
|
|
2009-09-25 08:35:31 +02:00
|
|
|
const bool starting = state == EngineStarting;
|
|
|
|
|
//const bool running = state == InferiorRunning;
|
2009-09-24 10:08:17 +02:00
|
|
|
|
2009-09-30 13:07:14 +02:00
|
|
|
const bool detachable = state == InferiorStopped
|
|
|
|
|
&& m_manager->startParameters()->startMode != AttachCore;
|
2009-09-24 10:08:17 +02:00
|
|
|
|
|
|
|
|
m_startExternalAction->setEnabled(!started && !starting);
|
|
|
|
|
m_attachExternalAction->setEnabled(!started && !starting);
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
m_attachCoreAction->setEnabled(false);
|
|
|
|
|
#else
|
|
|
|
|
m_attachCoreAction->setEnabled(!started && !starting);
|
|
|
|
|
#endif
|
|
|
|
|
m_startRemoteAction->setEnabled(!started && !starting);
|
2009-09-30 13:07:14 +02:00
|
|
|
m_detachAction->setEnabled(detachable);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-18 10:56:25 +01:00
|
|
|
void DebuggerPlugin::languageChanged(const QString &language)
|
|
|
|
|
{
|
|
|
|
|
if (!m_manager)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const bool debuggerIsCPP = (language == Constants::LANG_CPP);
|
|
|
|
|
|
|
|
|
|
m_startExternalAction->setVisible(debuggerIsCPP);
|
|
|
|
|
m_attachExternalAction->setVisible(debuggerIsCPP);
|
|
|
|
|
m_attachCoreAction->setVisible(debuggerIsCPP);
|
|
|
|
|
m_startRemoteAction->setVisible(debuggerIsCPP);
|
|
|
|
|
m_detachAction->setVisible(debuggerIsCPP);
|
2010-03-18 16:55:27 +01:00
|
|
|
|
2010-03-18 10:56:25 +01:00
|
|
|
}
|
|
|
|
|
|
2009-01-13 18:15:24 +01:00
|
|
|
void DebuggerPlugin::writeSettings() const
|
|
|
|
|
{
|
2009-01-14 18:09:02 +01:00
|
|
|
QSettings *s = settings();
|
2009-04-08 12:11:30 +02:00
|
|
|
DebuggerSettings::instance()->writeSettings(s);
|
2009-01-13 18:15:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::readSettings()
|
|
|
|
|
{
|
|
|
|
|
QSettings *s = settings();
|
2009-04-08 12:11:30 +02:00
|
|
|
DebuggerSettings::instance()->readSettings(s);
|
2009-01-13 18:15:24 +01:00
|
|
|
}
|
|
|
|
|
|
2009-05-15 16:54:54 +02:00
|
|
|
void DebuggerPlugin::onModeChanged(IMode *mode)
|
2009-01-13 18:15:24 +01:00
|
|
|
{
|
2009-05-25 18:21:31 +02:00
|
|
|
// 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-08-14 13:04:05 +02:00
|
|
|
if (mode != m_debugMode)
|
2009-01-13 18:15:24 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
EditorManager *editorManager = EditorManager::instance();
|
2010-02-09 20:44:40 +01:00
|
|
|
if (editorManager->currentEditor()) {
|
2009-01-13 18:15:24 +01:00
|
|
|
editorManager->currentEditor()->widget()->setFocus();
|
2010-02-09 20:44:40 +01:00
|
|
|
|
2010-03-18 10:56:25 +01:00
|
|
|
if (editorManager->currentEditor()->id() == CppEditor::Constants::C_CPPEDITOR)
|
2010-03-11 12:22:24 +01:00
|
|
|
m_uiSwitcher->setActiveLanguage(LANG_CPP);
|
2010-02-09 20:44:40 +01:00
|
|
|
|
|
|
|
|
}
|
2009-01-13 18:15:24 +01:00
|
|
|
}
|
|
|
|
|
|
2009-02-27 11:41:19 +01:00
|
|
|
void DebuggerPlugin::showSettingsDialog()
|
|
|
|
|
{
|
2009-04-28 15:08:52 +02:00
|
|
|
Core::ICore::instance()->showOptionsDialog(
|
2010-03-11 12:22:24 +01:00
|
|
|
_(DEBUGGER_SETTINGS_CATEGORY),
|
|
|
|
|
_(DEBUGGER_COMMON_SETTINGS_ID));
|
2009-02-27 11:41:19 +01:00
|
|
|
}
|
|
|
|
|
|
2009-05-05 17:48:54 +02:00
|
|
|
void DebuggerPlugin::startExternalApplication()
|
|
|
|
|
{
|
2009-09-17 14:30:28 +02:00
|
|
|
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
|
2010-02-09 20:44:40 +01:00
|
|
|
StartExternalDialog dlg(m_uiSwitcher->mainWindow());
|
2009-05-25 16:22:11 +02:00
|
|
|
dlg.setExecutableFile(
|
|
|
|
|
configValue(_("LastExternalExecutableFile")).toString());
|
|
|
|
|
dlg.setExecutableArguments(
|
|
|
|
|
configValue(_("LastExternalExecutableArguments")).toString());
|
2009-06-12 12:57:22 +02:00
|
|
|
if (dlg.exec() != QDialog::Accepted)
|
2009-05-25 16:22:11 +02:00
|
|
|
return;
|
2009-06-12 12:57:22 +02:00
|
|
|
|
2009-05-25 16:22:11 +02:00
|
|
|
setConfigValue(_("LastExternalExecutableFile"),
|
|
|
|
|
dlg.executableFile());
|
|
|
|
|
setConfigValue(_("LastExternalExecutableArguments"),
|
|
|
|
|
dlg.executableArguments());
|
|
|
|
|
sp->executable = dlg.executableFile();
|
2009-09-17 14:30:28 +02:00
|
|
|
sp->startMode = StartExternal;
|
2009-06-16 13:44:45 +02:00
|
|
|
if (!dlg.executableArguments().isEmpty())
|
|
|
|
|
sp->processArgs = dlg.executableArguments().split(QLatin1Char(' '));
|
|
|
|
|
|
2009-06-12 12:57:22 +02:00
|
|
|
if (dlg.breakAtMain())
|
|
|
|
|
m_manager->breakByFunctionMain();
|
2009-05-25 16:22:11 +02:00
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
if (RunControl *runControl = m_debuggerRunControlFactory->create(sp))
|
2010-03-11 12:22:24 +01:00
|
|
|
ProjectExplorerPlugin::instance()->startRunControl(runControl, PE::DEBUGMODE);
|
2009-05-05 17:48:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::attachExternalApplication()
|
|
|
|
|
{
|
2010-02-09 20:44:40 +01:00
|
|
|
AttachExternalDialog dlg(m_uiSwitcher->mainWindow());
|
2009-05-25 16:22:11 +02:00
|
|
|
if (dlg.exec() == QDialog::Accepted)
|
2010-03-17 10:57:19 +01:00
|
|
|
attachExternalApplication(dlg.attachPID(), dlg.executable(), QString());
|
2009-05-25 16:22:11 +02:00
|
|
|
}
|
|
|
|
|
|
2010-03-17 10:57:19 +01:00
|
|
|
void DebuggerPlugin::attachExternalApplication(qint64 pid,
|
|
|
|
|
const QString &binary,
|
|
|
|
|
const QString &crashParameter)
|
2009-05-25 16:22:11 +02:00
|
|
|
{
|
|
|
|
|
if (pid == 0) {
|
2010-03-11 12:22:24 +01:00
|
|
|
QMessageBox::warning(m_uiSwitcher->mainWindow(), tr("Warning"),
|
|
|
|
|
tr("Cannot attach to PID 0"));
|
2009-05-25 16:22:11 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2009-09-17 14:30:28 +02:00
|
|
|
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
|
2009-05-25 16:22:11 +02:00
|
|
|
sp->attachPID = pid;
|
2010-03-17 10:57:19 +01:00
|
|
|
sp->executable = binary;
|
2009-05-26 16:27:24 +02:00
|
|
|
sp->crashParameter = crashParameter;
|
2009-09-23 15:28:50 +02:00
|
|
|
sp->startMode = crashParameter.isEmpty() ? AttachExternal : AttachCrashedExternal;
|
2009-10-08 18:37:18 +02:00
|
|
|
if (RunControl *runControl = m_debuggerRunControlFactory->create(sp))
|
2010-03-11 12:22:24 +01:00
|
|
|
ProjectExplorerPlugin::instance()->startRunControl(runControl, PE::DEBUGMODE);
|
2009-05-05 17:48:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::attachCore()
|
|
|
|
|
{
|
2010-02-09 20:44:40 +01:00
|
|
|
AttachCoreDialog dlg(m_uiSwitcher->mainWindow());
|
2009-05-25 16:22:11 +02:00
|
|
|
dlg.setExecutableFile(
|
|
|
|
|
configValue(_("LastExternalExecutableFile")).toString());
|
|
|
|
|
dlg.setCoreFile(
|
|
|
|
|
configValue(_("LastExternalCoreFile")).toString());
|
|
|
|
|
if (dlg.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
|
|
|
|
setConfigValue(_("LastExternalExecutableFile"),
|
|
|
|
|
dlg.executableFile());
|
|
|
|
|
setConfigValue(_("LastExternalCoreFile"),
|
|
|
|
|
dlg.coreFile());
|
2009-09-30 12:27:03 +02:00
|
|
|
attachCore(dlg.coreFile(), dlg.executableFile());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebuggerPlugin::attachCore(const QString &core, const QString &exe)
|
|
|
|
|
{
|
|
|
|
|
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
|
|
|
|
|
sp->executable = exe;
|
|
|
|
|
sp->coreFile = core;
|
2009-09-17 14:30:28 +02:00
|
|
|
sp->startMode = AttachCore;
|
2009-10-08 18:37:18 +02:00
|
|
|
if (RunControl *runControl = m_debuggerRunControlFactory->create(sp))
|
2009-12-10 16:57:45 +01:00
|
|
|
ProjectExplorerPlugin::instance()->
|
2010-03-11 12:22:24 +01:00
|
|
|
startRunControl(runControl, PE::DEBUGMODE);
|
2009-05-05 17:48:54 +02:00
|
|
|
}
|
|
|
|
|
|
2009-05-06 13:27:11 +02:00
|
|
|
void DebuggerPlugin::startRemoteApplication()
|
2009-05-05 17:48:54 +02:00
|
|
|
{
|
2009-09-17 14:30:28 +02:00
|
|
|
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
|
2010-02-09 20:44:40 +01:00
|
|
|
StartRemoteDialog dlg(m_uiSwitcher->mainWindow());
|
2009-05-25 16:22:11 +02:00
|
|
|
QStringList arches;
|
|
|
|
|
arches.append(_("i386:x86-64:intel"));
|
2009-09-24 10:54:27 +02:00
|
|
|
arches.append(_("i386"));
|
2009-12-10 15:56:10 +01:00
|
|
|
QString lastUsed = configValue(_("LastRemoteArchitecture")).toString();
|
|
|
|
|
if (!arches.contains(lastUsed))
|
|
|
|
|
arches.prepend(lastUsed);
|
2009-05-25 16:22:11 +02:00
|
|
|
dlg.setRemoteArchitectures(arches);
|
|
|
|
|
dlg.setRemoteChannel(
|
|
|
|
|
configValue(_("LastRemoteChannel")).toString());
|
2009-12-10 16:57:45 +01:00
|
|
|
dlg.setLocalExecutable(
|
|
|
|
|
configValue(_("LastLocalExecutable")).toString());
|
2009-12-11 11:49:32 +01:00
|
|
|
dlg.setDebugger(configValue(_("LastDebugger")).toString());
|
2009-12-10 15:56:10 +01:00
|
|
|
dlg.setRemoteArchitecture(lastUsed);
|
2009-05-25 16:22:11 +02:00
|
|
|
dlg.setServerStartScript(
|
|
|
|
|
configValue(_("LastServerStartScript")).toString());
|
|
|
|
|
dlg.setUseServerStartScript(
|
|
|
|
|
configValue(_("LastUseServerStartScript")).toBool());
|
2009-12-10 16:57:45 +01:00
|
|
|
dlg.setSysRoot(configValue(_("LastSysroot")).toString());
|
2009-05-25 16:22:11 +02:00
|
|
|
if (dlg.exec() != QDialog::Accepted)
|
|
|
|
|
return;
|
|
|
|
|
setConfigValue(_("LastRemoteChannel"), dlg.remoteChannel());
|
2009-12-10 16:57:45 +01:00
|
|
|
setConfigValue(_("LastLocalExecutable"), dlg.localExecutable());
|
2009-12-11 11:49:32 +01:00
|
|
|
setConfigValue(_("LastDebugger"), dlg.debugger());
|
2009-05-25 16:22:11 +02:00
|
|
|
setConfigValue(_("LastRemoteArchitecture"), dlg.remoteArchitecture());
|
|
|
|
|
setConfigValue(_("LastServerStartScript"), dlg.serverStartScript());
|
|
|
|
|
setConfigValue(_("LastUseServerStartScript"), dlg.useServerStartScript());
|
2009-12-10 16:57:45 +01:00
|
|
|
setConfigValue(_("LastSysroot"), dlg.sysRoot());
|
2009-05-25 16:22:11 +02:00
|
|
|
sp->remoteChannel = dlg.remoteChannel();
|
|
|
|
|
sp->remoteArchitecture = dlg.remoteArchitecture();
|
2009-12-10 16:57:45 +01:00
|
|
|
sp->executable = dlg.localExecutable();
|
2009-12-11 11:49:32 +01:00
|
|
|
sp->debuggerCommand = dlg.debugger();
|
2009-09-17 14:30:28 +02:00
|
|
|
sp->startMode = StartRemote;
|
2009-05-25 16:22:11 +02:00
|
|
|
if (dlg.useServerStartScript())
|
|
|
|
|
sp->serverStartScript = dlg.serverStartScript();
|
2009-12-10 16:57:45 +01:00
|
|
|
sp->sysRoot = dlg.sysRoot();
|
2009-05-25 16:22:11 +02:00
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
if (RunControl *runControl = m_debuggerRunControlFactory->create(sp))
|
2009-12-10 16:57:45 +01:00
|
|
|
ProjectExplorerPlugin::instance()
|
2010-03-11 12:22:24 +01:00
|
|
|
->startRunControl(runControl, PE::DEBUGMODE);
|
2009-05-05 17:48:54 +02:00
|
|
|
}
|
|
|
|
|
|
2010-03-11 11:07:16 +01:00
|
|
|
void DebuggerPlugin::enableReverseDebuggingTriggered(const QVariant &value)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_reverseToolButton, return);
|
|
|
|
|
m_reverseToolButton->setVisible(value.toBool());
|
|
|
|
|
if (!value.toBool())
|
|
|
|
|
m_manager->debuggerManagerActions().reverseDirectionAction->setChecked(false);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "debuggerplugin.moc"
|
|
|
|
|
|
|
|
|
|
Q_EXPORT_PLUGIN(DebuggerPlugin)
|