From 28658836eee9860666a114756e13e1fdf7fd4637 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Sun, 22 Aug 2021 16:05:12 +0900 Subject: Add more event types, simplify event decoding --- helix-dap/src/types.rs | 133 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 126 insertions(+), 7 deletions(-) (limited to 'helix-dap/src/types.rs') diff --git a/helix-dap/src/types.rs b/helix-dap/src/types.rs index 3fd858de..fcbbf184 100644 --- a/helix-dap/src/types.rs +++ b/helix-dap/src/types.rs @@ -206,6 +206,21 @@ pub struct Variable { pub memory_reference: Option, } +#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Module { + pub id: String, // TODO: || number + pub name: String, + pub path: Option, + pub is_optimized: Option, + pub is_user_code: Option, + pub version: Option, + pub symbol_status: Option, + pub symbol_file_path: Option, + pub date_time_stamp: Option, + pub address_range: Option, +} + pub mod requests { use super::*; #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] @@ -411,6 +426,69 @@ pub mod requests { pub mod events { use super::*; + + #[derive(Debug, Clone, Serialize, Deserialize)] + #[serde(rename_all = "camelCase")] + #[serde(tag = "event", content = "body")] + // seq is omitted as unused and is not sent by some implementations + pub enum Event { + Initialized, + Stopped(Stopped), + Continued(Continued), + Exited(Exited), + Terminated(Terminated), + Thread(Thread), + Output(Output), + Breakpoint(Breakpoint), + Module(Module), + LoadedSource(LoadedSource), + Process(Process), + Capabilities(Capabilities), + // ProgressStart(), + // ProgressUpdate(), + // ProgressEnd(), + // Invalidated(), + Memory(Memory), + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct Stopped { + pub reason: String, + pub description: Option, + pub thread_id: Option, + pub preserve_focus_hint: Option, + pub text: Option, + pub all_threads_stopped: Option, + pub hit_breakpoint_ids: Option>, + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct Continued { + pub thread_id: usize, + pub all_threads_continued: Option, + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct Exited { + pub exit_code: usize, + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct Terminated { + pub restart: Option, + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct Thread { + pub reason: String, + pub thread_id: usize, + } + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Output { @@ -426,13 +504,54 @@ pub mod events { #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] - pub struct Stopped { + pub struct Breakpoint { pub reason: String, - pub description: Option, - pub thread_id: Option, - pub preserve_focus_hint: Option, - pub text: Option, - pub all_threads_stopped: Option, - pub hit_breakpoint_ids: Option>, + pub breakpoint: super::Breakpoint, + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct Module { + pub reason: String, + pub module: super::Module, + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct LoadedSource { + pub reason: String, + pub source: super::Source, + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct Process { + pub name: String, + pub system_process_id: Option, + pub is_local_process: Option, + pub start_method: String, // TODO: use enum + pub pointer_size: Option, + } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct Capabilities { + pub module: super::DebuggerCapabilities, + } + + // #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + // #[serde(rename_all = "camelCase")] + // pub struct Invalidated { + // pub areas: Vec, + // pub thread_id: Option, + // pub stack_frame_id: Option, + // } + + #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] + #[serde(rename_all = "camelCase")] + pub struct Memory { + pub memory_reference: String, + pub offset: usize, + pub count: usize, } } -- cgit v1.2.3-70-g09d2