Exemple #1
0
void GDBOutputWidget::currentSessionChanged(KDevelop::IDebugSession* s)
{
    if (!s)
        return;

    DebugSession *session = qobject_cast<DebugSession*>(s);
    if (!session)
        return;

     connect(this, &GDBOutputWidget::userGDBCmd,
             session, &DebugSession::addUserCommand);
     connect(this, &GDBOutputWidget::breakInto,
             session, &DebugSession::interruptDebugger);

     connect(session, &DebugSession::debuggerInternalCommandOutput,
             this, &GDBOutputWidget::slotInternalCommandStdout);
     connect(session, &DebugSession::debuggerUserCommandOutput,
             this, &GDBOutputWidget::slotUserCommandStdout);
     // debugger internal output, treat it as an internal command output
     connect(session, &DebugSession::debuggerInternalOutput,
             this, &GDBOutputWidget::slotInternalCommandStdout);

     connect(session, &DebugSession::debuggerStateChanged,
             this, &GDBOutputWidget::slotStateChanged);

     slotStateChanged(s_none, session->debuggerState());
}
void DisassembleWidget::runToCursor(){
    DebugSession *s = qobject_cast<DebugSession*>(KDevelop::ICore::
            self()->debugController()->currentSession());
    if (s && s->isRunning()) {
        QString address = m_disassembleWindow->selectedItems().at(0)->text(Address);
        s->runUntil(address);
    }
}
void GdbVariable::handleUpdate(const GDBMI::Value& var)
{
    if (var.hasField("type_changed")
        && var["type_changed"].literal() == "true")
    {
        deleteChildren();
        // FIXME: verify that this check is right.
        setHasMore(var["new_num_children"].toInt() != 0);
        fetchMoreChildren();
    }
    
    if (var.hasField("in_scope") && var["in_scope"].literal() == "false")
    {
        setInScope(false);
    }
    else
    {
        setInScope(true);

        if  (var.hasField("new_num_children")) {
            int nc = var["new_num_children"].toInt();
            Q_ASSERT(nc != -1);
            setHasMore(false);
            while (childCount() > nc) {
                TreeItem *c = child(childCount()-1);
                removeChild(childCount()-1);
                delete c;
            }
        }
                
        // FIXME: the below code is essentially copy-paste from
        // FetchMoreChildrenHandler. We need to introduce GDB-specific
        // subclass of KDevelop::Variable that is capable of creating
        // itself from MI output directly, and relay to that.
        if (var.hasField("new_children"))
        {                  
            const GDBMI::Value& children = var["new_children"];
            for (int i = 0; i < children.size(); ++i) {
                const GDBMI::Value& child = children[i];
                const QString& exp = child["exp"].literal();

                IDebugSession* is = ICore::self()->debugController()->currentSession();
                DebugSession* s = static_cast<DebugSession*>(is);
                KDevelop::Variable* xvar = s->variableController()->
                    createVariable(model(), this, exp);
                GdbVariable* var = static_cast<GdbVariable*>(xvar);
                var->setTopLevel(false);
                var->setVarobj(child["name"].literal());
                var->setHasMoreInitial(child["numchild"].toInt() != 0);
                appendChild(var);
                var->setValue(child["value"].literal());
            }
        }

        setValue(var["value"].literal());
        setHasMore(var.hasField("has_more") && var["has_more"].toInt());
    }
}
Exemple #4
0
void Variable::attachMaybe(QObject *callback, const char *callbackMethod)
{
    DebugSession* session = currentSession();
    if (session) {
        QVariantMap args;
        args["frame"] = session->frameStackModel()->currentFrame();
        args["expression"] = expression();
        session->sendCommand("evaluate", args, new EvaluateCallback(this, callback, callbackMethod));
    }
}
Exemple #5
0
void Variable::fetchMoreChildren()
{
    Q_ASSERT(m_ref);
    DebugSession* session = currentSession();
    if (session) {
        QVariantMap args;
        args["handle"] = m_ref;
        Callback<Variable>* cb = new Callback<Variable>(this, &Variable::handleLookup);
        session->sendCommand("lookup", args, cb);
    }
}
Exemple #6
0
void Variable::attachMaybe(QObject *callback, const char *callbackMethod)
{
    if (hasStartedSession()) {
        // FIXME: Eventually, should be a property of variable.
        KDevelop::IDebugSession* is = KDevelop::ICore::self()->debugController()->currentSession();
        DebugSession* s = static_cast<DebugSession*>(is);
        QStringList args;
        args << "-n " + expression();
        args << QString("-d %0").arg(s->frameStackModel()->currentFrame());
        s->connection()->sendCommand("property_get", args, QByteArray(),
                                     new PropertyGetCallback(this, callback, callbackMethod));
    }
}
Exemple #7
0
void DisassembleWidget::getAsmToDisplay(const QString& addr1, const QString& addr2)
{
    Q_ASSERT(!m_currentAddress.isNull());

    QString cmd = (addr2.isEmpty())?
        QString("-s %1 -e \"%1 + 128\" -- 0").arg( addr1.isEmpty() ? "$pc" : addr1 ):
        QString("-s %1 -e %2+1 -- 0").arg(addr1).arg(addr2); // if both addr set
        
    DebugSession *s = qobject_cast<DebugSession*>(KDevelop::ICore::
            self()->debugController()->currentSession());
    if (s) {
        s->addCommandToFront(
            new GDBCommand(DataDisassemble, cmd, this, &DisassembleWidget::memoryRead ) );
    }
}
void DisassembleWidget::getNextDisplay()
{
    kDebug();

    if (address_)
    {
        Q_ASSERT(!currentAddress_.isNull());

        QString cmd = QString("-s $pc -e \"$pc + 128\" -- 0");
        DebugSession *s = qobject_cast<DebugSession*>(KDevelop::ICore::self()->debugController()->currentSession());
        if (s) {
            s->addCommandToFront(
                        new GDBCommand(DataDisassemble, cmd, this, &DisassembleWidget::memoryRead ) );
        }
    }
}
void GdbVariable::fetchMoreChildren()
{
    int c = childItems.size();
    // FIXME: should not even try this if app is not started.
    // Probably need to disable open, or something
    if (hasStartedSession()) {
        // FIXME: Eventually, should be a property of variable.
        IDebugSession* is = ICore::self()->debugController()->currentSession();
        DebugSession* s = static_cast<DebugSession*>(is);
        s->addCommand(
            new GDBCommand(GDBMI::VarListChildren,
                           QString("--all-values \"%1\" %2 %3").arg(varobj_)
                           .arg(c).arg(c+5),
                           new FetchMoreChildrenHandler(this, s)));
    }
}
void GdbVariable::attachMaybe(QObject *callback, const char *callbackMethod)
{
    if (!varobj_.isEmpty())
        return;

    if (hasStartedSession()) {
        // FIXME: Eventually, should be a property of variable.
        IDebugSession* is = ICore::self()->debugController()->currentSession();
        DebugSession* s = static_cast<DebugSession*>(is);
        s->addCommand(
            new GDBCommand(
                GDBMI::VarCreate,
                QString("var%1 @ %2").arg(nextId++).arg(enquotedExpression()),
                new CreateVarobjHandler(this, callback, callbackMethod)));
    }
}
Exemple #11
0
void Variable::fetchMoreChildren()
{
    int c = childItems.size();
    // FIXME: should not even try this if app is not started.
    // Probably need to disable open, or something
    if (hasStartedSession()) {
        // FIXME: Eventually, should be a property of variable.
        KDevelop::IDebugSession* is = KDevelop::ICore::self()->debugController()->currentSession();
        DebugSession* s = static_cast<DebugSession*>(is);
        kDebug() << expression() << m_fullName;
        QStringList args;
        args << "-n " + m_fullName;
        args << QString("-d %0").arg(s->frameStackModel()->currentFrame());
        s->connection()->sendCommand("property_get", args, QByteArray(),
                                     new PropertyGetCallback(this, 0, 0));
    }
}
GdbVariable::~GdbVariable()
{
    if (!varobj_.isEmpty())
    {
        // Delete only top-level variable objects.
        if (topLevel()) {
            if (hasStartedSession()) {
                // FIXME: Eventually, should be a property of variable.
                IDebugSession* is = ICore::self()->debugController()->currentSession();
                DebugSession* s = static_cast<DebugSession*>(is);
                s->addCommand(new GDBCommand(GDBMI::VarDelete, 
                                             QString("\"%1\"").arg(varobj_)));
            }
        }
        allVariables_.remove(varobj_);
    }
}
void GDBOutputWidget::currentSessionChanged(KDevelop::IDebugSession* s)
{
    DebugSession *session = qobject_cast<DebugSession*>(s);
    if (!session) return;
     connect(this, &GDBOutputWidget::userGDBCmd,
             session, &DebugSession::slotUserGDBCmd);
     connect(this, &GDBOutputWidget::breakInto,
             session, &DebugSession::interruptDebugger);

     connect(session, &DebugSession::gdbInternalCommandStdout,
             this, &GDBOutputWidget::slotInternalCommandStdout);
     connect(session, &DebugSession::gdbUserCommandStdout,
             this, &GDBOutputWidget::slotUserCommandStdout);

     connect(session, &DebugSession::gdbStateChanged,
             this, &GDBOutputWidget::slotStateChanged);

     slotStateChanged(s_none, session->debuggerState());
}
Exemple #14
0
void GDBOutputWidget::currentSessionChanged(KDevelop::IDebugSession* s)
{
    DebugSession *session = qobject_cast<DebugSession*>(s);
    if (!session) return;
     connect( this,       SIGNAL(userGDBCmd(QString)),
             session, SLOT(slotUserGDBCmd(QString)));
     connect( this,       SIGNAL(breakInto()),
             session, SLOT(interruptDebugger()));

     connect( session, SIGNAL(gdbInternalCommandStdout(QString)),
             this,       SLOT(slotInternalCommandStdout(QString)) );
     connect( session, SIGNAL(gdbUserCommandStdout(QString)),
             this,       SLOT(slotUserCommandStdout(QString)) );

     connect( session, SIGNAL(gdbStateChanged(DBGStateFlags,DBGStateFlags)),
             this,       SLOT(slotStateChanged(DBGStateFlags,DBGStateFlags)));

     slotStateChanged(s_none, session->debuggerState());
}
Exemple #15
0
void DisassembleWidget::disassembleMemoryRegion(const QString& from, const QString& to)
{
    DebugSession *s = qobject_cast<DebugSession*>(KDevelop::ICore::
            self()->debugController()->currentSession());
    if(!s || !s->isRunning()) return;

    //only get $pc
    if (from.isEmpty()){
        s->addCommand(DataDisassemble, "-s \"$pc\" -e \"$pc+1\" -- 0",
                      this, &DisassembleWidget::updateExecutionAddressHandler);
    }else{

        QString cmd = (to.isEmpty())?
        QString("-s %1 -e \"%1 + 256\" -- 0").arg(from ):
        QString("-s %1 -e %2+1 -- 0").arg(from).arg(to); // if both addr set

        s->addCommand(DataDisassemble, cmd,
                      this, &DisassembleWidget::disassembleMemoryHandler);
   }
}