Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
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
}
// 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
{}
importv
:=
[]
*
traceImport
{}
...
...
@@ -223,7 +223,7 @@ func packageTrace(prog *loader.Program, pkgi *loader.PackageInfo) *Package {
textv
:=
strings
.
SplitN
(
comment
.
Text
,
" "
,
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
]
...
...
@@ -231,22 +231,28 @@ func packageTrace(prog *loader.Program, pkgi *loader.PackageInfo) *Package {
case
"//trace:event"
:
event
,
err
:=
parseTraceEvent
(
prog
,
pkgi
,
file
,
pos
,
arg
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
nil
,
err
}
eventv
=
append
(
eventv
,
event
)
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
for
_
,
imported
:=
range
importv
{
if
arg
==
imported
.
PkgPath
{
log
.
Fatalf
(
"%v: duplicate trace import of %v (previous at %v)"
,
pos
,
arg
,
imported
.
Pos
)
if
importPath
==
imported
.
PkgPath
{
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
:
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
import
(
"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"
)
...
...
@@ -41,3 +41,6 @@ func ParseURL(ustr string) (*url.URL, error) {
func
DoSomething
(
topic
string
)
{
traceDoSomething
(
topic
)
}
// TODO package-local non-exported tracepoint
go/xcommon/tracing/cmd/gotrace/testdata/src/b/pkg2/pkg2.go
View file @
255a3c99
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"
//trace:event DoSomething(i, j int, q string)
// additional tracepoint which pkg2 defines
//trace:event
trace
DoSomething(i, j int, q string)
func
DoSomething
(
i
,
j
int
,
q
string
)
{
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