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

Debugger when attached to a running process is using wrong file paths for some files #3537

Open
cthumuluru opened this issue Sep 14, 2024 · 3 comments
Labels
Debug Issues related to the debugging functionality of the extension. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@cthumuluru
Copy link

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.22.5 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

Build info
----------
golang.org/x/tools/gopls v0.16.2
    golang.org/x/tools/[email protected] h1:K1z03MlikHfaMTtG01cUeL5FAOTJnITuNe0TWOcg8tM=
    github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/[email protected] h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/[email protected] h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
    golang.org/x/[email protected] h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
    golang.org/x/[email protected] h1:Wm3cG5X6sZ0RSVRc/H1/sciC4AT6HAKgLCSH2lbpR/c=
    golang.org/x/[email protected] h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
    golang.org/x/[email protected] h1:6bJEg2w2kUHWlfdJaESYsmNfI1LKAZQi6zCa7LUn7eI=
    golang.org/x/[email protected] h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
    honnef.co/go/[email protected] h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
    mvdan.cc/[email protected] h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.22.5
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

1.93.0
4849ca9bdf9666755eb463db297b69e5385090e3
x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.42.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

## Environment

GOBIN: undefined
toolsGopath: 
gopath: /home/chandrat/go
GOROOT: /usr/local/go
PATH: /home/chandrat/.vscode-server/cli/servers/Stable-4849ca9bdf9666755eb463db297b69e5385090e3/server/bin/remote-cli:/home/chandrat/.sdkman/candidates/maven/current/bin:/home/chandrat/.sdkman/candidates/java/current/bin:/home/chandrat/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/nvim-linux64/bin:/usr/local/go/bin:/home/chandrat/go/bin

## Tools

	go:	/usr/local/go/bin/go: go version go1.22.5 linux/amd64

	gopls:	/home/chandrat/go/bin/gopls	(version: v0.16.2 built with go: go1.22.5)
	gotests:	/home/chandrat/go/bin/gotests	(version: v1.6.0 built with go: go1.22.5)
	gomodifytags:	not installed
	impl:	/home/chandrat/go/bin/impl	(version: v1.1.0 built with go: go1.22.5)
	goplay:	/home/chandrat/go/bin/goplay	(version: v1.0.0 built with go: go1.22.5)
	dlv:	/home/chandrat/go/bin/dlv	(version: v1.23.0 built with go: go1.22.5)
	staticcheck:	/home/chandrat/go/bin/staticcheck	(version: v0.4.7 built with go: go1.22.5)

## Go env

Workspace Folder (cockroach): /mnt/workspace/github.com/cockroach

	GO111MODULE=''
	GOARCH='amd64'
	GOBIN=''
	GOCACHE='/home/chandrat/.cache/go-build'
	GOENV='/home/chandrat/.config/go/env'
	GOEXE=''
	GOEXPERIMENT=''
	GOFLAGS=''
	GOHOSTARCH='amd64'
	GOHOSTOS='linux'
	GOINSECURE=''
	GOMODCACHE='/home/chandrat/go/pkg/mod'
	GONOPROXY=''
	GONOSUMDB=''
	GOOS='linux'
	GOPATH='/home/chandrat/go'
	GOPRIVATE=''
	GOPROXY='https://proxy.golang.org,direct'
	GOROOT='/usr/local/go'
	GOSUMDB='sum.golang.org'
	GOTMPDIR=''
	GOTOOLCHAIN='auto'
	GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
	GOVCS=''
	GOVERSION='go1.22.5'
	GCCGO='gccgo'
	GOAMD64='v1'
	AR='ar'
	CC='gcc'
	CXX='g++'
	CGO_ENABLED='1'
	GOMOD='/mnt/workspace/github.com/cockroach/go.mod'
	GOWORK=''
	CGO_CFLAGS='-O2 -g'
	CGO_CPPFLAGS=''
	CGO_CXXFLAGS='-O2 -g'
	CGO_FFLAGS='-O2 -g'
	CGO_LDFLAGS='-O2 -g'
	PKG_CONFIG='pkg-config'
	GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1584639556=/tmp/go-build -gno-record-gcc-switches'

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

"go.toolsManagement.autoUpdate": true

Describe the bug

VSCode debugger uses wrong paths for some files during remote attach debug session. This only happens with few files. Debugger some how assumes the file path is pkg/rpc/pkg/rpc/context.go while the actual file path is pkg/rpc/context.go and it fails to locate the file.

Steps to reproduce the behavior:

I'm not sure if there is an easy way to reproduce this but I can provide additional information as needed. Sharing launch.json file contents here:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to Process",
            "type": "go",
            "request": "attach",
            "processId": "${command:pickProcess}",
            "mode": "local",
            "cwd": "/mnt/workspace/github.com/cockroach",
            "substitutePath": [
                {
                    "from": "/mnt/workspace/github.com/",
                    "to": "github.com/cockroachdb/"
                },
            ]
        },
    ]
}

Screenshots or recordings

pkg/server/tenant.go where it works as expected:
Screenshot from 2024-09-14 16-46-53

pkg/rpc/context.go where it doesn't work as expected:
Screenshot from 2024-09-14 16-51-11

@gopherbot gopherbot added this to the Untriaged milestone Sep 14, 2024
@hyangah
Copy link
Contributor

hyangah commented Sep 19, 2024

Thanks for reaching out @cthumuluru

VSCode debugger uses wrong paths for some files during remote attach debug session. This only happens with few files.

Can you please tell us more about how you built the debugged binary?

And, can you query the problematic source files's paths recorded in the binary from the DEBUG CONSOLE? For example,

Screenshot 2024-09-19 at 1 40 59 PM

To run this dlv sources command, you will need to pause the debug target or stopped on a breakpoint first.

