Commit 36adb807 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a8243345
......@@ -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{Pkgi: 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.Pkgi.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 {{.Pkgi.Pkg.Name}}_{{.Name}}_Attach {{.Pkgi.Pkg.Path}}.{{.Name}}_Attach
func {{.Pkgi.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)
tpkg := packageTrace(lprog, pkgi)
// prologue
prologue := &Buffer{}
prologue.WriteString(magic)
prologue.emit("\npackage %v", pkg.Pkgi.Pkg.Name())
prologue.emit("\npackage %v", tpkg.Pkgi.Pkg.Name())
prologue.emit("// code generated for tracepoints")
prologue.emit("\nimport (")
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 tpkg.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 tpkg.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(tpkg.Importv) == 0 {
err = removeFile(ztrace_s)
} else {
text.Reset()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment