debuggermanager.cpp 46.2 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** 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.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** 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.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
con's avatar
con committed
29
30
31

#include "debuggermanager.h"

32
#include "debuggeractions.h"
33
#include "debuggerrunner.h"
con's avatar
con committed
34
35
36
37
38
39
40
41
#include "debuggerconstants.h"
#include "idebuggerengine.h"

#include "breakwindow.h"
#include "debuggeroutputwindow.h"
#include "moduleswindow.h"
#include "registerwindow.h"
#include "stackwindow.h"
42
#include "sourcefileswindow.h"
con's avatar
con committed
43
44
45
46
47
48
49
#include "threadswindow.h"
#include "watchwindow.h"

#include "breakhandler.h"
#include "moduleshandler.h"
#include "registerhandler.h"
#include "stackhandler.h"
50
#include "stackframe.h"
con's avatar
con committed
51
52
#include "watchhandler.h"

53
#include "debuggerdialogs.h"
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
54
#ifdef Q_OS_WIN
55
#  include "shared/peutils.h"
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
56
#endif
57
#include <coreplugin/icore.h>
58
#include <utils/qtcassert.h>
59
#include <utils/fancymainwindow.h>
60
#include <projectexplorer/toolchain.h>
61

con's avatar
con committed
62
63
64
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
65
#include <QtCore/QTextStream>
con's avatar
con committed
66
#include <QtCore/QTime>
67
#include <QtCore/QTimer>
con's avatar
con committed
68

69
#include <QtGui/QApplication>
con's avatar
con committed
70
71
72
73
74
75
76
77
#include <QtGui/QAction>
#include <QtGui/QComboBox>
#include <QtGui/QDockWidget>
#include <QtGui/QErrorMessage>
#include <QtGui/QFileDialog>
#include <QtGui/QLabel>
#include <QtGui/QMessageBox>
#include <QtGui/QPlainTextEdit>
78
#include <QtGui/QPushButton>
con's avatar
con committed
79
80
81
82
83
84
#include <QtGui/QStatusBar>
#include <QtGui/QTextBlock>
#include <QtGui/QTextCursor>
#include <QtGui/QToolButton>
#include <QtGui/QToolTip>

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

// The creation functions take a list of options pages they can add to.
// This allows for having a "enabled" toggle on the page indepently
// of the engine.
using namespace Debugger::Internal;

IDebuggerEngine *createWinEngine(DebuggerManager *, bool /* cmdLineEnabled */, QList<Core::IOptionsPage*> *)
#ifdef CDB_ENABLED
;
#else
{ return 0; }
#endif
IDebuggerEngine *createScriptEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *);
IDebuggerEngine *createTcfEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *);


101
namespace Debugger {
102
103
namespace Internal {

104
105
IDebuggerEngine *createGdbEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *);

106
107
IDebuggerEngine *createSymbianEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *);

108
109
110
111
112
113
114
115
116
117
118
QDebug operator<<(QDebug str, const DebuggerStartParameters &p)
{
    QDebug nospace = str.nospace();
    const QString sep = QString(QLatin1Char(','));
    nospace << "executable=" << p.executable << " coreFile=" << p.coreFile
            << " processArgs=" << p.processArgs.join(sep)
            << " environment=<" << p.environment.size() << " variables>"
            << " workingDir=" << p.workingDir << " buildDir=" << p.buildDir
            << " attachPID=" << p.attachPID << " useTerminal=" << p.useTerminal
            << " remoteChannel=" << p.remoteChannel
            << " remoteArchitecture=" << p.remoteArchitecture
119
120
            << " serverStartScript=" << p.serverStartScript
            << " toolchain=" << p.toolChainType << '\n';
121
122
123
    return str;
}

124
using namespace Constants;
con's avatar
con committed
125
126
127

static const QString tooltipIName = "tooltip";

128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
static const char *stateName(int s)
{
    switch (s) {
    case DebuggerProcessNotReady:
        return "DebuggerProcessNotReady";
    case DebuggerProcessStartingUp:
        return "DebuggerProcessStartingUp";
    case DebuggerInferiorRunningRequested:
        return "DebuggerInferiorRunningRequested";
    case DebuggerInferiorRunning:
        return "DebuggerInferiorRunning";
    case DebuggerInferiorStopRequested:
        return "DebuggerInferiorStopRequested";
    case DebuggerInferiorStopped:
        return "DebuggerInferiorStopped";
    }
    return "<unknown>";
}

con's avatar
con committed
147
148
149

///////////////////////////////////////////////////////////////////////
//
150
// DebuggerStartParameters
con's avatar
con committed
151
152
153
//
///////////////////////////////////////////////////////////////////////

154
155
DebuggerStartParameters::DebuggerStartParameters()
  : attachPID(-1),
156
    useTerminal(false),
hjk's avatar
hjk committed
157
158
    toolChainType(ProjectExplorer::ToolChain::UNKNOWN),
    startMode(NoStartMode)
159
{}
160
161
162
163
164
165
166
167
168
169
170

void DebuggerStartParameters::clear()
{
    executable.clear();
    coreFile.clear();
    processArgs.clear();
    environment.clear();
    workingDir.clear();
    buildDir.clear();
    attachPID = -1;
    useTerminal = false;
171
    crashParameter.clear();
172
173
174
    remoteChannel.clear();
    remoteArchitecture.clear();
    serverStartScript.clear();
175
    toolChainType = ProjectExplorer::ToolChain::UNKNOWN;
hjk's avatar
hjk committed
176
    startMode = NoStartMode;
177
178
}

179
180
181
182
183
184
185
186
187

///////////////////////////////////////////////////////////////////////
//
// DebuggerManager
//
///////////////////////////////////////////////////////////////////////

static IDebuggerEngine *gdbEngine = 0;
static IDebuggerEngine *scriptEngine = 0;
hjk's avatar
hjk committed
188
static IDebuggerEngine *symbianEngine = 0;
189
static IDebuggerEngine *tcfEngine = 0;
hjk's avatar
hjk committed
190
static IDebuggerEngine *winEngine = 0;
191
192
193

DebuggerManager::DebuggerManager()
  : m_startParameters(new DebuggerStartParameters),
194
    m_inferiorPid(0)
con's avatar
con committed
195
{
196
    init();
con's avatar
con committed
197
198
199
200
}

DebuggerManager::~DebuggerManager()
{
201
202
203
    #define doDelete(ptr) delete ptr; ptr = 0
    doDelete(gdbEngine);
    doDelete(scriptEngine);
hjk's avatar
hjk committed
204
    doDelete(symbianEngine);
205
    doDelete(tcfEngine);
hjk's avatar
hjk committed
206
    doDelete(winEngine);
207
    #undef doDelete
con's avatar
con committed
208
209
}

210
void DebuggerManager::init()
con's avatar
con committed
211
212
213
214
215
216
217
{
    m_status = -1;
    m_busy = false;

    m_modulesHandler = 0;
    m_registerHandler = 0;

218
    m_statusLabel = new QLabel;
219
220
    m_statusLabel->setMinimumSize(QSize(30, 10));

con's avatar
con committed
221
    m_breakWindow = new BreakWindow;
222
    m_modulesWindow = new ModulesWindow(this);
con's avatar
con committed
223
    m_outputWindow = new DebuggerOutputWindow;
224
225
    m_registerWindow = new RegisterWindow(this);
    m_stackWindow = new StackWindow(this);
226
    m_sourceFilesWindow = new SourceFilesWindow;
con's avatar
con committed
227
    m_threadsWindow = new ThreadsWindow;
228
229
230
    m_localsWindow = new WatchWindow(WatchWindow::LocalsType, this);
    m_watchersWindow = new WatchWindow(WatchWindow::WatchersType, this);
    //m_tooltipWindow = new WatchWindow(WatchWindow::TooltipType, this);
231
    m_statusTimer = new QTimer(this);
con's avatar
con committed
232

233
    m_mainWindow = new Core::Utils::FancyMainWindow;
con's avatar
con committed
234
235
236
237
238
239
240
241
242
243
    m_mainWindow->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
    m_mainWindow->setDocumentMode(true);

    // Stack
    m_stackHandler = new StackHandler;
    QAbstractItemView *stackView =
        qobject_cast<QAbstractItemView *>(m_stackWindow);
    stackView->setModel(m_stackHandler->stackModel());
    connect(stackView, SIGNAL(frameActivated(int)),
        this, SLOT(activateFrame(int)));
244
245
246
247
    connect(theDebuggerAction(ExpandStack), SIGNAL(triggered()),
        this, SLOT(reloadFullStack()));
    connect(theDebuggerAction(MaximalStackDepth), SIGNAL(triggered()),
        this, SLOT(reloadFullStack()));
con's avatar
con committed
248
249
250
251
252
253
254
255
256
257

    // Threads
    m_threadsHandler = new ThreadsHandler;
    QAbstractItemView *threadsView =
        qobject_cast<QAbstractItemView *>(m_threadsWindow);
    threadsView->setModel(m_threadsHandler->threadsModel());
    connect(threadsView, SIGNAL(threadSelected(int)),
        this, SLOT(selectThread(int)));

    // Breakpoints
258
    m_breakHandler = new BreakHandler(this);
con's avatar
con committed
259
260
261
    QAbstractItemView *breakView =
        qobject_cast<QAbstractItemView *>(m_breakWindow);
    breakView->setModel(m_breakHandler->model());
262
263
264
    connect(breakView, SIGNAL(breakpointActivated(int)),
        m_breakHandler, SLOT(activateBreakpoint(int)));
    connect(breakView, SIGNAL(breakpointDeleted(int)),
con's avatar
con committed
265
        m_breakHandler, SLOT(removeBreakpoint(int)));
266
267
    connect(breakView, SIGNAL(breakpointSynchronizationRequested()),
        this, SLOT(attemptBreakpointSynchronization()));
268
269
    connect(breakView, SIGNAL(breakByFunctionRequested(QString)),
        this, SLOT(breakByFunction(QString)), Qt::QueuedConnection);
270
271
    connect(breakView, SIGNAL(breakByFunctionMainRequested()),
        this, SLOT(breakByFunctionMain()), Qt::QueuedConnection);
con's avatar
con committed
272
273
274
275
276
277
278
279
280
281
282
283

    // Modules
    QAbstractItemView *modulesView =
        qobject_cast<QAbstractItemView *>(m_modulesWindow);
    m_modulesHandler = new ModulesHandler;
    modulesView->setModel(m_modulesHandler->model());
    connect(modulesView, SIGNAL(reloadModulesRequested()),
        this, SLOT(reloadModules()));
    connect(modulesView, SIGNAL(loadSymbolsRequested(QString)),
        this, SLOT(loadSymbols(QString)));
    connect(modulesView, SIGNAL(loadAllSymbolsRequested()),
        this, SLOT(loadAllSymbols()));
284
285
    connect(modulesView, SIGNAL(fileOpenRequested(QString)),
        this, SLOT(fileOpen(QString)));
hjk's avatar
hjk committed
286
287
    connect(modulesView, SIGNAL(newDockRequested(QWidget*)),
        this, SLOT(createNewDock(QWidget*)));
con's avatar
con committed
288

289
290
291
292
293
294
295
    // Source Files
    //m_sourceFilesHandler = new SourceFilesHandler;
    QAbstractItemView *sourceFilesView =
        qobject_cast<QAbstractItemView *>(m_sourceFilesWindow);
    //sourceFileView->setModel(m_stackHandler->stackModel());
    connect(sourceFilesView, SIGNAL(reloadSourceFilesRequested()),
        this, SLOT(reloadSourceFiles()));
296
297
    connect(sourceFilesView, SIGNAL(fileOpenRequested(QString)),
        this, SLOT(fileOpen(QString)));
con's avatar
con committed
298

299
    // Registers
con's avatar
con committed
300
301
302
303
304
    QAbstractItemView *registerView =
        qobject_cast<QAbstractItemView *>(m_registerWindow);
    m_registerHandler = new RegisterHandler;
    registerView->setModel(m_registerHandler->model());

305
306
307
308
309
310
311
312
    // Locals
    m_watchHandler = new WatchHandler;
    QTreeView *localsView = qobject_cast<QTreeView *>(m_localsWindow);
    localsView->setModel(m_watchHandler->model(LocalsWatch));

    // Watchers
    QTreeView *watchersView = qobject_cast<QTreeView *>(m_watchersWindow);
    watchersView->setModel(m_watchHandler->model(WatchersWatch));
hjk's avatar
hjk committed
313
314
315
316
    connect(m_watchHandler, SIGNAL(sessionValueRequested(QString,QVariant*)),
        this, SIGNAL(sessionValueRequested(QString,QVariant*)));
    connect(m_watchHandler, SIGNAL(setSessionValueRequested(QString,QVariant)),
        this, SIGNAL(setSessionValueRequested(QString,QVariant)));
317
    connect(theDebuggerAction(AssignValue), SIGNAL(triggered()),
318
        this, SLOT(assignValueInDebugger()), Qt::QueuedConnection);
con's avatar
con committed
319
320

    // Tooltip
321
322
    //QTreeView *tooltipView = qobject_cast<QTreeView *>(m_tooltipWindow);
    //tooltipView->setModel(m_watchHandler->model(TooltipsWatch));
323
324
    //qRegisterMetaType<WatchData>("Debugger::Internal::WatchData");
    qRegisterMetaType<WatchData>("WatchData");
hjk's avatar
hjk committed
325
    connect(m_watchHandler, SIGNAL(watchDataUpdateNeeded(WatchData)),
326
        this, SLOT(updateWatchData(WatchData)));
327

con's avatar
con committed
328
329
    m_continueAction = new QAction(this);
    m_continueAction->setText(tr("Continue"));
330
    m_continueAction->setIcon(QIcon(":/debugger/images/debugger_continue_small.png"));
con's avatar
con committed
331
332
333

    m_stopAction = new QAction(this);
    m_stopAction->setText(tr("Interrupt"));
334
    m_stopAction->setIcon(QIcon(":/debugger/images/debugger_interrupt_small.png"));
con's avatar
con committed
335
336
337
338
339
340
341

    m_resetAction = new QAction(this);
    m_resetAction->setText(tr("Reset Debugger"));

    m_nextAction = new QAction(this);
    m_nextAction->setText(tr("Step Over"));
    //m_nextAction->setShortcut(QKeySequence(tr("F6")));
342
    m_nextAction->setIcon(QIcon(":/debugger/images/debugger_stepover_small.png"));
con's avatar
con committed
343
344
345
346

    m_stepAction = new QAction(this);
    m_stepAction->setText(tr("Step Into"));
    //m_stepAction->setShortcut(QKeySequence(tr("F7")));
347
    m_stepAction->setIcon(QIcon(":/debugger/images/debugger_stepinto_small.png"));
con's avatar
con committed
348
349
350
351

    m_stepOutAction = new QAction(this);
    m_stepOutAction->setText(tr("Step Out"));
    //m_stepOutAction->setShortcut(QKeySequence(tr("Shift+F7")));
352
    m_stepOutAction->setIcon(QIcon(":/debugger/images/debugger_stepout_small.png"));
con's avatar
con committed
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368

    m_runToLineAction = new QAction(this);
    m_runToLineAction->setText(tr("Run to Line"));

    m_runToFunctionAction = new QAction(this);
    m_runToFunctionAction->setText(tr("Run to Outermost Function"));

    m_jumpToLineAction = new QAction(this);
    m_jumpToLineAction->setText(tr("Jump to Line"));

    m_breakAction = new QAction(this);
    m_breakAction->setText(tr("Toggle Breakpoint"));

    m_watchAction = new QAction(this);
    m_watchAction->setText(tr("Add to Watch Window"));

369
370
371
372
373
374
    m_reverseDirectionAction = new QAction(this);
    m_reverseDirectionAction->setText(tr("Reverse Direction"));
    m_reverseDirectionAction->setCheckable(true);
    m_reverseDirectionAction->setChecked(false);
    //m_reverseDirectionAction->setIcon(QIcon(":/debugger/images/debugger_stepoverproc_small.png"));

con's avatar
con committed
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
    // For usuage hints oin focus{In,Out}
    connect(m_continueAction, SIGNAL(triggered()),
        this, SLOT(continueExec()));

    connect(m_stopAction, SIGNAL(triggered()),
        this, SLOT(interruptDebuggingRequest()));
    connect(m_resetAction, SIGNAL(triggered()),
        this, SLOT(exitDebugger()));
    connect(m_nextAction, SIGNAL(triggered()),
        this, SLOT(nextExec()));
    connect(m_stepAction, SIGNAL(triggered()),
        this, SLOT(stepExec()));
    connect(m_stepOutAction, SIGNAL(triggered()),
        this, SLOT(stepOutExec()));
    connect(m_runToLineAction, SIGNAL(triggered()),
        this, SLOT(runToLineExec()));
    connect(m_runToFunctionAction, SIGNAL(triggered()),
        this, SLOT(runToFunctionExec()));
    connect(m_jumpToLineAction, SIGNAL(triggered()),
        this, SLOT(jumpToLineExec()));
    connect(m_watchAction, SIGNAL(triggered()),
        this, SLOT(addToWatchWindow()));
    connect(m_breakAction, SIGNAL(triggered()),
        this, SLOT(toggleBreakpoint()));

400
401
    connect(m_statusTimer, SIGNAL(timeout()),
        this, SLOT(clearStatusMessage()));
con's avatar
con committed
402

403
404
    connect(theDebuggerAction(ExecuteCommand), SIGNAL(triggered()),
        this, SLOT(executeDebuggerCommand()));
405

406
407
    connect(theDebuggerAction(WatchPoint), SIGNAL(triggered()),
        this, SLOT(watchPoint()));
con's avatar
con committed
408

409
410
411
412
    connect(theDebuggerAction(StepByInstruction), SIGNAL(triggered()),
        this, SLOT(stepByInstructionTriggered()));


413
    m_breakDock = m_mainWindow->addDockForWidget(m_breakWindow);
con's avatar
con committed
414

415
    m_modulesDock = m_mainWindow->addDockForWidget(m_modulesWindow);
con's avatar
con committed
416
417
418
    connect(m_modulesDock->toggleViewAction(), SIGNAL(toggled(bool)),
        this, SLOT(reloadModules()), Qt::QueuedConnection);

419
    m_registerDock = m_mainWindow->addDockForWidget(m_registerWindow);
con's avatar
con committed
420
421
422
    connect(m_registerDock->toggleViewAction(), SIGNAL(toggled(bool)),
        this, SLOT(reloadRegisters()), Qt::QueuedConnection);

423
    m_outputDock = m_mainWindow->addDockForWidget(m_outputWindow);
con's avatar
con committed
424

425
    m_stackDock = m_mainWindow->addDockForWidget(m_stackWindow);
con's avatar
con committed
426

427
    m_sourceFilesDock = m_mainWindow->addDockForWidget(m_sourceFilesWindow);
428
429
430
    connect(m_sourceFilesDock->toggleViewAction(), SIGNAL(toggled(bool)),
        this, SLOT(reloadSourceFiles()), Qt::QueuedConnection);

431
    m_threadsDock = m_mainWindow->addDockForWidget(m_threadsWindow);
con's avatar
con committed
432

433
434
435
436
    QSplitter *localsAndWatchers = new QSplitter(Qt::Vertical, 0);
    localsAndWatchers->setWindowTitle(m_localsWindow->windowTitle());
    localsAndWatchers->addWidget(m_localsWindow);
    localsAndWatchers->addWidget(m_watchersWindow);
437
    //localsAndWatchers->addWidget(m_tooltipWindow);
438
439
    localsAndWatchers->setStretchFactor(0, 3);
    localsAndWatchers->setStretchFactor(1, 1);
440
    localsAndWatchers->setStretchFactor(2, 1);
441
    m_watchDock = m_mainWindow->addDockForWidget(localsAndWatchers);
442

con's avatar
con committed
443
    setStatus(DebuggerProcessNotReady);
444
445
}

