# Path: debugger/enums.py
# class DebuggerState(Enum):
#     """
#     Represents debugger state.
#     """
#     Started = 1
#     BinaryLoaded = 2
#     Running = 3


import gdb
import sys
from gdb_helper import GdbHelper
from gdb_thread_manager import GdbThreadManager
from gdb_frame_manager import GdbFrameManager
from gdb_file_manager import GdbFileManager
from gdb_breakpoint_manager import GdbBreakpointManager
from memory import Memory
from debugger.enums import DebuggerState
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Devi.  If not, see <http://www.gnu.org/licenses/>.
#





class GdbDebugger(object):
    def __init__(self, options):
        self.memory = Memory()
        self.gdb_helper = GdbHelper()
        self.thread_manager = GdbThreadManager()
        self.frame_manager = GdbFrameManager()
        self.file_manager = GdbFileManager()
        self.bp_manager = GdbBreakpointManager(self.before_bp, self.after_bp)
        # self.bp_manager.add_breakpoint("malloc", self.handle_malloc)
        # self.bp_manager.add_breakpoint("free", self.handle_free)

        self.set_options()
        gdb.events.exited.connect(self.handle_exit)

        if "valgrind_pid" in options:
            gdb.execute("target remote | vgdb --pid={}".format(
                options["valgrind_pid"]))


# Path: debugger/enums.py
# class DebuggerState(Enum):
#     """
#     Represents debugger state.
#     """
#     Started = 1
#     BinaryLoaded = 2
#     Running = 3


# Path: debugger/gdbc/gdb_debugger.py
import gdb
import sys
from gdb_helper import GdbHelper
from gdb_thread_manager import GdbThreadManager
from gdb_frame_manager import GdbFrameManager
from gdb_file_manager import GdbFileManager
from gdb_breakpoint_manager import GdbBreakpointManager
from memory import Memory
from debugger.enums import DebuggerState

#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Devi.  If not, see <http://www.gnu.org/licenses/>.
#





class GdbDebugger(object):
    def __init__(self, options):
        self.memory = Memory()
        self.gdb_helper = GdbHelper()
        self.thread_manager = GdbThreadManager()
        self.frame_manager = GdbFrameManager()
        self.file_manager = GdbFileManager()
        self.bp_manager = GdbBreakpointManager(self.before_bp, self.after_bp)
        # self.bp_manager.add_breakpoint("malloc", self.handle_malloc)
        # self.bp_manager.add_breakpoint("free", self.handle_free)

        self.set_options()
        gdb.events.exited.connect(self.handle_exit)

        if "valgrind_pid" in options:
            gdb.execute("target remote | vgdb --pid={}".format(
                options["valgrind_pid"]))


        self.change_state(DebuggerState.Started)