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
a8243345
Commit
a8243345
authored
Jun 30, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e8921f0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
go/xcommon/tracing/cmd/gotrace/gotrace.go
go/xcommon/tracing/cmd/gotrace/gotrace.go
+14
-4
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
+1
-4
No files found.
go/xcommon/tracing/cmd/gotrace/gotrace.go
View file @
a8243345
...
...
@@ -375,7 +375,7 @@ func {{.Pkgi.Pkg.Name}}_{{.Name}}_Attach(*tracing.ProbeGroup, func({{.ArgvTypedR
// magic begins all files generated by gotrace
const
magic
=
"// Code generated by lab.nexedi.com/kirr/go123/tracing/cmd/gotrace; DO NOT EDIT.
\n
"
// checkCanWrite check
whether it is safe to writ
e at path
// checkCanWrite check
s whether it is safe to write to fil
e at path
// it is safe to write when either
// - the file does not exist, or
// - it exits but was previously generated by us
...
...
@@ -420,6 +420,7 @@ func removeFile(path string) error {
return
err
}
// Buffer is bytes.Buffer + syntatic sugar
type
Buffer
struct
{
bytes
.
Buffer
}
...
...
@@ -442,7 +443,7 @@ func (s StrSet) Delete(item string) {
delete
(
s
,
item
)
}
// Item
b
returns ordered slice of set items
// Item
v
returns ordered slice of set items
func
(
s
StrSet
)
Itemv
()
[]
string
{
itemv
:=
make
([]
string
,
0
,
len
(
s
))
for
item
:=
range
s
{
...
...
@@ -453,7 +454,10 @@ func (s StrSet) Itemv() []string {
}
// tracegen generates code according to tracing directives in a package @ pkgpath
func
tracegen
(
pkgpath
string
,
buildCtx
*
build
.
Context
)
error
{
//
// buildCtx is build context for discovering packages
// cwd is "current" directory for resolving local imports (e.g. packages like "./some/package")
func
tracegen
(
pkgpath
string
,
buildCtx
*
build
.
Context
,
cwd
string
)
error
{
// XXX typechecking is much slower than parsing + we don't need to
// load anything except the package in question
// TODO -> use just AST parsing for loading?
...
...
@@ -461,6 +465,7 @@ func tracegen(pkgpath string, buildCtx *build.Context) error {
ParserMode
:
parser
.
ParseComments
,
TypeCheckFuncBodies
:
func
(
path
string
)
bool
{
return
false
},
Build
:
buildCtx
,
Cwd
:
cwd
,
}
conf
.
Import
(
pkgpath
)
...
...
@@ -595,7 +600,12 @@ TODO ...
}
pkgpath
:=
argv
[
0
]
err
:=
tracegen
(
pkgpath
,
&
build
.
Default
)
cwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
err
=
tracegen
(
pkgpath
,
&
build
.
Default
,
cwd
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
View file @
a8243345
...
...
@@ -34,20 +34,17 @@ const (
// prepareTestTree copies files from src to dst recursively processing *.ok and *.rm depending on mode
// dst should not initially exist
func
prepareTestTree
(
src
,
dst
string
,
mode
TreePrepareMode
)
error
{
println
(
"AAA"
,
dst
)
err
:=
os
.
MkdirAll
(
dst
,
0777
)
if
err
!=
nil
{
return
err
}
return
filepath
.
Walk
(
src
,
func
(
srcpath
string
,
info
os
.
FileInfo
,
err
error
)
error
{
println
(
"*"
,
srcpath
)
if
srcpath
==
src
/* skip root */
||
err
!=
nil
{
return
err
}
dstpath
:=
dst
+
strings
.
TrimPrefix
(
srcpath
,
src
)
//println("·", dstpath)
if
info
.
IsDir
()
{
err
:=
os
.
Mkdir
(
dstpath
,
0777
)
return
err
...
...
@@ -139,7 +136,7 @@ func TestGoTraceGen(t *testing.T) {
testv
:=
[]
string
{
"a/pkg1"
,
"b/pkg2"
}
for
_
,
tpkg
:=
range
testv
{
err
=
tracegen
(
tpkg
,
tBuildCtx
)
err
=
tracegen
(
tpkg
,
tBuildCtx
,
""
/* = local imorts disabled */
)
if
err
!=
nil
{
t
.
Errorf
(
"%v: %v"
,
tpkg
,
err
)
}
...
...
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