446
QList<Core::IOptionsPage*> DebuggerManager::initializeEngines(unsigned enabledTypeFlags)
447
448
{
    QList<Core::IOptionsPage*> rc;
449
450
    if (enabledTypeFlags & GdbEngineType)
        gdbEngine = createGdbEngine(this, &rc);
hjk's avatar
hjk committed
451
452
    if (enabledTypeFlags & SymbianEngineType)
        symbianEngine = createSymbianEngine(this, &rc);
453
454
455
456
457
    winEngine = createWinEngine(this, (enabledTypeFlags & CdbEngineType), &rc);
    if (enabledTypeFlags & ScriptEngineType)
        scriptEngine = createScriptEngine(this, &rc);
    if (enabledTypeFlags & TcfEngineType)
        tcfEngine = createTcfEngine(this, &rc);
458
    m_engine = 0;
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
459
    if (Debugger::Constants::Internal::debug)
460
461
        qDebug() << Q_FUNC_INFO << gdbEngine << winEngine << scriptEngine << rc.size();
    return rc;
con's avatar
con committed
462
463
464
465
466
467
468
469
470
}

IDebuggerEngine *DebuggerManager::engine()
{
    return m_engine;
}

IDebuggerManagerAccessForEngines *DebuggerManager::engineInterface()
{
dt's avatar
dt committed
471
    return this;
con's avatar
con committed
472
473
}

