コード例 #1
0
    def ensure_lldb_is_running(cls, w=None):
        """Returns True if lldb is running (we don't care if we started it or not).
    Returns False on error"""
        # Ensure we reflect any changes to saved settings (including project settings)
        # reload_settings()

        if not w and window_ref():
            w = window_ref()
        else:
            # We're redefining the default window.
            set_window_ref(w)

        if driver_instance() is None:
            sm = SettingsManager.getSM()
            clear_view_on_startup = sm.get_default('i/o.view.clear_on_startup',
                                                   True)
            if clear_view_on_startup:
                LLDBLayoutManager.clear_view(lldb_out_view())

            if not cls.start_debugging(w):
                return False

            set_ui_updater(LLDBUIUpdater())
            g = cls.lldb_greeting()
            if lldb_out_view().size() > 0:
                g = '\n\n' + cls.lldb_greeting()
            lldb_view_write(g)
            lldb_view_write('cwd: ' + os.getcwd() + '\n')
            w.set_view_index(lldb_out_view(), 1, 0)

            cls.debug_prologue(driver_instance())
            return True

        return True
コード例 #2
0
    def ensure_lldb_is_running(cls, w=None):
        """Returns True if lldb is running (we don't care if we started it or not).
    Returns False on error"""
        # Ensure we reflect any changes to saved settings (including project settings)
        # reload_settings()

        if not w and window_ref():
            w = window_ref()
        else:
            # We're redefining the default window.
            set_window_ref(w)

        if driver_instance() is None:
            sm = SettingsManager.getSM()
            clear_view_on_startup = sm.get_default('i/o.view.clear_on_startup', True)
            if clear_view_on_startup:
                LLDBLayoutManager.clear_view(lldb_out_view())

            if not cls.start_debugging(w):
                return False

            set_ui_updater(LLDBUIUpdater())
            g = cls.lldb_greeting()
            if lldb_out_view().size() > 0:
                g = '\n\n' + cls.lldb_greeting()
            lldb_view_write(g)
            lldb_view_write('cwd: ' + os.getcwd() + '\n')
            w.set_view_index(lldb_out_view(), 1, 0)

            cls.debug_prologue(driver_instance())
            return True

        return True
コード例 #3
0
    def start_debugging(cls, w):
        global _is_debugging
        if _is_debugging:
            cls.cleanup(window_ref())

        cls.initialize_plugin()

        # Check for error conditions before starting the debugger
        global _did_not_find_debugserver, _macosx_is_too_old, _os_not_supported
        if _did_not_find_debugserver:
            sublime.error_message("Couldn't find the debugserver binary.\n" +  \
                        'Is XCode.app or the command line tools installed?')
            return False
        if _macosx_is_too_old:
            sublime.error_message('Your Mac OS X version is not supported.\n' +  \
                        'Supported versions: Lion and more recent\n\n' +        \
                        'If you think it should be supported, please contact the author.')
            return False
        if _os_not_supported:
            sublime.error_message('Your operating system is not supported by this plugin yet.\n' +          \
                        'If there is a stable version of lldb for your operating system and you would ' +   \
                        'like to have the plugin support it, please contact the author.')
            return False

        _is_debugging = True

        # Really start the debugger
        cls.initialize_lldb(w)

        driver_instance().debugger.SetInputFileHandle(sys.__stdin__, False)

        # We may also need to change the width upon window resize
        # debugger.SetTerminalWidth()
        return True
コード例 #4
0
 def set_lldb_window_layout(cls, window=window_ref()):
     sm = SettingsManager.getSM()
     lldb_window_layout = sm.get_default('layout',
                                         _default_lldb_window_layout)
     if lldb_out_view() != None and window.num_groups() != len(
             lldb_window_layout['cells']):
         window.run_command('set_layout', lldb_window_layout)
コード例 #5
0
    def start_debugging(cls, w):
        global _is_debugging
        if _is_debugging:
            cls.cleanup(window_ref())

        cls.initialize_plugin()

        # Check for error conditions before starting the debugger
        global _did_not_find_debugserver, _macosx_is_too_old, _os_not_supported
        if _did_not_find_debugserver:
            sublime.error_message("Couldn't find the debugserver binary.\n" +  \
                        'Is XCode.app or the command line tools installed?')
            return False
        if _macosx_is_too_old:
            sublime.error_message('Your Mac OS X version is not supported.\n' +  \
                        'Supported versions: Lion and more recent\n\n' +        \
                        'If you think it should be supported, please contact the author.')
            return False
        if _os_not_supported:
            sublime.error_message('Your operating system is not supported by this plugin yet.\n' +          \
                        'If there is a stable version of lldb for your operating system and you would ' +   \
                        'like to have the plugin support it, please contact the author.')
            return False

        _is_debugging = True

        # Really start the debugger
        cls.initialize_lldb(w)

        driver_instance().debugger.SetInputFileHandle(sys.__stdin__, False)

        # We may also need to change the width upon window resize
        # debugger.SetTerminalWidth()
        return True
コード例 #6
0
def process_stopped(driver, process, state=None):
    ui_updater().process_stopped(state, lambda: driver.maybe_get_input())

    # Open a new view on source code/disassembly, if needed.
    if process and driver.process_is_stopped(process):
        filespec = None
        line_entry = process.GetSelectedThread().GetSelectedFrame(
        ).GetLineEntry()
        if line_entry:
            # We don't need to run 'process status' like Driver.cpp
            # Since we open the file and show the source line.
            r = driver.interpret_command('thread list')
            lldb_view_send(stdout_msg(r[0].GetOutput()))
            lldb_view_send(stderr_msg(r[0].GetError()))
            r = driver.interpret_command('frame info')
            lldb_view_send(stdout_msg(r[0].GetOutput()))
            lldb_view_send(stderr_msg(r[0].GetError()))

            filespec = line_entry.GetFileSpec()
        else:
            # Give us some assembly to check the crash/stop
            r = driver.interpret_command('process status')
            lldb_view_send(stdout_msg(r[0].GetOutput()))
            lldb_view_send(stderr_msg(r[0].GetError()))
            if not line_entry:
                # Get ALL the SBFrames
                t = process.GetSelectedThread()
                n = t.GetNumFrames()
                for i in xrange(0, n):
                    f = t.GetFrameAtIndex(i)
                    if f:
                        line_entry = f.GetLineEntry()
                        if line_entry and line_entry.GetFileSpec():
                            filespec = line_entry.GetFileSpec()

        if filespec:
            filename = filespec.GetDirectory() + '/' + filespec.GetFilename()

            # Maybe we don't need to focus the first group. The user knows
            # what he/she wants.

            def to_ui_thread():
                window_ref().focus_group(0)
                v = window_ref().open_file(filename)
                lldb_view = get_lldb_view_for(v)
                if lldb_view is None:
                    lldb_view = LLDBCodeView(v, driver)
                # TODO: Maybe bring the view to the front?

            sublime.set_timeout(to_ui_thread, 0)
        else:
            # TODO: If we don't have a filespec, we can try to disassemble
            # around the thread's PC.
            sublime.set_timeout(
                lambda: window_ref().
                run_command('lldb_disassemble_frame',
                            {'thread': process.GetSelectedThread()}), 0)
コード例 #7
0
def process_stopped(driver, process, state=None):
    ui_updater().process_stopped(state, lambda: driver.maybe_get_input())

    # Open a new view on source code/disassembly, if needed.
    if process and driver.process_is_stopped(process):
        filespec = None
        line_entry = process.GetSelectedThread().GetSelectedFrame().GetLineEntry()
        if line_entry:
            # We don't need to run 'process status' like Driver.cpp
            # Since we open the file and show the source line.
            r = driver.interpret_command('thread list')
            lldb_view_send(stdout_msg(r[0].GetOutput()))
            lldb_view_send(stderr_msg(r[0].GetError()))
            r = driver.interpret_command('frame info')
            lldb_view_send(stdout_msg(r[0].GetOutput()))
            lldb_view_send(stderr_msg(r[0].GetError()))

            filespec = line_entry.GetFileSpec()
        else:
            # Give us some assembly to check the crash/stop
            r = driver.interpret_command('process status')
            lldb_view_send(stdout_msg(r[0].GetOutput()))
            lldb_view_send(stderr_msg(r[0].GetError()))
            if not line_entry:
                # Get ALL the SBFrames
                t = process.GetSelectedThread()
                n = t.GetNumFrames()
                for i in xrange(0, n):
                    f = t.GetFrameAtIndex(i)
                    if f:
                        line_entry = f.GetLineEntry()
                        if line_entry and line_entry.GetFileSpec():
                            filespec = line_entry.GetFileSpec()

        if filespec:
            filename = filespec.GetDirectory() + '/' + filespec.GetFilename()
            # Maybe we don't need to focus the first group. The user knows
            # what he/she wants.

            def to_ui_thread():
                window_ref().focus_group(0)
                v = window_ref().open_file(filename)
                lldb_view = get_lldb_view_for(v)
                if lldb_view is None:
                    lldb_view = LLDBCodeView(v, driver)
                # TODO: Maybe bring the view to the front?
            sublime.set_timeout(to_ui_thread, 0)
        else:
            # TODO: If we don't have a filespec, we can try to disassemble
            # around the thread's PC.
            sublime.set_timeout(lambda:
                window_ref().run_command('lldb_disassemble_frame', {'thread': process.GetSelectedThread()}), 0)
コード例 #8
0
 def to_ui_thread():
     window_ref().focus_group(0)
     v = window_ref().open_file(filename)
     lldb_view = get_lldb_view_for(v)
     if lldb_view is None:
         lldb_view = LLDBCodeView(v, driver)
コード例 #9
0
def unload_handler():
    debug(debugPlugin, 'unloading lldb plugin')
    LLDBPlugin.cleanup(window_ref())
コード例 #10
0
def atexit_function():
    debug(debugPlugin, 'running atexit_function')
    LLDBPlugin.cleanup(window_ref())
コード例 #11
0
 def set_regular_window_layout(cls, window=window_ref()):
     sm = SettingsManager.getSM()
     basic_layout = sm.get_default('layout.basic',
                                   _default_basic_window_layout)
     window.run_command('set_layout', basic_layout)
コード例 #12
0
 def good_lldb_layout(cls, window=window_ref()):
     # if the user already has two groups, it's a good layout
     sm = SettingsManager.getSM()
     lldb_window_layout = sm.get_default('layout',
                                         _default_lldb_window_layout)
     return window.num_groups() == len(lldb_window_layout['cells'])
コード例 #13
0
 def to_ui_thread():
     window_ref().focus_group(0)
     v = window_ref().open_file(filename)
     lldb_view = get_lldb_view_for(v)
     if lldb_view is None:
         lldb_view = LLDBCodeView(v, driver)
コード例 #14
0
def unload_handler():
    debug(debugPlugin, 'unloading lldb plugin')
    LLDBPlugin.cleanup(window_ref())
コード例 #15
0
def atexit_function():
    debug(debugPlugin, 'running atexit_function')
    LLDBPlugin.cleanup(window_ref())
コード例 #16
0
 def set_regular_window_layout(cls, window=window_ref()):
     sm = SettingsManager.getSM()
     basic_layout = sm.get_default('layout.basic', _default_basic_window_layout)
     window.run_command('set_layout', basic_layout)
コード例 #17
0
 def set_lldb_window_layout(cls, window=window_ref()):
     sm = SettingsManager.getSM()
     lldb_window_layout = sm.get_default('layout', _default_lldb_window_layout)
     if lldb_out_view() != None and window.num_groups() != len(lldb_window_layout['cells']):
         window.run_command('set_layout', lldb_window_layout)
コード例 #18
0
 def good_lldb_layout(cls, window=window_ref()):
     # if the user already has two groups, it's a good layout
     sm = SettingsManager.getSM()
     lldb_window_layout = sm.get_default('layout', _default_lldb_window_layout)
     return window.num_groups() == len(lldb_window_layout['cells'])