|
|
|
|
@ -40,7 +40,9 @@ import argparse
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
import signal
|
|
|
|
|
import sys
|
|
|
|
|
import threading
|
|
|
|
|
from contextlib import contextmanager
|
|
|
|
|
from typing import Any
|
|
|
|
|
from typing import List
|
|
|
|
|
from typing import Tuple
|
|
|
|
|
@ -376,6 +378,11 @@ def run(startup: List[str] | None = None, debug: bool = False) -> None:
|
|
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if bits[0] == "ipi":
|
|
|
|
|
# Spawn IPython shell, easy for debugging
|
|
|
|
|
run_ipython_shell()
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
# The command hasn't matched any of our filtered commands, just let LLDB
|
|
|
|
|
# handle it normally. Either in the context of the process, if we have
|
|
|
|
|
# one, or just in a general context.
|
|
|
|
|
@ -434,6 +441,37 @@ def parse(args: List[str], parser: argparse.ArgumentParser, unsupported: List[st
|
|
|
|
|
return args
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_ipython_shell():
|
|
|
|
|
@contextmanager
|
|
|
|
|
def switch_to_ipython_env():
|
|
|
|
|
saved_excepthook = sys.excepthook
|
|
|
|
|
try:
|
|
|
|
|
saved_ps = sys.ps1, sys.ps2
|
|
|
|
|
except AttributeError:
|
|
|
|
|
saved_ps = None
|
|
|
|
|
yield
|
|
|
|
|
# Restore Python's default `ps1`, `ps2`, and `excepthook`
|
|
|
|
|
# to ensure proper behavior of the LLDB `script` command.
|
|
|
|
|
if saved_ps is not None:
|
|
|
|
|
sys.ps1, sys.ps2 = saved_ps
|
|
|
|
|
else:
|
|
|
|
|
del sys.ps1
|
|
|
|
|
del sys.ps2
|
|
|
|
|
sys.excepthook = saved_excepthook
|
|
|
|
|
|
|
|
|
|
def start_ipi():
|
|
|
|
|
import IPython
|
|
|
|
|
import jedi # type: ignore[import-untyped]
|
|
|
|
|
|
|
|
|
|
jedi.Interpreter._allow_descriptor_getattr_default = False
|
|
|
|
|
IPython.embed(
|
|
|
|
|
colors="neutral", banner1="", confirm_exit=False, simple_prompt=False, user_ns=globals()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
with switch_to_ipython_env():
|
|
|
|
|
start_ipi()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
target_create_ap = argparse.ArgumentParser(add_help=False)
|
|
|
|
|
target_create_ap.add_argument("-S", "--sysroot")
|
|
|
|
|
target_create_ap.add_argument("-a", "--arch")
|
|
|
|
|
|