示例#1
0
void CodeLiteLLDBApp::EvalExpression(const LLDBCommand& command)
{
    wxPrintf("codelite-lldb: evaluating expression '%s'\n", command.GetExpression());

    if(CanInteract()) {
        // Evaluate the expression based on the current frame
        wxString expression = command.GetExpression();
        expression.Trim().Trim(false);
        lldb::SBValue value = m_target.GetProcess().GetSelectedThread().GetSelectedFrame().GetValueForVariablePath(
            expression.mb_str(wxConvUTF8).data());
        if(value.IsValid()) {

            LLDBReply reply;
            reply.SetReplyType(kReplyTypeExprEvaluated);
            reply.SetExpression(command.GetExpression());

            LLDBVariable::Vect_t vars;
            LLDBVariable::Ptr_t var(new LLDBVariable(value));
            vars.push_back(var);
            reply.SetVariables(vars);
            VariableWrapper wrapper;
            wrapper.value = value;
            // Cache the expanded variable (we will need it later for tooltip expansion
            m_variables.insert(std::make_pair(value.GetID(), wrapper));

            SendReply(reply);
        }
    }
}
示例#2
0
void CodeLiteLLDBApp::EvalExpression(const LLDBCommand& command)
{
    wxPrintf("codelite-lldb: evaluating expression '%s'\n", command.GetExpression());

    if(CanInteract()) {
        lldb::SBExpressionOptions options;
        lldb::SBValue value = m_target.EvaluateExpression(command.GetExpression().mb_str(wxConvUTF8).data(), options);
        if(value.IsValid()) {

            LLDBReply reply;
            reply.SetReplyType(kReplyTypeExprEvaluated);
            reply.SetExpression(command.GetExpression());

            LLDBVariable::Vect_t vars;
            LLDBVariable::Ptr_t var(new LLDBVariable(value));
            vars.push_back(var);
            reply.SetVariables(vars);
            VariableWrapper wrapper;
            wrapper.value = value;
            // Cache the expanded variable (we will need it later for tooltip expansion
            m_variables.insert(std::make_pair(value.GetID(), wrapper));

            SendReply(reply);
        }
    }
}
示例#3
0
// we need to return list of children for a variable
// we stashed the variables we got so far inside a map
void CodeLiteLLDBApp::ExpandVariable(const LLDBCommand& command)
{
    int variableId = command.GetLldbId();
    if(variableId == wxNOT_FOUND) {
        return;
    }

    LLDBVariable::Vect_t children;
    std::map<int, VariableWrapper>::iterator iter = m_variables.find(variableId);
    if(iter != m_variables.end()) {
        lldb::SBValue* pvalue = &(iter->second.value);
        lldb::SBValue deReferencedValue;
        int size = pvalue->GetNumChildren();

        lldb::TypeClass typeClass = pvalue->GetType().GetTypeClass();
        if(typeClass & lldb::eTypeClassArray) {
            size > (int)m_settings.GetMaxArrayElements() ? size = m_settings.GetMaxArrayElements() : size = size;
            wxPrintf("codelite-lldb: value %s is an array. Limiting its size\n", pvalue->GetName());
        } /*else if ( typeClass & lldb::eTypeClassPointer ) {
            // dereference is needed
            wxPrintf("codelite-lldb: value '%s' is a class pointer, dereferecning it\n", pvalue->GetName());
            deReferencedValue = pvalue->Dereference();

            // and update the number of children
            pvalue = &deReferencedValue;

            wxPrintf("codelite-lldb: new number of children is set to %d\n", size);
            size = pvalue->GetNumChildren();
        }*/

        for(int i = 0; i < size; ++i) {
            lldb::SBValue child = pvalue->GetChildAtIndex(i);
            if(child.IsValid()) {
                LLDBVariable::Ptr_t var(new LLDBVariable(child));
                children.push_back(var);
                VariableWrapper wrapper;
                wrapper.value = child;
                m_variables.insert(std::make_pair(child.GetID(), wrapper));
            }
        }

        LLDBReply reply;
        reply.SetReplyType(kReplyTypeVariableExpanded);
        reply.SetVariables(children);
        reply.SetLldbId(variableId);
        SendReply(reply);
    }
}
示例#4
0
void CodeLiteLLDBApp::NotifyLocals(LLDBVariable::Vect_t locals)
{
    wxPrintf("codelite-lldb: NotifyLocals called with %d locals\n", (int)locals.size());
    LLDBReply reply;
    reply.SetReplyType(kReplyTypeLocalsUpdated);
    reply.SetVariables(locals);
    SendReply(reply);
}
示例#5
0
void CodeLiteLLDBApp::LocalVariables(const LLDBCommand& command)
{
    wxUnusedVar(command);
    LLDBVariable::Vect_t locals;
    m_variables.clear();

    wxPrintf("codelite-lldb: fetching local variables for selected frame\n");
    lldb::SBFrame frame = m_target.GetProcess().GetSelectedThread().GetSelectedFrame();
    if(!frame.IsValid()) {
        NotifyLocals(locals);
        return;
    }

    // get list of locals
    lldb::SBValueList args = frame.GetVariables(true, true, false, true);
    for(size_t i = 0; i < args.GetSize(); ++i) {
        lldb::SBValue value = args.GetValueAtIndex(i);
        if(value.IsValid()) {
            LLDBVariable::Ptr_t var(new LLDBVariable(value));
            VariableWrapper wrapper;
            wrapper.value = value;
            m_variables.insert(std::make_pair(value.GetID(), wrapper));
            locals.push_back(var);
        }
    }

    // next, add the watches
    for(size_t i = 0; i < m_watches.GetCount(); ++i) {
        lldb::SBValue value = frame.EvaluateExpression(m_watches.Item(i).mb_str(wxConvUTF8).data());
        if(value.IsValid()) {
            LLDBVariable::Ptr_t var(new LLDBVariable(value));
            var->SetIsWatch(true);
            // override the name with the actual expression that we want to watch
            var->SetName(m_watches.Item(i));

            // Keep the info about this watch
            VariableWrapper wrapper;
            wrapper.value = value;
            wrapper.isWatch = true;
            wrapper.expression = m_watches.Item(i);
            m_variables.insert(std::make_pair(value.GetID(), wrapper));
            locals.push_back(var);
        }
    }
    NotifyLocals(locals);
}
示例#6
0
void LLDBLocalsView::DoAddVariableToView(const LLDBVariable::Vect_t& variables, wxTreeItemId parent)
{
    for(size_t i = 0; i < variables.size(); ++i) {
        LLDBVariable::Ptr_t variable = variables.at(i);
        wxTreeItemId item = m_treeList->AppendItem(
            parent, variable->GetName(), wxNOT_FOUND, wxNOT_FOUND, new LLDBVariableClientData(variable));
        m_treeList->SetItemText(item,
                                LOCALS_VIEW_SUMMARY_COL_IDX,
                                variable->GetSummary().IsEmpty() ? variable->GetValue() : variable->GetSummary());
        m_treeList->SetItemText(item, LOCALS_VIEW_VALUE_COL_IDX, variable->GetValue());
        m_treeList->SetItemText(item, LOCALS_VIEW_TYPE_COL_IDX, variable->GetType());
        if(variable->IsValueChanged()) {
            m_treeList->SetItemTextColour(item, "RED");
        }
        if(variable->HasChildren()) {
            // insert dummy item here
            m_treeList->AppendItem(item, "<dummy>");
        }
    }

    if(!variables.empty()) {
        m_treeList->Expand(parent);
    }
}
示例#7
0
void CodeLiteLLDBApp::LocalVariables(const LLDBCommand& command)
{
    wxUnusedVar( command );
    LLDBVariable::Vect_t locals;
    
    wxPrintf("codelite-lldb: fetching local variables for selected frame\n");
    lldb::SBFrame frame = m_target.GetProcess().GetSelectedThread().GetSelectedFrame();
    if ( !frame.IsValid() ) {
        NotifyLocals(locals);
        return;
    }

    // get list of locals
    lldb::SBValueList args = frame.GetVariables(true, true, false, true);
    for(size_t i=0; i<args.GetSize(); ++i) {
        lldb::SBValue value = args.GetValueAtIndex(i);
        if ( value.IsValid() ) {
            LLDBVariable::Ptr_t var( new LLDBVariable(value) );
            m_variables.insert( std::make_pair(value.GetID(), value) );
            locals.push_back( var );
        }
    }
    NotifyLocals( locals );
}