File: LLDBProcessEventHandlerThread.cpp

package info (click to toggle)
codelite 6.1.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 48,992 kB
  • ctags: 43,502
  • sloc: cpp: 334,263; ansic: 18,441; xml: 4,713; yacc: 2,653; lex: 2,449; python: 1,188; sh: 385; makefile: 40
file content (133 lines) | stat: -rw-r--r-- 4,875 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright            : (C) 2014 The CodeLite Team
// file name            : LLDBProcessEventHandlerThread.cpp
//
// -------------------------------------------------------------------------
// A
//              _____           _      _     _ _
//             /  __ \         | |    | |   (_) |
//             | /  \/ ___   __| | ___| |    _| |_ ___
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
//              \____/\___/ \__,_|\___\_____/_|\__\___|
//
//                                                  F i l e
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

#ifndef __WXMSW__

#include "LLDBProcessEventHandlerThread.h"
#include "file_logger.h"
#include "CodeLiteLLDBApp.h"
#include <lldb/API/SBEvent.h>
#include <wx/wxcrtvararg.h>

LLDBProcessEventHandlerThread::LLDBProcessEventHandlerThread(CodeLiteLLDBApp* app,
        lldb::SBDebugger& debugger,
        lldb::SBProcess process,
        eLLDBDebugSessionType sessionType)
    : wxThread(wxTHREAD_JOINABLE)
    , m_app(app)
    , m_process(process)
    , m_debugger( debugger )
    , m_sessionType(sessionType)
{
    m_listener = m_debugger.GetListener();
}

LLDBProcessEventHandlerThread::~LLDBProcessEventHandlerThread()
{
    wxPrintf("codelite-lldb: Process Event Handler thread is going down...\n");
    if ( IsAlive() ) {
        Delete(NULL, wxTHREAD_WAIT_BLOCK);
    } else {
        Wait(wxTHREAD_WAIT_BLOCK);
    }
    wxPrintf("codelite-lldb: Process Event Handler thread is going down...done\n");
}

#define DEBUG_MSG(s) wxPrintf("codelite-lldb: %s\n", s)

void* LLDBProcessEventHandlerThread::Entry()
{
    bool first_time_stopped = true;
    DEBUG_MSG("LLDB Thread: started");
    //m_listener.StartListeningForEventClass(m_debugger, lldb::SBTarget::GetBroadcasterClassName(), lldb::SBTarget::eBroadcastBitBreakpointChanged);
    while ( !TestDestroy() ) {
        lldb::SBEvent event;
        if ( m_listener.WaitForEvent(1, event) && event.IsValid() ) {
            lldb::StateType state = m_process.GetStateFromEvent( event );
            switch ( state ) {
            case lldb::eStateInvalid:
                DEBUG_MSG("LLDBHandlerThread: eStateInvalid");
                break;

            case lldb::eStateUnloaded:
                DEBUG_MSG("LLDBHandlerThread: eStateUnloaded");
                break;

            case lldb::eStateStopped:
                if ( first_time_stopped && m_sessionType != kDebugSessionTypeCore ) {
                    first_time_stopped = false;
                    DEBUG_MSG("LLDBHandlerThread: eStateStopped - first time");
                    m_app->CallAfter( &CodeLiteLLDBApp::NotifyStoppedOnFirstEntry );

                } else {
                    DEBUG_MSG("LLDBHandlerThread: eStateStopped");
                    m_app->CallAfter( &CodeLiteLLDBApp::NotifyStopped );
                    m_app->CallAfter( &CodeLiteLLDBApp::NotifyBreakpointsUpdated );
                }
                break;

            case lldb::eStateConnected:
                DEBUG_MSG("LLDBHandlerThread: eStateConnected");
                break;

            case lldb::eStateLaunching:
                DEBUG_MSG("LLDBHandlerThread: eStateLaunching");
                break;

            case lldb::eStateRunning:
                m_app->CallAfter( &CodeLiteLLDBApp::NotifyRunning );
                DEBUG_MSG("LLDBHandlerThread: eStateRunning");
                break;

            case lldb::eStateExited:
                DEBUG_MSG("LLDBHandlerThread: eStateExited");
                m_app->CallAfter( &CodeLiteLLDBApp::NotifyExited );
                break;

            case lldb::eStateAttaching:
                DEBUG_MSG("LLDBHandlerThread: eStateAttaching");
                break;

            case lldb::eStateStepping:
                DEBUG_MSG("LLDBHandlerThread: eStateStepping");
                break;

            case lldb::eStateCrashed:
                DEBUG_MSG("LLDBHandlerThread: eStateCrashed");
                break;

            case lldb::eStateDetached:
                DEBUG_MSG("LLDBHandlerThread: eStateDetached");
                break;

            case lldb::eStateSuspended:
                DEBUG_MSG("LLDBHandlerThread: eStateSuspended");
                break;
            }
        }
    }
    return NULL;
}
#endif // !__WXMSW__