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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefane Fermigier
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
Hide 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 (
// traceEvent represents 1 trace:event declaration
type
traceEvent
struct
{
// 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
// 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
_
=
tpkg
// 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
...
...
@@ -275,7 +276,7 @@ func (te *traceEvent) Argv() string {
// ArgvTyped returns argument list with types qualified relative to original package
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
{
...
...
@@ -368,8 +369,8 @@ func {{.Name}}_Attach(pg *tracing.ProbeGroup, probe func({{.ArgvTyped}})) *traci
// traceEventImportTmpl is code template generated for importing one trace event
var
traceEventImportTmpl
=
template
.
Must
(
template
.
New
(
"traceimport"
)
.
Parse
(
`
//go:linkname {{.Pkg
i.Pkg.Name}}_{{.Name}}_Attach {{.Pkgi
.Pkg.Path}}.{{.Name}}_Attach
func {{.Pkg
i.Pkg
.Name}}_{{.Name}}_Attach(*tracing.ProbeGroup, func({{.ArgvTypedRelativeTo .ImporterPkg}})) *tracing.Probe
//go:linkname {{.Pkg
.Name}}_{{.Name}}_Attach {{
.Pkg.Path}}.{{.Name}}_Attach
func {{.Pkg.Name}}_{{.Name}}_Attach(*tracing.ProbeGroup, func({{.ArgvTypedRelativeTo .ImporterPkg}})) *tracing.Probe
`
))
// magic begins all files generated by gotrace
...
...
@@ -490,12 +491,12 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
//return nil
// tracing info for this specified package
pkg
:=
packageTrace
(
lprog
,
pkgi
)
t
pkg
:=
packageTrace
(
lprog
,
pkgi
)
// prologue
prologue
:=
&
Buffer
{}
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
(
"
\n
import ("
)
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 {
// code for trace:event definitions
text
:=
&
Buffer
{}
for
_
,
event
:=
range
pkg
.
Eventv
{
for
_
,
event
:=
range
t
pkg
.
Eventv
{
needPkg
.
Add
(
event
.
NeedPkgv
()
...
)
err
=
traceEventCodeTmpl
.
Execute
(
text
,
event
)
if
err
!=
nil
{
...
...
@@ -516,7 +517,7 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
// TODO export hash
// code for trace:import imports
for
_
,
timport
:=
range
pkg
.
Importv
{
for
_
,
timport
:=
range
t
pkg
.
Importv
{
text
.
emit
(
"
\n
// traceimport: %v"
,
timport
.
PkgPath
)
impPkgi
:=
lprog
.
Package
(
timport
.
PkgPath
)
...
...
@@ -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
ztrace_s
:=
filepath
.
Join
(
pkgdir
,
"ztrace.s"
)
if
len
(
pkg
.
Importv
)
==
0
{
if
len
(
t
pkg
.
Importv
)
==
0
{
err
=
removeFile
(
ztrace_s
)
}
else
{
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