blob: b9cb90ad713337fd431d4560b28f04354a4783b6 (
plain)
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
|
import os
import subprocess
import sys
import importlib.util
def setup_toolchain_debugging():
try:
gcc_path = (
subprocess.check_output(["which", "x86_64-pc-elf-g++"])
.decode("utf-8")
.strip()
)
python_dir = None
share_path = os.path.join(os.path.dirname(os.path.dirname(gcc_path)), "share")
for root, dirs, _ in os.walk(share_path):
if "libstdcxx" in dirs:
python_dir = root
break
if python_dir:
sys.path.insert(0, python_dir)
if importlib.util.find_spec("libstdcxx.v6.printers") is None:
print(f"libstdcxx.v6.printers not found in {python_dir}, libstdc++ printers and XMethods will not be available.")
return
printers = importlib.import_module("libstdcxx.v6.printers")
xmethods = importlib.import_module("libstdcxx.v6.xmethods")
printers.register_libstdcxx_printers(None)
xmethods.register_libstdcxx_xmethods(None)
print(f"Loaded Printers & Xmethods from: {python_dir}")
except Exception as e:
print(f"Debug setup failed: {e}")
setup_toolchain_debugging()
|