StackTreeView::StackTreeView(QWidget *parent)
    : BaseTreeView(parent)
{
    setWindowTitle(tr("Stack"));
    setAlwaysAdjustColumnsAction(debuggerCore()->action(AlwaysAdjustStackColumnWidths));

    connect(debuggerCore()->action(UseAddressInStackView), SIGNAL(toggled(bool)),
        SLOT(showAddressColumn(bool)));
    connect(debuggerCore()->action(ExpandStack), SIGNAL(triggered()),
        SLOT(reloadFullStack()));
    connect(debuggerCore()->action(MaximalStackDepth), SIGNAL(triggered()),
        SLOT(reloadFullStack()));
    showAddressColumn(false);
}
void ThreadsHandler::updateThreadBox()
{
    QStringList list;
    foreach (const ThreadData &thread, m_threads)
        list.append(QString::fromLatin1("#%1 %2").arg(thread.id.raw()).arg(thread.name));
    debuggerCore()->setThreads(list, indexOf(m_currentId));
}
void CdbOptionsPage::apply()
{
    if (!m_widget)
        return;
    m_widget->group.apply(Core::ICore::settings());
    debuggerCore()->action(CdbBreakEvents)->setValue(m_widget->breakEvents());
}
CdbPathsPageWidget::CdbPathsPageWidget(QWidget *parent) :
    QWidget(parent)
{
    QVBoxLayout *layout = new QVBoxLayout(this);

    QString title = tr("Symbol Paths");
    QGroupBox* gbSymbolPath = new QGroupBox(this);
    gbSymbolPath->setTitle(title);
    QVBoxLayout *gbSymbolPathLayout = new QVBoxLayout(gbSymbolPath);
    m_symbolPathListEditor = new CdbSymbolPathListEditor(gbSymbolPath);
    gbSymbolPathLayout->addWidget(m_symbolPathListEditor);

    title = tr("Source Paths");
    QGroupBox* gbSourcePath = new QGroupBox(this);
    gbSourcePath->setTitle(title);
    QVBoxLayout *gbSourcePathLayout = new QVBoxLayout(gbSourcePath);
    m_sourcePathListEditor = new Utils::PathListEditor(gbSourcePath);
    gbSourcePathLayout->addWidget(m_sourcePathListEditor);

    layout->addWidget(gbSymbolPath);
    layout->addWidget(gbSourcePath);

    DebuggerCore *dc = debuggerCore();
    group.insert(dc->action(CdbSymbolPaths), m_symbolPathListEditor);
    group.insert(dc->action(CdbSourcePaths), m_sourcePathListEditor);
}
void SnapshotHandler::activateSnapshot(int index)
{
    m_currentIndex = index;
    //qDebug() << "ACTIVATING INDEX: " << m_currentIndex << " OF " << size();
    debuggerCore()->displayDebugger(at(index), true);
    reset();
}
CdbOptionsPageWidget::CdbOptionsPageWidget(QWidget *parent)
    : QWidget(parent)
    , m_breakEventWidget(new CdbBreakEventWidget)
{
    m_ui.setupUi(this);
    // Squeeze the groupbox layouts vertically to
    // accommodate all options. This page only shows on
    // Windows, which has large margins by default.

    const int margin = layout()->margin();
    const QMargins margins(margin, margin / 3, margin, margin / 3);

    m_ui.startupFormLayout->setContentsMargins(margins);

    QVBoxLayout *eventLayout = new QVBoxLayout;
    eventLayout->setContentsMargins(margins);
    eventLayout->addWidget(m_breakEventWidget);
    m_ui.eventGroupBox->setLayout(eventLayout);
    m_ui.breakCrtDbgReportCheckBox
        ->setText(CommonOptionsPage::msgSetBreakpointAtFunction(CdbOptionsPage::crtDbgReport));
    const QString hint = tr("This is useful to catch runtime error messages, for example caused by assert().");
    m_ui.breakCrtDbgReportCheckBox
        ->setToolTip(CommonOptionsPage::msgSetBreakpointAtFunctionToolTip(CdbOptionsPage::crtDbgReport, hint));

    DebuggerCore *dc = debuggerCore();
    group.insert(dc->action(CdbAdditionalArguments), m_ui.additionalArgumentsLineEdit);
    group.insert(dc->action(CdbBreakOnCrtDbgReport), m_ui.breakCrtDbgReportCheckBox);
    group.insert(dc->action(UseCdbConsole), m_ui.consoleCheckBox);
    group.insert(dc->action(CdbBreakPointCorrection), m_ui.breakpointCorrectionCheckBox);
    group.insert(dc->action(IgnoreFirstChanceAccessViolation),
                 m_ui.ignoreFirstChanceAccessViolationCheckBox);

    m_breakEventWidget->setBreakEvents(dc->stringListSetting(CdbBreakEvents));
}
void StackTreeView::setModel(QAbstractItemModel *model)
{
    BaseTreeView::setModel(model);
    resizeColumnToContents(0);
    resizeColumnToContents(3);
    showAddressColumn(debuggerCore()->action(UseAddressInStackView)->isChecked());
}
void RemoteGdbServerAdapter::setupInferior()
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    const DebuggerStartParameters &sp = startParameters();

    QString fileName;
    if (!sp.executable.isEmpty()) {
        QFileInfo fi(sp.executable);
        fileName = fi.absoluteFilePath();
    }
    const QByteArray sysroot = sp.sysroot.toLocal8Bit();
    const QByteArray remoteArch = sp.remoteArchitecture.toLatin1();
    const QByteArray gnuTarget = sp.gnuTarget.toLatin1();
    const QByteArray searchPath = startParameters().searchPath.toLocal8Bit();
    const QString args = sp.processArgs;

    if (!remoteArch.isEmpty())
        m_engine->postCommand("set architecture " + remoteArch);
    if (!gnuTarget.isEmpty())
        m_engine->postCommand("set gnutarget " + gnuTarget);
    if (!sysroot.isEmpty())
        m_engine->postCommand("set sysroot " + sysroot);
    if (!searchPath.isEmpty())
        m_engine->postCommand("set solib-search-path " + searchPath);
    if (!args.isEmpty())
        m_engine->postCommand("-exec-arguments " + args.toLocal8Bit());

    // This has to be issued before 'target remote'. On pre-7.0 the
    // command is not present and will result in ' No symbol table is
    // loaded.  Use the "file" command.' as gdb tries to set the
    // value of a variable with name 'target-async'.
    //
    // Testing with -list-target-features which was introduced at
    // the same time would not work either, as this need an existing
    // target.
    //
    // Using it even without a target and having it fail might still
    // be better as:
    // Some external comment: '[but] "set target-async on" with a native
    // windows gdb will work, but then fail when you actually do
    // "run"/"attach", I think..


    // gdb/mi/mi-main.c:1958: internal-error:
    // mi_execute_async_cli_command: Assertion `is_running (inferior_ptid)'
    // failed.\nA problem internal to GDB has been detected,[...]
    if (debuggerCore()->boolSetting(TargetAsync))
        m_engine->postCommand("set target-async on", CB(handleSetTargetAsync));

    if (fileName.isEmpty()) {
        showMessage(tr("No symbol file given."), StatusBar);
        callTargetRemote();
        return;
    }

    m_engine->postCommand("-file-exec-and-symbols \""
        + fileName.toLocal8Bit() + '"',
        CB(handleFileExecAndSymbols));
}
Beispiel #9
0
void ThreadsWindow::contextMenuEvent(QContextMenuEvent *ev)
{
    QMenu menu;
    QAction *adjustColumnAction =
        menu.addAction(tr("Adjust Column Widths to Contents"));
    menu.addAction(debuggerCore()->action(AlwaysAdjustThreadsColumnWidths));
    menu.addSeparator();

    menu.addAction(debuggerCore()->action(SettingsDialog));

    QAction *act = menu.exec(ev->globalPos());
    if (!act)
        return;

    if (act == adjustColumnAction)
        resizeColumnsToContents();
}
ThreadsWindow::ThreadsWindow(QWidget *parent)
    : BaseWindow(parent)
{
    setWindowTitle(tr("Thread"));
    setSortingEnabled(true);
    setAlwaysAdjustColumnsAction(debuggerCore()->action(AlwaysAdjustThreadsColumnWidths));
    setObjectName(QLatin1String("ThreadsWindow"));
}
Beispiel #11
0
void BaseWindow::addBaseContextActions(QMenu *menu)
{
    menu->addSeparator();
    if (m_alwaysAdjustColumnsAction)
        menu->addAction(m_alwaysAdjustColumnsAction);
    menu->addAction(m_adjustColumnsAction);
    menu->addSeparator();
    menu->addAction(debuggerCore()->action(SettingsDialog));
}
Beispiel #12
0
void ThreadsWindow::setModel(QAbstractItemModel *model)
{
    QTreeView::setModel(model);
    resizeColumnToContents(0); // Id
    resizeColumnToContents(4); // Line
    resizeColumnToContents(6); // Name
    if (header()) {
        bool adjust = debuggerCore()->boolSetting(AlwaysAdjustThreadsColumnWidths);
        setAlwaysResizeColumnsToContents(adjust);
    }
}
void GdbRemoteServerEngine::handleTargetRemote(const GdbResponse &response)
{
    QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
    if (response.resultClass == GdbResultDone) {
        // gdb server will stop the remote application itself.
        showMessage(_("INFERIOR STARTED"));
        showMessage(msgAttachedToStoppedInferior(), StatusBar);
        QString postAttachCommands = debuggerCore()->stringSetting(GdbPostAttachCommands);
        if (!postAttachCommands.isEmpty()) {
            foreach (const QString &cmd, postAttachCommands.split(QLatin1Char('\n')))
                postCommand(cmd.toLatin1());
        }
Beispiel #14
0
void PdbEngine::handleListSymbols(const PdbResponse &response)
{
    GdbMi out;
    out.fromString(response.data.trimmed());
    Symbols symbols;
    QString moduleName = response.cookie.toString();
    foreach (const GdbMi &item, out.children()) {
        Symbol symbol;
        symbol.name = _(item.findChild("name").data());
        symbols.append(symbol);
    }
   debuggerCore()->showModuleSymbols(moduleName, symbols);
}
void RemoteGdbServerAdapter::interruptInferior()
{
    QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state());
    if (debuggerCore()->boolSetting(TargetAsync)) {
        m_engine->postCommand("-exec-interrupt", GdbEngine::Immediate,
            CB(handleInterruptInferior));
    } else {
        bool ok = m_gdbProc.interrupt();
        if (!ok) {
            // FIXME: Extra state needed?
            m_engine->showMessage(_("NOTE: INFERIOR STOP NOT POSSIBLE"));
            m_engine->showStatusMessage(tr("Interrupting not possible"));
            m_engine->notifyInferiorRunOk();
        }
    }
}
void BreakHandler::saveBreakpoints()
{
    const QString one = _("1");
    //qDebug() << "SAVING BREAKPOINTS...";
    QTC_ASSERT(debuggerCore(), return);
    QList<QVariant> list;
    ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
    for ( ; it != et; ++it) {
        const BreakpointParameters &data = it->data;
        QMap<QString, QVariant> map;
        // Do not persist Watchpoints.
        if (data.isWatchpoint())
            continue;
        if (data.type != BreakpointByFileAndLine)
            map.insert(_("type"), data.type);
        if (!data.fileName.isEmpty())
            map.insert(_("filename"), data.fileName);
        if (data.lineNumber)
            map.insert(_("linenumber"), data.lineNumber);
        if (!data.functionName.isEmpty())
            map.insert(_("funcname"), data.functionName);
        if (data.address)
            map.insert(_("address"), data.address);
        if (!data.condition.isEmpty())
            map.insert(_("condition"), data.condition);
        if (data.ignoreCount)
            map.insert(_("ignorecount"), data.ignoreCount);
        if (data.threadSpec >= 0)
            map.insert(_("threadspec"), data.threadSpec);
        if (!data.enabled)
            map.insert(_("disabled"), one);
        if (data.pathUsage != BreakpointPathUsageEngineDefault)
            map.insert(_("usefullpath"), QString::number(data.pathUsage));
        if (data.tracepoint)
            map.insert(_("tracepoint"), one);
        if (!data.module.isEmpty())
            map.insert(_("module"), data.module);
        if (!data.command.isEmpty())
            map.insert(_("command"), data.command);
        list.append(map);
    }
    debuggerCore()->setSessionValue("Breakpoints", list);
    //qDebug() << "SAVED BREAKPOINTS" << this << list.size();
}
void AbstractPlainGdbAdapter::handleExecRun(const GdbResponse &response)
{
    QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
    if (response.resultClass == GdbResultRunning) {
        m_engine->notifyEngineRunAndInferiorRunOk();
        //showStatusMessage(tr("Running..."));
        showMessage(_("INFERIOR STARTED"));
        showMessage(msgInferiorSetupOk(), StatusBar);
        // FIXME: That's the wrong place for it.
        if (debuggerCore()->boolSetting(EnableReverseDebugging))
            m_engine->postCommand("target record");
    } else {
        QString msg = fromLocalEncoding(response.data.findChild("msg").data());
        //QTC_CHECK(status() == InferiorRunOk);
        //interruptInferior();
        showMessage(msg);
        m_engine->notifyEngineRunFailed();
    }
}
Beispiel #18
0
ThreadsWindow::ThreadsWindow(QWidget *parent)
    : QTreeView(parent)
{
    QAction *act = debuggerCore()->action(UseAlternatingRowColors);

    setAttribute(Qt::WA_MacShowFocusRect, false);
    setFrameStyle(QFrame::NoFrame);
    setWindowTitle(tr("Thread"));
    setAlternatingRowColors(act->isChecked());
    setRootIsDecorated(false);
    setIconSize(QSize(10, 10));

    header()->setDefaultAlignment(Qt::AlignLeft);

    connect(this, SIGNAL(activated(QModelIndex)),
        SLOT(rowActivated(QModelIndex)));
    connect(act, SIGNAL(toggled(bool)),
        SLOT(setAlternatingRowColorsHelper(bool)));
    connect(debuggerCore()->action(AlwaysAdjustThreadsColumnWidths),
        SIGNAL(toggled(bool)),
        SLOT(setAlwaysResizeColumnsToContents(bool)));
}
Beispiel #19
0
BaseWindow::BaseWindow(QWidget *parent)
    : QTreeView(parent)
{
    QAction *act = debuggerCore()->action(UseAlternatingRowColors);

    setAttribute(Qt::WA_MacShowFocusRect, false);
    setFrameStyle(QFrame::NoFrame);
    setAlternatingRowColors(act->isChecked());
    setRootIsDecorated(false);
    setIconSize(QSize(10, 10));
    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setUniformRowHeights(true);

    header()->setDefaultAlignment(Qt::AlignLeft);

    connect(act, SIGNAL(toggled(bool)),
        SLOT(setAlternatingRowColorsHelper(bool)));
    connect(this, SIGNAL(activated(QModelIndex)),
        SLOT(rowActivatedHelper(QModelIndex)));

    m_adjustColumnsAction = new QAction(tr("Adjust Column Widths to Contents"), 0);
    m_alwaysAdjustColumnsAction = 0;
}
void ThreadsWindow::contextMenuEvent(QContextMenuEvent *ev)
{
    QMenu menu;
    QAction *adjustColumnAction =
        menu.addAction(tr("Adjust Column Widths to Contents"));
    QAction *alwaysAdjustColumnAction =
        menu.addAction(tr("Always Adjust Column Widths to Contents"));
    alwaysAdjustColumnAction->setCheckable(true);
    alwaysAdjustColumnAction->setChecked(m_alwaysResizeColumnsToContents);
    menu.addSeparator();

    menu.addAction(debuggerCore()->action(SettingsDialog));

    QAction *act = menu.exec(ev->globalPos());
    if (!act)
        return;

    if (act == adjustColumnAction) {
        resizeColumnsToContents();
    } else if (act == alwaysAdjustColumnAction) {
        setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
    }
}
static DebuggerEngine *currentEngine()
{
    return debuggerCore()->currentEngine();
}
            map.insert(_("tracepoint"), one);
        if (!data.module.isEmpty())
            map.insert(_("module"), data.module);
        if (!data.command.isEmpty())
            map.insert(_("command"), data.command);
        list.append(map);
    }
    debuggerCore()->setSessionValue("Breakpoints", list);
    //qDebug() << "SAVED BREAKPOINTS" << this << list.size();
}

