示例#1
0
bool AddressDialog::getAddress( UnsignedCoordinate* result, QWidget* p, bool cityOnly )
{
	if ( result == NULL )
		return false;

	AddressDialog* window = new AddressDialog( p );
	window->m_skipStreetPosition = cityOnly;

	int value = window->exec();
	if ( value == Accepted )
		*result = window->m_result;

	delete window;
	return value == Accepted;
}
示例#2
0
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(action(ExpandStack));

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

    QAction *actSaveTaskFile = menu.addAction(tr("Save as Task File..."));
    actSaveTaskFile->setEnabled(model() != 0);

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

    QAction *additionalQmlStackAction = 0;
    if (engine->hasCapability(AdditionalQmlStackCapability))
        additionalQmlStackAction = menu.addAction(tr("Load QML Stack"));

    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 (engine->hasCapability(MemoryAddressCapability))
        menu.addAction(action(UseAddressInStackView));

    menu.addSeparator();
    menu.addAction(action(UseToolTipsInStackView));
    menu.addSeparator();
    menu.addAction(action(SettingsDialog));

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

    if (act == actCopyContents) {
        copyContentsToClipboard();
    } else if (act == actShowMemory) {
        MemoryViewSetupData data;
        data.startAddress = address;
        data.title = tr("Memory at Frame #%1 (%2) 0x%3").
            arg(row).arg(frame.function).arg(address, 0, 16);
        data.markup.push_back(MemoryMarkup(address, 1, QColor(Qt::blue).lighter(),
                                  tr("Frame #%1 (%2)").arg(row).arg(frame.function)));
        engine->openMemoryView(data);
    } 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 if (act == actSaveTaskFile)
        saveTaskFile(this, handler);
    else if (act == additionalQmlStackAction)
        engine->loadAdditionalQmlStack();
}
示例#3
0
bool RegisterHandler::contextMenuEvent(const ItemViewEvent &ev)
{
    const bool actionsEnabled = m_engine->debuggerActionsEnabled();
    const DebuggerState state = m_engine->state();

    RegisterItem *registerItem = itemForIndexAtLevel<1>(ev.index());
    RegisterSubItem *registerSubItem = itemForIndexAtLevel<2>(ev.index());

    const quint64 address = registerItem ? registerItem->addressValue() : 0;
    const QString registerName = registerItem ? registerItem->m_reg.name : QString();

    auto menu = new QMenu;

    addAction(menu, tr("Reload Register Listing"),
              m_engine->hasCapability(RegisterCapability)
                && (state == InferiorStopOk || state == InferiorUnrunnable),
              [this] { m_engine->reloadRegisters(); });

    menu->addSeparator();

    addAction(menu, tr("Open Memory View at Value of Register %1 0x%2")
              .arg(registerName).arg(address, 0, 16),
              tr("Open Memory View at Value of Register"),
              address,
              [this, registerName, address] {
                    MemoryViewSetupData data;
                    data.startAddress = address;
                    data.registerName = registerName;
                    data.trackRegisters = true;
                    data.separateView = true;
                    m_engine->openMemoryView(data);
              });

    addAction(menu, tr("Open Memory Editor at 0x%1").arg(address, 0, 16),
              tr("Open Memory Editor"),
              address && actionsEnabled && m_engine->hasCapability(ShowMemoryCapability),
              [this, registerName, address] {
                    MemoryViewSetupData data;
                    data.startAddress = address;
                    data.registerName = registerName;
                    data.markup = registerViewMarkup(address, registerName);
                    data.title = registerViewTitle(registerName);
                    m_engine->openMemoryView(data);
              });

    addAction(menu, tr("Open Disassembler at 0x%1").arg(address, 0, 16),
              tr("Open Disassembler"),
              address && m_engine->hasCapability(DisassemblerCapability),
              [this, address] { m_engine->openDisassemblerView(Location(address)); });

    addAction(menu, tr("Open Disassembler..."),
              m_engine->hasCapability(DisassemblerCapability),
              [this, address] {
                    AddressDialog dialog;
                    if (address)
                        dialog.setAddress(address);
                    if (dialog.exec() == QDialog::Accepted)
                        m_engine->openDisassemblerView(Location(dialog.address()));
              });

    menu->addSeparator();

    const RegisterFormat currentFormat = registerItem
            ? registerItem->m_format
            : registerSubItem
              ? registerSubItem->parent()->m_format
              : HexadecimalFormat;

    auto addFormatAction =
            [menu, currentFormat, registerItem](const QString &display, RegisterFormat format) {
        addCheckableAction(menu, display, registerItem, currentFormat == format,
                           [registerItem, format] {
            registerItem->m_format = format;
            registerItem->update();
        });
    };

    addFormatAction(tr("Hexadecimal"), HexadecimalFormat);
    addFormatAction(tr("Decimal"), DecimalFormat);
    addFormatAction(tr("Octal"), OctalFormat);
    addFormatAction(tr("Binary"), BinaryFormat);

    menu->addSeparator();
    menu->addAction(action(SettingsDialog));
    menu->popup(ev.globalPos());
    return true;
}
示例#4
0
bool StackHandler::contextMenuEvent(const ItemViewEvent &ev)
{
    auto menu = new QMenu;

    const int row = ev.index().row();
    StackFrame frame;
    if (row >= 0 && row < stackSize())
        frame = frameAt(row);
    const quint64 address = frame.address;

    menu->addAction(action(ExpandStack));

    addAction(menu, tr("Copy Contents to Clipboard"), true, [this] { copyContentsToClipboard(); });
    addAction(menu, tr("Save as Task File..."), true, [this] { saveTaskFile(); });

    if (m_engine->hasCapability(CreateFullBacktraceCapability))
        menu->addAction(action(CreateFullBacktrace));

    if (m_engine->hasCapability(AdditionalQmlStackCapability))
        addAction(menu, tr("Load QML Stack"), true, [this] { m_engine->loadAdditionalQmlStack(); });

    if (m_engine->hasCapability(ShowMemoryCapability))
        addAction(menu, tr("Open Memory Editor at 0x%1").arg(address, 0, 16),
                  tr("Open Memory Editor"),
                  address,
                  [this, row, frame, address] {
                        MemoryViewSetupData data;
                        data.startAddress = address;
                        data.title = tr("Memory at Frame #%1 (%2) 0x%3")
                                        .arg(row).arg(frame.function).arg(address, 0, 16);
                        data.markup.push_back(MemoryMarkup(address, 1, QColor(Qt::blue).lighter(),
                                                  tr("Frame #%1 (%2)").arg(row).arg(frame.function)));
                        m_engine->openMemoryView(data);
                   });

    if (m_engine->hasCapability(DisassemblerCapability)) {
        addAction(menu, tr("Open Disassembler at 0x%1").arg(address, 0, 16),
                  tr("Open Disassembler"),
                  address,
                  [this, frame] { m_engine->openDisassemblerView(frame); });

        addAction(menu, tr("Open Disassembler at Address..."), true,
                  [this, address] {
                        AddressDialog dialog;
                        if (address)
                            dialog.setAddress(address);
                        if (dialog.exec() == QDialog::Accepted)
                            m_engine->openDisassemblerView(Location(dialog.address()));
                   });

        addAction(menu, tr("Disassemble Function..."), true,
                  [this] {
                        const StackFrame frame = inputFunctionForDisassembly();
                        if (!frame.function.isEmpty())
                            m_engine->openDisassemblerView(Location(frame));
                  });
    }

    if (m_engine->hasCapability(ShowModuleSymbolsCapability)) {
        addAction(menu, tr("Try to Load Unknown Symbols"), true,
                  [this] { m_engine->loadSymbolsForStack(); });
    }

    if (m_engine->hasCapability(MemoryAddressCapability))
        menu->addAction(action(UseAddressInStackView));

    menu->addSeparator();
    menu->addAction(action(UseToolTipsInStackView));
    menu->addSeparator();
    menu->addAction(action(SettingsDialog));
    menu->popup(ev.globalPos());
    return true;
}