hjk's avatar
hjk committed
474
475
476
477
478
479
480
481
482
483
void DebuggerManager::createNewDock(QWidget *widget)
{
    QDockWidget *dockWidget = new QDockWidget(widget->windowTitle(), m_mainWindow);
    dockWidget->setObjectName(widget->windowTitle());
    dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
    dockWidget->setWidget(widget);
    m_mainWindow->addDockWidget(Qt::TopDockWidgetArea, dockWidget);
    dockWidget->show();
}

con's avatar
con committed
484
485
void DebuggerManager::setSimpleDockWidgetArrangement()
{
486
487
    m_mainWindow->setTrackingEnabled(false);
    QList<QDockWidget *> dockWidgets = m_mainWindow->dockWidgets();
488
489
    foreach (QDockWidget *dockWidget, dockWidgets) {
        dockWidget->setFloating(false);
con's avatar
con committed
490
        m_mainWindow->removeDockWidget(dockWidget);
491
    }
con's avatar
con committed
492

493
    foreach (QDockWidget *dockWidget, dockWidgets) {
con's avatar
con committed
494
495
496
497
498
499
500
501
502
        m_mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
        dockWidget->show();
    }

    m_mainWindow->tabifyDockWidget(m_watchDock, m_breakDock);
    m_mainWindow->tabifyDockWidget(m_watchDock, m_modulesDock);
    m_mainWindow->tabifyDockWidget(m_watchDock, m_outputDock);
    m_mainWindow->tabifyDockWidget(m_watchDock, m_registerDock);
    m_mainWindow->tabifyDockWidget(m_watchDock, m_threadsDock);
503
    m_mainWindow->tabifyDockWidget(m_watchDock, m_sourceFilesDock);
con's avatar
con committed
504

505
506
    // They following views are rarely used in ordinary debugging. Hiding them
    // saves cycles since the corresponding information won't be retrieved.
507
    m_sourceFilesDock->hide();
con's avatar
con committed
508
509
510
    m_registerDock->hide();
    m_modulesDock->hide();
    m_outputDock->hide();
511
    m_mainWindow->setTrackingEnabled(true);
con's avatar
con committed
512
513
514
515
516
517
518
}

QAbstractItemModel *DebuggerManager::threadsModel()
{
    return qobject_cast<ThreadsWindow*>(m_threadsWindow)->model();
}