@hyangah hyangah added Debug Issues related to the debugging functionality of the extension. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Sep 19, 2024
@cthumuluru
Copy link
Author

Hello @hyangah -- sorry for the delayed response.

The project I'm working on uses Bazel for build. If you are asking about the compiler options uses to compile, they are -gcflags '-N -l'.

Here is the output from DEBUG CONSOLE upon running dlv sources context.go:

GOROOT/src/context/context.go
GOROOT/src/html/template/context.go
github.com/andybalholm/brotli/external/com_github_andybalholm_brotli/context.go
github.com/apache/thrift/lib/go/thrift/external/com_github_apache_thrift/lib/go/thrift/context.go
github.com/apache/thrift/lib/go/thrift/external/com_github_apache_thrift/lib/go/thrift/header_context.go
github.com/aws/aws-sdk-go-v2/aws/external/com_github_aws_aws_sdk_go_v2/aws/context.go
github.com/aws/aws-sdk-go-v2/internal/context/external/com_github_aws_aws_sdk_go_v2/internal/context/context.go
github.com/aws/aws-sdk-go-v2/service/internal/checksum/external/com_github_aws_aws_sdk_go_v2_service_internal_checksum/middleware_setup_context.go
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url/external/com_github_aws_aws_sdk_go_v2_service_internal_presigned_url/context.go
github.com/aws/aws-sdk-go-v2/service/s3/external/com_github_aws_aws_sdk_go_v2_service_s3/bucket_context.go
github.com/aws/aws-sdk-go-v2/service/s3/internal/customizations/external/com_github_aws_aws_sdk_go_v2_service_s3/internal/customizations/context.go
github.com/aws/smithy-go/middleware/external/com_github_aws_smithy_go/middleware/context.go
github.com/aws/smithy-go/tracing/external/com_github_aws_smithy_go/tracing/context.go
github.com/cenkalti/backoff/v4/external/com_github_cenkalti_backoff_v4/context.go
github.com/cockroachdb/apd/v3/external/com_github_cockroachdb_apd_v3/context.go
github.com/cockroachdb/cockroach/pkg/ccl/cliccl/context.go
github.com/cockroachdb/cockroach/pkg/cli/clicfg/context.go
github.com/cockroachdb/cockroach/pkg/cli/clisqlcfg/context.go
github.com/cockroachdb/cockroach/pkg/cli/clisqlclient/context.go
github.com/cockroachdb/cockroach/pkg/cli/clisqlexec/context.go
github.com/cockroachdb/cockroach/pkg/cli/clisqlshell/context.go
github.com/cockroachdb/cockroach/pkg/cli/context.go
github.com/cockroachdb/cockroach/pkg/cli/democluster/context.go
github.com/cockroachdb/cockroach/pkg/kv/kvnemesis/kvnemesisutil/pkg/kv/kvnemesis/kvnemesisutil/context.go
github.com/cockroachdb/cockroach/pkg/kv/kvserver/batcheval/eval_context.go
github.com/cockroachdb/cockroach/pkg/kv/kvserver/pkg/kv/kvserver/replica_eval_context.go
github.com/cockroachdb/cockroach/pkg/rpc/pkg/rpc/context.go
github.com/cockroachdb/cockroach/pkg/server/authserver/context.go
github.com/cockroachdb/cockroach/pkg/sql/execinfra/flow_context.go
github.com/cockroachdb/cockroach/pkg/sql/job_exec_context.go
github.com/cockroachdb/cockroach/pkg/sql/sem/eval/context.go
github.com/cockroachdb/cockroach/pkg/util/ctxlog/context.go
github.com/cockroachdb/cockroach/pkg/util/ctxutil/context.go
github.com/cockroachdb/cockroach/pkg/util/log/ambient_context.go
github.com/cockroachdb/cockroach/pkg/util/tracing/context.go
github.com/cockroachdb/errors/contexttags/external/com_github_cockroachdb_errors/contexttags/with_context.go
github.com/cockroachdb/logtags/external/com_github_cockroachdb_logtags/context.go
github.com/getsentry/sentry-go/external/com_github_getsentry_sentry_go/dynamic_sampling_context.go
github.com/goccy/go-json/internal/decoder/external/com_github_goccy_go_json/internal/decoder/context.go
github.com/goccy/go-json/internal/encoder/external/com_github_goccy_go_json/internal/encoder/context.go
github.com/grpc-ecosystem/grpc-gateway/runtime/external/com_github_grpc_ecosystem_grpc_gateway/runtime/context.go
github.com/jackc/puddle/v2/external/com_github_jackc_puddle_v2/context.go
github.com/maruel/panicparse/v2/stack/external/com_github_maruel_panicparse_v2/stack/context.go
go.opencensus.io/tag/external/io_opencensus_go/tag/context.go
go.opentelemetry.io/otel/baggage/external/io_opentelemetry_go_otel/baggage/context.go
go.opentelemetry.io/otel/internal/baggage/external/io_opentelemetry_go_otel/internal/baggage/context.go
go.opentelemetry.io/otel/propagation/external/io_opentelemetry_go_otel/propagation/trace_context.go
go.opentelemetry.io/otel/trace/external/io_opentelemetry_go_otel_trace/context.go
golang.org/x/net/context/external/org_golang_x_net/context/context.go
golang.org/x/net/context/external/org_golang_x_net/context/go17.go
golang.org/x/net/context/external/org_golang_x_net/context/go19.go
golang.org/x/text/cases/external/org_golang_x_text/cases/context.go
golang.org/x/text/secure/precis/external/org_golang_x_text/secure/precis/context.go

@cthumuluru
Copy link
Author

Hi @hyangah, please let me know if you need any additional information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Debug Issues related to the debugging functionality of the extension. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants