~dave-cheney/goose/100-more-gccgo-fixes

« back to all changes in this revision

Viewing changes to testservices/hook/service_gccgo.go

  • Committer: Dave Cheney
  • Date: 2014-09-08 06:57:41 UTC
  • Revision ID: david.cheney@canonical.com-20140908065741-dgp0vpow392qj3sf
testservices/hook: gccgo fix

Fix build breakage from a change to the gccgo stack trace format

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
}