[Lldb-commits] [lldb] [lldb-dap] Refactoring DebugCommunication to improve test consistency. (PR #143818)
Ebuka Ezike via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 16 07:19:04 PDT 2025
================
@@ -10,17 +10,117 @@
import subprocess
import signal
import sys
+from dataclasses import dataclass
import threading
import time
-from typing import Any, Optional, Union, BinaryIO, TextIO
+from typing import (
+ IO,
+ Any,
+ Callable,
+ Dict,
+ List,
+ Optional,
+ Tuple,
+ TypeGuard,
+ TypeVar,
+ TypedDict,
+ Union,
+ BinaryIO,
+ TextIO,
+ Literal,
+ cast,
+)
## DAP type references
-Event = dict[str, Any]
-Request = dict[str, Any]
-Response = dict[str, Any]
+
+T = TypeVar("T")
+
+
+class Event(TypedDict):
+ type: Literal["event"]
+ seq: Literal[0]
+ event: str
+ body: Optional[dict]
+
+
+class Request(TypedDict):
+ type: Literal["request"]
+ seq: int
+ command: str
+ arguments: Optional[dict]
+
+
+class Response(TypedDict):
+ type: Literal["response"]
+ seq: Literal[0]
+ request_seq: int
+ success: bool
+ command: str
+ message: Optional[str]
+ body: Optional[dict]
+
+
ProtocolMessage = Union[Event, Request, Response]
+class AttachOrLaunchArguments(TypedDict, total=False):
+ stopOnEntry: bool
+ disableASLR: bool
+ disableSTDIO: bool
+ enableAutoVariableSummaries: bool
+ displayExtendedBacktrace: bool
+ enableSyntheticChildDebugging: bool
+ initCommands: List[str]
+ preRunCommands: List[str]
+ postRunCommands: List[str]
+ stopCommands: List[str]
+ exitCommands: List[str]
+ terminateCommands: List[str]
+ sourceMap: Union[List[Tuple[str, str]], Dict[str, str]]
+ sourcePath: str
+ debuggerRoot: str
+ commandEscapePrefix: str
+ customFrameFormat: str
+ customThreadFormat: str
+
+
+class LaunchArguments(AttachOrLaunchArguments, total=False):
+ program: str
+ args: List[str]
+ cwd: str
+ env: Dict[str, str]
+ shellExpandArguments: bool
+ runInTerminal: bool
+ launchCommands: List[str]
+
+
+class AttachArguments(AttachOrLaunchArguments, total=False):
+ program: str
+ pid: int
+ waitFor: bool
+ attachCommands: List[str]
+ coreFile: str
+ gdbRemotePort: int
+ gdbRemoteHostname: str
+
+
+class BreakpiontData(TypedDict, total=False):
----------------
da-viper wrote:
```suggestion
class BreakpointData(TypedDict, total=False):
```
https://github.com/llvm/llvm-project/pull/143818
More information about the lldb-commits
mailing list