# Path: debugger/debugee.py
# class HeapBlock(object):
#     def __init__(self, address, size):
#         """
#         @type address: str
#         @type size: int
#         """
#         self.address = address
#         self.size = size
# 
#     def __repr__(self):
#         return "[{}: {} bytes]".format(self.address, self.size)
# 
# Path: debugger/debugger_api.py
# class ProcessExitedEventData(object):
# class ProcessStoppedEventData(object):
# class StartupInfo(object):
# class HeapManager(object):
# class IOManager(object):
# class BreakpointManager(object):
# class FileManager(object):
# class ThreadManager(object):
# class VariableManager(object):
# class Debugger(object):
#     def __init__(self, return_code):
#     def __init__(self, stop_reason):
#     def __init__(self, cmd_arguments="", working_directory="", env_vars=None):
#     def copy(self):
#     def __repr__(self):
#     def __init__(self, debugger):
#     def watch(self):
#     def stop(self):
#     def find_block_by_address(self, addr):
#     def get_total_allocations(self):
#     def get_total_deallocations(self):
#     def __init__(self):
#     def handle_io(self):
#     def stop_io(self):
#     def __init__(self, debugger):
#     def add_breakpoint(self, location, line):
#     def toggle_breakpoint(self, location, line):
#     def get_breakpoints(self):
#     def find_breakpoint(self, location, line):
#     def remove_breakpoint(self, location, line):
#     def __init__(self, debugger):
#     def get_main_source_file(self):
#     def get_current_location(self):
#     def get_line_address(self, filename, line):
#     def disassemble(self, filename, line):
#     def disassemble_raw(self, filename, line):
#     def __init__(self, debugger):
#     def get_current_thread(self):
#     def get_thread_info(self):
#     def set_thread_by_index(self, thread_id):
#     def get_current_frame(self, with_variables=False):
#     def get_frames(self):
#     def get_frames_with_variables(self):
#     def change_frame(self, frame_index):
#     def __init__(self, debugger):
#     def get_type(self, expression, level=0):
#     def get_variable(self, expression, level=0):
#     def update_variable(self, variable):
#     def get_memory(self, address, count):
#     def get_registers(self):
#     def get_vector_items(self, vector):
#     def __init__(self):
#     def require_state(self, required_state):
#     def get_state(self):
#     def get_process_state(self):
#     def load_binary(self, binary_path):
#     def launch(self, startup_info=None):
#     def exec_continue(self):
#     def exec_pause(self):
#     def exec_step_over(self):
#     def exec_step_in(self):
#     def exec_step_out(self):
#     def quit_program(self, return_code=1):
#     def terminate(self):
#     def wait_for_stop(self):
#     def wait_for_exit(self):
# 
# Path: debugger/util.py
# def create_pipe():
# def get_root_path(path):
#     def init_logger(level):
#     def debug(message, *args, **kwargs):
#     def info(message, *args, **kwargs):
#     def __init__(self, time, callback):
#     def _callback(self):
#     def stop_repeating(self):
#     def dispatch(root_object, properties=None, arguments=None):
#     def __init__(self, required_state, current_state):
#     def __init__(self, enum_cls, initial_value=0):
#     def _check_cls(self, obj):
#     def set(self, value):
#     def unset(self, value):
#     def is_set(self, value):
#     def get_value(self):
#     def clear(self):
#     def __repr__(self):
#     def __init__(self):
#     def notify(self, *args, **kwargs):
#     def subscribe(self, listener):
#     def unsubscribe(self, listener):
#     def clear(self):
#     def redirect(self, broadcaster):
#     def __call__(self, *args, **kwargs):
#     def __init__(self, name=""):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
#     def __init__(self):
#     def stop(self):
#     def add_job(self, fn, args, callback):
#     def _do_work(self):
# class Logger(object):
# class RepeatTimer(Thread):
# class Dispatcher(object):
# class BadStateError(Exception):
# class Flags(object):
# class EventBroadcaster(object):
# class Profiler(object):
# class Worker(Thread):
#     WORKER_ID = 0
# 
# Path: debugger/util.py
# 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)


import os
import threading
import select
import traceback
from debugger.debugee import HeapBlock
from debugger import debugger_api, util
from debugger.util import Logger


class HeapManager(debugger_api.HeapManager):
    def __init__(self, debugger):
        """
        @type debugger: debugger.Debugger
        """
        super(HeapManager, self).__init__(debugger)
        self.heap = []
        """@type heap: list of HeapBlock"""

        self.total_allocations = 0
        self.total_deallocations = 0

        self.read_thread = None
        self.alloc_path = None
        self.file = None
        self.stop_flag = threading.Event()

    def watch(self):
        """
        @rtype: str
        """
        assert self.read_thread is None

        self.total_allocations = 0
        self.total_deallocations = 0

        self.stop_flag.clear()


