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
0fcbdc95
Commit
0fcbdc95
authored
7 years ago
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
92e8e1e0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
32 deletions
+46
-32
go/neo/connection.go
go/neo/connection.go
+3
-0
go/xcommon/tracing/cmd/gotracegen/gotracegen.go
go/xcommon/tracing/cmd/gotracegen/gotracegen.go
+33
-18
go/xcommon/x.go
go/xcommon/x.go
+6
-14
go/xcommon/xnet/pipenet/pipenet.go
go/xcommon/xnet/pipenet/pipenet.go
+4
-0
No files found.
go/neo/connection.go
View file @
0fcbdc95
...
...
@@ -737,6 +737,9 @@ func (c *Conn) err(op string, e error) error {
//trace:event traceConnRecv(c *Conn /*aaa*/, msg Msg)
//trace:event traceConnSend(c *Conn, msg Msg) // XXX -> traceConnSendPre ?
//XXX temp
//trace:import lab.nexedi.com/kirr/neo/go/xcommon/xnet/pipenet
// Recv receives message
// it receives packet and decodes message from it
func
(
c
*
Conn
)
Recv
()
(
Msg
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
go/xcommon/tracing/cmd/gotracegen/gotracegen.go
View file @
0fcbdc95
...
...
@@ -59,6 +59,7 @@ type traceEvent struct {
//Name string
//Argv string
PkgPath
string
// XXX -> pkg ?
*
ast
.
FuncDecl
}
...
...
@@ -101,50 +102,57 @@ func (v byEventName) Less(i, j int) bool { return v[i].Name.Name < v[j].Name.Nam
func
(
v
byEventName
)
Swap
(
i
,
j
int
)
{
v
[
i
],
v
[
j
]
=
v
[
j
],
v
[
i
]
}
func
(
v
byEventName
)
Len
()
int
{
return
len
(
v
)
}
// traceEventCode is code template generated for one trace event
const
traceEventCode
=
`
// traceEventCode
Tmpl
is code template generated for one trace event
var
traceEventCodeTmpl
=
template
.
Must
(
template
.
New
(
"traceevent"
)
.
Parse
(
`
// traceevent: {{.Name}}({{.TypedArgv}}) XXX better raw .Text (e.g. comments)
{{/* probe type for this trace event */}}
{{/* probe type for this trace event */
-
}}
type _t_{{.Name}} struct {
tracing.Probe
probefunc func({{.TypedArgv}})
}
{{/* list of probes attached (nil if nothing) */}}
{{/* list of probes attached (nil if nothing) */
-
}}
var _{{.Name}} *_t_{{.Name}}
{{/* function which event producer calls to notify about the event
*
* after https://github.com/golang/go/issues/19348 is done this separate
* checking function will be inlined and tracepoint won't cost a function
* call when it is disabled */}}
* call when it is disabled */
-
}}
func {{.Name}}({{.TypedArgv}}) {
if _{{.Name}} != nil {
_{{.Name}}_run({{.Argv}})
}
}
{{/* function to notify attached probes */}}
func _{{.Name}}
{{.Argv}}
_run({{.Argv}}) {
{{/* function to notify attached probes */
-
}}
func _{{.Name}}_run({{.Argv}}) {
for p := _{{.Name}}; p != nil; p = (*_t_{{.Name}})(unsafe.Pointer(p.Next())) {
p.probefunc({{.Argv}})
}
}
{{/* function to attach a probe to tracepoint */}}
{{/* function to attach a probe to tracepoint */
-
}}
func {{.Name}}_Attach(pg *tracing.ProbeGroup, probe func({{.TypedArgv}})) *tracing.Probe {
p := _t_{{.Name}}{probefunc: probe}
tracing.AttachProbe(pg, (**tracing.Probe)(unsafe.Pointer(&_{{.Name}}), &p.Probe)
return &p.Probe
}
`
`
))
var
traceEventCodeTmpl
=
template
.
Must
(
template
.
New
(
"traceevent"
)
.
Parse
(
traceEventCode
))
// traceEventImportTmpl is code template generated for importing one trace event
var
traceEventImportTmpl
=
template
.
Must
(
template
.
New
(
"traceimport"
)
.
Parse
(
`
// traceimport: {{.Pkgi.Pkg.Path}} {{.Name}}
// FIXME func args typs must be qualified
//go:linkname {{.Pkgi.Pkg.Name}}_{{.Name}}_Attach {{.Pkgi.Pkg.Path}}.{{.Name}}_Attach
func {{.Pkgi.Pkg.Name}}_{{.Name}}_Attach(*tracing.ProbeGroup, func(.TypedArgv)) *tracing.Probe
`
))
// parseTraceEvent parses trace event definition into traceEvent
// text is text argument after "//trace:event "
func
parseTraceEvent
(
text
string
)
(
*
traceEvent
,
error
)
{
func
parseTraceEvent
(
pkgi
*
loader
.
PackageInfo
,
text
string
)
(
*
traceEvent
,
error
)
{
if
!
strings
.
HasPrefix
(
text
,
"trace"
)
{
return
nil
,
fmt
.
Errorf
(
"trace event must start with
\"
trace
\"
"
)
// XXX pos
}
...
...
@@ -171,7 +179,7 @@ func parseTraceEvent(text string) (*traceEvent, error) {
return
nil
,
fmt
.
Errorf
(
"trace event must not return results"
)
}
return
&
traceEvent
{
declf
},
nil
return
&
traceEvent
{
pkgi
.
Pkg
.
Path
(),
declf
},
nil
}
// tracegen generates code according to tracing directives in a package @ pkgpath
...
...
@@ -194,8 +202,8 @@ func tracegen(pkgpath string) error {
pkg
:=
lprog
.
InitialPackages
()[
0
]
//fmt.Println(pkg)
eventv
:=
[]
*
traceEvent
{}
// events this package defines
importv
:=
map
[
/*pkgpath*/
string
][]
traceEvent
{}
// events this packag
e imports
eventv
:=
[]
*
traceEvent
{}
// events this package defines
importv
:=
[]
string
{}
// packages (pkgpath) this package trac
e imports
// go through files of the package and process //trace: directives
for
_
,
file
:=
range
pkg
.
Files
{
// ast.File
...
...
@@ -221,7 +229,7 @@ func tracegen(pkgpath string) error {
directive
,
arg
:=
textv
[
0
],
textv
[
1
]
switch
directive
{
case
"//trace:event"
:
event
,
err
:=
parseTraceEvent
(
arg
)
event
,
err
:=
parseTraceEvent
(
pkg
,
arg
)
if
err
!=
nil
{
log
.
Fatalf
(
"%v: %v"
,
pos
,
err
)
}
...
...
@@ -229,8 +237,8 @@ func tracegen(pkgpath string) error {
eventv
=
append
(
eventv
,
event
)
case
"//trace:import"
:
panic
(
"TODO"
)
// TODO arg is pkgpath - get trace events from tha
// XXX reject duplicate imports
importv
=
append
(
importv
,
arg
)
default
:
log
.
Fatalf
(
"%v: unknown tracing directive %q"
,
pos
,
directive
)
...
...
@@ -248,8 +256,15 @@ func tracegen(pkgpath string) error {
}
}
// TODO export hash
// generate code for trace:import imports
_
=
importv
fmt
.
Println
()
for
_
,
pkgpath
:=
range
importv
{
fmt
.
Printf
(
"// traceimport TODO %v
\n
"
,
pkgpath
)
}
// TODO check export hash
return
nil
// XXX
}
...
...
This diff is collapsed.
Click to expand it.
go/xcommon/x.go
View file @
0fcbdc95
// traceevent: traceConnRecv(c *Conn, msg Msg) XXX better raw .Text (e.g. comments)
type
_t_traceConnRecv
struct
{
tracing
.
Probe
probefunc
func
(
c
*
Conn
,
msg
Msg
)
}
var
_traceConnRecv
*
_t_traceConnRecv
func
traceConnRecv
(
c
*
Conn
,
msg
Msg
)
{
if
_traceConnRecv
!=
nil
{
_traceConnRecv_run
(
c
,
msg
)
}
}
func
_traceConnRecvc
,
msg_run
(
c
,
msg
)
{
func
_traceConnRecv_run
(
c
,
msg
)
{
for
p
:=
_traceConnRecv
;
p
!=
nil
;
p
=
(
*
_t_traceConnRecv
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
c
,
msg
)
}
}
func
traceConnRecv_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
({
31
[
0xc42358be80
0xc42358bec0
]
56
}))
*
tracing
.
Probe
{
func
traceConnRecv_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
c
*
Conn
,
msg
Msg
))
*
tracing
.
Probe
{
p
:=
_t_traceConnRecv
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceConnRecv
),
&
p
.
Probe
)
return
&
p
.
Probe
...
...
@@ -33,32 +28,29 @@ func traceConnRecv_Attach(pg *tracing.ProbeGroup, probe func({31 [0xc42358be80 0
// traceevent: traceConnSend(c *Conn, msg Msg) XXX better raw .Text (e.g. comments)
type
_t_traceConnSend
struct
{
tracing
.
Probe
probefunc
func
(
c
*
Conn
,
msg
Msg
)
}
var
_traceConnSend
*
_t_traceConnSend
func
traceConnSend
(
c
*
Conn
,
msg
Msg
)
{
if
_traceConnSend
!=
nil
{
_traceConnSend_run
(
c
,
msg
)
}
}
func
_traceConnSendc
,
msg_run
(
c
,
msg
)
{
func
_traceConnSend_run
(
c
,
msg
)
{
for
p
:=
_traceConnSend
;
p
!=
nil
;
p
=
(
*
_t_traceConnSend
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
c
,
msg
)
}
}
func
traceConnSend_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
({
31
[
0xc42358bf40
0xc42358bf80
]
48
}))
*
tracing
.
Probe
{
func
traceConnSend_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
c
*
Conn
,
msg
Msg
))
*
tracing
.
Probe
{
p
:=
_t_traceConnSend
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceConnSend
),
&
p
.
Probe
)
return
&
p
.
Probe
}
// traceimport TODO lab.nexedi.com/kirr/neo/go/xcommon/xnet/pipenet
This diff is collapsed.
Click to expand it.
go/xcommon/xnet/pipenet/pipenet.go
View file @
0fcbdc95
...
...
@@ -125,11 +125,15 @@ type dialReq struct {
// ----------------------------------------
// FIXME temp for testing
//trace:event traceNew(name string)
// New creates new pipenet Network
// name is name of this network under "pipe" namespace, e.g. "α" will give full network name "pipeα".
//
// New does not check whether network name provided is unique.
func
New
(
name
string
)
*
Network
{
traceNew
(
name
)
return
&
Network
{
name
:
name
,
hostMap
:
make
(
map
[
string
]
*
Host
)}
}
...
...
This diff is collapsed.
Click to expand it.
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