Skip to content
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

gdb is missing in all toolchains #157

Open
mahaase opened this issue Jun 22, 2022 · 7 comments
Open

gdb is missing in all toolchains #157

mahaase opened this issue Jun 22, 2022 · 7 comments

Comments

@mahaase
Copy link
Contributor

mahaase commented Jun 22, 2022

there are no gdbs included in toolchains built by bob (basement).
in our case the Ubuntu 18 LTS host gdb isn't compatible with the built artifacts.

issue:
unable to initialize decompress status for section .debug_aranges

fix: use a newer gdb, but i guess, the toolchain should include one?!

@jkloetzke
Copy link
Member

Strictly speaking it could be a separate package but I guess it makes sense to include it into the toolchain directly. It makes life easier, especially in cross-toolchains...

@mahaase
Copy link
Contributor Author

mahaase commented Jul 1, 2022

as i realized, that topic isn't that easy! 😂

because of the fact, that normally every build is a cross-build in bob, we need a combination of gdb and gdbserver.

variant 1: gdb must be built by host-toolchain and gdb-server must be built by target-toolchain.
than the binary have to be started with the gdbserver and than the gdb binary have to be connected to the server.

variant 2: we use the gdb built by target-toolchain on a target-platform (sandbox or whatever).

another tricky point is the python-scripting support, that is necessary to use the gdb in qtcreator ide.
for that we need a python-dev (library, not just executable) package. in my tests i used the pipython3 layer, but i guess the current stuff of basement will not work currently.

so we will need classes to provide gdb like that:

depends:
    - if: !expr |
        "${BOB_HOST_PLATFORM}" == "linux" && "${BASEMENT_DEBUG:-0}" == "1"
      depends:
          - name: devel::gdb-host
            tools:
                target-toolchain: host-toolchain
          - devel::gdb-target

or with target-toolchain:

depends:
    - if: !expr |
        "${BOB_HOST_PLATFORM}" == "linux" && "${BASEMENT_DEBUG:-0}" == "1"
      name: devel::gdb-host
    - name: devel::cross-toolchain-x86_64-linux-gnu
      use: [tools]
      forward: True
    - if: !expr |
        "${BOB_HOST_PLATFORM}" == "linux" && "${BASEMENT_DEBUG:-0}" == "1"
      name: devel::gdb-target

gdb:

inherit: [make, install, patch, libtool]

metaEnvironment:
    PKG_VERSION: "9.2"

depends:
    - pipython3-dev
    - libs::readline-dev
    - libs::expat-dev

    - use: []
      depends:
        - libs::readline-tgt
        - libs::expat-tgt

checkoutSCM:
    scm: url
    url: ${GNU_MIRROR}/gdb/gdb-${PKG_VERSION}.tar.xz
    digestSHA256: 360cd7ae79b776988e89d8f9a01c985d0b1fa21c767a4295e5f88cb49175c555
    stripComponents: 1

checkoutDeterministic: True
checkoutScript: |
    patchApplySeries $<<gdb/*.patch>>

buildTools: [target-toolchain, python3]
buildVars: [AUTOCONF_BUILD, AUTOCONF_HOST, AUTOCONF_TARGET]
buildSetup: |
    D=$1
    build()
    {
        mkdir -p build install
        pushd build
        if [[ $D/configure -nt .configure.stamp ]] ; then
            $D/configure \
                "${@}" \
                --with-python=$(which python3) \
                --without-libiconv-prefix \
                --with-readline=yes \
                --with-libreadline-prefix=${BOB_DEP_PATHS[libs::readline-dev]}/usr \
                --with-expat=yes \
                --with-libexpat-prefix=${BOB_DEP_PATHS[libs::expat-dev]}/usr \
                --prefix=/usr \
                --disable-gtk-doc \
                --disable-gtk-doc-html \
                --disable-doc \
                --disable-docs \
                --disable-documentation \
                --disable-debug
            touch .configure.stamp
        fi
        makeParallel
        makeSequential install DESTDIR=${PWD}/../install
        popd
    }

multiPackage:
    host:
        buildScript: |
            build \
                --host=${AUTOCONF_HOST} \
                --build=${AUTOCONF_BUILD} \
                --target=${AUTOCONF_TARGET:-${AUTOCONF_HOST}}

    target:
        buildScript: |
            build \
                --host=${AUTOCONF_TARGET:-${AUTOCONF_HOST}} \
                --build=${AUTOCONF_BUILD} \
                --target=${AUTOCONF_TARGET:-${AUTOCONF_HOST}} \
                --enable-gdbserver

packageScript: |
    # copy everything
    installPackageTgt "$1/install/" "*"

patch:

--- workspace/gdb/python/python-config.py	2022-06-23 17:44:20.404765700 +0200
+++ workspace/gdb/python/python-config.py	2022-06-23 17:42:49.784765700 +0200
@@ -68,7 +68,7 @@
         if opt == '--ldflags':
             if not getvar('Py_ENABLE_SHARED'):
                 if getvar('LIBPL') is not None:
-                    libs.insert(0, '-L' + getvar('LIBPL'))
+                    libs.insert(0, '-L' + getvar('LIBPL').replace('/usr', sysconfig.EXEC_PREFIX))
                 elif os.name == 'nt':
                     libs.insert(0, '-L' + sysconfig.PREFIX + '/libs')
             if getvar('LINKFORSHARED') is not None:

@Ferruck
Copy link
Contributor

Ferruck commented Jul 1, 2022

Personally, I don't have any need for the real GDB on the target, the server is all I want. With that being said, I think the whole recipe stuff could be streamlined a bit (untested recipe following):

inherit: [autotools, patch]

metaEnvironment:
    PKG_VERSION: "9.2"

checkoutSCM:
    scm: url
    url: ${GNU_MIRROR}/gdb/gdb-${PKG_VERSION}.tar.xz
    digestSHA256: 360cd7ae79b776988e89d8f9a01c985d0b1fa21c767a4295e5f88cb49175c555
    stripComponents: 1

checkoutDeterministic: True
checkoutScript: |
    patchApplySeries $<<gdb/*.patch>>

multiPackage:
    "":
        depends:
            - pipython3-dev
            - libs::readline-dev
            - libs::expat-dev
            - use: []
              depends:
                - libs::readline-tgt
                - libs::expat-tgt

        buildTools: [python3]
        buildScript: |
            autotoolsBuild "${1}" \
                --with-python=$(which python3) \
                --without-libiconv-prefix \
                --with-readline=yes \
                --with-libreadline-prefix=${BOB_DEP_PATHS[libs::readline-dev]}/usr \
                --with-expat=yes \
                --with-libexpat-prefix=${BOB_DEP_PATHS[libs::expat-dev]}/usr

        packageScript: autotoolsPackageBin

    server:
        buildTools: [host-toolchain]
        buildScript: |
            autotoolsBuild "${1}" \
                --disable-gdb \
                --disable-ld \
                --disable-gas \
                --disable-sim \
                --disable-gprofng

        packageScript: autotoolsPackageTgt

In your root fs recipe you could then include gdb-server and, if you wish so, gdb. For the host version of gdb you could add a host-tools root recipe or similar which depends on gdb. As I said, this is untested, but the gdb-server part is what we currently use (together with the cross GDB provided by the host distribution)[1]. I don't know if this proposal would work with the Python dependency, though, as I've never needed that from within Bob.

[1] Admittedly with version 12.1 of the GDB so YMMV...

@Ferruck
Copy link
Contributor

Ferruck commented Jul 1, 2022

BTW: Any reason not to provide a less ancient GDB version? Is it supposed to match your GCC's version?

@mahaase
Copy link
Contributor Author

mahaase commented Jul 4, 2022

BTW: Any reason not to provide a less ancient GDB version? Is it supposed to match your GCC's version?

is there any dependency between gcc and gdb versions? is the newest gdb compatible with (all) gcc versions? if that all will work, we should pick a newer one! 👍

ofc! using buildTools: [host-toolchain] at least will make the recipe much more easy. 🤔
i will try ur recipe and i will try to use the available python3 recipe, too.

@Ferruck
Copy link
Contributor

Ferruck commented Jul 4, 2022

is there any dependency between gcc and gdb versions? is the newest gdb compatible with (all) gcc versions?

I'm pretty sure it should be compatible, but if it actually is? Probably @jkloetzke can shed some more light on this.

@jkloetzke
Copy link
Member

There is no actual dependency between gcc and gdb. You can use gdb also for executables created with clang. There is only the requirement that gdb needs to understand all debug information created by the compiler (DWARD, STABS). This is why you want you gdb to not run too much behind the gcc release. So there is absolutely no reason not to use the latest version of gdb...

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

No branches or pull requests

3 participants