Exemplo n.º 1
0
DisassembleWidget::DisassembleWidget(CppDebuggerPlugin* plugin, QWidget *parent)
        : QWidget(parent),
        active_(false),
        lower_(0),
        upper_(0),
        address_(0),
        m_splitter(new KDevelop::AutoOrientedSplitter(this))
{
        QVBoxLayout* topLayout = new QVBoxLayout(this);

        QHBoxLayout* controlsLayout = new QHBoxLayout;

        topLayout->addLayout(controlsLayout);


    {   // initialize disasm/registers views
        topLayout->addWidget(m_splitter);

        //topLayout->setMargin(0);

        m_disassembleWindow = new DisassembleWindow(m_splitter, this);

        m_disassembleWindow->setWhatsThis(i18n("<b>Machine code display</b><p>"
                        "A machine code view into your running "
                        "executable with the current instruction "
                        "highlighted. You can step instruction by "
                        "instruction using the debuggers toolbar "
                        "buttons of \"step over\" instruction and "
                        "\"step into\" instruction."));

        m_disassembleWindow->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
        m_disassembleWindow->setSelectionMode(QTreeWidget::SingleSelection);
        m_disassembleWindow->setColumnCount(ColumnCount);
        m_disassembleWindow->setUniformRowHeights(true);
        m_disassembleWindow->setRootIsDecorated(false);

        m_disassembleWindow->setHeaderLabels(QStringList() << "" << i18n("Address") << i18n("Function") << i18n("Instruction"));

        m_splitter->setStretchFactor(0, 1);
        m_splitter->setContentsMargins(0, 0, 0, 0);

        m_registersManager = new RegistersManager(m_splitter);

        m_config = KSharedConfig::openConfig()->group("Disassemble/Registers View");

        QByteArray state = m_config.readEntry<QByteArray>("splitterState", QByteArray());
        if (!state.isEmpty()) {
            m_splitter->restoreState(state);
        }

    }

    setLayout(topLayout);

    setWindowIcon( QIcon::fromTheme("system-run", windowIcon()) );
    setWindowTitle(i18n("Disassemble/Registers View"));

    KDevelop::IDebugController* pDC=KDevelop::ICore::self()->debugController();
    Q_ASSERT(pDC);

    connect(pDC,
            &KDevelop::IDebugController::currentSessionChanged,
            this, &DisassembleWidget::currentSessionChanged);

    connect(plugin, &CppDebuggerPlugin::reset, this, &DisassembleWidget::slotDeactivate);

    m_dlg = new SelectAddressDialog(this);

    // show the data if debug session is active
    KDevelop::IDebugSession* pS = pDC->currentSession();

    currentSessionChanged(pS);

    if(pS && !pS->currentAddr().isEmpty())
        slotShowStepInSource(pS->currentUrl(), pS->currentLine(), pS->currentAddr());
}
Exemplo n.º 2
0
DisassembleWidget::DisassembleWidget(CppDebuggerPlugin* plugin, QWidget *parent)
        : QWidget(parent),
        active_(false),
        lower_(0),
        upper_(0),
        address_(0)
{
    QVBoxLayout* topLayout = new QVBoxLayout(this);
    
    {   // initialize controls
        QHBoxLayout* controlsLayout = new QHBoxLayout;
        QLabel* startAddr = new QLabel(i18n("Start address:"), this);
        QLabel* endAddr   = new QLabel(i18n("End Address:"), this);
        
        m_startAddress = new QComboBox(this);
        m_startAddress->setEditable(true);
        m_startAddress->setSizeAdjustPolicy(QComboBox::AdjustToContents);
        m_startAddress->setMinimumContentsLength( 2+2*sizeof(void*) );
        m_startAddress->setInsertPolicy(QComboBox::InsertAtTop);
        
        m_endAddress = new QComboBox(this);
        m_endAddress->setEditable(true);
        m_endAddress->setSizeAdjustPolicy(QComboBox::AdjustToContents);
        m_endAddress->setMinimumContentsLength( 2+2*sizeof(void*) );
        m_endAddress->setInsertPolicy(QComboBox::InsertAtTop);
        
        m_evalButton = new QPushButton(i18nc("@action:button", "Display"), this);
        controlsLayout->addWidget(startAddr);
        controlsLayout->addWidget(m_startAddress);
        controlsLayout->addWidget(endAddr);
        controlsLayout->addWidget(m_endAddress);
        controlsLayout->addWidget(m_evalButton);
        controlsLayout->addStretch(0);

        topLayout->addLayout(controlsLayout);

        connect(m_startAddress, SIGNAL(editTextChanged(QString)), 
                this, SLOT(slotValidateEdits()) );
        connect(m_endAddress, SIGNAL(editTextChanged(QString)), 
                this, SLOT(slotValidateEdits()) );

        connect(m_evalButton, SIGNAL(clicked(bool)),
                this, SLOT(slotShowAddrRange()) );
    }

    
    {   // initialize disasm view
        m_treeWidget = new QTreeWidget(this);

        m_treeWidget->setWhatsThis(i18n("<b>Machine code display</b><p>"
                        "A machine code view into your running "
                        "executable with the current instruction "
                        "highlighted. You can step instruction by "
                        "instruction using the debuggers toolbar "
                        "buttons of \"step over\" instruction and "
                        "\"step into\" instruction."));

        m_treeWidget->setFont(KGlobalSettings::fixedFont());
        m_treeWidget->setSelectionMode(QTreeWidget::SingleSelection);
        m_treeWidget->setColumnCount(ColumnCount);
        m_treeWidget->setUniformRowHeights(true);
        m_treeWidget->setRootIsDecorated(false);

        m_treeWidget->setHeaderLabels(QStringList() << "" << i18n("Address") << i18n("Function")
            << i18n("Offset") << i18n("Instruction"));

        topLayout->addWidget(m_treeWidget);
        topLayout->setStretchFactor(m_treeWidget, 1);
        topLayout->setMargin(0);
    }
    
    setLayout(topLayout);
    
    setWindowIcon( KIcon("system-run") );
    setWindowTitle(i18n("Disassemble View"));
    
    KDevelop::IDebugController* pDC=KDevelop::ICore::self()->debugController();
    Q_ASSERT(pDC);
    
    connect(pDC, 
            SIGNAL(currentSessionChanged(KDevelop::IDebugSession*)),
            SLOT(currentSessionChanged(KDevelop::IDebugSession*)));

    connect(plugin, SIGNAL(reset()), this, SLOT(slotDeactivate()));
    
    // context menu command
    m_selectAddrAction = new QAction(i18n("Change &address"), m_treeWidget);
    m_selectAddrAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    connect(m_selectAddrAction, SIGNAL(triggered()), this, SLOT(slotChangeAddress()));

    m_dlg = new SelectAddrDialog(this);
    
    // show the data if debug session is active
    KDevelop::IDebugSession* pS = pDC->currentSession();

    currentSessionChanged(pS);
    
    if(pS && !pS->currentAddr().isEmpty())
        slotShowStepInSource(pS->currentUrl(), pS->currentLine(), pS->currentAddr());
}