Skip to content

Commit

Permalink
Merge branch 'debugger' into use-toolchain-for-python
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony-Eid committed Jan 21, 2025
2 parents 4ded4d1 + 56abc60 commit cc545ff
Show file tree
Hide file tree
Showing 15 changed files with 974 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ CREATE TABLE IF NOT EXISTS "debug_clients" (
project_id INTEGER NOT NULL,
session_id BIGINT NOT NULL,
capabilities INTEGER NOT NULL,
ignore_breakpoints BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (id, project_id, session_id),
FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

ALTER TABLE debug_clients ADD COLUMN ignore_breakpoints BOOLEAN NOT NULL DEFAULT FALSE;
39 changes: 39 additions & 0 deletions crates/collab/src/db/queries/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,40 @@ impl Database {
.await
}

pub async fn ignore_breakpoint_state(
&self,
connection_id: ConnectionId,
update: &proto::IgnoreBreakpointState,
) -> Result<TransactionGuard<HashSet<ConnectionId>>> {
let project_id = ProjectId::from_proto(update.project_id);
self.project_transaction(project_id, |tx| async move {
let debug_clients = debug_clients::Entity::find()
.filter(
Condition::all()
.add(debug_clients::Column::ProjectId.eq(project_id))
.add(debug_clients::Column::SessionId.eq(update.session_id)),
)
.all(&*tx)
.await?;

for debug_client in debug_clients {
debug_clients::Entity::update(debug_clients::ActiveModel {
id: ActiveValue::Unchanged(debug_client.id),
project_id: ActiveValue::Unchanged(debug_client.project_id),
session_id: ActiveValue::Unchanged(debug_client.session_id),
capabilities: ActiveValue::Unchanged(debug_client.capabilities),
ignore_breakpoints: ActiveValue::Set(update.ignore),
})
.exec(&*tx)
.await?;
}

self.internal_project_connection_ids(project_id, connection_id, true, &tx)
.await
})
.await
}

pub async fn update_debug_adapter(
&self,
connection_id: ConnectionId,
Expand Down Expand Up @@ -647,6 +681,7 @@ impl Database {
project_id: ActiveValue::Set(project_id),
session_id: ActiveValue::Set(update.session_id as i64),
capabilities: ActiveValue::Set(0),
ignore_breakpoints: ActiveValue::Set(false),
};
new_debug_client.insert(&*tx).await?;
}
Expand Down Expand Up @@ -729,6 +764,7 @@ impl Database {
project_id: ActiveValue::Set(project_id),
session_id: ActiveValue::Set(update.session_id as i64),
capabilities: ActiveValue::Set(0),
ignore_breakpoints: ActiveValue::Set(false),
};
debug_client = Some(new_debug_client.insert(&*tx).await?);
}
Expand All @@ -742,6 +778,7 @@ impl Database {
project_id: ActiveValue::Unchanged(debug_client.project_id),
session_id: ActiveValue::Unchanged(debug_client.session_id),
capabilities: ActiveValue::Set(debug_client.capabilities),
ignore_breakpoints: ActiveValue::Set(debug_client.ignore_breakpoints),
})
.exec(&*tx)
.await?;
Expand Down Expand Up @@ -1086,6 +1123,7 @@ impl Database {

for (session_id, clients) in debug_sessions.into_iter() {
let mut debug_clients = Vec::default();
let ignore_breakpoints = clients.iter().any(|debug| debug.ignore_breakpoints); // Temp solution until client -> session change

for debug_client in clients.into_iter() {
let debug_panel_items = debug_client
Expand All @@ -1108,6 +1146,7 @@ impl Database {
project_id,
session_id: session_id as u64,
clients: debug_clients,
ignore_breakpoints,
});
}

Expand Down
1 change: 1 addition & 0 deletions crates/collab/src/db/tables/debug_clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Model {
pub session_id: i64,
#[sea_orm(column_type = "Integer")]
pub capabilities: i32,
pub ignore_breakpoints: bool,
}

impl Model {
Expand Down
29 changes: 29 additions & 0 deletions crates/collab/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,13 @@ impl Server {
.add_request_handler(forward_mutating_project_request::<proto::VariablesRequest>)
.add_message_handler(
broadcast_project_message_from_host::<proto::DapRestartStackFrameRequest>,
)
.add_message_handler(
broadcast_project_message_from_host::<proto::ToggleIgnoreBreakpoints>,
)
.add_message_handler(ignore_breakpoint_state)
.add_message_handler(
broadcast_project_message_from_host::<proto::DebuggerSessionEnded>,
);

Arc::new(server)
Expand Down Expand Up @@ -2155,6 +2162,28 @@ async fn shutdown_debug_client(
Ok(())
}

async fn ignore_breakpoint_state(
request: proto::IgnoreBreakpointState,
session: Session,
) -> Result<()> {
let guest_connection_ids = session
.db()
.await
.ignore_breakpoint_state(session.connection_id, &request)
.await?;

broadcast(
Some(session.connection_id),
guest_connection_ids.iter().copied(),
|connection_id| {
session
.peer
.forward_send(session.connection_id, connection_id, request.clone())
},
);
Ok(())
}

/// Notify other participants that a debug panel item has been updated
async fn update_debug_adapter(request: proto::UpdateDebugAdapter, session: Session) -> Result<()> {
let guest_connection_ids = session
Expand Down
Loading

0 comments on commit cc545ff

Please sign in to comment.