Ejemplo n.º 1
0
void SearchResultsLog::FocusEntry(size_t index)
{
    if (index >= 0 && index < (size_t)control->GetItemCount())
    {
        control->SetItemState(index, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
        control->EnsureVisible(index);
        SyncEditor(index);
    }
}
Ejemplo n.º 2
0
void ValgrindListLog::OnDoubleClick(wxCommandEvent& /*event*/)
{
	// go to the relevant file/line
	if (control->GetSelectedItemCount() == 0)
	{
		return;
	}
	// find selected item index
	const int Index = control->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	SyncEditor(Index);
} // end of OnDoubleClick
Ejemplo n.º 3
0
void DisassemblyTextCtrl::OnDclick(wxMouseEvent& event)
{

        if(GetStatus())
        {
            SetStatus(0);
           PluginsArray plugins = Manager::Get()->GetPluginManager()->GetDebuggerOffers();
            if (plugins.GetCount())
            {
                cbDebuggerPlugin* dbg = (cbDebuggerPlugin*)plugins[0];
                if (dbg)
                {
                    // is the debugger running?
                    if (dbg->IsRunning())
                    {
                        dbg->StepByStep();
                    }
                }
            }
        }
        int LineNum = GetCurrentLine();
        int L2 = GetCurrentLine();
        wxString LineText,SourceFile;
       unsigned long SourceLine=0;

        while(LineNum > 0)
        {
            LineText = GetLine(LineNum--);
            if(reRelativePath.Matches(LineText))
            break;
        }

        if(LineText.IsEmpty())
        return ;

        LineText.AfterLast(_T(':')).ToULong(&SourceLine,10);
        SourceFile = Manager::Get()->GetProjectManager()->GetActiveProject()->GetBasePath();
        SourceFile  <<  LineText.Before(_T(':'));



        SyncEditor(LineText.Before(_T(':')),SourceLine,true);

        SetReadOnly(false);
        MarkerDeleteAll(DEBUG_MARKER);
        MarkerAdd(SourceLine,DEBUG_MARKER);


        SetReadOnly(true);
    //wxMessageBox(wxString::Format(_T("%s:%d"),SourceFile.c_str(),SourceLine));
     event.Skip();

}
Ejemplo n.º 4
0
void SearchResultsLog::OnDoubleClick(wxCommandEvent& /*event*/)
{
    // go to the relevant file/line
    if (control->GetSelectedItemCount() == 0)
        return;

    // find selected item index
    int index = control->GetNextItem(-1,
                                     wxLIST_NEXT_ALL,
                                     wxLIST_STATE_SELECTED);

    SyncEditor(index);
} // end of OnDoubleClick
Ejemplo n.º 5
0
void PythonDebugger::OnTimer(wxTimerEvent& event)
{
    bool debugoutputmode=false;
    if (m_pp && m_pp->IsInputAvailable())
    {
        while(m_pp->IsInputAvailable())
        {
            int c;
            if (m_istream->CanRead())
                c = m_istream->GetC();
            if (m_istream->LastRead()>0)
                m_outbuf += c;
        }
        //TODO: Program could hang if debug output is incorrectly parsed
        m_outdebugbuf=m_outbuf;

        // Loop over the output, looking for parseable output separated by "(Pdb)" prompts

        while(true)
        {
            wxString s=m_outdebugbuf.Mid(m_debugbufpos);
            int pos=s.Find(_T("(Pdb)")); //position in the string of the Pdb prompt returning from the last call
            if(pos==wxNOT_FOUND)
                break;
            wxString logout=s.Mid(0,pos+5);
            wxString exprresult=s.Mid(0,pos);
            m_DebugCommandCount--;
            PythonCmdDispatchData cmd;
            if(!m_DispatchedCommands.empty())
            {
                cmd=m_DispatchedCommands.front();
                m_DispatchedCommands.pop_front();
            }
            m_debugbufpos+=pos+5;
            if(pos==0)
                continue;
            switch(cmd.type)
            {
                case DBGCMDTYPE_WATCHEXPRESSION:
                {
                    exprresult.RemoveLast();
                    exprresult.Replace(_T("\t"),_T("\\t"),true);
                    exprresult.Replace(_T("\n"),_T("\\n"),true);
                    wxString symbol=exprresult.BeforeFirst(_T('\001')).Trim(false);
                    exprresult=exprresult.AfterFirst(_T('\001'));
                    wxString type=exprresult.BeforeFirst(_T('\001')).Trim().Trim(false);
                    wxString value=exprresult.AfterFirst(_T('\001'));
                    for(size_t i=0;i<m_watchlist.size();++i)
                    {
                        cb::shared_ptr<cbWatch> p;
                        wxString s;
                        m_watchlist[i]->GetSymbol(s);
                        if (s==symbol)
                            p=m_watchlist[i];
                        else
                            p=m_watchlist[i]->FindChild(symbol);
                        if(p)
                        {
                            wxString oldval,oldtype;
                            p->GetValue(oldval);
                            p->GetType(oldtype);
                            p->MarkAsChanged(oldval!=value || oldtype!=type);
                            p->SetType(type);
                            p->SetValue(value);
                        }
                    }
                    DebuggerManager &dbg_manager = *Manager::Get()->GetDebuggerManager();
                    dbg_manager.GetWatchesDialog()->UpdateWatches();
                    break;
                }
                case DBGCMDTYPE_WATCHGETCHILDREN:
                {
                    exprresult.RemoveLast();
                    exprresult.Replace(_T("\t"),_T("\\t"),true);
                    exprresult.Replace(_T("\n"),_T("\\n"),true);
                    wxString parentsymbol=cmd.cmdtext.AfterFirst(_T(' '));
                    parentsymbol=parentsymbol.BeforeLast(_T('\n'));

                    //Find the parent watch and remove it's children
                    PythonWatch::Pointer parentwatch, pw;
                    PythonWatchesContainer::iterator it;
                    for(it=m_watchlist.begin();it!=m_watchlist.end();it++)
                    {
                        wxString symbol;
                        (*it)->GetSymbol(symbol);
                        if(symbol==parentsymbol)
                        {
                            parentwatch=*it;
                            break;
                        }
                    }
                    if(it==m_watchlist.end())
                    {
                        if (parentsymbol == _("*Locals:"))
                            parentwatch = m_locals_watch;
                        else
                            break;
                    }
//                    parentwatch->RemoveChildren();
//                    parentwatch->MarkAsChanged(true);

                    //Now add the newly updated children
                    std::set<wxString> foundsyms;
                    foundsyms.insert(_T("*Modules:"));
                    foundsyms.insert(_T("*Classes:"));
                    foundsyms.insert(_T("*Functions:"));
                    while (exprresult.Len()>0)
                    {
                        wxString symbol=exprresult.BeforeFirst(_T('\001')).Trim(false);
                        exprresult=exprresult.AfterFirst(_T('\001'));
                        wxString type=exprresult.BeforeFirst(_T('\001')).Trim(false).Trim();
                        exprresult=exprresult.AfterFirst(_T('\001'));
                        wxString value=exprresult.BeforeFirst(_T('\001'));
                        exprresult=exprresult.AfterFirst(_T('\001'));
                        foundsyms.insert(symbol);
                        cb::shared_ptr<cbWatch> p = parentwatch->FindChild(symbol);
                        pw = parentwatch;
                        if (parentwatch == m_locals_watch)
                        {
                            if(!p && type == _("<type 'module'>"))
                            {
                                p = m_modules_watch->FindChild(symbol);
                                pw = m_modules_watch;
                            }
                            if(!p && type == _("<type 'classobj'>"))
                            {
                                p = m_classes_watch->FindChild(symbol);
                                pw = m_classes_watch;
                            }
                            if(!p && type == _("<type 'function'>"))
                            {
                                p = m_functions_watch->FindChild(symbol);
                                pw = m_functions_watch;
                            }
                        }
                        if(!p)
                        {
                            p = cb::shared_ptr<cbWatch>(new PythonWatch(symbol));
                            cbWatch::AddChild(pw,p);
                        }
                        wxString oldval,oldtype;
                        p->GetValue(oldval);
                        p->GetType(oldtype);
                        p->MarkAsChanged(oldval!=value || oldtype!=type);
                        p->SetType(type);
                        p->SetValue(value);
                    }
                    RemoveMissingChildren(parentwatch, foundsyms);
                    if (parentwatch == m_locals_watch)
                    {
                        RemoveMissingChildren(m_functions_watch, foundsyms);
                        RemoveMissingChildren(m_classes_watch, foundsyms);
                        RemoveMissingChildren(m_modules_watch, foundsyms);
                    }
                    DebuggerManager &dbg_manager = *Manager::Get()->GetDebuggerManager();
                    dbg_manager.GetWatchesDialog()->UpdateWatches();
                    break;
                }
                case DBGCMDTYPE_WATCHTOOLTIP:
                {
                    wxString output;
                    wxString lines=exprresult;
                    if(lines.EndsWith(_T("\n")))
                        lines=lines.Left(lines.Length()-1);
                    int i=0;
                    int def_end=0;
                    while(lines!=_T(""))
                    {
                        if(i==1)
                            def_end=output.Length();
                        if(i>0)
                            output+=_T("\n");
                        wxString line=lines.BeforeFirst(_T('\n'));
                        lines=lines.AfterFirst(_T('\n'));
                        output+=line;
                        i++;
                        if(i>10)
                            break;
                    }
                    if(lines!=_T(""))
                    {
                        if(lines.BeforeLast(_T('\n'))!=_T(""))
                            output+=_T("\n...");
                        output+=_T("\n")+lines.AfterLast(_T('\n'));
                    }
    //                    exprresult.Replace(_T("\t"),_T("\\t"),true);
    //                    exprresult.Replace(_T("\n"),_T("\\n"),true);
                    SetWatchTooltip(output, def_end);
                    break;
                }
                case DBGCMDTYPE_FLOWCONTROL:
                {
                    wxRegEx re;
                    re.Compile(_T("\\> ([^\\n]*)\\((\\d+)\\)([^\\n]*)\\n([^\\n]*)\\n\\Z"),wxRE_ADVANCED); // Group 1 is the file, Group 2 is the line location, Group 3 is the source of the current line
                    if(re.Matches(exprresult))
                    {
                        m_curfile=re.GetMatch(exprresult,1);
                        re.GetMatch(exprresult,2).ToULong(&m_curline);
                        m_changeposition=true;
                    }
                    re.Compile(_T("Uncaught exception. Entering post mortem debugging\\nRunning 'cont' or 'step' will restart the program"),wxRE_ADVANCED);

    //                re.Compile(_T("Traceback \\(most recent call last\\):\\n  File .*\\n(\\w*Error\\:.+?)\n"),wxRE_ADVANCED); //Traceback notification
                    if(re.Matches(exprresult))
                    {
                        wxString err=re.GetMatch(exprresult,1);
    //                    wxMessageBox(_T("Runtime Error During Debug:\n")+err+_T("\n at line ")+wxString().Format(_T("%u"),m_curline)+_T(" in ")+m_curfile);
                        wxMessageBox(_T("Runtime Error During Debug:\nEntering post mortem debug mode...\nYou may inspect variables by updating the watch\n(Select continue/next to restart or Stop to cancel debug)\n\nError:\n")+err);
                    }
                    if(!debugoutputmode) // in standard debug mode, only log flow control information (clearer)
                    {
                        m_DebugLog->Append(cmd.cmdtext);
                        m_DebugLog->Append(logout);
                    }
                    break;
                }

                case DBGCMDTYPE_CALLSTACK:
                {
                    wxRegEx re;
                    re.Compile(_T("[> ] \\<string\\>\\(1\\)\\<module\\>\\(\\)\\n"),wxRE_ADVANCED);
                    if(!re.Matches(exprresult))
                        break;
                    size_t start,len;
                    wxString matchstr;
                    re.GetMatch(&start,&len,0);
                    matchstr=exprresult.Mid(start+len);
                    re.Compile(_T("[> ] ([^\\n]*)\\((\\d+)\\)([^\\n]*)\\n\\-\\> ([^\\n]*)\\n"),wxRE_ADVANCED); // Group 1 is the file, Group 2 is the line location, Group 3 is the source of the current line
                    m_stackinfo.frames.clear();
                    int n=0;
                    while(true)
                    {
                        if(!re.Matches(matchstr))
                            break;
                        wxString file=re.GetMatch(matchstr,1);
                        wxString line=re.GetMatch(matchstr,2);
                        wxString Module=re.GetMatch(matchstr,3);
                        wxString Code=re.GetMatch(matchstr,4);
                        bool active=(re.GetMatch(matchstr,0).Left(1)==_T(">"));
                        m_changeposition=true;
                        cb::shared_ptr<cbStackFrame> f=cb::shared_ptr<cbStackFrame>(new cbStackFrame);
                        f->SetFile(file,line);
                        f->SetNumber(n);
                        f->SetSymbol(Module);
                        f->SetAddress(0);
                        m_stackinfo.frames.push_back(f);
                        if(active)
                        {
                            m_stackinfo.activeframe=n;
                            m_curfile=file;
                            line.ToULong(&m_curline);
                        }
                        re.GetMatch(&start,&len,0);
                        matchstr=matchstr.Mid(start+len);
                        n++;
                    }
                    DebuggerManager &dbg_manager = *Manager::Get()->GetDebuggerManager();
                    dbg_manager.GetBacktraceDialog()->Reload();
                    break;
                }
            }

        }
    }
    if(m_DebugCommandCount==0)
    { //TODO: clear debug and program output strings as well
        if(m_changeposition)
        {
            if(m_curline<1)
            {
                wxMessageBox(_T("Invalid line position reported by PDB"));
                return;
            } else
            {
                SyncEditor(m_curfile,m_curline);
            }
        }
        m_changeposition=false;
        m_outbuf=_T("");
        m_bufpos=0;
        m_outdebugbuf=_T("");
        m_debugbufpos=0;
        m_outprogbuf=_T("");
        m_progbufpos=0;
        m_TimerPollDebugger.Stop();
    }

}