Merge lp:~dave-cheney/goose/100-more-gccgo-fixes into lp:goose

Proposed by Dave Cheney
Status: Merged
Approved by: Dave Cheney
Approved revision: 128
Merged at revision: 128
Proposed branch: lp:~dave-cheney/goose/100-more-gccgo-fixes
Merge into: lp:goose
Diff against target: 36 lines (+10/-2)
1 file modified
testservices/hook/service_gccgo.go (+10/-2)
To merge this branch: bzr merge lp:~dave-cheney/goose/100-more-gccgo-fixes
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+233669@code.launchpad.net

Commit message

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/

Description of the change

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/

To post a comment you must log in.
Revision history for this message
Dave Cheney (dave-cheney) wrote :

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):
   A [revision details]
   M testservices/hook/service_gccgo.go

Index: [revision details]
=== 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-20140702055133-xpuj6gm4pa0f3a0e
+New revision: <email address hidden>

Index: testservices/hook/service_gccgo.go
=== modified file 'testservices/hook/service_gccgo.go'
--- testservices/hook/service_gccgo.go 2014-02-06 00:42:49 +0000
+++ testservices/hook/service_gccgo.go 2014-09-08 06:57:41 +0000
@@ -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() {
@@ -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]
  }

Revision history for this message
Dave Cheney (dave-cheney) wrote :
Revision history for this message
Dave Cheney (dave-cheney) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'testservices/hook/service_gccgo.go'
--- testservices/hook/service_gccgo.go 2014-02-06 00:42:49 +0000
+++ testservices/hook/service_gccgo.go 2014-09-08 06:59:26 +0000
@@ -12,6 +12,9 @@
12// versions.12// versions.
13var callerDepth int13var callerDepth int
1414
15// namePartsPos defines the position within the raw method name, deliniated by periods.
16var namePartsPos = -1 // will panic if we cannot determine the position.
17
15type inner struct{}18type inner struct{}
1619
17func (i *inner) m() {20func (i *inner) m() {
@@ -21,6 +24,12 @@
21 panic("current method name cannot be found")24 panic("current method name cannot be found")
22 }25 }
23 if name := runtime.FuncForPC(pc).Name(); name == "hook.setCallerDepth" {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 return33 return
25 }34 }
26 }35 }
@@ -67,8 +76,7 @@
67 // This is very fragile. fullName will be something like:76 // This is very fragile. fullName will be something like:
68 // launchpad.net_goose_testservices_novaservice.removeServer.pN49_launchpad.net_goose_testservices_novaservice.Nova77 // launchpad.net_goose_testservices_novaservice.removeServer.pN49_launchpad.net_goose_testservices_novaservice.Nova
69 // so if the number of dots in the full package path changes,78 // so if the number of dots in the full package path changes,
70 // this will need to too...79 // We try to figure sniff this value at the top, but it may not work.
71 const namePartsPos = 2
72 nameParts := strings.Split(fullName, ".")80 nameParts := strings.Split(fullName, ".")
73 return nameParts[namePartsPos]81 return nameParts[namePartsPos]
74}82}

Subscribers

People subscribed via source and target branches