Skip to content
Draft
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
36 changes: 36 additions & 0 deletions .github/workflows/browser-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,29 @@ jobs:
with:
version: "4.0.21"

- name: Build Binaryen with final-DWARF repair
shell: bash
env:
BINARYEN_REVISION: 0c439cce601d5812209df1fc1188afe90100fca6
run: |
set -euo pipefail
source_dir="${GITHUB_WORKSPACE}/.tools/binaryen"
build_dir="${GITHUB_WORKSPACE}/.tools/binaryen-build"
git init "${source_dir}"
git -C "${source_dir}" remote add origin \
https://github.com/cpunion/binaryen.git
git -C "${source_dir}" fetch --depth=1 origin \
"${BINARYEN_REVISION}"
git -C "${source_dir}" checkout --detach FETCH_HEAD
test "$(git -C "${source_dir}" rev-parse HEAD)" = \
"${BINARYEN_REVISION}"
cmake -S "${source_dir}" -B "${build_dir}" -G Ninja \
-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF
cmake --build "${build_dir}" \
--target wasm-opt wasm-emscripten-finalize --parallel 2
"${build_dir}/bin/wasm-opt" --version
echo "EM_BINARYEN_ROOT=${build_dir}" >> "${GITHUB_ENV}"

- name: Set up Go
uses: ./.github/actions/setup-go

Expand Down Expand Up @@ -100,6 +123,19 @@ jobs:
test -s "${RUNNER_TEMP}/browser-external.debug.wasm"
ls -lh "${RUNNER_TEMP}"/browser-*.wasm

- name: Verify final browser DWARF
shell: bash
run: |
set -euo pipefail
for artifact in \
"${RUNNER_TEMP}/browser-embedded.wasm" \
"${RUNNER_TEMP}/browser-external.debug.wasm"
do
log="${artifact}.verify.log"
llvm-dwarfdump --verify "${artifact}" 2>&1 | tee "${log}"
grep -Fxq 'No errors.' "${log}"
done

- name: Test headless Chrome Language Extension
shell: bash
run: |
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/llgo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:
run: |
echo "Test lldb with llgo plugin on ${{matrix.os}} with LLVM ${{matrix.llvm}}"
bash cmd/llgo/lldbtest/runtest.sh -v
bash cmd/llgo/debugtest/native/runtest.sh

- name: DWARF standard tests
if: ${{ startsWith(matrix.os, 'macos') && matrix.os != 'macos-15-intel' }}
Expand Down Expand Up @@ -409,3 +410,13 @@ jobs:
grep -q 'external_debug_info' "$RUNNER_TEMP/runtime-external.sections"
! grep -q '\.debug_info' "$RUNNER_TEMP/runtime-external.sections"
grep -q '\.debug_info' "$RUNNER_TEMP/runtime-external-debug.sections"

for artifact in \
"$RUNNER_TEMP/runtime-debug.wasm" \
"$RUNNER_TEMP/runtime-external.debug.wasm"
do
log="${artifact}.verify.log"
llvm-dwarfdump --verify --error-display=quiet \
"${artifact}" 2>&1 | tee "${log}"
grep -Fxq 'No errors.' "${log}"
done
43 changes: 26 additions & 17 deletions cmd/llgo/debugtest/ACCEPTANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ compatibility target. Exact commands live in these focused fixtures:
- WASI: `cmd/llgo/debugtest/wasi`;
- browser: `cmd/internal/browser` and `internal/browserdebug`.