# Path: debugger/debugee.py
# class HeapBlock(object):
#     def __init__(self, address, size):
#         """
#         @type address: str
#         @type size: int
#         """
#         self.address = address
#         self.size = size
# 
#     def __repr__(self):
#         return "[{}: {} bytes]".format(self.address, self.size)
# 
# Path: debugger/debugger_api.py
# class ProcessExitedEventData(object):
# class ProcessStoppedEventData(object):
# class StartupInfo(object):
# class HeapManager(object):
# class IOManager(object):
# class BreakpointManager(object):
# class FileManager(object):
# class ThreadManager(object):
# class VariableManager(object):
# class Debugger(object):
#     def __init__(self, return_code):
#     def __init__(self, stop_reason):
#     def __init__(self, cmd_arguments="", working_directory="", env_vars=None):
#     def copy(self):
#     def __repr__(self):
#     def __init__(self, debugger):
#     def watch(self):
#     def stop(self):
#     def find_block_by_address(self, addr):
#     def get_total_allocations(self):
#     def get_total_deallocations(self):
#     def __init__(self):
#     def handle_io(self):
#     def stop_io(self):
#     def __init__(self, debugger):
#     def add_breakpoint(self, location, line):
#     def toggle_breakpoint(self, location, line):
#     def get_breakpoints(self):
#     def find_breakpoint(self, location, line):
#     def remove_breakpoint(self, location, line):
#     def __init__(self, debugger):
#     def get_main_source_file(self):
#     def get_current_location(self):
#     def get_line_address(self, filename, line):
#     def disassemble(self, filename, line):
#     def disassemble_raw(self, filename, line):
#     def __init__(self, debugger):
#     def get_current_thread(self):
#     def get_thread_info(self):
#     def set_thread_by_index(self, thread_id):
#     def get_current_frame(self, with_variables=False):
#     def get_frames(self):
#     def get_frames_with_variables(self):
#     def change_frame(self, frame_index):
#     def __init__(self, debugger):
#     def get_type(self, expression, level=0):
#     def get_variable(self, expression, level=0):
#     def update_variable(self, variable):
#     def get_memory(self, address, count):
#     def get_registers(self):
#     def get_vector_items(self, vector):
#     def __init__(self):
#     def require_state(self, required_state):
#     def get_state(self):
#     def get_process_state(self):
#     def load_binary(self, binary_path):
#     def launch(self, startup_info=None):
#     def exec_continue(self):
#     def exec_pause(self):
#     def exec_step_over(self):
#     def exec_step_in(self):
#     def exec_step_out(self):
#     def quit_program(self, return_code=1):
#     def terminate(self):
#     def wait_for_stop(self):
#     def wait_for_exit(self):
# 
# Path: debugger/util.py
# def create_pipe():
# def get_root_path(path):
#     def init_logger(level):
#     def debug(message, *args, **kwargs):
#     def info(message, *args, **kwargs):
#     def __init__(self, time, callback):
#     def _callback(self):
#     def stop_repeating(self):
#     def dispatch(root_object, properties=None, arguments=None):
#     def __init__(self, required_state, current_state):
#     def __init__(self, enum_cls, initial_value=0):
#     def _check_cls(self, obj):
#     def set(self, value):
#     def unset(self, value):
#     def is_set(self, value):
#     def get_value(self):
#     def clear(self):
#     def __repr__(self):
#     def __init__(self):
#     def notify(self, *args, **kwargs):
#     def subscribe(self, listener):
#     def unsubscribe(self, listener):
#     def clear(self):
#     def redirect(self, broadcaster):
#     def __call__(self, *args, **kwargs):
#     def __init__(self, name=""):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
#     def __init__(self):
#     def stop(self):
#     def add_job(self, fn, args, callback):
#     def _do_work(self):
# class Logger(object):
# class RepeatTimer(Thread):
# class Dispatcher(object):
# class BadStateError(Exception):
# class Flags(object):
# class EventBroadcaster(object):
# class Profiler(object):
# class Worker(Thread):
#     WORKER_ID = 0
# 
# Path: debugger/util.py
# 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/mi/heap_manager.py
import os
import threading
import select
import traceback
from debugger.debugee import HeapBlock
from debugger import debugger_api, util
from debugger.util import Logger



class HeapManager(debugger_api.HeapManager):
    def __init__(self, debugger):
        """
        @type debugger: debugger.Debugger
        """
        super(HeapManager, self).__init__(debugger)
        self.heap = []
        """@type heap: list of HeapBlock"""

        self.total_allocations = 0
        self.total_deallocations = 0

        self.read_thread = None
        self.alloc_path = None
        self.file = None
        self.stop_flag = threading.Event()

    def watch(self):
        """
        @rtype: str
        """
        assert self.read_thread is None

        self.total_allocations = 0
        self.total_deallocations = 0

        self.stop_flag.clear()


        self.alloc_path = util.create_pipe()