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

x/tools/go/ssa: position information not recorded for callsite #12999

Closed
DanielMorsing opened this issue Oct 20, 2015 · 2 comments
Closed

x/tools/go/ssa: position information not recorded for callsite #12999

DanielMorsing opened this issue Oct 20, 2015 · 2 comments

Comments

@DanielMorsing
Copy link
Contributor

Running ssadump -build FD on

package main 

type foo struct {
    g bar
}

type bar interface{
    baz() (int, int)
}

type test struct{
    i int
}

func (h *test) baz() (int, int) {
    return 0, 0
}

func main() {
    f := &foo{}
    f.g = &test{}
    a, b := f.g.baz()
    print(a)
    print(b)
}

prints out

# Name: main.main
# Package: main
# Location: /home/daniel/src/test/foo.go:19:6
func main():
0:                                                                entry P:0 S:0
    t0 = new foo (complit)                                             *foo
    ; address of *ast.CompositeLit @ 20:8 is t0
    ; *ast.UnaryExpr @ 20:7 is t0
    ; var f *main.foo @ 20:2 is t0
    ; var f *main.foo @ 21:2 is t0
    t1 = &t0.g [#0]                                                    *bar
    ; address of field g main.bar @ 21:4 is t1
    t2 = new test (complit)                                           *test
    ; address of *ast.CompositeLit @ 21:9 is t2
    ; *ast.UnaryExpr @ 21:8 is t2
    t3 = make bar <- *test (t2)                                         bar
    *t1 = t3
    ; field g main.bar @ 21:4 is t3
    ; var f *main.foo @ 22:10 is t0
    t4 = &t0.g [#0]                                                    *bar
    ; address of field g main.bar @ 22:12 is t4
    t5 = *t4                                                            bar
    ; *ast.SelectorExpr @ 22:10 is t5
    t6 = invoke t5.baz()                                         (int, int)
    t7 = extract t6 #0                                                  int
    ; var a int @ 22:2 is t7
    t8 = extract t6 #1                                                  int
    ; var b int @ 22:5 is t8
    ; var a int @ 23:8 is t7
    t9 = print(t7)                                                       ()
    ; *ast.CallExpr @ 23:2 is t9
    ; var b int @ 24:8 is t8
    t10 = print(t8)                                                      ()
    ; *ast.CallExpr @ 24:2 is t10
    return

Note that there is no debug information for t6. This makes it impossible to get callee information via the oracle.

@DanielMorsing
Copy link
Contributor Author

Looks like this is general for all functions that use extract

package main 

func baz() (int, int) {
    return 0, 0
}

func main() {
    _, _ = baz()
}

yields

# Name: main.main
# Package: main
# Location: /home/daniel/src/test/foo.go:7:6
func main():
0:                                                                entry P:0 S:0
    ; func main.baz() (int, int) @ 8:9 is baz
    t0 = baz()                                                   (int, int)
    t1 = extract t0 #0                                                  int
    t2 = extract t0 #1                                                  int
    return

@gopherbot
Copy link

CL https://golang.org/cl/16210 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants