-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathgdbfrontend.py
81 lines (61 loc) · 2.05 KB
/
gdbfrontend.py
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
# -*- coding: utf-8 -*-
#
# gdb-frontend is a easy, flexible and extensionable gui debugger
#
# https://github.com/rohanrhu/gdb-frontend
# https://oguzhaneroglu.com/projects/gdb-frontend/
#
# Licensed under GNU/GPLv3
# Copyright (C) 2019, Oğuzhan Eroğlu (https://oguzhaneroglu.com/) <[email protected]>
import threading
import importlib
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "python-libs"))
import config
sys.path.insert(0, config.PLUGINS_DIR)
import settings
import http_server
import http_handler
import websocket
import api.globalvars
import plugin
import util
import urls
import api.url
import commands
import debug_events
gdb = importlib.import_module("gdb")
try: gdb.execute("set confirm off")
except gdb.error as e: util.verbose(e)
try: gdb.execute("set non-stop off")
except gdb.error as e: util.verbose(e)
try: gdb.execute("set pagination off")
except gdb.error as e: util.verbose(e)
gdb.execute("shell tmux set-option status off")
gdb.execute("shell tmux set-option mouse on")
api.globalvars.init()
settings.init()
plugin.init()
plugin.loadAll()
api.globalvars.debugHandler = debug_events.GDBFrontendDebugEventsHandler()
all_urls = urls.urls
for _plugin_name, _plugin in plugin.plugins.items():
for _url_name, _url in _plugin.urls.items():
all_urls.prepend(_url_name, _url)
http_handler.url = api.url.URL(all_urls)
api.globalvars.httpServer = http_server.GDBFrontendHTTPServer(
(config.BIND_ADDRESS, config.HTTP_PORT),
http_handler.RequestHandler
)
thread = threading.Thread(target=api.globalvars.httpServer.serve_forever)
thread.setDaemon(True)
thread.start()
config.HTTP_PORT = api.globalvars.httpServer.server_port
if config.MMAP_PATH:
import mmap
import ctypes
fd = os.open(config.MMAP_PATH, os.O_RDWR)
mmapBuff = mmap.mmap(fd, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_WRITE)
http_port = ctypes.c_uint16.from_buffer(mmapBuff, 0)
http_port.value = api.globalvars.httpServer.server_port