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
f3f9949f
Commit
f3f9949f
authored
Jun 27, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0fcbdc95
Changes
3
Hide 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) {
}
*/
//trace:import lab.nexedi.com/kirr/neo/go/neo
// M drives cluster with 1 S through recovery -> verification -> service -> shutdown
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)
return
&
traceEvent
{
pkgi
.
Pkg
.
Path
(),
declf
},
nil
}
// 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
)
}
pkg
:=
lprog
.
InitialPackages
()[
0
]
//fmt.Println(pkg)
// Package represents tracing-related information about a package
type
Package
struct
{
PkgPath
string
Eventv
[]
*
traceEvent
// trace events this package defines
Importv
[]
string
// packages (pkgpath) this package trace imports
}
eventv
:=
[]
*
traceEvent
{}
// events this package defines
importv
:=
[]
string
{}
// packages (pkgpath) this package trace imports
// packageTrace returns tracing information about a package
func
packageTrace
(
lprog
*
loader
.
Program
,
pkgi
*
loader
.
PackageInfo
)
*
Package
{
eventv
:=
[]
*
traceEvent
{}
importv
:=
[]
string
{}
// 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
_
,
comment
:=
range
commgroup
.
List
{
// ast.Comment
pos
:=
lprog
.
Fset
.
Position
(
comment
.
Slash
)
...
...
@@ -229,7 +218,7 @@ func tracegen(pkgpath string) error {
directive
,
arg
:=
textv
[
0
],
textv
[
1
]
switch
directive
{
case
"//trace:event"
:
event
,
err
:=
parseTraceEvent
(
pkg
,
arg
)
event
,
err
:=
parseTraceEvent
(
pkg
i
,
arg
)
if
err
!=
nil
{
log
.
Fatalf
(
"%v: %v"
,
pos
,
err
)
}
...
...
@@ -247,9 +236,36 @@ func tracegen(pkgpath string) error {
}
}
// generate code for trace:event definitions
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
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -260,12 +276,14 @@ func tracegen(pkgpath string) error {
// generate code for trace:import imports
fmt
.
Println
()
for
_
,
pkgpath
:=
range
i
mportv
{
for
_
,
pkgpath
:=
range
pkg
.
I
mportv
{
fmt
.
Printf
(
"// traceimport TODO %v
\n
"
,
pkgpath
)
}
// 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
}
...
...
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