Skip to content

Commit 8ace37a

Browse files
committed
Fix flaky gdb tests by detaching from inside the bp commands
Replace the racy 'inner continue, outer continue, quit' pattern with 'detach, quit' inside the breakpoint commands. After the previous inner continue, the inferior could exit and the gdb stub could close the remote before gdb dispatched the outer continue, producing 'Remote connection closed' and a non-zero exit. The new shape lets the host run the guest call to completion on its own after detach, with no pending remote work in gdb. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent 8883c80 commit 8ace37a

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

  • src/hyperlight_host/examples/guest-debugging

src/hyperlight_host/examples/guest-debugging/main.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,17 @@ mod tests {
129129

130130
/// Build a gdb script that connects to `port`, sets a single
131131
/// breakpoint at `breakpoint`, prints `echo_msg` when hit, and
132-
/// continues to completion.
132+
/// detaches before quitting.
133+
///
134+
/// The breakpoint commands end with `detach` + `quit` instead of
135+
/// `continue`. The previous "inner continue, outer continue, quit"
136+
/// shape races with the inferior exit. After the breakpoint hits
137+
/// and the inner `continue` resumes the guest, the guest may run
138+
/// to completion and the gdb stub may close the remote before gdb
139+
/// has dispatched the outer `continue`, producing a non-zero exit
140+
/// with `Remote connection closed`. Detaching from the breakpoint
141+
/// commands removes that window. The host process keeps running
142+
/// the guest call to completion on its own after detach.
133143
fn single_breakpoint_script(
134144
manifest_dir: &str,
135145
port: u16,
@@ -150,13 +160,12 @@ mod tests {
150160
echo \"{echo_msg}\\n\"
151161
backtrace
152162
153-
continue
163+
set logging enabled off
164+
detach
165+
quit
154166
end
155167
156168
continue
157-
158-
set logging enabled off
159-
quit
160169
"
161170
);
162171
#[cfg(windows)]
@@ -337,16 +346,14 @@ mod tests {
337346
break +2
338347
commands 2
339348
print $xmm1.v4_float
340-
continue
349+
set logging enabled off
350+
detach
351+
quit
341352
end
342353
continue
343354
end
344-
345355
346356
continue
347-
348-
set logging enabled off
349-
quit
350357
"
351358
);
352359

0 commit comments

Comments
 (0)