void BreakHandler::loadBreakpoints()
{
    QTC_ASSERT(debuggerCore(), return);
    //qDebug() << "LOADING BREAKPOINTS...";
    QVariant value = debuggerCore()->sessionValue("Breakpoints");
    QList<QVariant> list = value.toList();
    //clear();
    foreach (const QVariant &var, list) {
        const QMap<QString, QVariant> map = var.toMap();
        BreakpointParameters data(BreakpointByFileAndLine);
        QVariant v = map.value(_("filename"));
        if (v.isValid())
            data.fileName = v.toString();
        v = map.value(_("linenumber"));
        if (v.isValid())
            data.lineNumber = v.toString().toInt();
        v = map.value(_("condition"));
        if (v.isValid())
            data.condition = v.toString().toLatin1();
        v = map.value(_("address"));
Beispiel #23
0
void ThreadsTreeView::rowActivated(const QModelIndex &index)
{
    ThreadId id = ThreadId(index.data(ThreadData::IdRole).toLongLong());
    debuggerCore()->currentEngine()->selectThread(id);
}
Beispiel #24
0
ThreadsTreeView::ThreadsTreeView()
{
    setSortingEnabled(true);
    setAlwaysAdjustColumnsAction(debuggerCore()->action(AlwaysAdjustThreadsColumnWidths));
}
GdbOptionsPageWidget::GdbOptionsPageWidget(QWidget *parent)
    : QWidget(parent)
{
    (void) new VariableChooser(this);

    groupBoxGeneral = new QGroupBox(this);
    groupBoxGeneral->setTitle(GdbOptionsPage::tr("General"));

    QLabel *labelGdbWatchdogTimeout = new QLabel(groupBoxGeneral);
    labelGdbWatchdogTimeout->setText(GdbOptionsPage::tr("GDB timeout:"));
    labelGdbWatchdogTimeout->setToolTip(GdbOptionsPage::tr(
        "The number of seconds Qt Creator will wait before it terminates\n"
        "a non-responsive GDB process. The default value of 20 seconds should\n"
        "be sufficient for most applications, but there are situations when\n"
        "loading big libraries or listing source files takes much longer than\n"
        "that on slow machines. In this case, the value should be increased."));

    spinBoxGdbWatchdogTimeout = new QSpinBox(groupBoxGeneral);
    spinBoxGdbWatchdogTimeout->setToolTip(labelGdbWatchdogTimeout->toolTip());
    spinBoxGdbWatchdogTimeout->setSuffix(GdbOptionsPage::tr("sec"));
    spinBoxGdbWatchdogTimeout->setLayoutDirection(Qt::LeftToRight);
    spinBoxGdbWatchdogTimeout->setMinimum(20);
    spinBoxGdbWatchdogTimeout->setMaximum(1000000);
    spinBoxGdbWatchdogTimeout->setSingleStep(20);
    spinBoxGdbWatchdogTimeout->setValue(20);

    checkBoxSkipKnownFrames = new QCheckBox(groupBoxGeneral);
    checkBoxSkipKnownFrames->setText(GdbOptionsPage::tr("Skip known frames when stepping"));
    checkBoxSkipKnownFrames->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body><p>"
        "Allows <i>Step Into</i> to compress several steps into one step\n"
        "for less noisy debugging. For example, the atomic reference\n"
        "counting code is skipped, and a single <i>Step Into</i> for a signal\n"
        "emission ends up directly in the slot connected to it."));

    checkBoxUseMessageBoxForSignals = new QCheckBox(groupBoxGeneral);
    checkBoxUseMessageBoxForSignals->setText(GdbOptionsPage::tr(
        "Show a message box when receiving a signal"));
    checkBoxUseMessageBoxForSignals->setToolTip(GdbOptionsPage::tr(
        "Displays a message box as soon as your application\n"
        "receives a signal like SIGSEGV during debugging."));

    checkBoxAdjustBreakpointLocations = new QCheckBox(groupBoxGeneral);
    checkBoxAdjustBreakpointLocations->setText(GdbOptionsPage::tr(
        "Adjust breakpoint locations"));
    checkBoxAdjustBreakpointLocations->setToolTip(GdbOptionsPage::tr(
        "GDB allows setting breakpoints on source lines for which no code \n"
        "was generated. In such situations the breakpoint is shifted to the\n"
        "next source code line for which code was actually generated.\n"
        "This option reflects such temporary change by moving the breakpoint\n"
        "markers in the source code editor."));

    checkBoxUseDynamicType = new QCheckBox(groupBoxGeneral);
    checkBoxUseDynamicType->setText(GdbOptionsPage::tr(
        "Use dynamic object type for display"));
    checkBoxUseDynamicType->setToolTip(GdbOptionsPage::tr(
        "Specifies whether the dynamic or the static type of objects will be "
        "displayed. Choosing the dynamic type might be slower."));

    checkBoxLoadGdbInit = new QCheckBox(groupBoxGeneral);
    checkBoxLoadGdbInit->setText(GdbOptionsPage::tr("Load .gdbinit file on startup"));
    checkBoxLoadGdbInit->setToolTip(GdbOptionsPage::tr(
        "Allows or inhibits reading the user's default\n"
        ".gdbinit file on debugger startup."));

    checkBoxLoadGdbDumpers = new QCheckBox(groupBoxGeneral);
    checkBoxLoadGdbDumpers->setText(GdbOptionsPage::tr("Load system GDB pretty printers"));
    checkBoxLoadGdbDumpers->setToolTip(GdbOptionsPage::tr(
        "Uses the default GDB pretty printers installed in your "
        "system or linked to the libraries your application uses."));

    checkBoxIntelFlavor = new QCheckBox(groupBoxGeneral);
    checkBoxIntelFlavor->setText(GdbOptionsPage::tr("Use Intel style disassembly"));
    checkBoxIntelFlavor->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body>GDB shows by default AT&&T style disassembly."
        "</body></html>"));

    checkBoxIdentifyDebugInfoPackages = new QCheckBox(groupBoxGeneral);
    checkBoxIdentifyDebugInfoPackages->setText(GdbOptionsPage::tr("Create tasks from missing packages"));
    checkBoxIdentifyDebugInfoPackages->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body><p>Attempts to identify missing debug info packages "
        "and lists them in the Issues output pane.</p><p>"
        "<b>Note:</b> This feature needs special support from the Linux "
        "distribution and GDB build and is not available everywhere.</p></body></html>"));

    QString howToUsePython = GdbOptionsPage::tr(
        "<p>To execute simple Python commands, prefix them with \"python\".</p>"
        "<p>To execute sequences of Python commands spanning multiple lines "
        "prepend the block with \"python\" on a separate line, and append "
        "\"end\" on a separate line.</p>"
        "<p>To execute arbitrary Python scripts, "
        "use <i>python execfile('/path/to/script.py')</i>.</p>");

    groupBoxStartupCommands = new QGroupBox(this);
    groupBoxStartupCommands->setTitle(GdbOptionsPage::tr("Additional Startup Commands"));
    groupBoxStartupCommands->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body><p>GDB commands entered here will be executed after "
        "GDB has been started, but before the debugged program is started or "
        "attached, and before the debugging helpers are initialized.</p>%1"
        "</body></html>").arg(howToUsePython));

    textEditStartupCommands = new QTextEdit(groupBoxStartupCommands);
    textEditStartupCommands->setAcceptRichText(false);
    textEditStartupCommands->setToolTip(groupBoxStartupCommands->toolTip());

    groupBoxPostAttachCommands = new QGroupBox(this);
    groupBoxPostAttachCommands->setTitle(GdbOptionsPage::tr("Additional Attach Commands"));
    groupBoxPostAttachCommands->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body><p>GDB commands entered here will be executed after "
        "GDB has successfully attached to remote targets.</p>"
        "<p>You can add commands to further set up the target here, "
        "such as \"monitor reset\" or \"load\"."
        "</body></html>"));

    textEditPostAttachCommands = new QTextEdit(groupBoxPostAttachCommands);
    textEditPostAttachCommands->setAcceptRichText(false);
    textEditPostAttachCommands->setToolTip(groupBoxPostAttachCommands->toolTip());

    groupBoxCustomDumperCommands = new QGroupBox(this);
    groupBoxCustomDumperCommands->setTitle(GdbOptionsPage::tr("Debugging Helper Customization"));
    groupBoxCustomDumperCommands->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body><p>GDB commands entered here will be executed after "
        "Qt Creator's debugging helpers have been loaded and fully initialized. "
        "You can load additional debugging helpers or modify existing ones here.</p>"
        "%1</body></html>").arg(howToUsePython));

    textEditCustomDumperCommands = new QTextEdit(groupBoxCustomDumperCommands);
    textEditCustomDumperCommands->setAcceptRichText(false);
    textEditCustomDumperCommands->setToolTip(groupBoxCustomDumperCommands->toolTip());

    extraDumperFile = new QLineEdit(groupBoxCustomDumperCommands);
    extraDumperFile->setToolTip(GdbOptionsPage::tr(
        "Path to a Python file containing additional data dumpers."));

    /*
    groupBoxPluginDebugging = new QGroupBox(q);
    groupBoxPluginDebugging->setTitle(GdbOptionsPage::tr(
        "Behavior of Breakpoint Setting in Plugins"));

    radioButtonAllPluginBreakpoints = new QRadioButton(groupBoxPluginDebugging);
    radioButtonAllPluginBreakpoints->setText(GdbOptionsPage::tr(
        "Always try to set breakpoints in plugins automatically"));
    radioButtonAllPluginBreakpoints->setToolTip(GdbOptionsPage::tr(
        "This is the slowest but safest option."));

    radioButtonSelectedPluginBreakpoints = new QRadioButton(groupBoxPluginDebugging);
    radioButtonSelectedPluginBreakpoints->setText(GdbOptionsPage::tr(
        "Try to set breakpoints in selected plugins"));

    radioButtonNoPluginBreakpoints = new QRadioButton(groupBoxPluginDebugging);
    radioButtonNoPluginBreakpoints->setText(GdbOptionsPage::tr(
        "Never set breakpoints in plugins automatically"));

    lineEditSelectedPluginBreakpointsPattern = new QLineEdit(groupBoxPluginDebugging);

    labelSelectedPluginBreakpoints = new QLabel(groupBoxPluginDebugging);
    labelSelectedPluginBreakpoints->setText(GdbOptionsPage::tr(
        "Matching regular expression: "));
    */

    VariableChooser::addVariableSupport(textEditCustomDumperCommands);
    VariableChooser::addVariableSupport(textEditPostAttachCommands);
    VariableChooser::addVariableSupport(textEditStartupCommands);
    VariableChooser::addVariableSupport(extraDumperFile);

    QFormLayout *formLayout = new QFormLayout(groupBoxGeneral);
    formLayout->addRow(labelGdbWatchdogTimeout, spinBoxGdbWatchdogTimeout);
    formLayout->addRow(checkBoxSkipKnownFrames);
    formLayout->addRow(checkBoxUseMessageBoxForSignals);
    formLayout->addRow(checkBoxAdjustBreakpointLocations);
    formLayout->addRow(checkBoxUseDynamicType);
    formLayout->addRow(checkBoxLoadGdbInit);
    formLayout->addRow(checkBoxLoadGdbDumpers);
    formLayout->addRow(checkBoxIntelFlavor);
    formLayout->addRow(checkBoxIdentifyDebugInfoPackages);

    QGridLayout *startLayout = new QGridLayout(groupBoxStartupCommands);
    startLayout->addWidget(textEditStartupCommands, 0, 0, 1, 1);

    QGridLayout *postAttachLayout = new QGridLayout(groupBoxPostAttachCommands);
    postAttachLayout->addWidget(textEditPostAttachCommands, 0, 0, 1, 1);

    QFormLayout *customDumperLayout = new QFormLayout(groupBoxCustomDumperCommands);
    customDumperLayout->addRow(GdbOptionsPage::tr("Additional file:"), extraDumperFile);
    customDumperLayout->addRow(textEditCustomDumperCommands);

    //QHBoxLayout *horizontalLayout = new QHBoxLayout();
    //horizontalLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Preferred, QSizePolicy::Minimum));
    //horizontalLayout->addWidget(labelSelectedPluginBreakpoints);
    //horizontalLayout->addWidget(lineEditSelectedPluginBreakpointsPattern);

    QGridLayout *gridLayout = new QGridLayout(this);
    gridLayout->addWidget(groupBoxGeneral, 0, 0, 2, 1);
    gridLayout->addWidget(groupBoxStartupCommands, 0, 1, 1, 1);
    gridLayout->addWidget(groupBoxPostAttachCommands, 1, 1, 1, 1);
    gridLayout->addWidget(groupBoxCustomDumperCommands, 2, 1, 1, 1);

    //gridLayout->addWidget(groupBoxStartupCommands, 0, 1, 1, 1);
    //gridLayout->addWidget(radioButtonAllPluginBreakpoints, 0, 0, 1, 1);
    //gridLayout->addWidget(radioButtonSelectedPluginBreakpoints, 1, 0, 1, 1);

    //gridLayout->addLayout(horizontalLayout, 2, 0, 1, 1);
    //gridLayout->addWidget(radioButtonNoPluginBreakpoints, 3, 0, 1, 1);
    //gridLayout->addWidget(groupBoxPluginDebugging, 1, 0, 1, 2);

    DebuggerCore *dc = debuggerCore();
    group.insert(dc->action(GdbStartupCommands), textEditStartupCommands);
    group.insert(dc->action(ExtraDumperFile), extraDumperFile);
    group.insert(dc->action(ExtraDumperCommands), textEditCustomDumperCommands);
    group.insert(dc->action(GdbPostAttachCommands), textEditPostAttachCommands);
    group.insert(dc->action(LoadGdbInit), checkBoxLoadGdbInit);
    group.insert(dc->action(LoadGdbDumpers), checkBoxLoadGdbDumpers);
    group.insert(dc->action(UseDynamicType), checkBoxUseDynamicType);
    group.insert(dc->action(AdjustBreakpointLocations), checkBoxAdjustBreakpointLocations);
    group.insert(dc->action(GdbWatchdogTimeout), spinBoxGdbWatchdogTimeout);
    group.insert(dc->action(IntelFlavor), checkBoxIntelFlavor);
    group.insert(dc->action(IdentifyDebugInfoPackages), checkBoxIdentifyDebugInfoPackages);
    group.insert(dc->action(UseMessageBoxForSignals), checkBoxUseMessageBoxForSignals);
    group.insert(dc->action(SkipKnownFrames), checkBoxSkipKnownFrames);

    //lineEditSelectedPluginBreakpointsPattern->
    //    setEnabled(dc->action(SelectedPluginBreakpoints)->value().toBool());
    //connect(radioButtonSelectedPluginBreakpoints, SIGNAL(toggled(bool)),
    //    lineEditSelectedPluginBreakpointsPattern, SLOT(setEnabled(bool)));
}
GdbOptionsPageWidget2::GdbOptionsPageWidget2(QWidget *parent)
    : QWidget(parent)
{
    groupBoxDangerous = new QGroupBox(this);
    groupBoxDangerous->setTitle(GdbOptionsPage::tr("Extended"));

    labelDangerous = new QLabel(GdbOptionsPage::tr(
        "The options below should be used with care."));
    labelDangerous->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body>The options below give access to advanced "
        "or experimental functions of GDB. Enabling them may negatively "
        "impact your debugging experience.</body></html>"));
    QFont f = labelDangerous->font();
    f.setItalic(true);
    labelDangerous->setFont(f);

    checkBoxTargetAsync = new QCheckBox(groupBoxDangerous);
    checkBoxTargetAsync->setText(GdbOptionsPage::tr(
        "Use asynchronous mode to control the inferior"));

    checkBoxAutoEnrichParameters = new QCheckBox(groupBoxDangerous);
    checkBoxAutoEnrichParameters->setText(GdbOptionsPage::tr(
        "Use common locations for debug information"));
    checkBoxAutoEnrichParameters->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body>Adds common paths to locations "
        "of debug information such as <i>/usr/src/debug</i> "
        "when starting GDB.</body></html>"));

    // #fixme: 2.7 Move to common settings page.
    checkBoxBreakOnWarning = new QCheckBox(groupBoxDangerous);
    checkBoxBreakOnWarning->setText(CommonOptionsPage::msgSetBreakpointAtFunction("qWarning"));
    checkBoxBreakOnWarning->setToolTip(CommonOptionsPage::msgSetBreakpointAtFunctionToolTip("qWarning"));

    checkBoxBreakOnFatal = new QCheckBox(groupBoxDangerous);
    checkBoxBreakOnFatal->setText(CommonOptionsPage::msgSetBreakpointAtFunction("qFatal"));
    checkBoxBreakOnFatal->setToolTip(CommonOptionsPage::msgSetBreakpointAtFunctionToolTip("qFatal"));

    checkBoxBreakOnAbort = new QCheckBox(groupBoxDangerous);
    checkBoxBreakOnAbort->setText(CommonOptionsPage::msgSetBreakpointAtFunction("abort"));
    checkBoxBreakOnAbort->setToolTip(CommonOptionsPage::msgSetBreakpointAtFunctionToolTip("abort"));

    checkBoxEnableReverseDebugging = new QCheckBox(groupBoxDangerous);
    checkBoxEnableReverseDebugging->setText(GdbOptionsPage::tr("Enable reverse debugging"));
    checkBoxEnableReverseDebugging->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body><p>Enables stepping backwards.</p><p>"
        "<b>Note:</b> This feature is very slow and unstable on the GDB side. "
        "It exhibits unpredictable behavior when going backwards over system "
        "calls and is very likely to destroy your debugging session.</p></body></html>"));

    checkBoxAttemptQuickStart = new QCheckBox(groupBoxDangerous);
    checkBoxAttemptQuickStart->setText(GdbOptionsPage::tr("Attempt quick start"));
    checkBoxAttemptQuickStart->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body>Postpones reading debug information as long as possible. "
        "This can result in faster startup times at the price of not being able to "
        "set breakpoints by file and number.</body></html>"));

    checkBoxMultiInferior = new QCheckBox(groupBoxDangerous);
    checkBoxMultiInferior->setText(GdbOptionsPage::tr("Debug all children"));
    checkBoxMultiInferior->setToolTip(GdbOptionsPage::tr(
        "<html><head/><body>Keeps debugging all children after a fork."
        "</body></html>"));


    QFormLayout *formLayout = new QFormLayout(groupBoxDangerous);
    formLayout->addRow(labelDangerous);
    formLayout->addRow(checkBoxTargetAsync);
    formLayout->addRow(checkBoxAutoEnrichParameters);
    formLayout->addRow(checkBoxBreakOnWarning);
    formLayout->addRow(checkBoxBreakOnFatal);
    formLayout->addRow(checkBoxBreakOnAbort);
    formLayout->addRow(checkBoxEnableReverseDebugging);
    formLayout->addRow(checkBoxAttemptQuickStart);
    formLayout->addRow(checkBoxMultiInferior);

    QGridLayout *gridLayout = new QGridLayout(this);
    gridLayout->addWidget(groupBoxDangerous, 0, 0, 2, 1);

    DebuggerCore *dc = debuggerCore();
    group.insert(dc->action(AutoEnrichParameters), checkBoxAutoEnrichParameters);
    group.insert(dc->action(TargetAsync), checkBoxTargetAsync);
    group.insert(dc->action(BreakOnWarning), checkBoxBreakOnWarning);
    group.insert(dc->action(BreakOnFatal), checkBoxBreakOnFatal);
    group.insert(dc->action(BreakOnAbort), checkBoxBreakOnAbort);
    group.insert(dc->action(AttemptQuickStart), checkBoxAttemptQuickStart);
    group.insert(dc->action(MultiInferior), checkBoxMultiInferior);
    group.insert(dc->action(EnableReverseDebugging), checkBoxEnableReverseDebugging);
}
QWidget *GdbOptionsPage::createPage(QWidget *parent)
{
    QWidget *w = new QWidget(parent);
    m_ui = new GdbOptionsPageUi;
    m_ui->setupUi(w);

    m_group.clear();
    m_group.insert(debuggerCore()->action(GdbStartupCommands),
        m_ui->textEditStartupCommands);
    m_group.insert(debuggerCore()->action(LoadGdbInit),
        m_ui->checkBoxLoadGdbInit);
    m_group.insert(debuggerCore()->action(AutoEnrichParameters),
        m_ui->checkBoxAutoEnrichParameters);
    m_group.insert(debuggerCore()->action(UseDynamicType),
        m_ui->checkBoxUseDynamicType);
    m_group.insert(debuggerCore()->action(TargetAsync),
        m_ui->checkBoxTargetAsync);
    m_group.insert(debuggerCore()->action(WarnOnReleaseBuilds),
        m_ui->checkBoxWarnOnReleaseBuilds);
    m_group.insert(debuggerCore()->action(AdjustBreakpointLocations),
        m_ui->checkBoxAdjustBreakpointLocations);
    m_group.insert(debuggerCore()->action(BreakOnWarning),
        m_ui->checkBoxBreakOnWarning);
    m_group.insert(debuggerCore()->action(BreakOnFatal),
        m_ui->checkBoxBreakOnFatal);
    m_group.insert(debuggerCore()->action(BreakOnAbort),
        m_ui->checkBoxBreakOnAbort);
    m_group.insert(debuggerCore()->action(GdbWatchdogTimeout),
        m_ui->spinBoxGdbWatchdogTimeout);
    m_group.insert(debuggerCore()->action(AttemptQuickStart),
        m_ui->checkBoxAttemptQuickStart);

    m_group.insert(debuggerCore()->action(UseMessageBoxForSignals),
        m_ui->checkBoxUseMessageBoxForSignals);
    m_group.insert(debuggerCore()->action(SkipKnownFrames),
        m_ui->checkBoxSkipKnownFrames);
    m_group.insert(debuggerCore()->action(EnableReverseDebugging),
        m_ui->checkBoxEnableReverseDebugging);
    m_group.insert(debuggerCore()->action(GdbWatchdogTimeout), 0);

    //m_ui->groupBoxPluginDebugging->hide();

    //m_ui->lineEditSelectedPluginBreakpointsPattern->
    //    setEnabled(debuggerCore()->action(SelectedPluginBreakpoints)->value().toBool());
    //connect(m_ui->radioButtonSelectedPluginBreakpoints, SIGNAL(toggled(bool)),
    //    m_ui->lineEditSelectedPluginBreakpointsPattern, SLOT(setEnabled(bool)));

    if (m_searchKeywords.isEmpty()) {
        QLatin1Char sep(' ');
        QTextStream(&m_searchKeywords)
                << sep << m_ui->groupBoxGeneral->title()
                << sep << m_ui->checkBoxLoadGdbInit->text()
                << sep << m_ui->checkBoxTargetAsync->text()
                << sep << m_ui->checkBoxWarnOnReleaseBuilds->text()
                << sep << m_ui->checkBoxUseDynamicType->text()
                << sep << m_ui->labelGdbWatchdogTimeout->text()
                << sep << m_ui->checkBoxEnableReverseDebugging->text()
                << sep << m_ui->checkBoxSkipKnownFrames->text()
                << sep << m_ui->checkBoxUseMessageBoxForSignals->text()
                << sep << m_ui->checkBoxAdjustBreakpointLocations->text()
                << sep << m_ui->checkBoxAttemptQuickStart->text()
        //        << sep << m_ui->groupBoxPluginDebugging->title()
        //        << sep << m_ui->radioButtonAllPluginBreakpoints->text()
        //        << sep << m_ui->radioButtonSelectedPluginBreakpoints->text()
        //        << sep << m_ui->labelSelectedPluginBreakpoints->text()
        //        << sep << m_ui->radioButtonNoPluginBreakpoints->text()
        ;
        m_searchKeywords.remove(QLatin1Char('&'));
    }

    return w;
}
void ThreadsWindow::rowActivated(const QModelIndex &index)
{
    debuggerCore()->currentEngine()->selectThread(index.row());
}
void StackTreeView::contextMenuEvent(QContextMenuEvent *ev)
{
    DebuggerEngine *engine = currentEngine();
    StackHandler *handler = engine->stackHandler();
    const QModelIndex index = indexAt(ev->pos());
    const int row = index.row();
    StackFrame frame;
    if (row >= 0 && row < handler->stackSize())
        frame = handler->frameAt(row);
    const quint64 address = frame.address;

    QMenu menu;
    menu.addAction(debuggerCore()->action(ExpandStack));

    QAction *actCopyContents = menu.addAction(tr("Copy Contents to Clipboard"));
    actCopyContents->setEnabled(model() != 0);

    if (engine->hasCapability(CreateFullBacktraceCapability))
        menu.addAction(debuggerCore()->action(CreateFullBacktrace));

    QAction *actShowMemory = 0;
    if (engine->hasCapability(ShowMemoryCapability)) {
        actShowMemory = menu.addAction(QString());
        if (address == 0) {
            actShowMemory->setText(tr("Open Memory Editor"));
            actShowMemory->setEnabled(false);
        } else {
            actShowMemory->setText(tr("Open Memory Editor at 0x%1").arg(address, 0, 16));
            actShowMemory->setEnabled(engine->hasCapability(ShowMemoryCapability));
        }
    }

    QAction *actShowDisassemblerAt = 0;
    QAction *actShowDisassemblerAtAddress = 0;
    QAction *actShowDisassemblerAtFunction = 0;

    if (engine->hasCapability(DisassemblerCapability)) {
        actShowDisassemblerAt = menu.addAction(QString());
        actShowDisassemblerAtAddress = menu.addAction(tr("Open Disassembler at Address..."));
        actShowDisassemblerAtFunction = menu.addAction(tr("Disassemble Function..."));
        if (address == 0) {
            actShowDisassemblerAt->setText(tr("Open Disassembler"));
            actShowDisassemblerAt->setEnabled(false);
        } else {
            actShowDisassemblerAt->setText(tr("Open Disassembler at 0x%1").arg(address, 0, 16));
        }
    }


    QAction *actLoadSymbols = 0;
    if (engine->hasCapability(ShowModuleSymbolsCapability))
        actLoadSymbols = menu.addAction(tr("Try to Load Unknown Symbols"));

#if 0 // @TODO: not implemented
    menu.addAction(debuggerCore()->action(UseToolTipsInStackView));
#endif
    if (engine->hasCapability(MemoryAddressCapability))
        menu.addAction(debuggerCore()->action(UseAddressInStackView));

    menu.addSeparator();

    addBaseContextActions(&menu);

    QAction *act = menu.exec(ev->globalPos());
    if (!act)
        return;

    if (act == actCopyContents)
        copyContentsToClipboard();
    else if (act == actShowMemory) {
        const QString title = tr("Memory at Frame #%1 (%2) 0x%3").
        arg(row).arg(frame.function).arg(address, 0, 16);
        QList<MemoryMarkup> ml;
        ml.push_back(MemoryMarkup(address, 1, QColor(Qt::blue).lighter(),
                                  tr("Frame #%1 (%2)").arg(row).arg(frame.function)));
        engine->openMemoryView(address, 0, ml, QPoint(), title);
    } else if (act == actShowDisassemblerAtAddress) {
        AddressDialog dialog;
        if (address)
            dialog.setAddress(address);
        if (dialog.exec() == QDialog::Accepted)
            currentEngine()->openDisassemblerView(Location(dialog.address()));
    } else if (act == actShowDisassemblerAtFunction) {
        const StackFrame frame = inputFunctionForDisassembly();
        if (!frame.function.isEmpty())
            currentEngine()->openDisassemblerView(Location(frame));
    } else if (act == actShowDisassemblerAt)
        engine->openDisassemblerView(frame);
    else if (act == actLoadSymbols)
        engine->loadSymbolsForStack();
    else
        handleBaseContextAction(act);
}