# Path: debugger/analysis/source_analyser.py
# class SourceAnalyzer(object):
#     def __init__(self, file_path=None):
#         self.tu = None
#         self.file = None
# 
#         if file_path:
#             self.set_file(file_path)
# 
#     def _create_tu_from_file(self, file_path):
#         return cindex.TranslationUnit.from_source(file_path, [])
# 
#     def _get_location(self, offset, column=None):
#         if column:
#             return cindex.SourceLocation.from_position(self.tu, self.file,
#                                                        offset,
#                                                        column)
#         else:
#             return cindex.SourceLocation.from_offset(self.tu, self.file,
#                                                      offset)
# 
#     def set_file(self, file_path):
#         """
#         Parses the given file and returns whether the parsing was successful.
#         @type file_path: str
#         @rtype: bool
#         """
#         try:
#             self.tu = self._create_tu_from_file(file_path)
#             self.file = cindex.File.from_name(self.tu, file_path)
#             return True
#         except:
#             return False
# 
#     def get_symbol_name(self, line, column=None):
#         """
#         Get's name of a symbol defined on the given line and column.
#         Returns None if no symbol was found or if no file is loaded.
#         @type line: int
#         @type column: int
#         @rtype: str | None
#         """
#         if self.tu is None or self.file is None:
#             return None
# 
#         location = self._get_location(line, column)
#         cursor = cindex.Cursor.from_location(self.tu, location)
# 
#         return cursor.spelling
# 
# Path: debugger/util.py
# class EventBroadcaster(object):
#     """
#     Object that broadcasts event to it's listeners.
# 
#     Evety broadcaster represents a single event type.
#     """
#     def __init__(self):
#         self.listeners = []
# 
#     def notify(self, *args, **kwargs):
#         """
#         Notifies all listeners that an event has occured.
#         @param args: arbitraty arguments that will be passed to the listeners
#         """
#         map(lambda listener: listener(*args, **kwargs), self.listeners)
# 
#     def subscribe(self, listener):
#         """
#         Subscribes an event listener, who will receive events from the
#         broadcaster.
#         @type listener: function
#         """
#         self.listeners.append(listener)
# 
#     def unsubscribe(self, listener):
#         """
#         Unsubscribes an event listener.
#         It will no longer receive events after he unsubscribes.
#         @param listener: function
#         """
#         self.listeners.remove(listener)
# 
#     def clear(self):
#         """
#         Removes all event listeners.
#         """
#         self.listeners = []
# 
#     def redirect(self, broadcaster):
#         """
#         Redirects this broadcaster to the given broadcaster.
# 
#         All events fired by this broadcaster will be also delivered to the
#         given broadcaster.
#         @type broadcaster: EventBroadcaster
#         """
#         self.subscribe(broadcaster.notify)
# 
#     def __call__(self, *args, **kwargs):
#         self.notify(*args, **kwargs)
# 
# class Logger(object):
#     """
#     Helper class for logging.
#     """
#     logger = None
# 
#     @staticmethod
#     def init_logger(level):
#         logging.basicConfig()
#         Logger.logger = logging.getLogger("debugger")
#         Logger.logger.setLevel(level)
# 
#     @staticmethod
#     def debug(message, *args, **kwargs):
#         Logger.logger.debug(message, *args, **kwargs)
# 
#     @staticmethod
#     def info(message, *args, **kwargs):
#         Logger.logger.info(message, *args, **kwargs)
# 
# Path: debugger/enums.py
# class ProcessState(Enum):
#     """
#     Represents the debugged process' state.
#     """
#     Attaching = 3
#     Connected = 2
#     Crashed = 8
#     Detached = 9
#     Exited = 10
#     Invalid = 0
#     Launching = 4
#     Running = 6
#     Stepping = 7
#     Stopped = 5
#     Suspended = 11
#     Unloaded = 1
# 
# class DebuggerState(Enum):
#     """
#     Represents debugger state.
#     """
#     Started = 1
#     BinaryLoaded = 2
#     Running = 3


from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import Gtk
from gi.repository import GtkSource
from enum import Enum
from debugger.analysis.source_analyser import SourceAnalyzer
from debugger.util import EventBroadcaster, Logger
from debugger.enums import ProcessState, DebuggerState
from gui_util import run_on_gui, require_gui_thread
import os
import paths
        self.set_right_margin_position(80)

        self.file = None
        self.on_breakpoint_changed = EventBroadcaster()

        self.exec_line = None
        self.bp_lines = set()

        self.analyser = SourceAnalyzer()
        self.connect("motion-notify-event",
                     lambda widget, event: self._handle_mouse_move(event))
        self.connect("button-press-event",
                     lambda widget, event: self._handle_mouse_click(event))
        self.on_symbol_hover = EventBroadcaster()

        self.debugger.breakpoint_manager.on_breakpoint_changed.subscribe(
            self._handle_model_breakpoint_change)
        self.breakpoint_lines = []

    def _handle_model_breakpoint_change(self, breakpoint):
        """
        @type breakpoint: debugee.Breakpoint
        """
        self._refresh_breakpoints()

    def _refresh_breakpoints(self):
        lines = []

        if (self.file and
                self.debugger.state.is_set(DebuggerState.BinaryLoaded) and

# Path: debugger/analysis/source_analyser.py
# class SourceAnalyzer(object):
#     def __init__(self, file_path=None):
#         self.tu = None
#         self.file = None
# 
#         if file_path:
#             self.set_file(file_path)
# 
#     def _create_tu_from_file(self, file_path):
#         return cindex.TranslationUnit.from_source(file_path, [])
# 
#     def _get_location(self, offset, column=None):
#         if column:
#             return cindex.SourceLocation.from_position(self.tu, self.file,
#                                                        offset,
#                                                        column)
#         else:
#             return cindex.SourceLocation.from_offset(self.tu, self.file,
#                                                      offset)
# 
#     def set_file(self, file_path):
#         """
#         Parses the given file and returns whether the parsing was successful.
#         @type file_path: str
#         @rtype: bool
#         """
#         try:
#             self.tu = self._create_tu_from_file(file_path)
#             self.file = cindex.File.from_name(self.tu, file_path)
#             return True
#         except:
#             return False
# 
#     def get_symbol_name(self, line, column=None):
#         """
#         Get's name of a symbol defined on the given line and column.
#         Returns None if no symbol was found or if no file is loaded.
#         @type line: int
#         @type column: int
#         @rtype: str | None
#         """
#         if self.tu is None or self.file is None:
#             return None
# 
#         location = self._get_location(line, column)
#         cursor = cindex.Cursor.from_location(self.tu, location)
# 
#         return cursor.spelling
# 
# Path: debugger/util.py
# class EventBroadcaster(object):
#     """
#     Object that broadcasts event to it's listeners.
# 
#     Evety broadcaster represents a single event type.
#     """
#     def __init__(self):
#         self.listeners = []
# 
#     def notify(self, *args, **kwargs):
#         """
#         Notifies all listeners that an event has occured.
#         @param args: arbitraty arguments that will be passed to the listeners
#         """
#         map(lambda listener: listener(*args, **kwargs), self.listeners)
# 
#     def subscribe(self, listener):
#         """
#         Subscribes an event listener, who will receive events from the
#         broadcaster.
#         @type listener: function
#         """
#         self.listeners.append(listener)
# 
#     def unsubscribe(self, listener):
#         """
#         Unsubscribes an event listener.
#         It will no longer receive events after he unsubscribes.
#         @param listener: function
#         """
#         self.listeners.remove(listener)
# 
#     def clear(self):
#         """
#         Removes all event listeners.
#         """
#         self.listeners = []
# 
#     def redirect(self, broadcaster):
#         """
#         Redirects this broadcaster to the given broadcaster.
# 
#         All events fired by this broadcaster will be also delivered to the
#         given broadcaster.
#         @type broadcaster: EventBroadcaster
#         """
#         self.subscribe(broadcaster.notify)
# 
#     def __call__(self, *args, **kwargs):
#         self.notify(*args, **kwargs)
# 
# class Logger(object):
#     """
#     Helper class for logging.
#     """
#     logger = None
# 
#     @staticmethod
#     def init_logger(level):
#         logging.basicConfig()
#         Logger.logger = logging.getLogger("debugger")
#         Logger.logger.setLevel(level)
# 
#     @staticmethod
#     def debug(message, *args, **kwargs):
#         Logger.logger.debug(message, *args, **kwargs)
# 
#     @staticmethod
#     def info(message, *args, **kwargs):
#         Logger.logger.info(message, *args, **kwargs)
# 
# Path: debugger/enums.py
# class ProcessState(Enum):
#     """
#     Represents the debugged process' state.
#     """
#     Attaching = 3
#     Connected = 2
#     Crashed = 8
#     Detached = 9
#     Exited = 10
#     Invalid = 0
#     Launching = 4
#     Running = 6
#     Stepping = 7
#     Stopped = 5
#     Suspended = 11
#     Unloaded = 1
# 
# class DebuggerState(Enum):
#     """
#     Represents debugger state.
#     """
#     Started = 1
#     BinaryLoaded = 2
#     Running = 3


# Path: gui/source_edit.py
from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import Gtk
from gi.repository import GtkSource
from enum import Enum
from debugger.analysis.source_analyser import SourceAnalyzer
from debugger.util import EventBroadcaster, Logger
from debugger.enums import ProcessState, DebuggerState
from gui_util import run_on_gui, require_gui_thread
import os
import paths

        self.set_right_margin_position(80)

        self.file = None
        self.on_breakpoint_changed = EventBroadcaster()

        self.exec_line = None
        self.bp_lines = set()

        self.analyser = SourceAnalyzer()
        self.connect("motion-notify-event",
                     lambda widget, event: self._handle_mouse_move(event))
        self.connect("button-press-event",
                     lambda widget, event: self._handle_mouse_click(event))
        self.on_symbol_hover = EventBroadcaster()

        self.debugger.breakpoint_manager.on_breakpoint_changed.subscribe(
            self._handle_model_breakpoint_change)
        self.breakpoint_lines = []

    def _handle_model_breakpoint_change(self, breakpoint):
        """
        @type breakpoint: debugee.Breakpoint
        """
        self._refresh_breakpoints()

    def _refresh_breakpoints(self):
        lines = []

        if (self.file and
                self.debugger.state.is_set(DebuggerState.BinaryLoaded) and

                self.debugger.process_state != ProcessState.Running):