Skip to content

Commit ea1f7a9

Browse files
committed
Review feedback.
1 parent 6252848 commit ea1f7a9

File tree

5 files changed

+20
-114
lines changed

5 files changed

+20
-114
lines changed

Cargo.lock

Lines changed: 1 addition & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/debugger/src/host.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ pub fn add_debuggee<T: Send + 'static>(
2929
})?)
3030
}
3131

32-
/// A provider of a [`ResourceTable`] for debugger host APIs.
33-
pub trait DebuggerView: Send {
34-
/// Provide a mutable borrow of the underlying resource table.
35-
fn table(&mut self) -> &mut ResourceTable;
36-
}
37-
3832
/// Add the debugger world's host functions to a [`wasmtime::component::Linker`].
3933
pub fn add_to_linker<T: Send + 'static>(
4034
linker: &mut wasmtime::component::Linker<T>,

crates/debugger/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use wasmtime::{
2828
};
2929

3030
mod host;
31-
pub use host::{DebuggerComponent, DebuggerView, add_debuggee, add_to_linker, wit};
31+
pub use host::{DebuggerComponent, add_debuggee, add_to_linker, wit};
3232

3333
/// A `Debuggee` wraps up state associated with debugging the code
3434
/// running in a single `Store`.

crates/test-programs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ flate2 = "1.0.28"
2626
log = { workspace = true }
2727
env_logger = { workspace = true }
2828
pin-project-lite = { workspace = true }
29-
wstd = "0.6.5"
29+

crates/test-programs/src/bin/debugger_component.rs

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! stderr to communicate success.
66
77
use std::time::Duration;
8-
use wstd::runtime::AsyncPollable;
98

109
mod api {
1110
wit_bindgen::generate!({
@@ -49,53 +48,44 @@ api::export!(Component with_types_in api);
4948

5049
impl api::exports::bytecodealliance::wasmtime::debugger::Guest for Component {
5150
fn debug(d: &Debuggee, args: Vec<String>) {
52-
wstd::runtime::block_on(async {
53-
match args.get(1).map(|s| s.as_str()) {
54-
Some("simple") => test_simple(d).await,
55-
Some("loop") => test_loop(d).await,
56-
other => panic!("unknown test mode: {other:?}"),
51+
match args.get(1).map(|s| s.as_str()) {
52+
Some("simple") => {
53+
test_simple(d);
5754
}
58-
});
55+
Some("loop") => {
56+
test_loop(d);
57+
}
58+
other => panic!("unknown test mode: {other:?}"),
59+
}
5960
}
6061
}
6162

6263
struct Resumption {
6364
future: EventFuture,
64-
pollable: Option<AsyncPollable>,
6565
}
6666

6767
impl Resumption {
6868
fn single_step(d: &Debuggee) -> Self {
6969
let future = d.single_step(ResumptionValue::Normal);
70-
let pollable = Some(AsyncPollable::new(future.subscribe()));
71-
Self { future, pollable }
70+
Self { future }
7271
}
7372

7473
fn continue_(d: &Debuggee) -> Self {
7574
let future = d.continue_(ResumptionValue::Normal);
76-
let pollable = Some(AsyncPollable::new(future.subscribe()));
77-
Self { future, pollable }
78-
}
79-
80-
async fn wait(&mut self) {
81-
if let Some(p) = self.pollable.as_mut() {
82-
p.wait_for().await;
83-
}
75+
Self { future }
8476
}
8577

86-
fn result(mut self, d: &Debuggee) -> Result<Event, Error> {
87-
let _ = self.pollable.take();
78+
fn result(self, d: &Debuggee) -> Result<Event, Error> {
8879
EventFuture::finish(self.future, d)
8980
}
9081
}
9182

9283
/// Tests single-stepping.
9384
///
9485
/// Tests against `debugger_debuggee_simple.wat`.
95-
async fn test_simple(d: &Debuggee) {
86+
fn test_simple(d: &Debuggee) {
9687
// Step once to reach the first instruction.
97-
let mut r = Resumption::single_step(d);
98-
r.wait().await;
88+
let r = Resumption::single_step(d);
9989
let _event = r.result(d).unwrap();
10090

10191
let mut pcs = vec![];
@@ -105,8 +95,7 @@ async fn test_simple(d: &Debuggee) {
10595
let pc = frames[0].get_pc(d).unwrap();
10696
pcs.push(pc);
10797

108-
let mut r = Resumption::single_step(d);
109-
r.wait().await;
98+
let r = Resumption::single_step(d);
11099
match r.result(d).unwrap() {
111100
Event::Breakpoint => {}
112101
other => panic!("unexpected event: {other:?}"),
@@ -125,9 +114,9 @@ async fn test_simple(d: &Debuggee) {
125114
/// to completion.
126115
///
127116
/// Tests against `debugger_debuggee_loop.wat`.
128-
async fn test_loop(d: &Debuggee) {
117+
fn test_loop(d: &Debuggee) {
129118
// Continue execution (the debuggee should loop).
130-
let mut r = Resumption::continue_(d);
119+
let r = Resumption::continue_(d);
131120

132121
// Yield to the event loop and let it run for a bit.
133122
std::thread::sleep(Duration::from_millis(100));
@@ -136,7 +125,6 @@ async fn test_loop(d: &Debuggee) {
136125
d.interrupt();
137126

138127
// Wait for the interrupt event.
139-
r.wait().await;
140128
let event = r.result(d).unwrap();
141129
assert!(
142130
matches!(event, Event::Interrupted),
@@ -153,8 +141,7 @@ async fn test_loop(d: &Debuggee) {
153141
}
154142

155143
// Continue; the debuggee should exit normally now.
156-
let mut r = Resumption::continue_(d);
157-
r.wait().await;
144+
let r = Resumption::continue_(d);
158145
let event = r.result(d).unwrap();
159146
assert!(
160147
matches!(event, Event::Complete),

0 commit comments

Comments
 (0)