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
0da5fa01
Commit
0da5fa01
authored
Jul 03, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
79928d00
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
100 additions
and
67 deletions
+100
-67
go/xcommon/tracing/cmd/gotrace/gotrace.go
go/xcommon/tracing/cmd/gotrace/gotrace.go
+95
-60
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
+2
-1
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/ztrace.go
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/ztrace.go
+0
-6
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/pkg4.go
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/pkg4.go
+3
-0
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace.go.rm
...mmon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace.go.rm
+0
-0
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace.s.rm
...ommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace.s.rm
+0
-0
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace_test.go.rm
...tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace_test.go.rm
+0
-0
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace_test.s.rm
.../tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace_test.s.rm
+0
-0
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace_x_test.go.rm
...acing/cmd/gotrace/testdata/src/d/pkg4/ztrace_x_test.go.rm
+0
-0
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace_x_test.s.rm
...racing/cmd/gotrace/testdata/src/d/pkg4/ztrace_x_test.s.rm
+0
-0
No files found.
go/xcommon/tracing/cmd/gotrace/gotrace.go
View file @
0da5fa01
...
@@ -494,6 +494,7 @@ func (s StrSet) Itemv() []string {
...
@@ -494,6 +494,7 @@ func (s StrSet) Itemv() []string {
return
itemv
return
itemv
}
}
/*
// findPackageNoZTrace is (*build.Context).Import but filters-out ztrace* files from found package
// findPackageNoZTrace is (*build.Context).Import but filters-out ztrace* files from found package
//
//
// we don't load what should be generated by us for 2 reasons:
// we don't load what should be generated by us for 2 reasons:
...
@@ -528,6 +529,7 @@ func findPackageNoZTrace(ctxt *build.Context, importPath, fromDir string, mode b
...
@@ -528,6 +529,7 @@ func findPackageNoZTrace(ctxt *build.Context, importPath, fromDir string, mode b
return bp, err
return bp, err
}
}
*/
// tracegen generates code according to tracing directives in a package @ pkgpath
// tracegen generates code according to tracing directives in a package @ pkgpath
//
//
...
@@ -536,12 +538,36 @@ func findPackageNoZTrace(ctxt *build.Context, importPath, fromDir string, mode b
...
@@ -536,12 +538,36 @@ func findPackageNoZTrace(ctxt *build.Context, importPath, fromDir string, mode b
func
tracegen
(
pkgpath
string
,
ctxt
*
build
.
Context
,
cwd
string
)
error
{
func
tracegen
(
pkgpath
string
,
ctxt
*
build
.
Context
,
cwd
string
)
error
{
// TODO test-only with .TestGoFiles .XTestGoFiles
// TODO test-only with .TestGoFiles .XTestGoFiles
// filter-out ztrace* files when disovering packages
//
// we don't load what should be generated by us for 2 reasons:
// - code generated could be wrong with older version of the
// tool - it should not prevent from regenerating.
// - generated code imports packages which might be not there
// yet in gopath (lab.nexedi.com/kirr/go123/tracing)
ctxtReadDir
:=
ctxt
.
ReadDir
if
ctxtReadDir
==
nil
{
ctxtReadDir
=
ioutil
.
ReadDir
}
ctxtNoZTrace
:=
*
ctxt
ctxtNoZTrace
.
ReadDir
=
func
(
dir
string
)
([]
os
.
FileInfo
,
error
)
{
fv
,
err
:=
ctxtReadDir
(
dir
)
okv
:=
fv
[
:
0
]
for
_
,
f
:=
range
fv
{
if
!
strings
.
HasPrefix
(
f
.
Name
(),
"ztrace"
)
{
okv
=
append
(
okv
,
f
)
}
}
return
okv
,
err
}
// XXX text
conf
:=
loader
.
Config
{
conf
:=
loader
.
Config
{
ParserMode
:
parser
.
ParseComments
,
ParserMode
:
parser
.
ParseComments
,
TypeCheckFuncBodies
:
func
(
path
string
)
bool
{
return
false
},
TypeCheckFuncBodies
:
func
(
path
string
)
bool
{
return
false
},
Build
:
ctxt
,
Build
:
&
ctxtNoZTrace
,
Cwd
:
cwd
,
Cwd
:
cwd
,
FindPackage
:
findPackageNoZTrace
,
//
FindPackage: findPackageNoZTrace,
}
}
conf
.
Import
(
pkgpath
)
conf
.
Import
(
pkgpath
)
...
@@ -570,6 +596,14 @@ func tracegen(pkgpath string, ctxt *build.Context, cwd string) error {
...
@@ -570,6 +596,14 @@ func tracegen(pkgpath string, ctxt *build.Context, cwd string) error {
return
err
// XXX err ctx
return
err
// XXX err ctx
}
}
// write ztrace.go with code generated for trace events and imports
ztrace_go
:=
filepath
.
Join
(
pkgdir
,
"ztrace.go"
)
if
len
(
tpkg
.
Eventv
)
==
0
&&
len
(
tpkg
.
Importv
)
==
0
{
err
=
removeFile
(
ztrace_go
)
if
err
!=
nil
{
return
err
}
}
else
{
// prologue
// prologue
prologue
:=
&
Buffer
{}
prologue
:=
&
Buffer
{}
prologue
.
WriteString
(
magic
)
prologue
.
WriteString
(
magic
)
...
@@ -637,17 +671,18 @@ func tracegen(pkgpath string, ctxt *build.Context, cwd string) error {
...
@@ -637,17 +671,18 @@ func tracegen(pkgpath string, ctxt *build.Context, cwd string) error {
// write output to ztrace.go
// write output to ztrace.go
fulltext
:=
append
(
prologue
.
Bytes
(),
text
.
Bytes
()
...
)
fulltext
:=
append
(
prologue
.
Bytes
(),
text
.
Bytes
()
...
)
err
=
writeFile
(
filepath
.
Join
(
pkgdir
,
"ztrace.go"
)
,
fulltext
)
err
=
writeFile
(
ztrace_go
,
fulltext
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
}
// write empty ztrace.s so go:linkname works, if there are trace imports
// write empty ztrace.s so go:linkname works, if there are trace imports
ztrace_s
:=
filepath
.
Join
(
pkgdir
,
"ztrace.s"
)
ztrace_s
:=
filepath
.
Join
(
pkgdir
,
"ztrace.s"
)
if
len
(
tpkg
.
Importv
)
==
0
{
if
len
(
tpkg
.
Importv
)
==
0
{
err
=
removeFile
(
ztrace_s
)
err
=
removeFile
(
ztrace_s
)
}
else
{
}
else
{
text
.
Reset
()
text
:=
&
Buffer
{}
text
.
WriteString
(
magic
)
text
.
WriteString
(
magic
)
text
.
emit
(
"// empty .s so `go build` does not use -complete for go:linkname to work"
)
text
.
emit
(
"// empty .s so `go build` does not use -complete for go:linkname to work"
)
...
...
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
View file @
0da5fa01
...
@@ -136,7 +136,8 @@ func TestGoTraceGen(t *testing.T) {
...
@@ -136,7 +136,8 @@ func TestGoTraceGen(t *testing.T) {
}
}
// XXX autodetect (go list ?)
// XXX autodetect (go list ?)
testv
:=
[]
string
{
"a/pkg1"
,
"b/pkg2"
,
"c/pkg3"
}
//testv := []string{"a/pkg1", "b/pkg2", "c/pkg3", "d/pkg4"}
testv
:=
[]
string
{
"a/pkg1"
}
for
_
,
tpkg
:=
range
testv
{
for
_
,
tpkg
:=
range
testv
{
err
=
tracegen
(
tpkg
,
tBuildCtx
,
""
/* = local imorts disabled */
)
err
=
tracegen
(
tpkg
,
tBuildCtx
,
""
/* = local imorts disabled */
)
...
...
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/ztrace.go
View file @
0da5fa01
// Code generated by lab.nexedi.com/kirr/go123/tracing/cmd/gotrace; DO NOT EDIT.
// Code generated by lab.nexedi.com/kirr/go123/tracing/cmd/gotrace; DO NOT EDIT.
package
pkg1
import
(
"non-existent"
)
Bad
bad
bad
-
I
'
m
invalid
go
file
.
Bad
bad
bad
-
I
'
m
invalid
go
file
.
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/pkg4.go
0 → 100644
View file @
0da5fa01
package
pkg4
// this package does not use tracepoints at all
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace.go.rm
0 → 100644
View file @
0da5fa01
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace.s.rm
0 → 100644
View file @
0da5fa01
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace_test.go.rm
0 → 100644
View file @
0da5fa01
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace_test.s.rm
0 → 100644
View file @
0da5fa01
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace_x_test.go.rm
0 → 100644
View file @
0da5fa01
go/xcommon/tracing/cmd/gotrace/testdata/src/d/pkg4/ztrace_x_test.s.rm
0 → 100644
View file @
0da5fa01
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