Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/starry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ Stress configs are available through explicit QEMU config variants; see

## GDB Smoke

The `gdb-smoke` case is a RISC-V QEMU app workflow that prepares a temporary
rootfs overlay with GDB, GDBServer, and tiny debugger smoke targets.
The `gdb-smoke` case is a QEMU app workflow that prepares a temporary rootfs
overlay with GDB, GDBServer, and tiny debugger smoke targets. Native GDB smoke
and gdbserver smoke are available on x86_64, riscv64, aarch64, and loongarch64.

```bash
cargo xtask starry app qemu -t gdb-smoke --arch x86_64
cargo xtask starry app qemu -t gdb-smoke --arch riscv64
cargo xtask starry app qemu -t gdb-smoke --arch riscv64 \
--qemu-config qemu-riscv64-gdbserver.toml
Expand Down
93 changes: 93 additions & 0 deletions apps/starry/gdb-smoke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ aarch64, loongarch64, and x86_64.
Use this command for the automated native GDB batch smoke:

```bash
cargo xtask starry app qemu -t gdb-smoke --arch x86_64
cargo xtask starry app qemu -t gdb-smoke --arch riscv64
```

Expand Down Expand Up @@ -55,6 +56,8 @@ Success requires all `GDB_NATIVE_*` markers from
Use this entry when you want an interactive StarryOS shell:

```bash
cargo xtask starry app qemu -t gdb-smoke --arch x86_64 \
--qemu-config qemu-x86_64-manual.toml
cargo xtask starry app qemu -t gdb-smoke --arch riscv64 \
--qemu-config qemu-riscv64-manual.toml
```
Expand Down Expand Up @@ -99,6 +102,96 @@ The native target uses a clear call chain:
main -> demo_entry -> demo_worker -> native_marker
```

## Manual Native GDB TUI Demo

Use the same interactive QEMU entry as the manual native GDB demo:

```bash
docker exec -it tgoskits-dev cargo xtask starry app qemu -t gdb-smoke --arch riscv64 \
--qemu-config qemu-riscv64-manual.toml
```

Inside StarryOS:

```bash
gdb-native-tui.sh
```

The helper sets a usable `TERM` when needed and starts `gdb -tui` on
`/usr/bin/gdb-native-smoke-target`. To debug a different program, pass it as the
first argument:

```bash
gdb-native-tui.sh /path/to/program
```

For the scripted layout demo, run:

```bash
gdb-native-tui.sh --demo
```

The demo breaks at `native_marker`, runs to the breakpoint, and opens
`layout src`. The target source is copied into the guest under the same
`/workspace/...` path used by the debug info so `layout src` can show the smoke
target source. It stops at the GDB prompt after printing
`GDB_NATIVE_TUI_READY`.

Inside GDB:

```gdb
layout asm
layout regs
refresh
tui disable
bt
continue
quit
```

For the current StarryOS TTY implementation, prefer disabling TUI before
continuing the target to process exit. `layout regs` is useful while the process
is stopped, but after the inferior exits GDB may still try to refresh the
register window and leave stale full-screen drawing on the serial console.
`refresh` or `Ctrl-L` can repaint the current TUI screen; `tui disable` returns
to the normal CLI view.

This path is intentionally manual. GDB TUI is a full-screen terminal UI, so it
is not part of the default batch smoke or CI path.

### PTY Console Variant

The default manual config uses QEMU `-nographic`, which routes the guest serial
console through the same stdio stream as the QEMU process. For comparing GDB
TUI responsiveness, use the PTY variant:

```bash
docker exec -it tgoskits-dev cargo xtask starry app qemu -t gdb-smoke --arch riscv64 \
--qemu-config qemu-riscv64-tui-pty.toml
```

QEMU prints a line like:

```text
char device redirected to /dev/pts/N
```

Open a second terminal and attach to that PTY inside the same Docker container.
Use a bidirectional PTY tool such as `socat`:

```bash
docker exec -it tgoskits-dev sh -lc 'command -v socat >/dev/null || (apt-get update && apt-get install -y --no-install-recommends socat); socat -,raw,echo=0 /dev/pts/N,raw,echo=0'
```

If `screen` is already available, this is also fine:

```bash
docker exec -it tgoskits-dev screen /dev/pts/N
```

Then run the same guest-side GDB TUI commands. This path is for manual
comparison only; it is not suitable for default CI.

