Beispiel #1
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);
   }
}
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)));
    }
}
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_);
    }
}