Пример #1
0
void LLDBDebuggerPlugin::OnDebugStart(clDebugEvent& event)
{
    event.Skip();
    return;
    
    if ( ::PromptForYesNoDialogWithCheckbox(_("Would you like to use LLDB debugger as your primary debugger?"), "UseLLDB") != wxID_YES ) {
        event.Skip();
        return;
    }
    
    // Get the executable to debug
    wxString errMsg;
    ProjectPtr pProject = WorkspaceST::Get()->FindProjectByName(event.GetProjectName(), errMsg);
    if ( !pProject ) {
        event.Skip();
        return;
    }
    
    wxSetWorkingDirectory ( pProject->GetFileName().GetPath() );
    BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf ( pProject->GetName(), wxEmptyString );
    if ( !bldConf ) {
        event.Skip();
        return;
    }
    
    // Show the terminal
    ShowTerminal("LLDB Console Window");
    if ( m_debugger.Start("/home/eran/devl/TestArea/TestHang/Debug/TestHang") ) {
        m_debugger.AddBreakpoint("main");
        m_debugger.ApplyBreakpoints();
        m_debugger.Run("/tmp/in", "/tmp/out", "/tmp/err", wxArrayString(), wxArrayString(), ::wxGetCwd());
    }
}
Пример #2
0
void NodeJSDebugger::OnDebugContinue(clDebugEvent& event)
{
    event.Skip();
    CHECK_RUNNING();
    event.Skip(false);
    Continue();
}
Пример #3
0
void NodeJSDebugger::OnCanInteract(clDebugEvent& event)
{
    event.Skip();
    CHECK_RUNNING();
    event.Skip(false);
    event.SetAnswer(IsCanInteract());
}
Пример #4
0
void NodeJSDebugger::OnVoid(clDebugEvent& event)
{
    event.Skip();
    CHECK_RUNNING();
    event.Skip(false);
    wxUnusedVar(event);
}
Пример #5
0
void NodeJSDebugger::OnDebugStart(clDebugEvent& event)
{
    event.Skip();
    CHECK_COND_RET(NodeJSWorkspace::Get()->IsOpen());

    // Our to handle
    event.Skip(false);
    if(m_socket && m_socket->IsConnected()) {
        Continue();
        return;
    };

    NodeJSDebuggerDlg dlg(EventNotifier::Get()->TopFrame(), NodeJSDebuggerDlg::kDebug);
    if(dlg.ShowModal() != wxID_OK) {
        return;
    }

    wxString command = dlg.GetCommand();

    if(!m_node.ExecuteConsole(command, "", false, command)) {
        ::wxMessageBox(_("Failed to start NodeJS application"), "CodeLite", wxOK | wxICON_ERROR | wxCENTER);
        m_socket.Reset(NULL);
    }

    // already connected?
    m_socket.Reset(new NodeJSSocket(this));
    NodeJSWorkspaceUser userConf(NodeJSWorkspace::Get()->GetFilename().GetFullPath());
    userConf.Load();
    m_socket->Connect("127.0.0.1", userConf.GetDebuggerPort());
}
Пример #6
0
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);
        }
    }
}
Пример #7
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
}
Пример #8
0
void LLDBPlugin::OnDebugContinue(clDebugEvent& event)
{
    event.Skip();
    if(m_connector.IsRunning()) {
        // we are the active debugger
        CL_DEBUG("CODELITE>> continue...");
        m_connector.Continue();
        event.Skip(false);
    }
}
Пример #9
0
void NodeJSDebugger::OnStopDebugger(clDebugEvent& event)
{
    event.Skip();
    CHECK_RUNNING();

    event.Skip(false);
    m_node.Terminate();
#if defined(__WXGTK__)||defined(__WXOSX__)
    ConnectionLost("Debug session stopped");
#endif
}
Пример #10
0
void DebuggerDisassemblyTab::OnDebuggerStopped(clDebugEvent& e)
{
    e.Skip();
    DoClearDisassembleView();
    DoClearRegistersView();
    m_oldValues.clear();
}
Пример #11
0
void NodeJSDebuggerPane::OnConsoleLog(clDebugEvent& event)
{
    event.Skip();
    m_consoleLog->AppendText(event.GetString());
    ::clRecalculateSTCHScrollBar(m_consoleLog);
    m_consoleLog->ScrollToEnd();
}
Пример #12
0
void LLDBPlugin::OnToggleInterrupt(clDebugEvent& event)
{
    CHECK_IS_LLDB_SESSION();
    event.Skip();
    CL_DEBUG("CODELITE: interrupting debuggee");
    if(!m_connector.IsCanInteract()) { m_connector.Interrupt(kInterruptReasonNone); }
}
Пример #13
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 );
    }
}
Пример #14
0
void WebTools::OnNodeJSDebuggerStarted(clDebugEvent& event)
{
    event.Skip();
    m_savePerspective = clGetManager()->GetDockingManager()->SavePerspective();

    // Show the debugger pane
    if(!m_nodejsDebuggerPane) {
        m_nodejsDebuggerPane = new NodeJSDebuggerPane(EventNotifier::Get()->TopFrame());
        clGetManager()->GetDockingManager()->AddPane(m_nodejsDebuggerPane,
                                                     wxAuiPaneInfo()
                                                         .Layer(5)
                                                         .Name("nodejs_debugger")
                                                         .Caption("Node.js Debugger")
                                                         .CloseButton(false)
                                                         .MaximizeButton()
                                                         .Bottom()
                                                         .Position(0));
    }

    wxString layout;
    wxFileName fnNodeJSLayout(clStandardPaths::Get().GetUserDataDir(), "nodejs.layout");
    fnNodeJSLayout.AppendDir("config");
    if(FileUtils::ReadFileContent(fnNodeJSLayout, layout)) {
        m_mgr->GetDockingManager()->LoadPerspective(layout);
    }
    EnsureAuiPaneIsVisible("nodejs_debugger", true);

    m_hideToolBarOnDebugStop = false;
    if(!m_mgr->AllowToolbar()) {
        // Using native toolbar
        m_hideToolBarOnDebugStop = !m_mgr->IsToolBarShown();
        m_mgr->ShowToolBar(true);
    }
}
Пример #15
0
void NodeJSDebuggerPane::OnExceptionThrown(clDebugEvent& event)
{
    event.Skip();
    ::wxMessageBox(_("An uncaught exception thrown!"), "CodeLite", wxICON_ERROR | wxOK | wxCENTER);
    NodeJSDebugger::Ptr_t debugger = NodeJSWorkspace::Get()->GetDebugger();
    if(!debugger) return;
    debugger->Callstack();
}
Пример #16
0
void NodeJSDebugger::OnDebugStepOut(clDebugEvent& event)
{
    event.Skip();
    CHECK_RUNNING();

    event.Skip(false);
    // Build the request
    JSONElement request = JSONElement::createObject();
    request.addProperty("type", "request");
    request.addProperty("command", "continue");
    JSONElement args = JSONElement::createObject("arguments");
    request.append(args);
    args.addProperty("stepaction", "out");
    args.addProperty("stepcount", 1); // how we tell nodejs to continue until next bp is hit?

    // Write the command
    m_socket->WriteRequest(request, new NodeJSContinueHandler());
}
Пример #17
0
void NodeJSDebugger::OnDebugIsRunning(clDebugEvent& event)
{
    if(m_socket && m_socket->IsConnected()) {
        event.SetAnswer(true);

    } else {
        event.Skip();
    }
}
Пример #18
0
void ConsoleFrame::OnDebuggerEnded(clDebugEvent& e)
{
#ifndef __WXMSW__
    m_manager->GetDockingManager()->DetachPane(this);
    Destroy();
    m_manager->GetDockingManager()->Update();
#endif
    e.Skip();
}
Пример #19
0
void NodeJSDebuggerPane::OnSessionStarted(clDebugEvent& event)
{
    event.Skip();
    m_consoleLog->ClearAll();
    LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexer("text");
    if(lexer) {
        lexer->Apply(m_consoleLog);
    }
}
Пример #20
0
void XDebugManager::OnDebugIsRunning(clDebugEvent& e)
{
    if ( m_readerThread ) {
        e.SetAnswer( true );
        
    } else {
        e.Skip();
    }
}
Пример #21
0
void XDebugManager::OnStopDebugger(clDebugEvent& e)
{
    if ( m_readerThread ) {
        // abort
        wxDELETE(m_readerThread);

    } else {
        e.Skip();
    }
}
Пример #22
0
void NodeJSDebugger::OnDebugStart(clDebugEvent& event)
{
    event.Skip();
    CHECK_COND_RET(NodeJSWorkspace::Get()->IsOpen());

    event.SetFeatures(0); // No special features by the NodeJS debugger

    // Our to handle
    event.Skip(false);
    if(m_socket && m_socket->IsConnected()) {
        Continue();
        return;
    };

    NodeJSDebuggerDlg dlg(EventNotifier::Get()->TopFrame(), NodeJSDebuggerDlg::kDebug);
    if(dlg.ShowModal() != wxID_OK) { return; }

    StartDebugger(dlg.GetCommand(), dlg.GetWorkingDirectory());
}
Пример #23
0
void NodeJSDebuggerPane::OnUpdateCallstack(clDebugEvent& event)
{
    event.Skip();
    wxWindowUpdateLocker locker(m_dataviewLocals);
    ClearCallstack();

    JSONRoot root(event.GetString());
    JSONElement frames = root.toElement().namedObject("body").namedObject("frames");
    JSONElement refs = root.toElement().namedObject("refs");

    // Load the handlers into a map
    m_handles.clear();
    ParseRefsArray(refs);

    int count = frames.arraySize();
    for(int i = 0; i < count; ++i) {
        JSONElement frame = frames.arrayItem(i);
        int index = frame.namedObject("index").toInt();
        int funcRef = frame.namedObject("func").namedObject("ref").toInt();
        int fileRef = frame.namedObject("script").namedObject("ref").toInt();
        int line = frame.namedObject("line").toInt() + 1;

        wxVector<wxVariant> cols;
        cols.push_back(wxString() << index);
        wxString file, func;
        if(m_handles.count(funcRef)) {
            func = m_handles.find(funcRef)->second.value;
        }
        if(m_handles.count(funcRef)) {
            file = m_handles.find(fileRef)->second.value;
        }
        cols.push_back(func);
        cols.push_back(file);
        cols.push_back(wxString() << line);

        FrameData* cd = new FrameData();
        cd->file = file;
        cd->line = line;
        cd->function = func;
        cd->index = i;
        m_dvListCtrlCallstack->AppendItem(cols, (wxUIntPtr)cd);

        if(i == 0) {
            // Notify the debugger to use frame #0 for the indicator
            clDebugEvent event(wxEVT_NODEJS_DEBUGGER_MARK_LINE);
            event.SetLineNumber(line);
            event.SetFileName(file);
            EventNotifier::Get()->AddPendingEvent(event);
            BuildLocals(frame);
            BuildArguments(frame);
        }
    }
}
Пример #24
0
void NodeJSDebugger::OnTooltip(clDebugEvent& event)
{
    event.Skip();
    CHECK_RUNNING();
    event.Skip(false);

    CHECK_PTR_RET(clGetManager()->GetActiveEditor());

    wxString selection = event.GetString();
    CHECK_COND_RET(!selection.IsEmpty());

    // Build the request
    JSONElement request = JSONElement::createObject();
    request.addProperty("type", "request");
    request.addProperty("command", "evaluate");
    JSONElement args = JSONElement::createObject("arguments");
    request.append(args);
    args.addProperty("expression", selection);

    // Write the command
    m_socket->WriteRequest(request, new NodeJSEvaluateExprHandler(selection));
}
Пример #25
0
void NodeJSDebugger::OnEvalExpression(clDebugEvent& event)
{
    event.Skip();

    // Build the request
    JSONElement request = JSONElement::createObject();
    request.addProperty("type", "request");
    request.addProperty("command", "evaluate");
    JSONElement args = JSONElement::createObject("arguments");
    request.append(args);
    args.addProperty("expression", event.GetString());

    // Write the command
    m_socket->WriteRequest(request, new NodeJSEvaluateExprHandler(event.GetString(), kNodeJSContextConsole));
}
Пример #26
0
void NodeJSDebuggerPane::OnUpdateDebuggerView(clDebugEvent& event)
{
    event.Skip();
    NodeJSDebugger::Ptr_t debugger = NodeJSWorkspace::Get()->GetDebugger();
    if(!debugger) return;
    m_dvListCtrlBreakpoints->DeleteAllItems();
    const NodeJSBreakpoint::List_t& breakpoints = debugger->GetBreakpointsMgr()->GetBreakpoints();
    std::for_each(breakpoints.begin(), breakpoints.end(), [&](const NodeJSBreakpoint& bp) {
        wxVector<wxVariant> cols;
        cols.push_back(wxString() << bp.GetNodeBpID());
        cols.push_back(wxString() << bp.GetLine());
        cols.push_back(bp.GetFilename());
        m_dvListCtrlBreakpoints->AppendItem(cols);
    });
}
Пример #27
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;
    }
}
Пример #28
0
void XDebugManager::OnDebugStartOrContinue(clDebugEvent& e)
{
    if ( !PHPWorkspace::Get()->IsOpen() ) {
        e.Skip();
        return;
    }
    
    // a PHP debug session requested to start
    if ( !m_readerThread ) {
        // starting the debugger
        DoStartDebugger();
        
    } else {
        DoContinue();
    }
}
Пример #29
0
void WebTools::OnNodeJSDebuggerStopped(clDebugEvent& event)
{
    event.Skip();

    wxFileName fnNodeJSLayout(clStandardPaths::Get().GetUserDataDir(), "nodejs.layout");
    fnNodeJSLayout.AppendDir("config");
    FileUtils::WriteFileContent(fnNodeJSLayout, m_mgr->GetDockingManager()->SavePerspective());

    if(!m_savePerspective.IsEmpty()) {
        m_mgr->GetDockingManager()->LoadPerspective(m_savePerspective);
        m_savePerspective.clear();
    }

    if(m_hideToolBarOnDebugStop) {
        m_mgr->ShowToolBar(false);
    }
}
Пример #30
0
void LLDBPlugin::OnDebugCoreFile(clDebugEvent& event)
{
    if(event.GetDebuggerName() != LLDB_DEBUGGER_NAME) {
        event.Skip();
        return;
    }

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

    if(!DoInitializeDebugger(event, false)) {
        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();

        LLDBCommand startCommand;
        startCommand.FillEnvFromMemory();
        startCommand.SetCommandType(kCommandDebugCoreFile);
        startCommand.SetExecutable(event.GetExecutableName());
        startCommand.SetCorefile(event.GetCoreFile());
        startCommand.SetWorkingDirectory(event.GetWorkingDirectory());
        startCommand.SetRedirectTTY(m_terminalTTY);
        m_connector.OpenCoreFile(startCommand);
    } 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;
    }
}