Skip to content

misc/gdb: gdb picks wrong i from two variables both named i #6913

@glycerine

Description

@glycerine
In the demonstration below, when stopped at line 11, gdb reports i being 0 rather than
the correct local value of 32.

package main
  import (
      "os"
      "fmt"
  )

  func main() {
      i := int64(0)
      if os.Args[0] != "blah" {
          i := 32
B =>      fmt.Printf("i = %v\n", i) // line 11
      }
      i++
  }


GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>;...
Reading symbols from /home/jaten/gdblies2...done.
Loading Go Runtime support.
(gdb) break gdblies2.go:11
Breakpoint 1 at 0x400ca6: file /home/jaten/gdblies2.go, line 11.
(gdb) run
Starting program: /home/jaten/gdblies2
warning: no loadable sections found in added symbol-file system-supplied DSO at
0x7ffff7ffd000
[Inferior 1 (process 23017) exited normally]
(gdb) run
`/home/jaten/gdblies2' has changed; re-reading symbols.
Starting program: /home/jaten/gdblies2

Breakpoint 1, main.main () at /home/jaten/gdblies2.go:11
(gdb) p i
$1 = 0
(gdb) n
[New LWP 23035]
i = 32
[LWP 23035 exited]
[Inferior 1 (process 23033) exited normally]
(gdb) 

ubuntu 12.04 amd64
go 1.2rc3
built with: go build -gcflags "-N -l" gdblies2.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeSuggestedIssues that may be good for new contributors looking for work to do.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions