-
Notifications
You must be signed in to change notification settings - Fork 6
gdb: package the GNU debugger 17.2 #544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| let { standaloneTest, Attrs, BuildSpec, Local, OutputBin, OutputData, Source, Test, .. } = import "minimal.ncl" in | ||
| let base = import "../base/build.ncl" in | ||
| let bash = import "../bash/build.ncl" in | ||
| let coreutils = import "../coreutils/build.ncl" in | ||
| let expat = import "../expat/build.ncl" in | ||
| let gcc = import "../gcc/build.ncl" in | ||
| let glibc = import "../glibc/build.ncl" in | ||
| let gmp = import "../gmp/build.ncl" in | ||
| let make = import "../make/build.ncl" in | ||
| let mpfr = import "../mpfr/build.ncl" in | ||
| let ncurses = import "../ncurses/build.ncl" in | ||
| let pkgconf = import "../pkgconf/build.ncl" in | ||
| let python = import "../python/build.ncl" in | ||
| let readline = import "../readline/build.ncl" in | ||
| let toolchain = import "../toolchain/build.ncl" in | ||
| let xz = import "../xz/build.ncl" in | ||
| let zlib = import "../zlib/build.ncl" in | ||
| let zstd = import "../zstd/build.ncl" in | ||
|
|
||
| let version = "17.2" in | ||
| { | ||
| name = "gdb", | ||
| build_deps = [ | ||
| { file = "build.sh" } | Local, | ||
| { | ||
| url = "gs://minimal-staging-archives/gdb-%{version}.tar.xz", | ||
| sha256 = "1c036c0d72e4b3d1fb5c94c88632add6f9d76f4d7c4d2ea793c12a9f19a3228c", | ||
| } | Source, | ||
| base, | ||
| toolchain, | ||
| gcc, | ||
| make, | ||
| pkgconf, | ||
| glibc, | ||
| # Terminal + line editing. Built --with-system-readline so gdb uses OUR | ||
| # readline rather than its bundled copy — a bundled copy would be invisible | ||
| # to pkgscan, which is the same reasoning applied to rizin's use_sys_* flags. | ||
| ncurses, | ||
| readline, | ||
| # XML target descriptions and remote memory maps. Effectively required in | ||
| # practice even though configure treats it as optional. | ||
| expat, | ||
| # Debug-info compression formats gdb reads directly from ELF sections. | ||
| zlib, | ||
| xz, | ||
| zstd, | ||
| # Expression arithmetic. | ||
| gmp, | ||
| mpfr, | ||
| # LOAD-BEARING: gef is a Python extension and cannot load into a gdb built | ||
| # without --with-python. See build.sh. | ||
| python, | ||
| ], | ||
| runtime_deps = [ | ||
| bash, | ||
| # `gcore` is a shell script with a `#!/usr/bin/env` shebang, so env must be | ||
| # present at RUNTIME or the script is unrunnable. Caught by the | ||
| # missing_runtime_deps checker rather than by us noticing. | ||
| coreutils, | ||
| ncurses, | ||
| readline, | ||
| expat, | ||
| zlib, | ||
| xz, | ||
| zstd, | ||
| gmp, | ||
| mpfr, | ||
| python, | ||
| ], | ||
|
|
||
| cmd = "./build.sh", | ||
| build_args = { | ||
| include version, | ||
| }, | ||
|
|
||
| outputs = { | ||
| gdb = { glob = "usr/bin/gdb" } | OutputBin, | ||
| gdb_add_index = { glob = "usr/bin/gdb-add-index" } | OutputBin, | ||
| gcore = { glob = "usr/bin/gcore" } | OutputBin, | ||
| gdbserver = { glob = "usr/bin/gdbserver" } | OutputBin, | ||
| # gdb's Python runtime support files — the `python` directory it loads its | ||
| # own pretty-printers and commands from. | ||
| gdb_data = { glob = "usr/share/gdb/**" } | OutputData, | ||
| }, | ||
| tests = { | ||
| smoketest = standaloneTest "/bin/gdb --version", | ||
|
|
||
| # PIN THE TWO PROPERTIES THE CONFIGURE FLAGS EXIST FOR. Both regress | ||
| # SILENTLY: configure probes for Python and for target support, and if | ||
| # either probe fails it prints a note and carries on to a successful build. | ||
| # You would get a gdb that installs, runs, passes a --version smoketest, and | ||
| # is useless for the thing it was packaged to do. | ||
| capabilities = | ||
| { | ||
| class = 'Standalone, | ||
| test_deps = [base], | ||
| cmds = [ | ||
| # --with-python: gef is a Python extension. Without this gdb reports | ||
| # "Python scripting is not supported in this copy of GDB" and gef | ||
| # cannot load at all. | ||
| ["/bin/bash", "-c", "gdb -batch -ex 'python print(\"py-ok\")' | grep -q py-ok"], | ||
| # --enable-targets=all: a foreign architecture must be selectable, or | ||
| # gdb cannot disassemble a binary emulated under qemu-user's gdbstub. | ||
| # i386 is foreign on every arch we build for. | ||
| ["/bin/bash", "-c", "gdb -batch -ex 'set architecture' 2>&1 | grep -q i386"], | ||
| ], | ||
| } | Test, | ||
| }, | ||
|
|
||
| attrs = | ||
| { | ||
| upstream_version = version, | ||
| license_spdx = "GPL-3.0-or-later", | ||
| source_provenance = { | ||
| category = 'GnuProject, | ||
| name = "gdb", | ||
| }, | ||
| } | Attrs, | ||
| } | BuildSpec | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | ||||||||||||
| #!/bin/sh | ||||||||||||
| set -e | ||||||||||||
|
|
||||||||||||
| tar -xof "gdb-${MINIMAL_ARG_VERSION}.tar.xz" | ||||||||||||
| cd "gdb-${MINIMAL_ARG_VERSION}" | ||||||||||||
|
|
||||||||||||
| case $(uname -m) in | ||||||||||||
| x86_64) MARCH="-march=x86-64-v3" ;; | ||||||||||||
| aarch64) MARCH="-march=armv8-a" ;; | ||||||||||||
| *) MARCH="" ;; | ||||||||||||
| esac | ||||||||||||
|
|
||||||||||||
| # Reproducibility flags per the pkgs AGENTS.md C/C++ stack: two builds of the | ||||||||||||
| # same source must be byte-identical. | ||||||||||||
| export CFLAGS="$MARCH -O2 -pipe -gno-record-gcc-switches -ffile-prefix-map=$(pwd)=/builddir" | ||||||||||||
| export CXXFLAGS="$CFLAGS" | ||||||||||||
| export LDFLAGS="-Wl,--build-id=none" | ||||||||||||
| export ARFLAGS=Drc | ||||||||||||
|
|
||||||||||||
| # The gdb tarball ships the ENTIRE binutils-gdb tree — bfd, gas, ld, gprof and | ||||||||||||
| # the binutils programs are all in here. Building them would silently produce a | ||||||||||||
| # second `ld`/`objdump`/`as` that collide with our binutils package. Disable all | ||||||||||||
| # of them; we want exactly one binary out of this tree. | ||||||||||||
| # | ||||||||||||
| # --with-python is LOAD-BEARING, not a nicety: gef is a Python extension and | ||||||||||||
| # cannot load into a gdb built without Python support. Since the whole point of | ||||||||||||
| # packaging gdb here is to carry gef, a non-Python gdb would satisfy the build | ||||||||||||
| # and fail the actual goal. | ||||||||||||
| # | ||||||||||||
| # --enable-targets=all costs nothing at build time and lets gdb disassemble | ||||||||||||
| # foreign architectures — which is what makes it useful against a binary being | ||||||||||||
| # emulated under qemu-user's gdbstub, and mirrors the fix the binutils package | ||||||||||||
| # still needs. | ||||||||||||
| # | ||||||||||||
| # MAKEINFO=true skips building the info manuals so we do not have to package | ||||||||||||
| # texinfo for a doc format nothing here reads. | ||||||||||||
| ./configure \ | ||||||||||||
| --prefix=/usr \ | ||||||||||||
| --disable-binutils \ | ||||||||||||
| --disable-ld \ | ||||||||||||
| --disable-gas \ | ||||||||||||
| --disable-gprof \ | ||||||||||||
| --disable-gold \ | ||||||||||||
| --disable-sim \ | ||||||||||||
| --disable-nls \ | ||||||||||||
| --disable-werror \ | ||||||||||||
| --with-python=/usr/bin/python3 \ | ||||||||||||
| --with-system-readline \ | ||||||||||||
| --with-system-zlib \ | ||||||||||||
| --enable-targets=all \ | ||||||||||||
| MAKEINFO=true | ||||||||||||
|
|
||||||||||||
| make -j"$(nproc)" MAKEINFO=true | ||||||||||||
| make install DESTDIR="$OUTPUT_DIR" MAKEINFO=true | ||||||||||||
|
|
||||||||||||
| # `make install` from this tree also drops libbfd/libopcodes headers and static | ||||||||||||
| # archives that belong to the binutils package. Remove them so the two packages | ||||||||||||
| # cannot disagree about who owns bfd.h. | ||||||||||||
| rm -rf "$OUTPUT_DIR/usr/include" "$OUTPUT_DIR/usr/lib/libbfd."* "$OUTPUT_DIR/usr/lib/libopcodes."* | ||||||||||||
| rm -rf "$OUTPUT_DIR/usr/share/info" "$OUTPUT_DIR/usr/share/locale" | ||||||||||||
|
Comment on lines
+59
to
+60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Remove all installed libtool archives. Autotools C/C++ package builds must remove installed Proposed fix rm -rf "$OUTPUT_DIR/usr/include" "$OUTPUT_DIR/usr/lib/libbfd."* "$OUTPUT_DIR/usr/lib/libopcodes."*
rm -rf "$OUTPUT_DIR/usr/share/info" "$OUTPUT_DIR/usr/share/locale"
+find "$OUTPUT_DIR" -type f -name '*.la' -delete📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: gominimal/pkgs
Length of output: 17810
🏁 Script executed:
Repository: gominimal/pkgs
Length of output: 11776
🏁 Script executed:
Repository: gominimal/pkgs
Length of output: 50370
🌐 Web query:
GNU GDB 17.2 gdb-add-index source script objcopy readelf PATH💡 Result:
The gdb-add-index utility is a helper script provided with GNU GDB (including version 17.2) designed to speed up GDB startup by adding an index section to a symbol file [1][2][3]. By default, gdb-add-index searches the PATH environment variable to locate the required programs: gdb, objcopy, and readelf [2][3]. If you need to use specific versions of these tools or if they are not in your system's PATH, you can override the default search by setting the following environment variables [2][3][4]: GDB: Specifies the path to the gdb executable [3]. OBJCOPY: Specifies the path to the objcopy executable [3]. READELF: Specifies the path to the readelf executable [3]. The script uses readelf to inspect the binary for existing indices and objcopy to inject the newly created.gdb_index (or DWARF 5.debug_names and.debug_str) section into the target file [2][5][3]. The target symbol file must be writable for the operation to succeed [2][3].
Citations:
🏁 Script executed:
Repository: gominimal/pkgs
Length of output: 41014
🏁 Script executed:
Repository: gominimal/pkgs
Length of output: 26286
🏁 Script executed:
Repository: gominimal/pkgs
Length of output: 27039
Declare
gdb-add-index’s binutils tools at runtime.Import
binutilsandsubsetOf, then addsubsetOf binutils ["objcopy", "readelf"]toruntime_deps; add a standalone test that runsgdb-add-indexon a copied debuggable ELF.🤖 Prompt for AI Agents