mirror of
https://github.com/lvgl/lvgl.git
synced 2024-11-23 01:33:59 +08:00
refactor(gdb): refactor gdb Debugger to be a gdb command (#7140)
This commit is contained in:
parent
7f690a2f22
commit
a8d2cc05f1
@ -73,3 +73,18 @@ Example:
|
||||
32 = {num = 90, ptr = 0x5a, color = {blue = 90 'Z', green = 0 '\000', red = 0 '\000'}}
|
||||
158 = {num = 32767, ptr = 0x7fff, color = {blue = 255 '\377', green = 127 '\177', red = 0 '\000'}}
|
||||
(gdb)
|
||||
|
||||
Connect to Debugger
|
||||
-------------------
|
||||
|
||||
This command provides the ability to connect and debug GDB Python Script using IDE.
|
||||
|
||||
Connect to ``PyCharm`` / ``VSCode`` / ``Eclipse(not support yet)``
|
||||
|
||||
``debugger -t pycharm``
|
||||
|
||||
``debugger -t vscode``
|
||||
|
||||
``debugger -t eclipse``
|
||||
|
||||
How to use it specifically, search ``pydevd_pycharm`` / ``debugpy`` for details.
|
||||
|
@ -1,7 +1,16 @@
|
||||
from .lvgl import *
|
||||
from .value import *
|
||||
from .debugger import *
|
||||
|
||||
# Debugger
|
||||
Debugger()
|
||||
|
||||
# Dumps
|
||||
DumpObj()
|
||||
|
||||
# Infos
|
||||
InfoStyle()
|
||||
InfoDrawUnit()
|
||||
|
||||
# Set instance
|
||||
set_lvgl_instance(None)
|
||||
|
@ -1,7 +1,54 @@
|
||||
class Debugger(object):
|
||||
import argparse
|
||||
|
||||
import gdb
|
||||
|
||||
|
||||
class Debugger(gdb.Command):
|
||||
"""Start debugpy server or connect to a debug server, so we can debug python code from IDE like PyCharm/VSCode"""
|
||||
|
||||
def __init__(self, host="localhost", port=11451):
|
||||
self.__host = host
|
||||
self.__port = port
|
||||
super().__init__("debugger", gdb.COMMAND_USER)
|
||||
|
||||
def invoke(self, args, from_tty):
|
||||
parser = argparse.ArgumentParser(description=Debugger.__doc__)
|
||||
parser.add_argument(
|
||||
"--host",
|
||||
type=str,
|
||||
help="Server listening host",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--port",
|
||||
type=int,
|
||||
help="Server listening port",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-t",
|
||||
"--type",
|
||||
choices=["pycharm", "vscode", "eclipse"],
|
||||
help="Debugger type",
|
||||
required=True,
|
||||
)
|
||||
|
||||
try:
|
||||
args = parser.parse_args(gdb.string_to_argv(args))
|
||||
except SystemExit:
|
||||
return
|
||||
|
||||
if args.host:
|
||||
self.__host = args.host
|
||||
|
||||
if args.port:
|
||||
self.__port = args.port
|
||||
|
||||
if args.type == "pycharm":
|
||||
self.connect_to_pycharm()
|
||||
elif args.type == "vscode":
|
||||
self.connect_to_vscode()
|
||||
elif args.type == "eclipse":
|
||||
self.connect_to_eclipse()
|
||||
|
||||
def connect_to_pycharm(self):
|
||||
try:
|
||||
@ -13,7 +60,14 @@ class Debugger(object):
|
||||
pydevd_pycharm.settrace(self.__host, port=self.__port, stdoutToServer=True, stderrToServer=True)
|
||||
|
||||
def connect_to_vscode(self):
|
||||
raise NotImplementedError()
|
||||
try:
|
||||
import debugpy
|
||||
except ImportError:
|
||||
print("debugpy module not found. Please install it using pip.")
|
||||
return
|
||||
|
||||
debugpy.listen((self.__host, self.__port))
|
||||
debugpy.wait_for_client()
|
||||
|
||||
def connect_to_eclipse(self):
|
||||
raise NotImplementedError()
|
||||
print("Eclipse is not implemented yet")
|
||||
|
Loading…
Reference in New Issue
Block a user