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
7d170b2c
Commit
7d170b2c
authored
Jun 28, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1ecdd605
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
4 deletions
+49
-4
go/xcommon/tracing/cmd/gotrace/gotrace.go
go/xcommon/tracing/cmd/gotrace/gotrace.go
+47
-4
go/xcommon/xnet/pipenet/trace.go
go/xcommon/xnet/pipenet/trace.go
+2
-0
No files found.
go/xcommon/tracing/cmd/gotrace/gotrace.go
View file @
7d170b2c
...
@@ -278,9 +278,7 @@ func (te *traceEvent) TypedArgv() string {
...
@@ -278,9 +278,7 @@ func (te *traceEvent) TypedArgv() string {
}
}
arg
:=
strings
.
Join
(
namev
,
", "
)
arg
:=
strings
.
Join
(
namev
,
", "
)
//arg += " " + types.ExprString(field.Type)
typ
:=
te
.
typinfo
.
Types
[
field
.
Type
]
.
Type
typ
:=
te
.
typinfo
.
Types
[
field
.
Type
]
.
Type
fmt
.
Printf
(
"AAA %v
\n
"
,
typ
)
arg
+=
" "
+
types
.
TypeString
(
typ
,
qf
)
arg
+=
" "
+
types
.
TypeString
(
typ
,
qf
)
argv
=
append
(
argv
,
arg
)
argv
=
append
(
argv
,
arg
)
...
@@ -302,6 +300,28 @@ func (te *traceEvent) Argv() string {
...
@@ -302,6 +300,28 @@ func (te *traceEvent) Argv() string {
return
strings
.
Join
(
argv
,
", "
)
return
strings
.
Join
(
argv
,
", "
)
}
}
// NeedPkgv returns packages that are needed for argument types
func
(
te
*
traceEvent
)
NeedPkgv
()
[]
string
{
pkgset
:=
map
[
string
/*pkgpath*/
]
int
{}
qf
:=
func
(
pkg
*
types
.
Package
)
string
{
// if we are called - pkg is used
pkgset
[
pkg
.
Path
()]
=
1
return
""
// don't care
}
for
_
,
field
:=
range
te
.
FuncDecl
.
Type
.
Params
.
List
{
typ
:=
te
.
typinfo
.
Types
[
field
.
Type
]
.
Type
_
=
types
.
TypeString
(
typ
,
qf
)
}
pkgv
:=
[]
string
{}
for
pkgpath
:=
range
pkgset
{
pkgv
=
append
(
pkgv
,
pkgpath
)
}
sort
.
Strings
(
pkgv
)
return
pkgv
}
// traceEventCodeTmpl is code template generated for one trace event
// traceEventCodeTmpl is code template generated for one trace event
var
traceEventCodeTmpl
=
template
.
Must
(
template
.
New
(
"traceevent"
)
.
Parse
(
`
var
traceEventCodeTmpl
=
template
.
Must
(
template
.
New
(
"traceevent"
)
.
Parse
(
`
// traceevent: {{.Name}}({{.TypedArgv}}) XXX better raw .Text (e.g. comments)
// traceevent: {{.Name}}({{.TypedArgv}}) XXX better raw .Text (e.g. comments)
...
@@ -416,6 +436,7 @@ func tracegen(pkgpath string) error {
...
@@ -416,6 +436,7 @@ func tracegen(pkgpath string) error {
}
}
pkgdir
:=
filepath
.
Dir
(
lprog
.
Fset
.
File
(
pkgi
.
Files
[
0
]
.
Pos
())
.
Name
())
pkgdir
:=
filepath
.
Dir
(
lprog
.
Fset
.
File
(
pkgi
.
Files
[
0
]
.
Pos
())
.
Name
())
pkgpath
=
pkgi
.
Pkg
.
Path
()
// e.g. "." -> "path/to/package"
//println("pkgpath", pkgpath)
//println("pkgpath", pkgpath)
//println("pkgdir", pkgdir)
//println("pkgdir", pkgdir)
//return nil
//return nil
...
@@ -432,7 +453,30 @@ func tracegen(pkgpath string) error {
...
@@ -432,7 +453,30 @@ func tracegen(pkgpath string) error {
buf
.
emit
(
"
\n
import ("
)
buf
.
emit
(
"
\n
import ("
)
buf
.
emit
(
"
\t
%q"
,
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
)
buf
.
emit
(
"
\t
%q"
,
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
)
buf
.
emit
(
"
\t
%q"
,
"unsafe"
)
buf
.
emit
(
"
\t
%q"
,
"unsafe"
)
// TODO import all packages for used types
// import all packages needed for used types
needPkg
:=
map
[
string
/*pkgpath*/
]
int
{}
// set<string>
for
_
,
event
:=
range
pkg
.
Eventv
{
for
_
,
needpkg
:=
range
event
.
NeedPkgv
()
{
if
needpkg
!=
pkgpath
{
needPkg
[
needpkg
]
=
1
}
}
}
needPkgv
:=
[]
string
{}
for
needpkg
:=
range
needPkg
{
needPkgv
=
append
(
needPkgv
,
needpkg
)
}
sort
.
Strings
(
needPkgv
)
if
len
(
needPkgv
)
>
0
{
buf
.
emit
(
""
)
for
_
,
pkgpath
:=
range
needPkgv
{
buf
.
emit
(
"
\t
%q"
,
pkgpath
)
}
}
buf
.
emit
(
")"
)
buf
.
emit
(
")"
)
// code for trace:event definitions
// code for trace:event definitions
...
@@ -467,7 +511,6 @@ func tracegen(pkgpath string) error {
...
@@ -467,7 +511,6 @@ func tracegen(pkgpath string) error {
// TODO check export hash
// TODO check export hash
// write output to trace.go
// write output to trace.go
err
=
writeFile
(
filepath
.
Join
(
pkgdir
,
"trace.go"
),
buf
.
Bytes
())
err
=
writeFile
(
filepath
.
Join
(
pkgdir
,
"trace.go"
),
buf
.
Bytes
())
if
err
!=
nil
{
if
err
!=
nil
{
...
...
go/xcommon/xnet/pipenet/trace.go
View file @
7d170b2c
...
@@ -6,6 +6,8 @@ package pipenet
...
@@ -6,6 +6,8 @@ package pipenet
import
(
import
(
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
"unsafe"
"unsafe"
"net"
)
)
// traceevent: traceAccept(conn net.Conn) XXX better raw .Text (e.g. comments)
// traceevent: traceAccept(conn net.Conn) XXX better raw .Text (e.g. comments)
...
...
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