Debian Codegraph @

debugger/src/briefcase_debugger/pdb.py

raw
1 import sys
2
3 from remote_pdb import RemotePdb
4
5 from briefcase_debugger.config import DebuggerConfig
6
7
8 def start_pdb(config: DebuggerConfig, verbose: bool):
9 """Start remote PDB server."""
10 # Parsing host/port
11 host = config["host"]
12 port = config["port"]
13
14 # Print help message
15 host_os = config["host_os"]
16 telnet_cmd = f"telnet {host} {port}"
17 nc_cmd = f"nc {host} {port}"
18 if host_os == "Windows":
19 cmds_hint = f" {telnet_cmd}"
20 elif host_os in ("Linux", "Darwin"):
21 cmds_hint = f" {nc_cmd}"
22 else:
23 cmds_hint = f"""\
24 - {telnet_cmd}
25 - {nc_cmd}
26 """
27 print(f"""
28 Remote PDB server opened at {host}:{port}.
29 Waiting for debugger to attach...
30 To connect to remote PDB use for example:
31
32 {cmds_hint}
33
34 For more information see: https://briefcase.beeware.org/en/stable/how-to/debugging/pdb/#bundled-app
35 """)
36
37 # Create a RemotePdb instance
38 remote_pdb = RemotePdb(host, port, quiet=True)
39
40 # Connect the remote PDB with the "breakpoint()" function
41 sys.breakpointhook = remote_pdb.set_trace
42
43 print("Debugger client attached.")
44 print("-" * 75)