Exemple #1
0
void XDebugManager::OnToggleBreakpoint(clDebugEvent& e)
{
    if ( !PHPWorkspace::Get()->IsOpen() ) {
        e.Skip();
        return;
    }
    
    // User toggled a breakpoint
    IEditor* editor = m_plugin->GetManager()->GetActiveEditor();
    if ( editor && editor->GetFileName().GetFullPath() == e.GetFileName() ) {
        // Correct editor
        // add marker
        if ( m_breakpointsMgr.HasBreakpoint(e.GetFileName(), e.GetInt()) ) {
            
            XDebugBreakpoint bp;
            m_breakpointsMgr.GetBreakpoint(e.GetFileName(), e.GetInt(), bp);
            if ( bp.IsApplied() && m_readerThread ) {
                // Remove it from XDebug as well
                DoDeleteBreakpoint( bp.GetBreakpointId() );
                
            }
            m_breakpointsMgr.DeleteBreakpoint( e.GetFileName(), e.GetInt() );
            
        } else {
            m_breakpointsMgr.AddBreakpoint( e.GetFileName(), e.GetInt() );
            DoApplyBreakpoints();
            
        }
        DoRefreshBreakpointsMarkersForEditor( editor );
    }
}
void NodeJSDebugger::OnToggleBreakpoint(clDebugEvent& event)
{
    event.Skip();
    if(NodeJSWorkspace::Get()->IsOpen()) {
        event.Skip(false);
        IEditor* editor = clGetManager()->GetActiveEditor();
        if(editor && (editor->GetFileName().GetFullPath() == event.GetFileName())) {
            // Correct editor
            // add marker
            NodeJSBreakpoint bp = m_bptManager.GetBreakpoint(event.GetFileName(), event.GetInt());
            if(bp.IsOk()) {
                if(bp.IsApplied() && IsConnected()) {
                    // Tell NodeJS to delete this breakpoint
                    DeleteBreakpoint(bp);
                }
                m_bptManager.DeleteBreakpoint(event.GetFileName(), event.GetInt());
            } else {
                // We have no breakpoint on this file/line (yet)
                m_bptManager.AddBreakpoint(event.GetFileName(), event.GetInt());
                bp = m_bptManager.GetBreakpoint(event.GetFileName(), event.GetInt());
                if(IsConnected()) {
                    SetBreakpoint(bp);
                }
            }

            // Update the UI
            m_bptManager.SetBreakpoints(editor);
            clDebugEvent event(wxEVT_NODEJS_DEBUGGER_UPDATE_BREAKPOINTS_VIEW);
            EventNotifier::Get()->AddPendingEvent(event);
        }
    }
}
Exemple #3
0
void LLDBPlugin::OnDebugAttachToProcess(clDebugEvent& event)
{
    if(event.GetDebuggerName() != LLDB_DEBUGGER_NAME) {
        event.Skip();
        return;
    }

#ifdef __WXMSW__
    ::wxMessageBox(
        _("Attach to process with LLDB is not supported under Windows"), "CodeLite", wxOK | wxCENTER | wxICON_WARNING);
    return;
#endif

    wxString terminalTitle;
    terminalTitle << "Console PID " << event.GetInt();
    if(!DoInitializeDebugger(event, true, terminalTitle))
        return;

    LLDBConnectReturnObject retObj;
    LLDBSettings settings;
    settings.Load();

    if(m_connector.Connect(retObj, settings, 5)) {

        // Apply the environment
        EnvSetter env;

        // remove all breakpoints from previous session
        m_connector.DeleteAllBreakpoints();
        LLDBSettings settings;
        settings.Load();

        // Attach to the process
        LLDBCommand command;
        command.SetCommandType(kCommandAttachProcess);
        command.SetProcessID(event.GetInt());
        command.SetSettings(settings);
        m_connector.AttachProcessWithPID(command);

    } else {
        // Failed to connect, notify and perform cleanup
        DoCleanup();
        wxString message;
        message << _("Could not connect to codelite-lldb at '") << m_connector.GetConnectString() << "'";
        ::wxMessageBox(message, "CodeLite", wxICON_ERROR | wxOK | wxCENTER);
        return;
    }
}
Exemple #4
0
void LLDBPlugin::OnToggleBreakpoint(clDebugEvent& event)
{
    // Call Skip() here since we want codelite to manage the breakpoint as well ( in term of serialization in the
    // session file )
    CHECK_IS_LLDB_SESSION();

    // check to see if we are removing a breakpoint or adding one
    LLDBBreakpoint::Ptr_t bp(new LLDBBreakpoint(event.GetFileName(), event.GetInt()));
    IEditor* editor = m_mgr->GetActiveEditor();

    if(editor) {
        // get the marker type set on the line
        int markerType = editor->GetCtrl()->MarkerGet(bp->GetLineNumber() - 1);
        for(size_t type = smt_FIRST_BP_TYPE; type <= smt_LAST_BP_TYPE; ++type) {
            int markerMask = (1 << type);
            if(markerType & markerMask) {
                // removing a breakpoint. "DeleteBreakpoint" will handle the interactive/non-interactive mode
                // of the debugger
                m_connector.MarkBreakpointForDeletion(bp);
                m_connector.DeleteBreakpoints();
                return;
            }
        }

        // if we got here, its a new breakpoint, add it
        // Add the breakpoint to the list of breakpoints
        m_connector.AddBreakpoint(bp->GetFilename(), bp->GetLineNumber());

        // apply it. In case the debugger can not interact with, it will be interrupted and the interrupt reason
        // will be set to ApplyBreakpoints
        m_connector.ApplyBreakpoints();
    }
}
Exemple #5
0
void NodeJSDebugger::OnAttach(clDebugEvent& event)
{
#ifdef __WXMSW__
    if(event.GetDebuggerName() != "NodeJS Debugger") {
        event.Skip();
        return;
    }
    event.Skip(false);
    ::wxMessageBox(_("Debugging a running Node.js process is only available on Linux / OSX"), "CodeLite",
                   wxICON_WARNING | wxCENTER | wxOK);
#else

    if(event.GetDebuggerName() != "NodeJS Debugger") {
        event.Skip();
        return;
    }

    event.Skip(false); // ours to handle, stop the event chain

    if(m_socket && m_socket->IsConnected()) {
        ::wxMessageBox(_("An active debug session is already running"), "CodeLite", wxICON_WARNING | wxCENTER | wxOK);
        return;
    };

    ::kill(event.GetInt(), SIGUSR1);
    // already connected?
    m_socket.Reset(new NodeJSSocket(this));
    m_socket->Connect("127.0.0.1", 5858);
#endif
}