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
c92cd912
Commit
c92cd912
authored
Jun 28, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3504efb2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
34 deletions
+65
-34
go/xcommon/tracing/cmd/gotrace/gotrace.go
go/xcommon/tracing/cmd/gotrace/gotrace.go
+36
-8
go/xcommon/tracing/runtime.s
go/xcommon/tracing/runtime.s
+0
-0
go/xcommon/tracing/tracing.go
go/xcommon/tracing/tracing.go
+4
-1
go/xcommon/xnet/pipenet/trace.go
go/xcommon/xnet/pipenet/trace.go
+25
-25
No files found.
go/xcommon/tracing/cmd/gotrace
gen/gotracegen
.go
→
go/xcommon/tracing/cmd/gotrace
/gotrace
.go
View file @
c92cd912
...
...
@@ -16,9 +16,10 @@
// See COPYING file for full licensing terms.
/*
gotracegen generates code according to tracing annotations and imports
gotrace
gen generates code according to tracing annotations and imports
gotracegen package
gotrace gen package
gotrace list package TODO
XXX tracepoints this package defines
XXX tracepoints this package imports
...
...
@@ -45,7 +46,7 @@ import (
"golang.org/x/tools/go/loader"
)
// traceEvent represents 1 trace:event d
irective
// traceEvent represents 1 trace:event d
eclaration
type
traceEvent
struct
{
// TODO += Pos token.Position
Pkgi
*
loader
.
PackageInfo
...
...
@@ -98,9 +99,31 @@ func parseTraceEvent(pkgi *loader.PackageInfo, text string) (*traceEvent, error)
}
// trace event definition as func declaration
text
=
"package xxx
\n
func "
+
text
// XXX
buf
:=
&
Buffer
{}
// XXX package name must be from trace definition context
buf
.
emit
(
"package xxx"
)
// add
// 1. all imports from original source file TODO
// 2. add dot-import of original package TODO
// so inside it all looks like as if it was in original source context
buf
.
emit
(
"
\n
import ("
)
for
_
,
imp
:=
range
file
.
Imports
{
impline
:=
""
if
imp
.
Name
!=
nil
{
impline
+=
imp
.
Name
.
Name
+
" "
}
impline
+=
`"`
+
imp
.
Path
.
Value
+
`"`
buf
.
emit
(
"%s"
,
impline
)
}
buf
.
emit
(
"
\t
. %q"
,
pkgi
.
Pkg
.
Path
)
buf
.
emit
(
")"
)
text
=
"
\n
func "
+
text
// XXX add all imports from file of trace event definition context
fset
:=
token
.
NewFileSet
()
// XXX
filename
:=
"tracefunc.go"
// XXX
filename
:=
"tracefunc.go"
// XXX
-> original_file.go:<lineno> ?
f
,
err
:=
parser
.
ParseFile
(
fset
,
filename
,
text
,
0
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -119,6 +142,7 @@ func parseTraceEvent(pkgi *loader.PackageInfo, text string) (*traceEvent, error)
return
nil
,
fmt
.
Errorf
(
"trace event must not return results"
)
}
// XXX +pos
return
&
traceEvent
{
pkgi
,
declf
},
nil
}
...
...
@@ -174,6 +198,7 @@ func packageTrace(lprog *loader.Program, pkgi *loader.PackageInfo) *Package {
}
}
// events and imports go in canonical order
sort
.
Sort
(
byEventName
(
eventv
))
sort
.
Sort
(
byPkgPath
(
importv
))
...
...
@@ -194,7 +219,10 @@ func (te *traceEvent) TypedArgv() string {
}
arg
:=
strings
.
Join
(
namev
,
", "
)
arg
+=
" "
+
types
.
ExprString
(
field
.
Type
)
//arg += " " + types.ExprString(field.Type)
typ
:=
te
.
Pkgi
.
Types
[
field
.
Type
]
.
Type
fmt
.
Println
(
"AAA %v
\n
"
,
typ
)
arg
+=
" "
+
types
.
TypeString
(
typ
,
nil
)
// XXX qf=nil
argv
=
append
(
argv
,
arg
)
}
...
...
@@ -261,7 +289,7 @@ var traceEventImportTmpl = template.Must(template.New("traceimport").Parse(`
func {{.Pkgi.Pkg.Name}}_{{.Name}}_Attach(*tracing.ProbeGroup, func({{.TypedArgv}})) *tracing.Probe
`
))
//
XXX go123 in magic
//
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 write at path
...
...
@@ -315,7 +343,7 @@ func tracegen(pkgpath string) error {
conf
.
Import
(
pkgpath
)
// load package + all its imports
// XXX ignore trace.go & trace.s on load here?
// XXX ignore trace.go & trace.s on load here?
-> TODO remove the first
lprog
,
err
:=
conf
.
Load
()
if
err
!=
nil
{
log
.
Fatal
(
err
)
...
...
go/xcommon/tracing/
tracing
.s
→
go/xcommon/tracing/
runtime
.s
View file @
c92cd912
File moved
go/xcommon/tracing/tracing.go
View file @
c92cd912
...
...
@@ -21,6 +21,9 @@
// - tracepoints
// - probes
// - probes can be attached/detached to/from tracepoints
//
// TODO document //trace:event & //trace:import
// TODO document `gotrace gen` + `gotrace list`
package
tracing
import
(
...
...
@@ -151,7 +154,7 @@ func (pg *ProbeGroup) Add(p *Probe) {
pg
.
probev
=
append
(
pg
.
probev
,
p
)
}
// Done detaches all probes registered
in
the group
// Done detaches all probes registered
to
the group
// Must be called under normal conditions, not under Lock
func
(
pg
*
ProbeGroup
)
Done
()
{
verifyUnlocked
()
...
...
go/xcommon/xnet/pipenet/trace.go
View file @
c92cd912
...
...
@@ -8,136 +8,136 @@ import (
"unsafe"
)
// traceevent: traceAccept(conn
net.Conn
) XXX better raw .Text (e.g. comments)
// traceevent: traceAccept(conn
<nil>
) XXX better raw .Text (e.g. comments)
type
_t_traceAccept
struct
{
tracing
.
Probe
probefunc
func
(
conn
net
.
Conn
)
probefunc
func
(
conn
<
nil
>
)
}
var
_traceAccept
*
_t_traceAccept
func
traceAccept
(
conn
net
.
Conn
)
{
func
traceAccept
(
conn
<
nil
>
)
{
if
_traceAccept
!=
nil
{
_traceAccept_run
(
conn
)
}
}
func
_traceAccept_run
(
conn
net
.
Conn
)
{
func
_traceAccept_run
(
conn
<
nil
>
)
{
for
p
:=
_traceAccept
;
p
!=
nil
;
p
=
(
*
_t_traceAccept
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
conn
)
}
}
func
traceAccept_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
conn
net
.
Conn
))
*
tracing
.
Probe
{
func
traceAccept_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
conn
<
nil
>
))
*
tracing
.
Probe
{
p
:=
_t_traceAccept
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceAccept
)),
&
p
.
Probe
)
return
&
p
.
Probe
}
// traceevent: traceDial(addr
string
) XXX better raw .Text (e.g. comments)
// traceevent: traceDial(addr
<nil>
) XXX better raw .Text (e.g. comments)
type
_t_traceDial
struct
{
tracing
.
Probe
probefunc
func
(
addr
string
)
probefunc
func
(
addr
<
nil
>
)
}
var
_traceDial
*
_t_traceDial
func
traceDial
(
addr
string
)
{
func
traceDial
(
addr
<
nil
>
)
{
if
_traceDial
!=
nil
{
_traceDial_run
(
addr
)
}
}
func
_traceDial_run
(
addr
string
)
{
func
_traceDial_run
(
addr
<
nil
>
)
{
for
p
:=
_traceDial
;
p
!=
nil
;
p
=
(
*
_t_traceDial
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
addr
)
}
}
func
traceDial_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
addr
string
))
*
tracing
.
Probe
{
func
traceDial_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
addr
<
nil
>
))
*
tracing
.
Probe
{
p
:=
_t_traceDial
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceDial
)),
&
p
.
Probe
)
return
&
p
.
Probe
}
// traceevent: traceListen(laddr
string
) XXX better raw .Text (e.g. comments)
// traceevent: traceListen(laddr
<nil>
) XXX better raw .Text (e.g. comments)
type
_t_traceListen
struct
{
tracing
.
Probe
probefunc
func
(
laddr
string
)
probefunc
func
(
laddr
<
nil
>
)
}
var
_traceListen
*
_t_traceListen
func
traceListen
(
laddr
string
)
{
func
traceListen
(
laddr
<
nil
>
)
{
if
_traceListen
!=
nil
{
_traceListen_run
(
laddr
)
}
}
func
_traceListen_run
(
laddr
string
)
{
func
_traceListen_run
(
laddr
<
nil
>
)
{
for
p
:=
_traceListen
;
p
!=
nil
;
p
=
(
*
_t_traceListen
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
laddr
)
}
}
func
traceListen_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
laddr
string
))
*
tracing
.
Probe
{
func
traceListen_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
laddr
<
nil
>
))
*
tracing
.
Probe
{
p
:=
_t_traceListen
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceListen
)),
&
p
.
Probe
)
return
&
p
.
Probe
}
// traceevent: traceNew(name
string
) XXX better raw .Text (e.g. comments)
// traceevent: traceNew(name
<nil>
) XXX better raw .Text (e.g. comments)
type
_t_traceNew
struct
{
tracing
.
Probe
probefunc
func
(
name
string
)
probefunc
func
(
name
<
nil
>
)
}
var
_traceNew
*
_t_traceNew
func
traceNew
(
name
string
)
{
func
traceNew
(
name
<
nil
>
)
{
if
_traceNew
!=
nil
{
_traceNew_run
(
name
)
}
}
func
_traceNew_run
(
name
string
)
{
func
_traceNew_run
(
name
<
nil
>
)
{
for
p
:=
_traceNew
;
p
!=
nil
;
p
=
(
*
_t_traceNew
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
name
)
}
}
func
traceNew_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
name
string
))
*
tracing
.
Probe
{
func
traceNew_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
name
<
nil
>
))
*
tracing
.
Probe
{
p
:=
_t_traceNew
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceNew
)),
&
p
.
Probe
)
return
&
p
.
Probe
}
// traceevent: traceNewHost(host
*Host
) XXX better raw .Text (e.g. comments)
// traceevent: traceNewHost(host
<nil>
) XXX better raw .Text (e.g. comments)
type
_t_traceNewHost
struct
{
tracing
.
Probe
probefunc
func
(
host
*
Host
)
probefunc
func
(
host
<
nil
>
)
}
var
_traceNewHost
*
_t_traceNewHost
func
traceNewHost
(
host
*
Host
)
{
func
traceNewHost
(
host
<
nil
>
)
{
if
_traceNewHost
!=
nil
{
_traceNewHost_run
(
host
)
}
}
func
_traceNewHost_run
(
host
*
Host
)
{
func
_traceNewHost_run
(
host
<
nil
>
)
{
for
p
:=
_traceNewHost
;
p
!=
nil
;
p
=
(
*
_t_traceNewHost
)(
unsafe
.
Pointer
(
p
.
Next
()))
{
p
.
probefunc
(
host
)
}
}
func
traceNewHost_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
host
*
Host
))
*
tracing
.
Probe
{
func
traceNewHost_Attach
(
pg
*
tracing
.
ProbeGroup
,
probe
func
(
host
<
nil
>
))
*
tracing
.
Probe
{
p
:=
_t_traceNewHost
{
probefunc
:
probe
}
tracing
.
AttachProbe
(
pg
,
(
**
tracing
.
Probe
)(
unsafe
.
Pointer
(
&
_traceNewHost
)),
&
p
.
Probe
)
return
&
p
.
Probe
...
...
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