519
520
521
522
523
void DebuggerManager::clearStatusMessage()
{
    m_statusLabel->setText(m_lastPermanentStatusMessage);
}

con's avatar
con committed
524
525
526
void DebuggerManager::showStatusMessage(const QString &msg, int timeout)
{
    Q_UNUSED(timeout)
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
527
528
    if (Debugger::Constants::Internal::debug)
        qDebug() << "STATUS MSG: " << msg;
529
    showDebuggerOutput(LogStatus, msg);
hjk's avatar
hjk committed
530
    m_statusLabel->setText(QLatin1String("   ") + msg);
531
532
533
534
535
536
537
    if (timeout > 0) {
        m_statusTimer->setSingleShot(true);
        m_statusTimer->start(timeout);
    } else {
        m_lastPermanentStatusMessage = msg;
        m_statusTimer->stop();
    }
con's avatar
con committed
538
539
}

hjk's avatar
hjk committed
540
541
542
543
544
545
void DebuggerManager::notifyInferiorStopRequested()
{
    setStatus(DebuggerInferiorStopRequested);
    showStatusMessage(tr("Stop requested..."), 5000);
}

con's avatar
con committed
546
547
548
549
550
551
552
553
554
555
void DebuggerManager::notifyInferiorStopped()
{
    resetLocation();
    setStatus(DebuggerInferiorStopped);
    showStatusMessage(tr("Stopped."), 5000);
}

void DebuggerManager::notifyInferiorRunningRequested()
{
    setStatus(DebuggerInferiorRunningRequested);
556
    showStatusMessage(tr("Running requested..."), 5000);
con's avatar
con committed
557
558
559
560
561
562
563
564
565
566
}

void DebuggerManager::notifyInferiorRunning()
{
    setStatus(DebuggerInferiorRunning);
    showStatusMessage(tr("Running..."), 5000);
}

void DebuggerManager::notifyInferiorExited()
{
hjk's avatar
hjk committed
567
    setStatus(DebuggerProcessNotReady);
con's avatar
con committed
568
569
570
    showStatusMessage(tr("Stopped."), 5000);
}

571
void DebuggerManager::notifyInferiorPidChanged(qint64 pid)
con's avatar
con committed
572
{
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
573
    if (Debugger::Constants::Internal::debug)
574
575
576
577
578
579
        qDebug() << Q_FUNC_INFO << m_inferiorPid << pid;

    if (m_inferiorPid != pid) {
        m_inferiorPid = pid;
        emit inferiorPidChanged(pid);
    }
con's avatar
con committed
580
581
}

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
582
void DebuggerManager::showApplicationOutput(const QString &str)
con's avatar
con committed
583
{
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
584
     emit applicationOutputAvailable(str);
con's avatar
con committed
585
586
587
588
}

void DebuggerManager::shutdown()
{
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
589
590
591
592
    if (Debugger::Constants::Internal::debug)
        qDebug() << Q_FUNC_INFO << m_engine;

    if (m_engine)
593
594
595
        m_engine->shutdown();
    m_engine = 0;

596
597
598
599
600
    #define doDelete(ptr) delete ptr; ptr = 0
    doDelete(scriptEngine);
    doDelete(gdbEngine);
    doDelete(winEngine);
    doDelete(tcfEngine);
601

con's avatar
con committed
602
603
    // Delete these manually before deleting the manager
    // (who will delete the models for most views)
604
605
606
607
608
609
610
    doDelete(m_breakWindow);
    doDelete(m_modulesWindow);
    doDelete(m_outputWindow);
    doDelete(m_registerWindow);
    doDelete(m_stackWindow);
    doDelete(m_sourceFilesWindow);
    doDelete(m_threadsWindow);
611
    //doDelete(m_tooltipWindow);
612
613
614
615
616
617
618
619
620
621
    doDelete(m_watchersWindow);
    doDelete(m_localsWindow);

    doDelete(m_breakHandler);
    doDelete(m_threadsHandler);
    doDelete(m_modulesHandler);
    doDelete(m_registerHandler);
    doDelete(m_stackHandler);
    doDelete(m_watchHandler);
    #undef doDelete
con's avatar
con committed
622
623
}

624
625
626
627
628
629
630
631
BreakpointData *DebuggerManager::findBreakpoint(const QString &fileName, int lineNumber)
{
    if (!m_breakHandler)
        return 0;
    int index = m_breakHandler->findBreakpoint(fileName, lineNumber);
    return index == -1 ? 0 : m_breakHandler->at(index);
}

con's avatar
con committed
632
633
634
635
636
637
638
639
640
641
642
643
void DebuggerManager::toggleBreakpoint()
{
    QString fileName;
    int lineNumber = -1;
    queryCurrentTextEditor(&fileName, &lineNumber, 0);
    if (lineNumber == -1)
        return;
    toggleBreakpoint(fileName, lineNumber);
}

void DebuggerManager::toggleBreakpoint(const QString &fileName, int lineNumber)
{
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
644
645
646
    if (Debugger::Constants::Internal::debug)
        qDebug() << Q_FUNC_INFO << fileName << lineNumber;

647
    QTC_ASSERT(m_breakHandler, return);
hjk's avatar
hjk committed
648
    if (status() != DebuggerInferiorRunning
649
         && status() != DebuggerInferiorStopped
hjk's avatar
hjk committed
650
         && status() != DebuggerProcessNotReady) {
hjk's avatar
hjk committed
651
652
653
654
655
        showStatusMessage(tr("Changing breakpoint state requires either a "
            "fully running or fully stopped application."));
        return;
    }

656
    int index = m_breakHandler->findBreakpoint(fileName, lineNumber);
con's avatar
con committed
657
    if (index == -1)
658
        m_breakHandler->setBreakpoint(fileName, lineNumber);
con's avatar
con committed
659
    else
660
        m_breakHandler->removeBreakpoint(index);
661

hjk's avatar
hjk committed
662
    attemptBreakpointSynchronization();
con's avatar
con committed
663
664
}

665
666
667
668
669
670
671
void DebuggerManager::toggleBreakpointEnabled(const QString &fileName, int lineNumber)
{
    if (Debugger::Constants::Internal::debug)
        qDebug() << Q_FUNC_INFO << fileName << lineNumber;

    QTC_ASSERT(m_breakHandler, return);
    if (status() != DebuggerInferiorRunning
672
         && status() != DebuggerInferiorStopped
673
674
675
676
677
678
679
         && status() != DebuggerProcessNotReady) {
        showStatusMessage(tr("Changing breakpoint state requires either a "
            "fully running or fully stopped application."));
        return;
    }

    m_breakHandler->toggleBreakpointEnabled(fileName, lineNumber);
hjk's avatar
hjk committed
680
681

    attemptBreakpointSynchronization();
682
683
}

684
685
void DebuggerManager::attemptBreakpointSynchronization()
{
hjk's avatar
hjk committed
686
687
    if (m_engine)
        m_engine->attemptBreakpointSynchronization();
688
689
}

690
void DebuggerManager::setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos)
con's avatar
con committed
691
{
hjk's avatar
hjk committed
692
    if (m_engine)
693
        m_engine->setToolTipExpression(mousePos, editor, cursorPos);
con's avatar
con committed
694
695
}

696
697
698
699
700
701
void DebuggerManager::updateWatchData(const WatchData &data)
{
    if (m_engine)
        m_engine->updateWatchData(data);
}

hjk's avatar
hjk committed
702
static QString msgEngineNotAvailable(const char *engine)
703
{
hjk's avatar
hjk committed
704
705
    return DebuggerManager::tr("The application requires the debugger engine '%1', "
        "which is disabled.").arg(QLatin1String(engine));
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
}

static IDebuggerEngine *debuggerEngineForToolChain(ProjectExplorer::ToolChain::ToolChainType tc)
{
    IDebuggerEngine *rc = 0;
    switch (tc) {
    case ProjectExplorer::ToolChain::LinuxICC:
    case ProjectExplorer::ToolChain::MinGW:
    case ProjectExplorer::ToolChain::GCC:
        rc = gdbEngine;
        break;
    case ProjectExplorer::ToolChain::MSVC:
    case ProjectExplorer::ToolChain::WINCE:
        rc = winEngine;
        break;
    case ProjectExplorer::ToolChain::OTHER:
    case ProjectExplorer::ToolChain::UNKNOWN:
    case ProjectExplorer::ToolChain::INVALID:
724
    default:
725
726
727
728
729
730
731
732
733
        break;
    }
    if (Debugger::Constants::Internal::debug)
        qDebug()  << "Toolchain" << tc << rc;
    return rc;
}

// Figure out the debugger type of an executable. Analyze executable
// unless the toolchain provides a hint.
734
static IDebuggerEngine *determineDebuggerEngine(const QString &executable,
735
736
737
                                                int toolChainType,
                                                QString *errorMessage,
                                                QString *settingsIdHint)
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
738
{
739
740
741
742
743
    if (executable.endsWith(_(".js"))) {
        if (!scriptEngine) {
            *errorMessage = msgEngineNotAvailable("Script Engine");
            return 0;
        }
744
        return scriptEngine;
745
    }
746

hjk's avatar
hjk committed
747
748
749
750
751
752
753
754
755
756
    if (executable.endsWith(_(".sym"))) {
        if (!symbianEngine) {
            *errorMessage = msgEngineNotAvailable("Symbian Engine");
            return 0;
        }
        return symbianEngine;
    }

    if (IDebuggerEngine *tce = debuggerEngineForToolChain(
            static_cast<ProjectExplorer::ToolChain::ToolChainType>(toolChainType)))
757
758
        return tce;

759
#ifndef Q_OS_WIN
760
    Q_UNUSED(settingsIdHint)
761
762
763
764
765
    if (!gdbEngine) {
        *errorMessage = msgEngineNotAvailable("Gdb Engine");
        return 0;
    }

766
    return gdbEngine;
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
767
768
769
770
#else
    // If a file has PDB files, it has been compiled by VS.
    QStringList pdbFiles;
    if (!getPDBFiles(executable, &pdbFiles, errorMessage))
771
        return 0;
772
    if (pdbFiles.empty())
773
        return gdbEngine;
774

Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
775
776
777
    // We need the CDB debugger in order to be able to debug VS
    // executables
    if (!winEngine) {
778
779
        *errorMessage = DebuggerManager::tr("Debugging VS executables is currently not enabled.");
        *settingsIdHint = QLatin1String("Cdb");
780
        return 0;
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
781
    }
782
    return winEngine;
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
783
784
785
#endif
}

Friedemann Kleint's avatar
Friedemann Kleint committed
786
// Figure out the debugger type of a PID
787
static IDebuggerEngine *determineDebuggerEngine(int  /* pid */,
788
789
                                                int toolChainType,
                                                QString *errorMessage)
Friedemann Kleint's avatar
Friedemann Kleint committed
790
{
hjk's avatar
hjk committed
791
792
    if (IDebuggerEngine *tce = debuggerEngineForToolChain(
            static_cast<ProjectExplorer::ToolChain::ToolChainType>(toolChainType)))
793
        return tce;
Friedemann Kleint's avatar
Friedemann Kleint committed
794
795
#ifdef Q_OS_WIN
    // Preferably Windows debugger
796
797
798
799
800
801
    if (winEngine)
        return winEngine;
    if (gdbEngine)
        return gdbEngine;
    *errorMessage = msgEngineNotAvailable("Gdb Engine");
    return 0;
Friedemann Kleint's avatar
Friedemann Kleint committed
802
#else
803
804
805
806
807
    if (!gdbEngine) {
        *errorMessage = msgEngineNotAvailable("Gdb Engine");
        return 0;
    }

808
    return gdbEngine;
Friedemann Kleint's avatar
Friedemann Kleint committed
809
810
811
#endif
}

