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: Wrong values for local variables #8256

Open
gopherbot opened this issue Jun 20, 2014 · 10 comments
Open

gdb: Wrong values for local variables #8256

gopherbot opened this issue Jun 20, 2014 · 10 comments
Milestone

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 20, 2014

by andreas.nusser:

What does 'go version' print?
Tried with 
.)go version go1.3 linux/amd64
and
.)go version devel +e0ad7e329637 Thu Jun 19 22:19:56 2014 -0700 linux/amd64

As gdb I'm using "GNU gdb (GDB) 7.6.2 (Debian 7.6.2-1.1+b1)"

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

1. Write a short test program similar to the one attached. (You can find it here too:
http://play.golang.org./p/Y5b-t2iobd)
2. Compile it with go build -gcflags "-N -l" to prevent inlining
3. Run the resulting binary with gdb and observe as gdb reports wrong values for the
local variables. It even doesn't report the changed value of "z" in line 13.

What happened?
 - Instead of the values of the variables, gdb shows garbage.

What should have happened instead?
 - gdb should show the correct values.

Thanks for your help!
Andreas

Attachments:

  1. gdb_fail.go (276 bytes)
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 20, 2014

Comment 1:

Labels changed: added repo-main, release-go1.4.

@mholt
Copy link

@mholt mholt commented Sep 4, 2014

Comment 2:

Not sure if it matters, but I'm able to reproduce this on Mac OS 10.9.4 with GNU gdb
(GDB) 7.7.1 and Go 1.3.1. I used the same build command with the same flags.
My Go program and garbage output are both attached for reference.

Attachments:

  1. gdbtest.go (76 bytes)
  2. gdb_garbage_out.txt (821 bytes)
@rsc
Copy link
Contributor

@rsc rsc commented Sep 15, 2014

Comment 3:

Probably not for 1.4.

Labels changed: added release-go1.5, removed release-go1.4.

Status changed to Accepted.

@gopherbot
Copy link
Author

@gopherbot gopherbot commented Sep 25, 2014

Comment 4 by jeromelaurens:

Same here with :
go version go1.3.1 darwin/amd64
GNU gdb (GDB) 7.8
I also have the flags : -gcflags "-N -l"
I'm using LiteIDE
local variable showing odd values
Very annoying when you want to inspect your variables
Thanks for your help
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Sep 27, 2014

Comment 5 by holgerfinger:

Same problem with go version go1.3 linux/amd64.
I tried gdb 7.4 and gdb 7.8.
go 1.2.2 seems to be working fine.
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Oct 9, 2014

Comment 6 by ludmiloff:

When to expect a bug fix
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 9, 2014

Comment 7:

See http://golang.org/doc/gdb .  As it says there, making Go work well with gdb is not a
priority for the Go project.  Of course Go is an open source project and we are always
happy to accept patches.  But at the moment I'm not aware of anybody working on this
issue, so I can not predict when it will be fixed.
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Nov 28, 2014

Comment 8 by lars.oppermann:

If gdb is not a priority, what is the recommended way for debugging go programs?
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Nov 28, 2014

Comment 9 by eidmanna:

Even if debugging with command line is possible, it is much easier to find bugs with a
good debugger (such as the Google Chrome Javascript Debugger). Why has this issue as low
priority?
@mholt
Copy link

@mholt mholt commented Nov 28, 2014

Comment 10:

Using the fmt and log packages is a pretty common way of debugging Go programs, and the
log package especially is safe for concurrent execution. gdb... not so much.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants