appengine icon indicating copy to clipboard operation
appengine copied to clipboard

Debugging a go111 app

Open PeterKnego opened this issue 6 years ago • 2 comments

I'm starting with a very simple go111 app that builds and runs normally on a local dev server via dev_appserver.py app.yaml.

However, if I try to debug this app via dev_appserver.py --go_debugging=true app.yaml, than build phase fails with

Failed to build Go application: (Executed command: go build -o /var/folders/--shortened--/_ah_exe -N -l) flag provided but not defined: -N

It seems that the debug flags passed by dev_appserver.py to go debug are wrong? If I'm not mistaken it should be -gcflags "all=-N -l" not just -N -l"?

Is there anything else I'm missing?

PeterKnego avatar Nov 29 '18 20:11 PeterKnego

Hi,

I have the same issue since i migrate to go111

I also tried this:

  1. go build -gcflags "all=-N -l" github.com/user/project
  2. ./project
  3. dlv attach --headless=true --listen=:2345 --api-version=2 <PID>

But I get this error: panic: Metadata fetch failed for 'instance/attributes/gae_project': Get http://metadata/computeMetadata/v1/instance/attributes/gae_project: dial tcp: lookup metadata: no such host

calvernaz avatar Jan 09 '19 00:01 calvernaz

Sorry for not seeing this bug earlier.

The good news is that this is an easy fix you can apply to your local dev_appserver instance.

Edit lines 89-91 of $(dirname $(which gcloud))/../platform/google_appengine/google/appengine/tools/devappserver2/go/gaego.py to look like:

    args = ['build']
    if self._enable_debugging:
      args.extend(['-gcflags', '"all=-N -l"'])
    args.extend(['-o', exe_name, self._main_executable_path])

Or, in diff format:

89c89
<     args = ['build', '-o', exe_name, self._main_executable_path]
---
>     args = ['build']
91c91,92
<       args.extend(['-N', '-l'])
---
>       args.extend(['-gcflags', '"all=-N -l"'])
>     args.extend(['-o', exe_name, self._main_executable_path])

I'll try to get this out in an upcoming cloud SDK release.

sbuss avatar Sep 26 '19 22:09 sbuss

While using dev_appserver.py with --go_debugging=true I got :

invalid value ""all=-N -l"" for flag -gcflags: parameter may not start with quote character "

The error disappears when modifying /usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/go/gaego.py with args.extend(['-gcflags', '"all=-N -l"']) ==to=> args.extend(['-gcflags', 'all=-N -l']) There is no error with -gcflags=all=-N -l neither

lecajer avatar Sep 05 '23 07:09 lecajer