The browser lane uses Emscripten 4.0.21 and temporarily pins Binaryen commit
`0c439cce601d5812209df1fc1188afe90100fca6`, which contains the DWARF range
repair proposed in
[WebAssembly/binaryen#8964](https://github.com/WebAssembly/binaryen/pull/8964).
The pin can move back to an Emscripten-provided Binaryen release once that
repair is upstream and included in the supported SDK.

## CI baseline

| Gate | Workflow | What must be observed |
| --- | --- | --- |
| Native Darwin/Linux | `llgo.yml` | source breakpoints, scopes, locals/globals, runtime values, goroutine ownership/stacks, and raw non-LLGo fallback |
| Native Darwin/Linux | `llgo.yml` | source breakpoints, scopes, locals/globals, runtime values, goroutine ownership/stacks, panic/fault source locations, optimized inline stepping, Go/C/Go frames, and raw non-LLGo fallback |
| Emulated embedded | `targets.yml` | host ELF, GDB Remote and LLDB `gdb-remote`, source values/backtrace, identical flashed bytes with/without host DWARF, and verified retained DWARF |
| WASI | `wasi-debug.yml` | final Wasm DWARF, Wasmtime guest stub, source breakpoint, parameter/local, call stack, and clean exit |
| WASI | `wasi-debug.yml`, `llgo.yml` | strict final embedded/external Wasm DWARF verification, Wasmtime guest stub, source breakpoint, parameter/local, call stack, and clean exit |
| Browser | `browser-debug.yml` | embedded and external DWARF, standard build identity, escaped sidecar URL, source remapping, all common runtime-layout categories, real LLGo Wasm registration, and no-extension fallback |

Physical hardware is deliberately outside required PR CI. Its guarded script
Expand Down Expand Up @@ -58,21 +65,23 @@ Platform-specific limits remain explicit:
- A missing external Wasm sidecar and a mismatched `build_id` fail before the
browser launches. A consumer without the LLGo extension keeps raw/name
section symbolication but does not get Go runtime presentation.
- The current Asyncify-transformed browser runtime is accepted by Go's DWARF
reader and Chrome, but LLVM's final `llvm-dwarfdump --verify` still reports
overlapping/range-containment diagnostics. With Emscripten 4.0.21 and
Binaryen 125, relinking the exact same objects without Asyncify passes the
verifier across all compile units; Asyncify alone introduces invalid ranges
in both LLGo and Emscripten C-library DIEs. This matches Binaryen issue
[#6406](https://github.com/WebAssembly/binaryen/issues/6406). A source map
can recover source lines but cannot repair Wasm-local variable locations, so
it is not a substitute for this gate. This is a final-artifact blocker, not a
condition that the acceptance lane may suppress.

Panic/trap source stops, optimized inline stepping, Go/host boundary frames,
and clean final DWARF after every LTO/post-link transform remain required
before the umbrella issue itself can be closed. Keep those failures visible in
focused fixtures rather than weakening the validators.
- Binaryen updates DWARF after Asyncify with a conservative range-topology
repair. Representable parent scopes are rebuilt from surviving children;
lost, reversed, or ambiguous scopes are reported as unavailable instead of
being assigned unrelated code. The browser lane runs
`llvm-dwarfdump --verify` against both the final embedded module and the
external DWARF sidecar after all post-link transforms. A verifier diagnostic
remains a hard failure; source maps are not accepted as a substitute for
variable, scope, or type DWARF.

The native lane additionally stops explicit panic, integer division by zero,
invalid memory, and a real host trap at their exact source locations. Its
optimized fixture must preserve nested LLVM inline frames and step back to the
physical caller, while its callback fixture preserves ordered Go/C/Go frames.
Equivalent boundary coverage remains platform-specific. Clean final DWARF
after every LTO/post-link transform is still required before the umbrella
issue itself can be closed; keep transform failures visible in focused
fixtures rather than weakening the validators.

## Artifact-size accounting

Expand Down
15 changes: 15 additions & 0 deletions cmd/llgo/debugtest/native/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Native fault and boundary debugging

This fixture builds one final native LLGo artifact and drives it through stock
LLDB. It verifies that explicit panic, integer division by zero, and invalid
memory retain their exact Go source locations at the shared panic path; that a
real host trap stops on both its C source and Go caller; and that a callback
stack preserves ordered Go-to-C-to-Go boundary frames. A separate `-O2`
artifact must expose nested LLVM inline frames and step from the inline leaf
back to the non-inline caller's next source line.

Run it after installing LLGo and LLDB 18 or newer:

```sh
bash cmd/llgo/debugtest/native/runtest.sh
```
Loading
Loading