Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefane Fermigier
neo
Commits
255a3c99
Commit
255a3c99
authored
Jul 03, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fe1ca6f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
12 deletions
+22
-12
go/xcommon/tracing/cmd/gotrace/gotrace.go
go/xcommon/tracing/cmd/gotrace/gotrace.go
+13
-7
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/pkg1.go
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/pkg1.go
+4
-1
go/xcommon/tracing/cmd/gotrace/testdata/src/b/pkg2/pkg2.go
go/xcommon/tracing/cmd/gotrace/testdata/src/b/pkg2/pkg2.go
+5
-4
No files found.
go/xcommon/tracing/cmd/gotrace/gotrace.go
View file @
255a3c99
...
@@ -201,7 +201,7 @@ func parseTraceEvent(prog *loader.Program, pkgi *loader.PackageInfo, srcfile *as
...
@@ -201,7 +201,7 @@ func parseTraceEvent(prog *loader.Program, pkgi *loader.PackageInfo, srcfile *as
}
}
// packageTrace returns tracing information about a package
// packageTrace returns tracing information about a package
func
packageTrace
(
prog
*
loader
.
Program
,
pkgi
*
loader
.
PackageInfo
)
*
Package
{
func
packageTrace
(
prog
*
loader
.
Program
,
pkgi
*
loader
.
PackageInfo
)
(
*
Package
,
error
)
{
eventv
:=
[]
*
traceEvent
{}
eventv
:=
[]
*
traceEvent
{}
importv
:=
[]
*
traceImport
{}
importv
:=
[]
*
traceImport
{}
...
@@ -223,7 +223,7 @@ func packageTrace(prog *loader.Program, pkgi *loader.PackageInfo) *Package {
...
@@ -223,7 +223,7 @@ func packageTrace(prog *loader.Program, pkgi *loader.PackageInfo) *Package {
textv
:=
strings
.
SplitN
(
comment
.
Text
,
" "
,
2
)
textv
:=
strings
.
SplitN
(
comment
.
Text
,
" "
,
2
)
if
len
(
textv
)
!=
2
{
if
len
(
textv
)
!=
2
{
log
.
Fatalf
(
"%v: invalid directive format"
)
return
nil
,
fmt
.
Errorf
(
"%v: invalid directive format"
,
pos
)
}
}
directive
,
arg
:=
textv
[
0
],
textv
[
1
]
directive
,
arg
:=
textv
[
0
],
textv
[
1
]
...
@@ -231,22 +231,28 @@ func packageTrace(prog *loader.Program, pkgi *loader.PackageInfo) *Package {
...
@@ -231,22 +231,28 @@ func packageTrace(prog *loader.Program, pkgi *loader.PackageInfo) *Package {
case
"//trace:event"
:
case
"//trace:event"
:
event
,
err
:=
parseTraceEvent
(
prog
,
pkgi
,
file
,
pos
,
arg
)
event
,
err
:=
parseTraceEvent
(
prog
,
pkgi
,
file
,
pos
,
arg
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
nil
,
err
}
}
eventv
=
append
(
eventv
,
event
)
eventv
=
append
(
eventv
,
event
)
case
"//trace:import"
:
case
"//trace:import"
:
// Unqote arg as in regular import
importPath
,
err
:=
strconv
.
Unquote
(
arg
)
if
err
!=
nil
||
arg
[
0
]
==
`'`
{
nil
,
fmt
.
Errorf
(
"%v: invalid trace-import path %v"
,
pos
,
arg
)
}
// reject duplicate imports
// reject duplicate imports
for
_
,
imported
:=
range
importv
{
for
_
,
imported
:=
range
importv
{
if
arg
==
imported
.
PkgPath
{
if
importPath
==
imported
.
PkgPath
{
log
.
Fatalf
(
"%v: duplicate trace import of %v (previous at %v)"
,
pos
,
arg
,
imported
.
Pos
)
return
nil
,
fmt
.
Errorf
(
"%v: duplicate trace import of %v (previous at %v)"
,
pos
,
importPath
,
imported
.
Pos
)
}
}
}
}
importv
=
append
(
importv
,
&
traceImport
{
Pos
:
pos
,
PkgPath
:
arg
})
importv
=
append
(
importv
,
&
traceImport
{
Pos
:
pos
,
PkgPath
:
importPath
})
default
:
default
:
log
.
Fatal
f
(
"%v: unknown tracing directive %q"
,
pos
,
directive
)
return
nil
,
fmt
.
Error
f
(
"%v: unknown tracing directive %q"
,
pos
,
directive
)
}
}
}
}
}
}
...
...
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/pkg1.go
View file @
255a3c99
...
@@ -3,7 +3,7 @@ package pkg1
...
@@ -3,7 +3,7 @@ package pkg1
import
(
import
(
"net/url"
"net/url"
// extra import which is used in package but should not be used in tracing
// extra import which is used in package but should not be used in tracing
code
"fmt"
"fmt"
)
)
...
@@ -41,3 +41,6 @@ func ParseURL(ustr string) (*url.URL, error) {
...
@@ -41,3 +41,6 @@ func ParseURL(ustr string) (*url.URL, error) {
func
DoSomething
(
topic
string
)
{
func
DoSomething
(
topic
string
)
{
traceDoSomething
(
topic
)
traceDoSomething
(
topic
)
}
}
// TODO package-local non-exported tracepoint
go/xcommon/tracing/cmd/gotrace/testdata/src/b/pkg2/pkg2.go
View file @
255a3c99
package
pkg2
package
pkg2
import
"a/pkg1"
// TODO should not be needed eventually
// XXX vvv kill
//import "a/pkg1" // TODO should not be needed eventually
//trace:import
a/pkg1
//trace:import
"a/pkg1"
// additional tracepoint which pkg2 defines
//trace:event DoSomething(i, j int, q string)
//trace:event
trace
DoSomething(i, j int, q string)
func
DoSomething
(
i
,
j
int
,
q
string
)
{
func
DoSomething
(
i
,
j
int
,
q
string
)
{
traceDoSomething
(
i
,
j
,
q
)
traceDoSomething
(
i
,
j
,
q
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment