Commit 1ecdd605 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b8258107
......@@ -60,9 +60,11 @@ type traceEvent struct {
//
// func traceConnRecv(c *Conn, msg Msg)
//
// the func declaration is not added anywhere in the sources - just its AST is
// constructed. XXX + types
// the func declaration is not added anywhere in the sources - just its
// AST + package is virtually constructed.
*ast.FuncDecl
typinfo *types.Info
typpkg *types.Package // XXX needed ?
}
// traceImport represents 1 trace:import directive
......@@ -154,11 +156,14 @@ func parseTraceEvent(prog *loader.Program, pkgi *loader.PackageInfo, srcfile *as
return nil, err // should already have pos' as prefix
}
if len(tf.Decls) != 1 {
// must be:
// GenDecl{IMPORT}
// FuncDecl
if len(tf.Decls) != 2 {
return nil, posErr("trace event must be func-like")
}
declf, ok := tf.Decls[0].(*ast.FuncDecl)
declf, ok := tf.Decls[1].(*ast.FuncDecl)
if !ok {
return nil, posErr("trace event must be func-like, not %v", tf.Decls[0])
}
......@@ -185,8 +190,8 @@ func parseTraceEvent(prog *loader.Program, pkgi *loader.PackageInfo, srcfile *as
_ = tpkg
// XXX +pos
return &traceEvent{pkgi, declf}, nil // XXX + tinfo, tpkg, ...
// XXX +pos? -> pos is already there in tfunc
return &traceEvent{Pkgi: pkgi, FuncDecl: declf, typinfo: tinfo, typpkg: tpkg}, nil
}
// packageTrace returns tracing information about a package
......@@ -255,6 +260,17 @@ func (te *traceEvent) TypedArgv() string {
//format.Node(&buf, fset, te.FuncDecl.Type.Params)
argv := []string{}
// qualifier
qf := func(pkg *types.Package) string {
// original package - unqualified
if pkg == te.Pkgi.Pkg {
return ""
}
// default qualification
return pkg.Name()
}
for _, field := range te.FuncDecl.Type.Params.List {
namev := []string{}
for _, name := range field.Names {
......@@ -263,9 +279,9 @@ func (te *traceEvent) TypedArgv() string {
arg := strings.Join(namev, ", ")
//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
typ := te.typinfo.Types[field.Type].Type
fmt.Printf("AAA %v\n", typ)
arg += " " + types.TypeString(typ, qf)
argv = append(argv, arg)
}
......
// Code generated by lab.nexedi.com/kirr/go123/tracing/cmd/gotrace; DO NOT EDIT.
package pipenet
// code generated for tracepoints
import (
"lab.nexedi.com/kirr/neo/go/xcommon/tracing"
"unsafe"
)
// traceevent: traceAccept(conn net.Conn) XXX better raw .Text (e.g. comments)
type _t_traceAccept struct {
tracing.Probe
probefunc func(conn net.Conn)
}
var _traceAccept *_t_traceAccept
func traceAccept(conn net.Conn) {
if _traceAccept != nil {
_traceAccept_run(conn)
}
}
func _traceAccept_run(conn net.Conn) {
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 {
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)
type _t_traceDial struct {
tracing.Probe
probefunc func(addr string)
}
var _traceDial *_t_traceDial
func traceDial(addr string) {
if _traceDial != nil {
_traceDial_run(addr)
}
}
func _traceDial_run(addr string) {
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 {
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)
type _t_traceListen struct {
tracing.Probe
probefunc func(laddr string)
}
var _traceListen *_t_traceListen
func traceListen(laddr string) {
if _traceListen != nil {
_traceListen_run(laddr)
}
}
func _traceListen_run(laddr string) {
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 {
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)
type _t_traceNew struct {
tracing.Probe
probefunc func(name string)
}
var _traceNew *_t_traceNew
func traceNew(name string) {
if _traceNew != nil {
_traceNew_run(name)
}
}
func _traceNew_run(name string) {
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 {
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)
type _t_traceNewHost struct {
tracing.Probe
probefunc func(host *Host)
}
var _traceNewHost *_t_traceNewHost
func traceNewHost(host *Host) {
if _traceNewHost != nil {
_traceNewHost_run(host)
}
}
func _traceNewHost_run(host *Host) {
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 {
p := _t_traceNewHost{probefunc: probe}
tracing.AttachProbe(pg, (**tracing.Probe)(unsafe.Pointer(&_traceNewHost)), &p.Probe)
return &p.Probe
}
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