Skip to content

Build some test binaries alongside the debugger; add shared-library debugging test#1105

Merged
xusheng6 merged 1 commit into
devfrom
test_shared_library_binaries
Jul 3, 2026
Merged

Build some test binaries alongside the debugger; add shared-library debugging test#1105
xusheng6 merged 1 commit into
devfrom
test_shared_library_binaries

Conversation

@xusheng6

Copy link
Copy Markdown
Member

Implements #818 and adds a regression test for #1104 (the scenario tracked in #540).

Infra — build test binaries alongside the debugger (opt-in)

  • Top-level CMakeLists.txt: new BUILD_DEBUGGER_TEST_BINARIES option (default OFF) that add_subdirectory(test). Adding a new test binary no longer needs a separate build.
  • Removed the stale test/src/* (36 files) and the old test/CMakeLists.txt — these were unused since binary builds moved to the debugger-test-binaries CI repo.
  • Fresh, focused test/CMakeLists.txt: defaults ARCH to the host and builds only what the host toolchain can produce.
  • test/README.md rewritten to document the new model.
  • .gitignore: allow committing the test shared_lib.{so,dylib} (otherwise caught by the blanket *.so/*.dylib ignore).

New binaries + test (#540)

  • test/src/shared_lib.c — shared library exporting shared_lib_add.
  • test/src/load_shared_lib.c — executable that links and calls into it (@loader_path/$ORIGIN so the library resolves beside it).
  • Committed unsigned shared_lib.dylib / load_shared_lib for Darwin-arm64 and Darwin-x86_64.
  • test_debug_shared_library: analyzes the library, sets executable_path to the loader, stops at the system entry point, and asserts the launched program is the loader (not the library, not /bin/sh), then runs to a clean exit_code == 0 (which also proves the dependent library loaded and was called).

Verification

Debugger Result
Locally-built fixed (e45cd3f) OK (arm64 + x86_64/Rosetta)
Bundled pre-fix FAILED — reproduces #1104

The test goes green with the fix and red without it.

Follow-up

Only macOS arm64/x86_64 binaries were built locally. The Linux/Windows shared_lib.{so,dll} + load_shared_lib should be produced by the debugger-test-binaries CI for the test to run there.

🤖 Generated with Claude Code

@xusheng6 xusheng6 force-pushed the test_shared_library_binaries branch 2 times, most recently from e2838d2 to fea220a Compare July 3, 2026 15:59
…ry test and docs

Add infra to build debugger unit-test binaries alongside the debugger instead of
building them separately. Implements #818.

- CMakeLists.txt: BUILD_DEBUGGER_TEST_BINARIES option, on by default, so both
  local and CI debugger builds produce the test binaries via add_subdirectory(test).
- test/CMakeLists.txt: fresh, focused build that stages binaries into
  test/binaries/<OS>-<arch> alongside the committed test binaries. A universal macOS
  build still emits thin binaries, one per architecture (per-arch targets). Signing
  is left to the existing debuggercore POST_BUILD step (core/CMakeLists.txt), which
  codesigns test/binaries/<OS>-<arch> into the -signed directory the tests load from;
  the top-level build makes debuggercore depend on the staged binaries so they exist
  before signing. The staged binaries are not committed (see .gitignore); the previous
  test/src sources and CMakeLists were unused (builds moved to the
  debugger-test-binaries repo) and are removed.

For #540, add a shared library and a
loader executable plus a test that analyzes the library while setting the executable
path to the loader, and expand the "Debugging a shared library, DLL, or dylib" docs
to cover .so/.dylib in addition to Windows DLLs. This regresses
#1104, where the debugger created the
LLDB target from the input file (the library) and dyld fell back to launching
/bin/sh. The test stops at the system entry point to confirm the loader (not
/bin/sh) was launched, then runs to a clean exit; it skips when the binaries were
not built. Verified it fails against the pre-fix debugger and passes after e45cd3f.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@xusheng6 xusheng6 force-pushed the test_shared_library_binaries branch from fea220a to 2691043 Compare July 3, 2026 16:06
@xusheng6 xusheng6 merged commit b1aefa2 into dev Jul 3, 2026
1 of 2 checks passed
@xusheng6 xusheng6 deleted the test_shared_library_binaries branch July 3, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant