Debugging dockerd with dlv fails

101 views
Skip to first unread message

thecrossner

unread,
May 3, 2020, 11:25:41 AM5/3/20
to delve-dev
Hey!

I am trying to understand something inside `dockerd` using `dlv` debugger. Unfortunately, every time I am trying to do that I am facing errors. I can't do `dlv exec` nor `dlv attach`.

The following diff shows some changes I applied to make sure that some go optimizations are avoided and debugging is possible:

```diff
diff --git i/hack/make/.binary w/hack/make/.binary
index d56e3f3..e6835fa 100644
--- i/hack/make/.binary
+++ w/hack/make/.binary
@@ -84,6 +84,7 @@ hash_files() {
        go build \
                -o "$DEST/$BINARY_FULLNAME" \
                "${BUILDFLAGS[@]}" \
+               -gcflags="all=-N -l" \
                -ldflags "
                $LDFLAGS
                $LDFLAGS_STATIC_DOCKER
```

I also modified `dockerd-rootless.sh` to make sure I don't use plain `exec` but `dlv exec dockerd -- $@`. Unfortunately every time I get the following error:

    Could not create config directory: mkdir /root/.config: permission denied.could not launch process: could not get .debug_frame section: could not find .debug_frame section

Does anyone have an idea what could be causing it?

INFO:

OS: Fedora 31

```
go version

go version go1.13.10 linux/amd64
```

```
dlv version

Delve Debugger
Version: 1.4.0
Build: $Id: 67422e6f7148fa1efa0eac1423ab5594b223d93b $
```

```
docker version

Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b7f0
 Built:             Wed Mar 11 01:27:05 2020
 OS/Arch:           linux/amd64
 Experimental:      false
```

alessandr...@gmail.com

unread,
May 3, 2020, 12:47:51 PM5/3/20
to thecrossner, delve-dev
> Could not create config directory: mkdir /root/.config: permission
> denied

This means you don't have permission to write to /root/ (but for some reason
that is your home directory).

> could not get .debug_frame section: could
> not find .debug_frame section

This means that the executable you are trying to debug is stripped. Probably
a -w in LDFLAGS.
> --
> You received this message because you are subscribed to the Google Groups "delve-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to delve-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/delve-dev/75824092-b5dc-46cb-b397-0784767d536c%40googlegroups.com.
>

thecrossner

unread,
May 3, 2020, 1:12:11 PM5/3/20
to delve-dev
> This means you don't have permission to write to /root/ (but for some reason
> that is your home directory).

Yeah, but I think it is more related to the fact that this is is rootless docker which uses rootlesskit.
I am running the executable as a normal user.
> To unsubscribe from this group and stop receiving emails from it, send an email to delv...@googlegroups.com.
> To unsubscribe from this group and stop receiving emails from it, send an email to delv...@googlegroups.com.

thecrossner

unread,
May 3, 2020, 2:59:15 PM5/3/20
to delve-dev
But you were right! This was due to presence of "-w" flag..


On Sunday, 3 May 2020 18:47:51 UTC+2, alessandro.arzilli wrote:
> To unsubscribe from this group and stop receiving emails from it, send an email to delv...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages