From 2128ce52448fb812b1f08e05b0bf952b862f131a Mon Sep 17 00:00:00 2001 From: swananan Date: Wed, 9 Sep 2026 18:36:51 +0800 Subject: [PATCH] feat: explain value display failures and capture limits Expose stable value diagnostics in printed values and trace details so users can distinguish unavailable variables, failed reads, adapter fallbacks, and capture limits. Preserve path-qualified notes in CLI and TUI output independently of capture selection and register locations. Embed --value-diagnostics-help, provide matching English and Chinese guidance, and update the runtime-analysis skill to 0.0.6. Explain failed read triage without treating errno or static display limits as a cause. Consolidate diagnostic e2e coverage around reasons, retained values, streams, and exit status, including ordinary null-pointer reads and register-backed arguments with static display notes. --- .github/workflows/ci.yml | 5 +- README-zh.md | 6 +- README.md | 6 +- docs/architecture.md | 30 + docs/configuration.md | 4 + docs/input-commands.md | 2 + docs/limitations.md | 2 + docs/scripting.md | 11 +- docs/value-diagnostics.md | 175 ++++ docs/zh/architecture.md | 24 + docs/zh/configuration.md | 4 + docs/zh/input-commands.md | 2 + docs/zh/limitations.md | 2 + docs/zh/scripting.md | 11 +- docs/zh/value-diagnostics.md | 145 ++++ e2e-tests/README.md | 44 + e2e-tests/tests/common/termination.rs | 5 +- .../tests/entry_value_recovery_execution.rs | 6 +- .../sized/alloc.rs | 124 +++ .../rust_value_diagnostics_program/main.rs | 112 +++ .../register.rs | 32 + e2e-tests/tests/globals_target_execution.rs | 2 +- .../optimized_inline_call_value_execution.rs | 66 -- .../rust_adapter_diagnostics_execution.rs | 70 -- .../tests/rust_legacy_btree_execution.rs | 2 +- e2e-tests/tests/rust_legacy_hash_execution.rs | 2 +- .../tests/rust_legacy_sequence_execution.rs | 2 +- .../tests/rust_legacy_string_execution.rs | 2 +- e2e-tests/tests/rust_path_execution.rs | 8 +- e2e-tests/tests/rust_script_execution.rs | 37 +- .../tests/rust_version_matrix_execution.rs | 2 +- .../tests/value_diagnostics_execution.rs | 782 ++++++++++++++++++ ghostscope-compiler/src/ebpf/codegen/args.rs | 180 ++-- .../ebpf/codegen/value_capture/diagnostics.rs | 102 +++ .../src/ebpf/codegen/value_capture/mod.rs | 2 + .../codegen/value_capture/presentation.rs | 24 +- .../src/ebpf/codegen/value_capture/tests.rs | 29 + ghostscope-compiler/src/lib.rs | 4 + ghostscope-dwarf/src/analyzer/type_context.rs | 318 +++++-- ghostscope-dwarf/src/language/mod.rs | 17 +- .../src/language/rust/composition.rs | 7 +- ghostscope-dwarf/src/language/rust/mod.rs | 2 +- ghostscope-dwarf/src/lib.rs | 9 +- ghostscope-dwarf/src/semantics/mod.rs | 2 +- ghostscope-dwarf/src/semantics/value.rs | 74 ++ ghostscope-protocol/src/format_printer.rs | 140 +++- ghostscope-protocol/src/lib.rs | 3 + ghostscope-protocol/src/trace_context.rs | 112 ++- ghostscope-protocol/src/value_diagnostic.rs | 98 +++ ghostscope-protocol/src/value_presentation.rs | 3 + .../src/components/app/runtime_status.rs | 20 + .../command_panel/response_formatter.rs | 5 + .../components/command_panel/script_editor.rs | 3 + ghostscope-ui/src/events/runtime.rs | 32 + ghostscope-ui/src/model/panel_state.rs | 4 + ghostscope-ui/tests/ansi_color_test.rs | 77 ++ ghostscope/src/cli/docs.rs | 5 + ghostscope/src/cli/mod.rs | 2 +- ghostscope/src/cli/value-diagnostics.md | 1 + ghostscope/src/config/args.rs | 95 ++- ghostscope/src/main.rs | 4 + ghostscope/src/script/attach.rs | 1 + ghostscope/src/script/cli.rs | 13 +- ghostscope/src/script/tui.rs | 3 + ghostscope/src/trace/instance.rs | 5 +- ghostscope/src/trace/manager.rs | 4 + ghostscope/src/trace/snapshot.rs | 1 + ghostscope/src/tui/coordinator.rs | 2 + ghostscope/src/tui/info_handlers.rs | 1 + skills/ghostscope-runtime-analysis/SKILL.md | 16 +- skills/ghostscope-runtime-analysis/VERSION | 2 +- .../references/cli-cookbook.md | 14 + .../references/doc-map.md | 14 + .../references/issue-reporting.md | 5 + 74 files changed, 2762 insertions(+), 420 deletions(-) create mode 100644 docs/value-diagnostics.md create mode 100644 docs/zh/value-diagnostics.md create mode 100644 e2e-tests/tests/fixtures/rust_adapter_rejection_program/sized/alloc.rs create mode 100644 e2e-tests/tests/fixtures/rust_value_diagnostics_program/main.rs create mode 100644 e2e-tests/tests/fixtures/rust_value_diagnostics_program/register.rs delete mode 100644 e2e-tests/tests/rust_adapter_diagnostics_execution.rs create mode 100644 e2e-tests/tests/value_diagnostics_execution.rs create mode 100644 ghostscope-compiler/src/ebpf/codegen/value_capture/diagnostics.rs create mode 100644 ghostscope-protocol/src/value_diagnostic.rs create mode 120000 ghostscope/src/cli/value-diagnostics.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caa92d8a..30989b63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -296,11 +296,14 @@ jobs: - name: Build debug run: cargo build --all-features - - name: Verify embedded script help matches docs + - name: Verify embedded help matches docs run: | tmpfile="$(mktemp)" + trap 'rm -f "$tmpfile"' EXIT target/debug/ghostscope --script-help > "$tmpfile" diff -u docs/scripting.md "$tmpfile" + target/debug/ghostscope --value-diagnostics-help > "$tmpfile" + diff -u docs/value-diagnostics.md "$tmpfile" - name: Build release run: cargo build --release --all-features diff --git a/README-zh.md b/README-zh.md index 9885a298..45a86e6d 100644 --- a/README-zh.md +++ b/README-zh.md @@ -221,6 +221,10 @@ GhostScope 把编译后的二进制重新变成“可观测系统”。在 TUI - [**使用限制**](docs/zh/limitations.md) 已知的限制和约束 +- [**值诊断**](docs/zh/value-diagnostics.md) + 理解值不可用、内存读取失败、展示降级和采集限制; + 使用 `ghostscope --value-diagnostics-help` 离线查看 + @@ -237,7 +241,7 @@ GhostScope 把编译后的二进制重新变成“可观测系统”。在 TUI 输入模式所有可用命令 - [**脚本语言**](docs/zh/scripting.md) - 编写强大的追踪脚本 + 编写追踪脚本;使用 `ghostscope --script-help` 离线查看 diff --git a/README.md b/README.md index 4cc37796..b90dcd4a 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,10 @@ See [Limitations](docs/limitations.md) for unsupported and explicitly degraded s - [**Limitations**](docs/limitations.md) Known limitations and constraints +- [**Value Diagnostics**](docs/value-diagnostics.md) + Understand unavailable values, read failures, display fallbacks, and capture limits; + read offline with `ghostscope --value-diagnostics-help` + @@ -242,7 +246,7 @@ See [Limitations](docs/limitations.md) for unsupported and explicitly degraded s All available commands for Input Mode - [**Script Language**](docs/scripting.md) - Write powerful trace scripts + Write trace scripts; read offline with `ghostscope --script-help` diff --git a/docs/architecture.md b/docs/architecture.md index d220fb97..498efb20 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -39,6 +39,36 @@ validated protocol record or explicit failure state | Event transport | `LOSS-1` | RingBuf or PerfEventArray carries events; output-helper failures increment per-trace loss counters. | | Protocol and rendering | `IDENT-1`, `FAIL-1` | Trace/PID/TID metadata and structured unavailable, expression-error, and backtrace states remain visible to consumers. | +## Value Display Diagnostics + +Static display limits and runtime read statuses travel separately. The DWARF +layer resolves a `ValueReadPlanResolution` containing an optional capture plan, +path-qualified static notes, and any rejected root adapter report. Notes survive +even when no semantic capture is selected; ordinary DWARF reads retain their +runtime address checks. The compiler adds limits discovered during bounded +capture lowering and finalizes notes for both memory-backed and register-backed +arguments, binding them to expression/type indices in `TraceContext`. Setup messages deduplicate +resolved expressions, types, and reasons even when internal indices differ. + +CLI, TUI creation results, and trace snapshots consume the same structured +notes. Snapshots retain them for `info trace`, independently of logs and loader +actor ownership. Runtime read failures retain `VariableStatus` and individual +nested-child statuses; the formatter never parses logs to infer failures. +Diagnostic metadata adds no eBPF memory reads and does not change the binary +status layout. Optional sequence-width metadata identifies proven element-limit +truncation; legacy metadata retains a general capture-limit explanation. + +At semantic depth boundaries, bounded type-only lookahead avoids diagnosing +plain field-only structs as failed adapters. It does not traverse runtime +pointer graphs. Static enum-path notes describe possible branches, not observed +read failures. User-facing explanations and next steps are in +[value diagnostics](value-diagnostics.md). + +The CLI embeds that same Markdown file for `--value-diagnostics-help`, using the same +early-exit path as `--script-help`. CI compares both outputs with their source +documents. Skills route to the installed binary's reference instead of +maintaining a separate copy of the guide. + ## System Overview ``` diff --git a/docs/configuration.md b/docs/configuration.md index 4bb344ea..52ca4f93 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -68,6 +68,9 @@ ghostscope --script-file trace.gs # Print the embedded script language reference and exit ghostscope --script-help +# Explain value failures, display fallbacks, and capture limits offline +ghostscope --value-diagnostics-help + # Choose script-mode event stdout rendering ghostscope --script-output pretty # default: formatted stdout ghostscope --script-output plain # payload-only stdout @@ -290,6 +293,7 @@ index is reported in CLI/TUI startup status before falling back. | `--script