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
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
f3f9949f
Commit
f3f9949f
authored
Jun 27, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0fcbdc95
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
26 deletions
+45
-26
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+1
-0
go/neo/server/trace.go.dont
go/neo/server/trace.go.dont
+0
-0
go/xcommon/tracing/cmd/gotracegen/gotracegen.go
go/xcommon/tracing/cmd/gotracegen/gotracegen.go
+44
-26
No files found.
go/neo/server/cluster_test.go
View file @
f3f9949f
...
@@ -121,6 +121,7 @@ func (tc *TraceChecker) ExpectNetTx(src, dst string, pkt string) {
...
@@ -121,6 +121,7 @@ func (tc *TraceChecker) ExpectNetTx(src, dst string, pkt string) {
}
}
*/
*/
//trace:import lab.nexedi.com/kirr/neo/go/neo
// M drives cluster with 1 S through recovery -> verification -> service -> shutdown
// M drives cluster with 1 S through recovery -> verification -> service -> shutdown
func
TestMasterStorage
(
t
*
testing
.
T
)
{
func
TestMasterStorage
(
t
*
testing
.
T
)
{
...
...
go/neo/server/trace.go
→
go/neo/server/trace.go
.dont
View file @
f3f9949f
File moved
go/xcommon/tracing/cmd/gotracegen/gotracegen.go
View file @
f3f9949f
...
@@ -182,31 +182,20 @@ func parseTraceEvent(pkgi *loader.PackageInfo, text string) (*traceEvent, error)
...
@@ -182,31 +182,20 @@ func parseTraceEvent(pkgi *loader.PackageInfo, text string) (*traceEvent, error)
return
&
traceEvent
{
pkgi
.
Pkg
.
Path
(),
declf
},
nil
return
&
traceEvent
{
pkgi
.
Pkg
.
Path
(),
declf
},
nil
}
}
// tracegen generates code according to tracing directives in a package @ pkgpath
// Package represents tracing-related information about a package
func
tracegen
(
pkgpath
string
)
error
{
type
Package
struct
{
// XXX typechecking is much slower than parsing + we don't need to
PkgPath
string
// load anything except the package in question
Eventv
[]
*
traceEvent
// trace events this package defines
// TODO -> use just AST parsing for loading
Importv
[]
string
// packages (pkgpath) this package trace imports
conf
:=
loader
.
Config
{
}
ParserMode
:
parser
.
ParseComments
,
TypeCheckFuncBodies
:
func
(
path
string
)
bool
{
return
false
},
}
conf
.
Import
(
pkgpath
)
// load package + all its imports
lprog
,
err
:=
conf
.
Load
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
pkg
:=
lprog
.
InitialPackages
()[
0
]
//fmt.Println(pkg)
eventv
:=
[]
*
traceEvent
{}
// events this package defines
// packageTrace returns tracing information about a package
importv
:=
[]
string
{}
// packages (pkgpath) this package trace imports
func
packageTrace
(
lprog
*
loader
.
Program
,
pkgi
*
loader
.
PackageInfo
)
*
Package
{
eventv
:=
[]
*
traceEvent
{}
importv
:=
[]
string
{}
// go through files of the package and process //trace: directives
// go through files of the package and process //trace: directives
for
_
,
file
:=
range
pkg
.
Files
{
// ast.File
for
_
,
file
:=
range
pkg
i
.
Files
{
// ast.File
for
_
,
commgroup
:=
range
file
.
Comments
{
// ast.CommentGroup
for
_
,
commgroup
:=
range
file
.
Comments
{
// ast.CommentGroup
for
_
,
comment
:=
range
commgroup
.
List
{
// ast.Comment
for
_
,
comment
:=
range
commgroup
.
List
{
// ast.Comment
pos
:=
lprog
.
Fset
.
Position
(
comment
.
Slash
)
pos
:=
lprog
.
Fset
.
Position
(
comment
.
Slash
)
...
@@ -229,7 +218,7 @@ func tracegen(pkgpath string) error {
...
@@ -229,7 +218,7 @@ func tracegen(pkgpath string) error {
directive
,
arg
:=
textv
[
0
],
textv
[
1
]
directive
,
arg
:=
textv
[
0
],
textv
[
1
]
switch
directive
{
switch
directive
{
case
"//trace:event"
:
case
"//trace:event"
:
event
,
err
:=
parseTraceEvent
(
pkg
,
arg
)
event
,
err
:=
parseTraceEvent
(
pkg
i
,
arg
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"%v: %v"
,
pos
,
err
)
log
.
Fatalf
(
"%v: %v"
,
pos
,
err
)
}
}
...
@@ -247,9 +236,36 @@ func tracegen(pkgpath string) error {
...
@@ -247,9 +236,36 @@ func tracegen(pkgpath string) error {
}
}
}
}
// generate code for trace:event definitions
sort
.
Sort
(
byEventName
(
eventv
))
sort
.
Sort
(
byEventName
(
eventv
))
for
_
,
event
:=
range
eventv
{
sort
.
Strings
(
importv
)
return
&
Package
{
PkgPath
:
pkgi
.
Pkg
.
Path
(),
Eventv
:
eventv
,
Importv
:
importv
}
}
// tracegen generates code according to tracing directives in a package @ pkgpath
func
tracegen
(
pkgpath
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
conf
:=
loader
.
Config
{
ParserMode
:
parser
.
ParseComments
,
TypeCheckFuncBodies
:
func
(
path
string
)
bool
{
return
false
},
}
conf
.
Import
(
pkgpath
)
// load package + all its imports
lprog
,
err
:=
conf
.
Load
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
pkgi
:=
lprog
.
InitialPackages
()[
0
]
//fmt.Println(pkgi)
pkg
:=
packageTrace
(
lprog
,
pkgi
)
// generate code for trace:event definitions
for
_
,
event
:=
range
pkg
.
Eventv
{
err
=
traceEventCodeTmpl
.
Execute
(
os
.
Stdout
,
event
)
err
=
traceEventCodeTmpl
.
Execute
(
os
.
Stdout
,
event
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
...
@@ -260,12 +276,14 @@ func tracegen(pkgpath string) error {
...
@@ -260,12 +276,14 @@ func tracegen(pkgpath string) error {
// generate code for trace:import imports
// generate code for trace:import imports
fmt
.
Println
()
fmt
.
Println
()
for
_
,
pkgpath
:=
range
i
mportv
{
for
_
,
pkgpath
:=
range
pkg
.
I
mportv
{
fmt
.
Printf
(
"// traceimport TODO %v
\n
"
,
pkgpath
)
fmt
.
Printf
(
"// traceimport TODO %v
\n
"
,
pkgpath
)
}
}
// TODO check export hash
// TODO check export hash
// TODO trace.s with "// empty .s so `go build` does not use -complete for go:linkname to work"
return
nil
// XXX
return
nil
// XXX
}
}
...
...
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