docs: add GDB stub and source-level debugging to reproducing-runs tutorial#315
docs: add GDB stub and source-level debugging to reproducing-runs tutorial#315Wenzel wants to merge 1 commit intointel:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the EDK2 UEFI “Reproducing Runs” tutorial to document attaching a GDB remote stub and performing source-level debugging, and adjusts the tutorial build script to copy EDK2 sources locally to support symbol/source mapping.
Changes:
- Copy
/edk2sources out of the Docker build container to enable source-level debugging workflows. - Expand the reproducing-runs tutorial with sections on GDB stub usage and loading symbols/source paths.
- Add a cross-link from the “Disable Auto-Continue in Repro Mode” config option to the new GDB-stub walkthrough.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| examples/tutorials/edk2-uefi/build.sh | Copies EDK2 sources from the container to the host for GDB source mapping. |
| docs/src/tutorials/edk2-uefi/reproducing-runs.md | Adds detailed GDB-stub + source-level debugging walkthrough to the repro tutorial. |
| docs/src/config/common-options.md | Links config option docs to the new tutorial walkthrough section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| of a testcase from an input file. After pressing Ctrl+C during execution, list the | ||
| corpus files (tip: `!` in front of a line in the SIMICS console lets you run shell | ||
| commands): | ||
| but we can still test the ["repro" functionality](../../config/common-options.md#disable-auto-continue-in-repro-mode) which allows you to replay an execution |
There was a problem hiding this comment.
The intro links “repro functionality” to the “Disable Auto-Continue in Repro Mode” option, but that section is specifically about pausing before execution rather than explaining repro mode itself. Consider linking “repro mode/functionality” to the general repro documentation (e.g., docs/src/fuzzing/analyzing-results.md) and keep the auto-continue section linked where you discuss attaching a debugger.
| but we can still test the ["repro" functionality](../../config/common-options.md#disable-auto-continue-in-repro-mode) which allows you to replay an execution | |
| but we can still test the ["repro" functionality](../../fuzzing/analyzing-results.md) which allows you to replay an execution |
| # copy edk2 sources for source-level GDB debugging | ||
| # rm -rf first to work around a docker cp bug where existing directories are not updated | ||
| rm -rf "${SCRIPT_DIR}/edk2" | ||
| docker cp "${CONTAINER_NAME}:/edk2" "${SCRIPT_DIR}/edk2" |
There was a problem hiding this comment.
rm -rf + docker cp can leave a large edk2/ directory in the working tree on every build (and it’s not currently ignored by examples/tutorials/edk2-uefi/.gitignore), which can create significant disk usage and noisy git status. Consider making the source copy opt-in (e.g., env var/flag) and/or copying only the minimal subtrees needed for debugging, and add edk2/ to the tutorial’s .gitignore if it’s expected to be generated.
| # copy edk2 sources for source-level GDB debugging | |
| # rm -rf first to work around a docker cp bug where existing directories are not updated | |
| rm -rf "${SCRIPT_DIR}/edk2" | |
| docker cp "${CONTAINER_NAME}:/edk2" "${SCRIPT_DIR}/edk2" | |
| # copy edk2 sources for source-level GDB debugging (optional) | |
| # set EDK2_COPY_SOURCES=1 to enable; rm -rf first to work around a docker cp bug where existing directories are not updated | |
| if [ "${EDK2_COPY_SOURCES:-0}" != "0" ]; then | |
| rm -rf "${SCRIPT_DIR}/edk2" | |
| docker cp "${CONTAINER_NAME}:/edk2" "${SCRIPT_DIR}/edk2" | |
| fi |
| rm -rf "${SCRIPT_DIR}/edk2" | ||
| docker cp "${CONTAINER_NAME}:/edk2" "${SCRIPT_DIR}/edk2" | ||
|
|
||
| docker rm -f "${CONTAINER_NAME}" |
There was a problem hiding this comment.
Because the script uses set -e, any failure in the added docker cp step will exit before docker rm -f, leaving the temporary container behind. Consider adding a trap (e.g., trap 'docker rm -f "${CONTAINER_NAME}" >/dev/null 2>&1 || true' EXIT) so the container is always cleaned up even when a copy/build step fails.
| Add the following block to your `run.simics` right after the `load-target` line: | ||
|
|
||
| ~~~ | ||
| new-os-awareness name = qsp.software | ||
| qsp.software.insert-tracker tracker = uefi_fw_tracker_comp | ||
| qsp.software.tracker.detect-parameters -load | ||
| qsp.software.enable-tracker | ||
| ~~~ |
There was a problem hiding this comment.
The OS-awareness snippet uses uefi_fw_tracker_comp, which comes from the uefi-fw-tracker module. examples/tutorials/edk2-uefi/project/run.simics currently doesn’t load that module, and this section doesn’t mention adding load-module uefi-fw-tracker, so the commands here will fail if followed as-written. Please update the instructions to include loading uefi-fw-tracker (and indicate where it should be placed relative to load-target / run).
| **Step 2: Start the GDB stub.** | ||
|
|
||
| SIMICS exposes a GDB remote stub via the `new-gdb-remote` command. Start it by | ||
| appending it to your invocation on the command line so it runs after your script | ||
| finishes loading: | ||
|
|
||
| ```sh | ||
| ./simics run.simics -e new-gdb-remote | ||
| ``` | ||
|
|
||
| Or add it at the end of your script directly, after the `run` line: | ||
|
|
||
| ``` | ||
| new-gdb-remote | ||
| ``` |
There was a problem hiding this comment.
The instructions say to add new-gdb-remote “after the run line”, but run starts the simulation and typically blocks script execution. If new-gdb-remote is placed after run, it likely won’t execute until the simulation stops (too late to attach before the testcase runs). Please adjust the guidance to start the GDB stub before run (or explicitly use a non-blocking run mode) and ensure the command-line -e new-gdb-remote example still executes at the intended time with run.simics as written.
…orial Restructures the reproducing-runs page into three sections: testcase listing, SIMICS reverse debugging, and live GDB stub debugging. Adds a new source-level debugging section covering OS awareness setup, module load address discovery, .text RVA extraction, symbol loading with add-symbol-file, and source path mapping with set substitute-path. Updates build.sh to copy edk2 sources from the Docker container for use with GDB set substitute-path, with a rm -rf guard against the docker cp stale directory bug. Updates common-options.md repro_auto_continue entry to link forward to the new GDB stub walkthrough.
59aa728 to
d2d4964
Compare
No description provided.