hjk's avatar
hjk committed
812
void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
con's avatar
con committed
813
{
hjk's avatar
hjk committed
814
    m_startParameters = sp;
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
815
    if (Debugger::Constants::Internal::debug)
hjk's avatar
hjk committed
816
        qDebug() << Q_FUNC_INFO << '\n' << *m_startParameters;
817

hjk's avatar
hjk committed
818
819
    m_inferiorPid = m_startParameters->attachPID > 0
        ? m_startParameters->attachPID : 0;
820
    const QString toolChainName = ProjectExplorer::ToolChain::toolChainName(static_cast<ProjectExplorer::ToolChain::ToolChainType>(m_startParameters->toolChainType));
con's avatar
con committed
821
822

    emit debugModeRequested();
823
824
    showDebuggerOutput(LogStatus,
        tr("Starting debugger for tool chain '%1'...").arg(toolChainName));
825
    showDebuggerOutput(LogDebug, DebuggerSettings::instance()->dump());
con's avatar
con committed
826

Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
827
    QString errorMessage;
828
829
830
    QString settingsIdHint;
    switch (startMode()) {
    case AttachExternal:
831
    case AttachCrashedExternal:
hjk's avatar
hjk committed
832
833
        m_engine = determineDebuggerEngine(m_startParameters->attachPID,
            m_startParameters->toolChainType, &errorMessage);
834
835
        break;
    case AttachTcf:
836
        m_engine = tcfEngine;
837
838
        break;
    default:
hjk's avatar
hjk committed
839
840
        m_engine = determineDebuggerEngine(m_startParameters->executable, 
            m_startParameters->toolChainType, &errorMessage, &settingsIdHint);
841
842
        break;
    }
843

844
    if (!m_engine) {
845
        debuggingFinished();
846
847
        // Create Message box with possibility to go to settings
        QAbstractButton *settingsButton = 0;
848
849
850
851
        QMessageBox msgBox(QMessageBox::Warning, tr("Warning"),
            tr("Cannot debug '%1' (tool chain: '%2'): %3").
            arg(m_startParameters->executable, toolChainName, errorMessage),
            QMessageBox::Ok);
852
853
854
855
        if (!settingsIdHint.isEmpty())
            settingsButton = msgBox.addButton(tr("Settings..."), QMessageBox::AcceptRole);
        msgBox.exec();
        if (msgBox.clickedButton() == settingsButton)
hjk's avatar
hjk committed
856
857
            Core::ICore::instance()->showOptionsDialog(
                _(Debugger::Constants::DEBUGGER_SETTINGS_CATEGORY), settingsIdHint);
858
        return;
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
859
    }
860

Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
861
    if (Debugger::Constants::Internal::debug)
862
        qDebug() << m_startParameters->executable << m_engine;
con's avatar
con committed
863

864
    setBusyCursor(false);
hjk's avatar
hjk committed
865
    setStatus(DebuggerProcessStartingUp);
hjk's avatar
hjk committed
866
867
868
869
870
871
872
873
874
    connect(m_engine, SIGNAL(startFailed()), this, SLOT(startFailed()));
    m_engine->startDebugger(m_startParameters);
}

void DebuggerManager::startFailed()
{
    disconnect(m_engine, SIGNAL(startFailed()), this, SLOT(startFailed()));
    setStatus(DebuggerProcessNotReady);
    debuggingFinished();
con's avatar
con committed
875
876
877
878
879
880
881
882
883
884
}

void DebuggerManager::cleanupViews()
{
    resetLocation();
    breakHandler()->setAllPending();
    stackHandler()->removeAll();
    threadsHandler()->removeAll();
    modulesHandler()->removeAll();
    watchHandler()->cleanup();
885
    registerHandler()->removeAll();
886
    m_sourceFilesWindow->removeAll();
con's avatar
con committed
887
888
889
890
}

void DebuggerManager::exitDebugger()
{
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
891
892
893
    if (Debugger::Constants::Internal::debug)
        qDebug() << Q_FUNC_INFO;

hjk's avatar
hjk committed
894
895
    if (m_engine)
        m_engine->exitDebugger();
con's avatar
con committed
896
897
898
899
900
901
    cleanupViews();
    setStatus(DebuggerProcessNotReady);
    setBusyCursor(false);
    emit debuggingFinished();
}

902
903
904
905
906
907
908
909
910
911
QSharedPointer<DebuggerStartParameters> DebuggerManager::startParameters() const
{
    return m_startParameters;
}

qint64 DebuggerManager::inferiorPid() const
{
    return m_inferiorPid;
}

912
913
914
void DebuggerManager::assignValueInDebugger()
{
    if (QAction *action = qobject_cast<QAction *>(sender())) {
915
916
917
918
        QString str = action->data().toString();
        int i = str.indexOf('=');
        if (i != -1)
            assignValueInDebugger(str.left(i), str.mid(i + 1));
919
920
    }
}
921

con's avatar
con committed
922
923
void DebuggerManager::assignValueInDebugger(const QString &expr, const QString &value)
{
924
925
    QTC_ASSERT(m_engine, return);
    m_engine->assignValueInDebugger(expr, value);
con's avatar
con committed
926
927
928
929
}

void DebuggerManager::activateFrame(int index)
{
930
931
    QTC_ASSERT(m_engine, return);
    m_engine->activateFrame(index);
con's avatar
con committed
932
933
934
935
}

void DebuggerManager::selectThread(int index)
{
936
937
    QTC_ASSERT(m_engine, return);
    m_engine->selectThread(index);
con's avatar
con committed
938
939
940
941
}

void DebuggerManager::loadAllSymbols()
{
942
943
    QTC_ASSERT(m_engine, return);
    m_engine->loadAllSymbols();
con's avatar
con committed
944
945
946
947
}

void DebuggerManager::loadSymbols(const QString &module)
{
948
949
    QTC_ASSERT(m_engine, return);
    m_engine->loadSymbols(module);
con's avatar
con committed
950
951
}

952
953
954
955
956
957
QList<Symbol> DebuggerManager::moduleSymbols(const QString &moduleName)
{
    QTC_ASSERT(m_engine, return QList<Symbol>());
    return m_engine->moduleSymbols(moduleName);
}

con's avatar
con committed
958
959
void DebuggerManager::stepExec()
{
960
    QTC_ASSERT(m_engine, return);
con's avatar
con committed
961
    resetLocation();
962
963
964
965
    if (theDebuggerBoolSetting(StepByInstruction))
        m_engine->stepIExec();
    else
        m_engine->stepExec();
966
}
con's avatar
con committed
967
968
969

void DebuggerManager::stepOutExec()
{
970
    QTC_ASSERT(m_engine, return);
con's avatar
con committed
971
    resetLocation();
972
    m_engine->stepOutExec();
con's avatar
con committed
973
974
975
976
}

void DebuggerManager::nextExec()
{
977
    QTC_ASSERT(m_engine, return);
con's avatar
con committed
978
    resetLocation();
979
980
981
982
    if (theDebuggerBoolSetting(StepByInstruction))
        m_engine->nextIExec();
    else
        m_engine->nextExec();
con's avatar
con committed
983
984
}

985
986
987
988
989
990
991
void DebuggerManager::watchPoint()
{
    if (QAction *action = qobject_cast<QAction *>(sender()))
        if (m_engine)
            m_engine->watchPoint(action->data().toPoint());
}

992
993
994
995
996
997
void DebuggerManager::executeDebuggerCommand()
{
    if (QAction *action = qobject_cast<QAction *>(sender()))
        executeDebuggerCommand(action->data().toString());
}

con's avatar
con committed
998
999
void DebuggerManager::executeDebuggerCommand(const QString &command)
{
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
1000
1001
1002
    if (Debugger::Constants::Internal::debug)
        qDebug() << Q_FUNC_INFO <<command;

1003
1004
    QTC_ASSERT(m_engine, return);
    m_engine->executeDebuggerCommand(command);
con's avatar
con committed
1005
1006
1007
1008
}

void DebuggerManager::sessionLoaded()
{
1009
1010
1011
    cleanupViews();
    setStatus(DebuggerProcessNotReady);
    setBusyCursor(false);
con's avatar
con committed
1012
1013
1014
    loadSessionData();
}

1015
void DebuggerManager::aboutToUnloadSession()
1016
{
1017
    cleanupViews();
1018
1019
1020
1021
1022
1023
    if (m_engine)
        m_engine->shutdown();
    setStatus(DebuggerProcessNotReady);
    setBusyCursor(false);
}

con's avatar
con committed
1024
1025
1026
1027
1028
1029
1030
1031
void DebuggerManager::aboutToSaveSession()
{
    saveSessionData();
}

void DebuggerManager::loadSessionData()
{
    m_breakHandler->loadSessionData();
hjk's avatar
hjk committed
1032
    m_watchHandler->loadSessionData();
con's avatar
con committed
1033
1034
1035
1036
1037
}

void DebuggerManager::saveSessionData()
{
    m_breakHandler->saveSessionData();
hjk's avatar
hjk committed
1038
    m_watchHandler->saveSessionData();
con's avatar
con committed
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
}

void DebuggerManager::dumpLog()
{
    QString fileName = QFileDialog::getSaveFileName(mainWindow(),
        tr("Save Debugger Log"), QDir::tempPath());
    if (fileName.isEmpty())
        return;
    QFile file(fileName);
    if (!file.open(QIODevice::WriteOnly))
        return;
1050
    QTextStream ts(&file);
con's avatar
con committed
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
    ts << m_outputWindow->inputContents();
    ts << "\n\n=======================================\n\n";
    ts << m_outputWindow->combinedContents();
}

void DebuggerManager::addToWatchWindow()
{
    // requires a selection, but that's the only case we want...
    QObject *ob = 0;
    queryCurrentTextEditor(0, 0, &ob);
    QPlainTextEdit *editor = qobject_cast<QPlainTextEdit*>(ob);
    if (!editor)
        return;
    QTextCursor tc = editor->textCursor();
hjk's avatar
hjk committed
1065
    theDebuggerAction(WatchExpression)->setValue(tc.selectedText());
con's avatar
con committed
1066
1067
1068
1069
}

void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber)
{
Friedemann Kleint's avatar
m.txt  
Friedemann Kleint committed
1070
1071
1072
    if (Debugger::Constants::Internal::debug)
        qDebug() << Q_FUNC_INFO << fileName << lineNumber;

1073
1074
    QTC_ASSERT(m_breakHandler, return);
    m_breakHandler->setBreakpoint(fileName, lineNumber);
hjk's avatar
hjk committed
1075
    attemptBreakpointSynchronization();
con's avatar
con committed
1076
1077
}

1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
void DebuggerManager::breakByFunctionMain()
{
#ifdef Q_OS_WIN
    // FIXME: wrong on non-Qt based binaries
    emit breakByFunction("qMain");
#else
    emit breakByFunction("main");
#endif
}

con's avatar
con committed
1088
1089
void DebuggerManager::breakByFunction(const QString &functionName)
{
1090
1091
    QTC_ASSERT(m_breakHandler, return);
    m_breakHandler->breakByFunction(functionName);
hjk's avatar
hjk committed
1092
    attemptBreakpointSynchronization();
con's avatar
con committed
1093
1094
}

1095
1096
1097
1098
static bool isAllowedTransition(int from, int to)
{
    return (from == -1)
      || (from == DebuggerProcessNotReady && to == DebuggerProcessStartingUp)
1099
      //|| (from == DebuggerProcessStartingUp && to == DebuggerInferiorStopped)
1100
1101
1102
      || (from == DebuggerInferiorStopped && to == DebuggerInferiorRunningRequested)
      || (from == DebuggerInferiorRunningRequested && to == DebuggerInferiorRunning)
      || (from == DebuggerInferiorRunning && to == DebuggerInferiorStopRequested)
1103
      || (from == DebuggerInferiorRunning && to == DebuggerInferiorStopped)
1104
      || (from == DebuggerInferiorStopRequested && to == DebuggerInferiorStopped