~go-bot/goose/trunk

« back to all changes in this revision

Viewing changes to testservices/hook/service_gccgo.go

  • Committer: Tarmac
  • Author(s): Dave Cheney
  • Date: 2014-09-08 07:56:34 UTC
  • mfrom: (127.1.1 100-more-gccgo-fixes)
  • Revision ID: tarmac-20140908075634-5iinsru19k3d8w55
[r=dave-cheney],[bug=1365480] testservices/hook: fix gccgo build failure

Try to make the detection of the location in the raw stack trace where the method name is mentioned smarter.

Fixes build errors on ppc

https://codereview.appspot.com/141720043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
// versions.
13
13
var callerDepth int
14
14
 
 
15
// namePartsPos defines the position within the raw method name, deliniated by periods.
 
16
var namePartsPos = -1 // will panic if we cannot determine the position.
 
17
 
15
18
type inner struct{}
16
19
 
17
20
func (i *inner) m() {
21
24
                        panic("current method name cannot be found")
22
25
                }
23
26
                if name := runtime.FuncForPC(pc).Name(); name == "hook.setCallerDepth" {
 
27
                        for i, s := range strings.Split(name, ".") {
 
28
                                if s == "setCallerDepth" {
 
29
                                        namePartsPos = i
 
30
                                        break
 
31
                                }
 
32
                        }
24
33
                        return
25
34
                }
26
35
        }
67
76
        // This is very fragile.  fullName will be something like:
68
77
        // launchpad.net_goose_testservices_novaservice.removeServer.pN49_launchpad.net_goose_testservices_novaservice.Nova
69
78
        // so if the number of dots in the full package path changes,
70
 
        // this will need to too...
71
 
        const namePartsPos = 2
 
79
        // We try to figure sniff this value at the top, but it may not work.
72
80
        nameParts := strings.Split(fullName, ".")
73
81
        return nameParts[namePartsPos]
74
82
}