Debug Tooling - #78
Conversation
b3ce052 to
f1b29e1
Compare
f1b29e1 to
c010938
Compare
vvysokikh1
left a comment
There was a problem hiding this comment.
some small improvements needed, close to completion
| # links resolve to these same files. | ||
| RUN set -ex; \ | ||
| gdb-add-index /opt/xrpld/bin/xrpld; \ | ||
| gdb-add-index /opt/fuzzer/bin/rippled-fuzzer |
There was a problem hiding this comment.
gdb-add-index exits 0 when it produces no index, so set -e won't catch a failure.
maybe worth adding additional checks here?
RUN set -ex; \
> gdb-add-index /opt/xrpld/bin/xrpld; \
> gdb-add-index /opt/fuzzer/bin/rippled-fuzzer; \
> readelf -S /opt/xrpld/bin/xrpld | grep -q '\.gdb_index'; \
> readelf -S /opt/fuzzer/bin/rippled-fuzzer | grep -q '\.gdb_index'; \
> /opt/xrpld/bin/xrpld --version
(If you switch to --dwarf-5, the grep target becomes .debug_names.)
| # VM, can overrun the debug-session command window; the index lets gdb jump straight | ||
| # to the units it needs. One-time build cost (the scan happens here); the /symbols/* | ||
| # links resolve to these same files. | ||
| RUN set -ex; \ |
There was a problem hiding this comment.
This RUN rewrites files that arrived via COPY --from=build, so overlayfs stores a full second copy of both binaries in the new layer while the originals stay in the lower layer. That's a couple of gigabytes at this point.
Doing the indexing in an intermediate stage keeps one copy in the final image.
|
|
||
| # Embed a .gdb_index in the binaries (gdb-add-index ships with gdb; it uses objcopy | ||
| # from binutils). Without it, gdb rebuilds its symbol table by scanning ~600 MB of | ||
| # DWARF at startup -- significant CPU and memory that, on a resource-constrained MVD |
There was a problem hiding this comment.
The PR description says this "(should)" fix the timeouts — since the whole change is a performance one, worth landing a measured number in the comment rather than "minutes → seconds":
time gdb -batch -nx -ex 'file /opt/xrpld/bin/xrpld' -ex 'thread apply all bt' -ex quit
Also: clang 22 defaults to DWARF 5, and gdb-add-index --dwarf-5 emits the native .debug_names accelerator instead of .gdb_index. On DWARF-5 input that's often the faster of the two, so it seems worth A/B-ing before settling on the default.
The existing Dockerfile already included
gdbwhich is useful when using Antithesis' MVD. This PR addsbinutilsand introduces pre-built gdb indexes to the image. This (should) optimize gdb in MVD to avoid timeout issues.