firedbg_protocol/
breakpoint.rs

1//! Definition of Breakpoint
2use crate::source::LineColumn;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
6/// Breakpoint
7pub struct Breakpoint {
8    pub id: u32,
9    pub file_id: u32,
10    pub loc: LineColumn,
11    pub loc_end: Option<LineColumn>,
12    pub breakpoint_type: BreakpointType,
13    pub capture: VariableCapture,
14}
15
16#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
17/// Reason to set this breakpoint
18pub enum BreakpointType {
19    #[default]
20    Breakpoint,
21    FunctionCall {
22        /// Breaking at a specifc line of code is fuzzy, sometimes we might end up in a different location due to inlining etc.
23        /// We need the function name to double check.
24        fn_name: String,
25    },
26    FunctionReturn,
27}
28
29#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
30/// Option for capturing variables.
31pub enum VariableCapture {
32    /// Capture all arguments
33    Arguments,
34    /// Capture all local variables
35    Locals,
36    /// Capture only these variables by name
37    Only(Vec<String>),
38    #[default]
39    /// Capture nothing
40    None,
41}
42
43impl BreakpointType {
44    pub fn as_str(&self) -> &'static str {
45        match self {
46            Self::Breakpoint => "Breakpoint",
47            Self::FunctionCall { .. } => "FunctionCall",
48            Self::FunctionReturn => "FunctionReturn",
49        }
50    }
51}