compat: make thread IDs signed

Delve needs it
pull/574/head
Dmitry Sharshakov 3 years ago
parent c63ad60c31
commit cf7237d0b9
No known key found for this signature in database
GPG Key ID: 471FD32E15FD8473

@ -28,9 +28,9 @@ pub struct Client {
request_counter: AtomicU64, request_counter: AtomicU64,
pub caps: Option<DebuggerCapabilities>, pub caps: Option<DebuggerCapabilities>,
// thread_id -> frames // thread_id -> frames
pub stack_frames: HashMap<usize, Vec<StackFrame>>, pub stack_frames: HashMap<isize, Vec<StackFrame>>,
pub thread_states: HashMap<usize, String>, pub thread_states: HashMap<isize, String>,
pub thread_id: Option<usize>, pub thread_id: Option<isize>,
/// Currently active frame for the current thread. /// Currently active frame for the current thread.
pub active_frame: Option<usize>, pub active_frame: Option<usize>,
} }
@ -298,7 +298,7 @@ impl Client {
self.request::<requests::ConfigurationDone>(()).await self.request::<requests::ConfigurationDone>(()).await
} }
pub async fn continue_thread(&mut self, thread_id: usize) -> Result<Option<bool>> { pub async fn continue_thread(&mut self, thread_id: isize) -> Result<Option<bool>> {
let args = requests::ContinueArguments { thread_id }; let args = requests::ContinueArguments { thread_id };
let response = self.request::<requests::Continue>(args).await?; let response = self.request::<requests::Continue>(args).await?;
@ -307,7 +307,7 @@ impl Client {
pub async fn stack_trace( pub async fn stack_trace(
&mut self, &mut self,
thread_id: usize, thread_id: isize,
) -> Result<(Vec<StackFrame>, Option<usize>)> { ) -> Result<(Vec<StackFrame>, Option<usize>)> {
let args = requests::StackTraceArguments { let args = requests::StackTraceArguments {
thread_id, thread_id,
@ -345,7 +345,7 @@ impl Client {
Ok(response.variables) Ok(response.variables)
} }
pub async fn step_in(&mut self, thread_id: usize) -> Result<()> { pub async fn step_in(&mut self, thread_id: isize) -> Result<()> {
let args = requests::StepInArguments { let args = requests::StepInArguments {
thread_id, thread_id,
target_id: None, target_id: None,
@ -355,7 +355,7 @@ impl Client {
self.request::<requests::StepIn>(args).await self.request::<requests::StepIn>(args).await
} }
pub async fn step_out(&mut self, thread_id: usize) -> Result<()> { pub async fn step_out(&mut self, thread_id: isize) -> Result<()> {
let args = requests::StepOutArguments { let args = requests::StepOutArguments {
thread_id, thread_id,
granularity: None, granularity: None,
@ -364,7 +364,7 @@ impl Client {
self.request::<requests::StepOut>(args).await self.request::<requests::StepOut>(args).await
} }
pub async fn next(&mut self, thread_id: usize) -> Result<()> { pub async fn next(&mut self, thread_id: isize) -> Result<()> {
let args = requests::NextArguments { let args = requests::NextArguments {
thread_id, thread_id,
granularity: None, granularity: None,
@ -373,7 +373,7 @@ impl Client {
self.request::<requests::Next>(args).await self.request::<requests::Next>(args).await
} }
pub async fn pause(&mut self, thread_id: usize) -> Result<()> { pub async fn pause(&mut self, thread_id: isize) -> Result<()> {
let args = requests::PauseArguments { thread_id }; let args = requests::PauseArguments { thread_id };
self.request::<requests::Pause>(args).await self.request::<requests::Pause>(args).await

@ -157,7 +157,7 @@ pub struct StackFrame {
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Thread { pub struct Thread {
pub id: usize, pub id: isize,
pub name: String, pub name: String,
} }
@ -317,7 +317,7 @@ pub mod requests {
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ContinueArguments { pub struct ContinueArguments {
pub thread_id: usize, pub thread_id: isize,
} }
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
@ -338,7 +338,7 @@ pub mod requests {
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct StackTraceArguments { pub struct StackTraceArguments {
pub thread_id: usize, pub thread_id: isize,
pub start_frame: Option<usize>, pub start_frame: Option<usize>,
pub levels: Option<usize>, pub levels: Option<usize>,
pub format: Option<StackFrameFormat>, pub format: Option<StackFrameFormat>,
@ -424,7 +424,7 @@ pub mod requests {
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct StepInArguments { pub struct StepInArguments {
pub thread_id: usize, pub thread_id: isize,
pub target_id: Option<usize>, pub target_id: Option<usize>,
pub granularity: Option<String>, pub granularity: Option<String>,
} }
@ -441,7 +441,7 @@ pub mod requests {
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct StepOutArguments { pub struct StepOutArguments {
pub thread_id: usize, pub thread_id: isize,
pub granularity: Option<String>, pub granularity: Option<String>,
} }
@ -457,7 +457,7 @@ pub mod requests {
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct NextArguments { pub struct NextArguments {
pub thread_id: usize, pub thread_id: isize,
pub granularity: Option<String>, pub granularity: Option<String>,
} }
@ -473,7 +473,7 @@ pub mod requests {
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct PauseArguments { pub struct PauseArguments {
pub thread_id: usize, pub thread_id: isize,
} }
#[derive(Debug)] #[derive(Debug)]
@ -551,7 +551,7 @@ pub mod events {
pub struct Stopped { pub struct Stopped {
pub reason: String, pub reason: String,
pub description: Option<String>, pub description: Option<String>,
pub thread_id: Option<usize>, pub thread_id: Option<isize>,
pub preserve_focus_hint: Option<bool>, pub preserve_focus_hint: Option<bool>,
pub text: Option<String>, pub text: Option<String>,
pub all_threads_stopped: Option<bool>, pub all_threads_stopped: Option<bool>,
@ -561,7 +561,7 @@ pub mod events {
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Continued { pub struct Continued {
pub thread_id: usize, pub thread_id: isize,
pub all_threads_continued: Option<bool>, pub all_threads_continued: Option<bool>,
} }
@ -581,7 +581,7 @@ pub mod events {
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Thread { pub struct Thread {
pub reason: String, pub reason: String,
pub thread_id: usize, pub thread_id: isize,
} }
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]

@ -29,7 +29,7 @@ pub fn resume_application(debugger: &mut Client) {
debugger.thread_id = None; debugger.thread_id = None;
} }
pub async fn select_thread_id(editor: &mut Editor, thread_id: usize, force: bool) { pub async fn select_thread_id(editor: &mut Editor, thread_id: isize, force: bool) {
let debugger = match &mut editor.debugger { let debugger = match &mut editor.debugger {
Some(debugger) => debugger, Some(debugger) => debugger,
None => return, None => return,

Loading…
Cancel
Save