+// namePartsPos defines the position within the raw method name,
deliniated by periods.
+var namePartsPos = -1 // will panic if we cannot determine the position.
+
type inner struct{}
func (i *inner) m() {
@@ -21,6 +24,12 @@
panic("current method name cannot be found")
}
if name := runtime.FuncForPC(pc).Name(); name == "hook.setCallerDepth" {
+ for i, s := range strings.Split(name, ".") {
+ if s == "setCallerDepth" {
+ namePartsPos = i
+ break
+ }
+ }
return
}
}
@@ -67,8 +76,7 @@
// This is very fragile. fullName will be something like:
//
launchpad.net_goose_testservices_novaservice.removeServer.pN49_launchpad.net_goose_testservices_novaservice.Nova
// so if the number of dots in the full package path changes,
- // this will need to too...
- const namePartsPos = 2
+ // We try to figure sniff this value at the top, but it may not work.
nameParts := strings.Split(fullName, ".")
return nameParts[namePartsPos]
}
Reviewers: mp+233669_ code.launchpad. net,
Message:
Please take a look.
Description:
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:/ /code.launchpad .net/~dave- cheney/ goose/100- more-gccgo- fixes/+ merge/233669
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/141720043/
Affected files (+12, -2 lines): hook/service_ gccgo.go
A [revision details]
M testservices/
Index: [revision details] 20140702055133- xpuj6gm4pa0f3a0 e
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: testservices/ hook/service_ gccgo.go hook/service_ gccgo.go' hook/service_ gccgo.go 2014-02-06 00:42:49 +0000 hook/service_ gccgo.go 2014-09-08 06:57:41 +0000
=== modified file 'testservices/
--- testservices/
+++ testservices/
@@ -12,6 +12,9 @@
// versions.
var callerDepth int
+// namePartsPos defines the position within the raw method name,
deliniated by periods.
+var namePartsPos = -1 // will panic if we cannot determine the position.
+
type inner struct{}
func (i *inner) m() { FuncForPC( pc).Name( ); name == "hook.setCaller Depth" { net_goose_ testservices_ novaservice. removeServer. pN49_launchpad. net_goose_ testservices_ novaservice. Nova Split(fullName, ".") namePartsPos]
@@ -21,6 +24,12 @@
panic("current method name cannot be found")
}
if name := runtime.
+ for i, s := range strings.Split(name, ".") {
+ if s == "setCallerDepth" {
+ namePartsPos = i
+ break
+ }
+ }
return
}
}
@@ -67,8 +76,7 @@
// This is very fragile. fullName will be something like:
//
launchpad.
// so if the number of dots in the full package path changes,
- // this will need to too...
- const namePartsPos = 2
+ // We try to figure sniff this value at the top, but it may not work.
nameParts := strings.
return nameParts[
}