## Native Thread GDB Smoke

Use this command for the native GDB thread smoke:
Expand Down
9 changes: 9 additions & 0 deletions apps/starry/gdb-smoke/native/gdb-native-tui.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set pagination off
set confirm off
set debuginfod enabled off
directory /workspace/apps/starry/gdb-smoke/native/src
break native_marker
run
layout src
echo GDB_NATIVE_TUI_READY\n
echo Use "layout asm" or "layout regs" to switch layouts.\n
13 changes: 13 additions & 0 deletions apps/starry/gdb-smoke/native/gdb-native-tui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
set -eu

if [ -z "${TERM:-}" ] || [ "${TERM:-}" = "dumb" ]; then
export TERM=xterm
fi

if [ "${1:-}" = "--demo" ]; then
shift
exec gdb -q -tui -x /usr/bin/gdb-native-tui.gdb "${1:-/usr/bin/gdb-native-smoke-target}"
fi

exec gdb -q -tui "${1:-/usr/bin/gdb-native-smoke-target}"
12 changes: 11 additions & 1 deletion apps/starry/gdb-smoke/prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ install_guest_packages() {
--no-interactive \
--force-no-chroot \
--scripts=no \
add gdb gcc musl-dev
add gdb gcc musl-dev ncurses-terminfo-base
}

compile_target() {
Expand Down Expand Up @@ -236,6 +236,8 @@ populate_overlay() {
"$app_dir/native/src/main.c" \
/usr/bin/gdb-native-smoke-target \
-Wall -Wextra -Werror -O0 -g
install -Dm0644 "$app_dir/native/src/main.c" \
"$overlay_dir/workspace/apps/starry/gdb-smoke/native/src/main.c"
compile_target \
"$app_dir/native-thread/src/main.c" \
/usr/bin/gdb-native-thread-target \
Expand All @@ -261,13 +263,21 @@ populate_overlay() {
mkdir -p "$overlay_dir/usr/share"
cp -a "$staging_root/usr/share/gdb" "$overlay_dir/usr/share/"
fi
if [[ -d "$staging_root/usr/share/terminfo" ]]; then
mkdir -p "$overlay_dir/usr/share"
cp -a "$staging_root/usr/share/terminfo" "$overlay_dir/usr/share/"
fi
if [[ -d "$staging_root/usr/lib/python3.12" ]]; then
mkdir -p "$overlay_dir/usr/lib"
cp -a "$staging_root/usr/lib/python3.12" "$overlay_dir/usr/lib/"
fi

install -Dm0755 "$app_dir/native/gdb-native-smoke.gdb" \
"$overlay_dir/usr/bin/gdb-native-smoke.gdb"
install -Dm0755 "$app_dir/native/gdb-native-tui.sh" \
"$overlay_dir/usr/bin/gdb-native-tui.sh"
install -Dm0644 "$app_dir/native/gdb-native-tui.gdb" \
"$overlay_dir/usr/bin/gdb-native-tui.gdb"
install -Dm0755 "$app_dir/native-thread/gdb-native-threads.gdb" \
"$overlay_dir/usr/bin/gdb-native-threads.gdb"
install -Dm0644 "$app_dir/gdbserver/gdbserver-smoke.gdb" \
Expand Down
22 changes: 22 additions & 0 deletions apps/starry/gdb-smoke/qemu-riscv64-tui-pty.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
args = [
"-display", "none",
"-m", "512M",
"-cpu", "rv64",
"-device", "virtio-blk-pci,drive=disk0",
"-drive", "id=disk0,if=none,format=raw,file=${workspace}/tmp/axbuild/rootfs/rootfs-riscv64-alpine.img",
"-device", "virtio-net-pci,netdev=net0",
"-netdev", "user,id=net0",
"-serial", "pty",
]
uefi = false
to_bin = true
shell_prefix = "root@starry:"
success_regex = []
fail_regex = [
'(?i)\bpanic(?:ked)?\b',
'(?m)FAIL',
'gdb: not found',
'Python Exception',
'Python initialization failed',
]
timeout = 0
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ args = [
uefi = false
to_bin = false
shell_prefix = "root@starry:"
timeout = 3600
timeout = 0
10 changes: 0 additions & 10 deletions apps/starry/gdb/build-x86_64-unknown-none.toml

This file was deleted.

Loading