ghostscope_platform/
types.rs

1/// Basic error types for platform-specific operations
2#[derive(Debug, Clone)]
3pub enum PlatformError {
4    /// Cannot determine prologue end - parameters may be optimized
5    PrologueAnalysisFailed(String),
6    /// Parameter optimization detected
7    ParameterOptimized(String),
8    /// Evaluation failed
9    EvaluationFailed(String),
10    /// Unsupported architecture
11    UnsupportedArchitecture(String),
12}
13
14impl std::fmt::Display for PlatformError {
15    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16        match self {
17            PlatformError::PrologueAnalysisFailed(msg) => {
18                write!(f, "Prologue analysis failed: {msg}")
19            }
20            PlatformError::ParameterOptimized(msg) => write!(f, "Parameter optimized: {msg}"),
21            PlatformError::EvaluationFailed(msg) => write!(f, "Evaluation failed: {msg}"),
22            PlatformError::UnsupportedArchitecture(msg) => {
23                write!(f, "Unsupported architecture: {msg}")
24            }
25        }
26    }
27}
28
29impl std::error::Error for PlatformError {}
30
31/// Source location information for debugging
32#[derive(Debug, Clone)]
33pub struct SourceLocation {
34    pub file_path: String,
35    pub line_number: u32,
36    pub column: Option<u32>,
37}
38
39/// Simplified context for code reading operations
40pub trait CodeReader {
41    /// Read code bytes from the specified address
42    fn read_code_bytes(&self, address: u64, size: usize) -> Option<Vec<u8>>;
43
44    /// Get source location information for the given address
45    fn get_source_location_slow(&self, address: u64) -> Option<SourceLocation>;
46
47    /// Find the next is_stmt=true address after the given function start address
48    /// This is used for prologue detection following GDB's approach
49    fn find_next_stmt_address(&self, function_start: u64) -> Option<u64>;
50}