5

I've been trying to install gdbserver package on Alpine Docker image (https://hub.docker.com/_/alpine/)

apk add gdbserver

was giving me this:

ERROR: unsatisfiable constraints: gdbserver (missing): required by: world[gdbserver]

At the same time,

apk add gdb

works just fine. So, what's the correct way to install the gdbserver package on Alpine?

P.S.

apk update has been executed before everything else.

user3346684
  • 111
  • 1
  • 3

2 Answers2

10

Currently it seems that gdbserver is not a package available at the alpine repositories and the gdb package does not contain gdbserver.

But you can install gdb from source which contains gdbserver.

First you will need to install the required packages for the compilation:

apk add --no-cache make
apk add --no-cache linux-headers
apk add --no-cache texinfo
apk add --no-cache gcc
apk add --no-cache g++

then you can install it , downloading the source and compiling it:

wget http://ftp.gnu.org/gnu/gdb/gdb-7.11.tar.xz
tar -xvf gdb-7.11.tar.xz
cd gdb-7.11
./configure --prefix=/usr
make
make -C gdb install

After that you should be able to run gdbserver from the shell.

I have been using this procedure in Docker, with the following dockerfile which also includes a ssh server installation:

FROM alpine
RUN apk update
# we need make and linux-headers to compile gdb
RUN apk add --no-cache make
RUN apk add --no-cache linux-headers
RUN apk add --no-cache texinfo
RUN apk add --no-cache gcc
RUN apk add --no-cache g++
RUN apk add --no-cache gfortran
# install gdb
# RUN apk add --no-cache gdb
RUN mkdir gdb-build ;\
    cd gdb-build;\
    wget http://ftp.gnu.org/gnu/gdb/gdb-7.11.tar.xz;\
    tar -xvf gdb-7.11.tar.xz;\
    cd gdb-7.11;\
    ./configure --prefix=/usr;\
    make;\
    make -C gdb install;\
    cd ..;\
    rm -rf gdb-build/;
# install ssh server support and keys
RUN apk add --no-cache openssh
RUN ssh-keygen -A
rulonder
  • 171
  • 1
  • 6
  • Thank you very much for your answer, rulonder! Some time ago I tried to build the grab from the sources, just like you suggested, but failed for some obscure (for me, at least :) reason. You see - I'm a mostly a windows dev and I have been using Docker images to play with building and debugging Linux apps from inside MS Visual Studio 2015. On Debian it worked just fine, but that image is too fat, so I tried Alpine and got this problem with gdbserver. Thanks again! – user3346684 Jun 20 '16 at 21:58
3

With Alpine 3.8 and newer (gdb >= 8.0.1-r6), gdbserver is readily available as part of the gdb package:

https://pkgs.alpinelinux.org/contents?file=gdbserver&path=&name=gdb&branch=v3.8&repo=main&arch=x86_64

valiano
  • 16,433
  • 7
  • 64
  • 79