#!/usr/bin/env python3
"""
Debugger Models - 디버거 데이터 모델
디버깅 시스템에 필요한 모든 데이터 클래스와 enum 정의
"""
import uuid
from datetime import datetime
from typing import Dict, List, Optional, Any, Union
from dataclasses import dataclass, field
from enum import Enum
class DebuggerLanguage(Enum):
"""지원하는 디버깅 언어"""
PYTHON = "python"
JAVASCRIPT = "javascript"
TYPESCRIPT = "typescript"
GO = "go"
JAVA = "java"
CPP = "cpp"
CSHARP = "csharp"
MOCK = "mock" # 테스트용
class DebuggerState(Enum):
"""디버거 상태"""
CREATED = "created"
INITIALIZING = "initializing"
READY = "ready"
RUNNING = "running"
PAUSED = "paused"
STOPPED = "stopped"
ERROR = "error"
@dataclass
class BreakpointInfo:
"""브레이크포인트 정보"""
id: str
file_path: str
line: int
condition: Optional[str] = None
enabled: bool = True
hit_count: int = 0
created_at: datetime = None
def __post_init__(self):
if self.created_at is None:
self.created_at = datetime.now()
@dataclass
class StackFrame:
"""스택 프레임 정보"""
id: int
name: str
file_path: str
line: int
column: int
scopes_reference: int
@dataclass
class Scope:
"""스코프 정보"""
name: str
variables_reference: int
expensive: bool = False
@dataclass
class Variable:
"""변수 정보"""
name: str
value: str
type: str
variables_reference: int = 0
@dataclass
class DebugSession:
"""디버깅 세션 정보"""
session_id: str
language: DebuggerLanguage
name: str
state: DebuggerState
executable_path: Optional[str]
created_at: datetime
last_activity: datetime
breakpoints: Dict[str, BreakpointInfo] = field(default_factory=dict)
stack_frames: List[StackFrame] = field(default_factory=list)
current_frame_id: Optional[int] = None
process_id: Optional[int] = None
debug_port: Optional[int] = None
def __post_init__(self):
if not hasattr(self, 'created_at') or self.created_at is None:
self.created_at = datetime.now()
if not hasattr(self, 'last_activity') or self.last_activity is None:
self.last_activity = datetime.now()
@dataclass
class DebugEvent:
"""디버그 이벤트"""
event_type: str
session_id: str
timestamp: datetime
data: Dict[str, Any] = field(default_factory=dict)
def __post_init__(self):
if not hasattr(self, 'timestamp') or self.timestamp is None:
self.timestamp = datetime.now()
@dataclass
class ExecutionContext:
"""실행 컨텍스트"""
thread_id: int
frame_id: int
file_path: str
line: int
column: int
function_name: str
local_variables: Dict[str, Variable] = field(default_factory=dict)
global_variables: Dict[str, Variable] = field(default_factory=dict)
@dataclass
class DebugConfiguration:
"""디버그 설정"""
language: DebuggerLanguage
executable_path: Optional[str] = None
workspace_path: Optional[str] = None
environment_vars: Dict[str, str] = field(default_factory=dict)
launch_args: List[str] = field(default_factory=list)
stop_on_entry: bool = False
just_my_code: bool = True
console_output: bool = True
debug_port: Optional[int] = None