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
36adb807
Commit
36adb807
authored
Jun 30, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a8243345
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
go/xcommon/tracing/cmd/gotrace/gotrace.go
go/xcommon/tracing/cmd/gotrace/gotrace.go
+11
-10
No files found.
go/xcommon/tracing/cmd/gotrace/gotrace.go
View file @
36adb807
...
@@ -52,7 +52,8 @@ import (
...
@@ -52,7 +52,8 @@ import (
// traceEvent represents 1 trace:event declaration
// traceEvent represents 1 trace:event declaration
type
traceEvent
struct
{
type
traceEvent
struct
{
// TODO += Pos token.Position
// TODO += Pos token.Position
Pkgi
*
loader
.
PackageInfo
// Pkgi *loader.PackageInfo
Pkg
*
types
.
Package
// package where trace event is declared
// declaration of function to signal the event
// declaration of function to signal the event
// the declaration is constructed on the fly via converting e.g.
// the declaration is constructed on the fly via converting e.g.
...
@@ -196,7 +197,7 @@ func parseTraceEvent(prog *loader.Program, pkgi *loader.PackageInfo, srcfile *as
...
@@ -196,7 +197,7 @@ func parseTraceEvent(prog *loader.Program, pkgi *loader.PackageInfo, srcfile *as
_
=
tpkg
_
=
tpkg
// XXX +pos? -> pos is already there in tfunc
// XXX +pos? -> pos is already there in tfunc
return
&
traceEvent
{
Pkg
i
:
pkgi
,
FuncDecl
:
declf
,
typinfo
:
tinfo
,
typpkg
:
tpkg
},
nil
return
&
traceEvent
{
Pkg
:
pkgi
.
Pkg
,
FuncDecl
:
declf
,
typinfo
:
tinfo
,
typpkg
:
tpkg
},
nil
}
}
// packageTrace returns tracing information about a package
// packageTrace returns tracing information about a package
...
@@ -275,7 +276,7 @@ func (te *traceEvent) Argv() string {
...
@@ -275,7 +276,7 @@ func (te *traceEvent) Argv() string {
// ArgvTyped returns argument list with types qualified relative to original package
// ArgvTyped returns argument list with types qualified relative to original package
func
(
te
*
traceEvent
)
ArgvTyped
()
string
{
func
(
te
*
traceEvent
)
ArgvTyped
()
string
{
return
te
.
ArgvTypedRelativeTo
(
te
.
Pkg
i
.
Pkg
)
return
te
.
ArgvTypedRelativeTo
(
te
.
Pkg
)
}
}
func
(
te
*
traceEvent
)
ArgvTypedRelativeTo
(
pkg
*
types
.
Package
)
string
{
func
(
te
*
traceEvent
)
ArgvTypedRelativeTo
(
pkg
*
types
.
Package
)
string
{
...
@@ -368,8 +369,8 @@ func {{.Name}}_Attach(pg *tracing.ProbeGroup, probe func({{.ArgvTyped}})) *traci
...
@@ -368,8 +369,8 @@ func {{.Name}}_Attach(pg *tracing.ProbeGroup, probe func({{.ArgvTyped}})) *traci
// traceEventImportTmpl is code template generated for importing one trace event
// traceEventImportTmpl is code template generated for importing one trace event
var
traceEventImportTmpl
=
template
.
Must
(
template
.
New
(
"traceimport"
)
.
Parse
(
`
var
traceEventImportTmpl
=
template
.
Must
(
template
.
New
(
"traceimport"
)
.
Parse
(
`
//go:linkname {{.Pkg
i.Pkg.Name}}_{{.Name}}_Attach {{.Pkgi
.Pkg.Path}}.{{.Name}}_Attach
//go:linkname {{.Pkg
.Name}}_{{.Name}}_Attach {{
.Pkg.Path}}.{{.Name}}_Attach
func {{.Pkg
i.Pkg
.Name}}_{{.Name}}_Attach(*tracing.ProbeGroup, func({{.ArgvTypedRelativeTo .ImporterPkg}})) *tracing.Probe
func {{.Pkg.Name}}_{{.Name}}_Attach(*tracing.ProbeGroup, func({{.ArgvTypedRelativeTo .ImporterPkg}})) *tracing.Probe
`
))
`
))
// magic begins all files generated by gotrace
// magic begins all files generated by gotrace
...
@@ -490,12 +491,12 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
...
@@ -490,12 +491,12 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
//return nil
//return nil
// tracing info for this specified package
// tracing info for this specified package
pkg
:=
packageTrace
(
lprog
,
pkgi
)
t
pkg
:=
packageTrace
(
lprog
,
pkgi
)
// prologue
// prologue
prologue
:=
&
Buffer
{}
prologue
:=
&
Buffer
{}
prologue
.
WriteString
(
magic
)
prologue
.
WriteString
(
magic
)
prologue
.
emit
(
"
\n
package %v"
,
pkg
.
Pkgi
.
Pkg
.
Name
())
prologue
.
emit
(
"
\n
package %v"
,
t
pkg
.
Pkgi
.
Pkg
.
Name
())
prologue
.
emit
(
"// code generated for tracepoints"
)
prologue
.
emit
(
"// code generated for tracepoints"
)
prologue
.
emit
(
"
\n
import ("
)
prologue
.
emit
(
"
\n
import ("
)
prologue
.
emit
(
"
\t
%q"
,
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
)
prologue
.
emit
(
"
\t
%q"
,
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
)
...
@@ -505,7 +506,7 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
...
@@ -505,7 +506,7 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
// code for trace:event definitions
// code for trace:event definitions
text
:=
&
Buffer
{}
text
:=
&
Buffer
{}
for
_
,
event
:=
range
pkg
.
Eventv
{
for
_
,
event
:=
range
t
pkg
.
Eventv
{
needPkg
.
Add
(
event
.
NeedPkgv
()
...
)
needPkg
.
Add
(
event
.
NeedPkgv
()
...
)
err
=
traceEventCodeTmpl
.
Execute
(
text
,
event
)
err
=
traceEventCodeTmpl
.
Execute
(
text
,
event
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -516,7 +517,7 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
...
@@ -516,7 +517,7 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
// TODO export hash
// TODO export hash
// code for trace:import imports
// code for trace:import imports
for
_
,
timport
:=
range
pkg
.
Importv
{
for
_
,
timport
:=
range
t
pkg
.
Importv
{
text
.
emit
(
"
\n
// traceimport: %v"
,
timport
.
PkgPath
)
text
.
emit
(
"
\n
// traceimport: %v"
,
timport
.
PkgPath
)
impPkgi
:=
lprog
.
Package
(
timport
.
PkgPath
)
impPkgi
:=
lprog
.
Package
(
timport
.
PkgPath
)
...
@@ -563,7 +564,7 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
...
@@ -563,7 +564,7 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
// write empty ztrace.s so go:linkname works, if there are trace imports
// write empty ztrace.s so go:linkname works, if there are trace imports
ztrace_s
:=
filepath
.
Join
(
pkgdir
,
"ztrace.s"
)
ztrace_s
:=
filepath
.
Join
(
pkgdir
,
"ztrace.s"
)
if
len
(
pkg
.
Importv
)
==
0
{
if
len
(
t
pkg
.
Importv
)
==
0
{
err
=
removeFile
(
ztrace_s
)
err
=
removeFile
(
ztrace_s
)
}
else
{
}
else
{
text
.
Reset
()
text
.
Reset
()
...
...
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