This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug runtime/21704] New: return values can not be printed when using golang


https://sourceware.org/bugzilla/show_bug.cgi?id=21704

            Bug ID: 21704
           Summary: return values can not be printed when using golang
           Product: systemtap
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: runtime
          Assignee: systemtap at sourceware dot org
          Reporter: ing.gila at gmail dot com
  Target Milestone: ---

Consider the following go program:

package main

import "fmt"

func traceme(a int, b int) (ret int) {
        return a + b

}

func main() {

        ret := traceme(1, 2)
        fmt.Printf("ret %d\n", ret)
}

compiling this with:

go build -gcflags "-N -l"  -o stap

Listing the probes yields among others:

stap -L 'process("./stap").function("*")' | grep main
process("/code/go/stap").function("main.init@<unknown source>")
process("/code/go/stap").function("main.main@/code/go/main.go:10") $ret:int
process("/code/go/stap").function("main.traceme@/code/go/main.go:5") $a:int
$b:int $ret:int

Trying to trace the return value does not work:

stap -vvv -e 'probe process("/code/go/stap").function("main.traceme").return {
printf("%d\n", $return)}'
<SNIP>
semantic error: while processing probe
process("/code/go/stap").function("main.traceme@/code/go/main.go:5").return
from: process("/code/go/stap").function("main.traceme").return
   thrown from: elaborate.cxx:5653
semantic error: function main.traceme (go) has no return value: identifier
'$return' at <input>:1:81
   thrown from: dwflpp.cxx:4020
        source: probe process("/code/go/stap").function("main.traceme").return
{ printf("%d\n", $return)}

from the listing of probes, we can see that the ret value (named return value
as go calls them) should contain the return value. Using it, however, results
in 0 instead of the expected 3 (as go initializes all values with 0/nil by
default)  and stap gives this warning:

➜  go stap -e 'probe process("/code/go/stap").function("main.traceme").return {
printf("%d\n", $ret)}' -c ./stap
WARNING: confusing usage, consider @entry($ret) in .return probe: identifier
'$ret' at <input>:1:81
 source: probe process("/code/go/stap").function("main.traceme").return {
printf("%d\n", $ret)}
                                                                               
         ^
ret 3
0

By the looks of it, it seems that stap cant figure out that $ret is the actual
return value. Using unnamed returns we get some weird made up return value like
$~r0

Trying it with gccgo makes nu difference either (what is different is the
number if probe points -- the go compiler has much more compared to gccgo)

Perhaps somewhat related, trying to use the "statement" functionality does not
work either wich seems weird as well:

➜  go stap -vvvv -e 'probe
process("/code/go/stap").statement("main.traceme@/code/go/main.go:5") {
printf("Works")}' -c ./stap
<SNIP>
parse 'main.traceme@/code/go/main.go:5', func 'main.traceme', file
'/code/go/main.go', line 5
focused on module '/code/go/stap' = [0x400000-0x51b1c0, bias 0 file
/code/go/stap ELF machine |x86_64 (code 62)
focused on module '/code/go/stap'
selected source file '/code/go/main.go'
semantic error: resolution failed in DWARF builder
   thrown from: elaborate.cxx:1092
semantic error: while resolving probe point: identifier 'process' at
<input>:1:7
   thrown from: elaborate.cxx:1080
        source: probe
process("/code/go/stap").statement("main.traceme@/code/go/main.go:5") {
printf("Works")}
                      ^

semantic error: no match
   thrown from: elaborate.cxx:1043
Pass 2: analyzed script: 0 probes, 0 functions, 0 embeds, 0 globals using
121784virt/54796res/7900shr/46980data kb, in 20usr/0sys/12real ms.
Pass 2: analysis failed.  [man error::pass2]
Running rm -rf /tmp/stap9fRUBK

Some environment info:

➜  go cat /etc/issue
Ubuntu 17.04 \n \l
➜  go go version
go version go1.8.1 linux/amd64
➜  go which stap
/root/systemtap-3.2-19658/bin/stap

Using the systemtap version from the ubuntu repo's produces the same results.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]