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
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
Levin Zimmermann
neoppod
Commits
19c9d587
Commit
19c9d587
authored
Jul 05, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Consisteny checks via link failures work
parent
84c4f5f2
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
13 deletions
+49
-13
go/xcommon/tracing/cmd/gotrace/gotrace.go
go/xcommon/tracing/cmd/gotrace/gotrace.go
+27
-12
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/pkg1c.go
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/pkg1c.go
+1
-1
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/ztrace.go.ok
...mmon/tracing/cmd/gotrace/testdata/src/a/pkg1/ztrace.go.ok
+3
-0
go/xcommon/tracing/cmd/gotrace/testdata/src/b/pkg2/ztrace.go.ok
...mmon/tracing/cmd/gotrace/testdata/src/b/pkg2/ztrace.go.ok
+8
-0
go/xcommon/tracing/cmd/gotrace/testdata/src/c/pkg3/ztrace_test.go.ok
...tracing/cmd/gotrace/testdata/src/c/pkg3/ztrace_test.go.ok
+5
-0
go/xcommon/tracing/cmd/gotrace/testdata/src/c/pkg3/ztrace_x_test.go.ok
...acing/cmd/gotrace/testdata/src/c/pkg3/ztrace_x_test.go.ok
+5
-0
No files found.
go/xcommon/tracing/cmd/gotrace/gotrace.go
View file @
19c9d587
...
@@ -512,6 +512,13 @@ var traceEventImportTmpl = template.Must(template.New("traceimport").Parse(`
...
@@ -512,6 +512,13 @@ var traceEventImportTmpl = template.Must(template.New("traceimport").Parse(`
func {{.ImportSpec.PkgName}}_{{.Name}}_Attach(*tracing.ProbeGroup, func({{.ArgvTypedRelativeTo .ImporterPkg .ImportedAs}})) *tracing.Probe
func {{.ImportSpec.PkgName}}_{{.Name}}_Attach(*tracing.ProbeGroup, func({{.ArgvTypedRelativeTo .ImporterPkg .ImportedAs}})) *tracing.Probe
`
))
`
))
// traceEventImportCheckTmpl is code template generated to check consistency with one imported package
var
traceEventImportCheckTmpl
=
template
.
Must
(
template
.
New
(
"traceimportcheck"
)
.
Parse
(
`
//go:linkname {{.ImportSpec.PkgName}}_trace_exporthash {{.ImportSpec.PkgPath}}._trace_exporthash_{{.ExportHash}}
func {{.ImportSpec.PkgName}}_trace_exporthash()
func init() { {{.ImportSpec.PkgName}}_trace_exporthash() } // rerun "gotrace gen" if you see link failure here
`
))
// magic begins all files generated by gotrace
// magic begins all files generated by gotrace
const
magic
=
"// Code generated by lab.nexedi.com/kirr/go123/tracing/cmd/gotrace; DO NOT EDIT.
\n
"
const
magic
=
"// Code generated by lab.nexedi.com/kirr/go123/tracing/cmd/gotrace; DO NOT EDIT.
\n
"
...
@@ -744,15 +751,6 @@ func tracegen1(P *Program, tpkg *Package, pkgdir string, kind string) error {
...
@@ -744,15 +751,6 @@ func tracegen1(P *Program, tpkg *Package, pkgdir string, kind string) error {
text
:=
&
Buffer
{}
text
:=
&
Buffer
{}
// export hash symbol so that if importing package is out of
// sync - it will have it different and linking will fail.
if
len
(
tpkg
.
Eventv
)
>
0
{
//text.emit("\n---- 8< ---- (export signature)")
//fmt.Fprintf(text, "%s", traceExport(tpkg, kind))
//text.emit("---- 8< ----")
text
.
emit
(
"
\n
var _t_exporthash_%s bool"
,
traceExportHash
(
tpkg
,
kind
))
}
// code for trace:event definitions
// code for trace:event definitions
for
_
,
event
:=
range
tpkg
.
Eventv
{
for
_
,
event
:=
range
tpkg
.
Eventv
{
needPkg
.
Add
(
event
.
NeedPkgv
()
...
)
needPkg
.
Add
(
event
.
NeedPkgv
()
...
)
...
@@ -762,6 +760,16 @@ func tracegen1(P *Program, tpkg *Package, pkgdir string, kind string) error {
...
@@ -762,6 +760,16 @@ func tracegen1(P *Program, tpkg *Package, pkgdir string, kind string) error {
}
}
}
}
// export hash symbol so that if importing package is out of
// sync - it will have it different and linking will fail.
if
len
(
tpkg
.
Eventv
)
>
0
{
text
.
emit
(
"
\n
// trace export signature"
)
//text.emit("---- 8< ----")
//fmt.Fprintf(text, "%s", traceExport(tpkg, kind))
//text.emit("---- 8< ----")
text
.
emit
(
"func _trace_exporthash_%s() {}"
,
traceExportHash
(
tpkg
,
kind
))
}
// code for trace:import imports
// code for trace:import imports
for
_
,
timport
:=
range
tpkg
.
Importv
{
for
_
,
timport
:=
range
tpkg
.
Importv
{
text
.
emit
(
"
\n
// traceimport: %s"
,
timport
.
ImportSpec
())
text
.
emit
(
"
\n
// traceimport: %s"
,
timport
.
ImportSpec
())
...
@@ -787,9 +795,16 @@ func tracegen1(P *Program, tpkg *Package, pkgdir string, kind string) error {
...
@@ -787,9 +795,16 @@ func tracegen1(P *Program, tpkg *Package, pkgdir string, kind string) error {
return
fmt
.
Errorf
(
"%v: package %v does not export anything trace-related"
,
timport
.
Pos
,
timport
.
PkgPath
)
return
fmt
.
Errorf
(
"%v: package %v does not export anything trace-related"
,
timport
.
Pos
,
timport
.
PkgPath
)
}
}
// verify export hash
// verify export hash so link fails if it gets out of sync with imported package
text
.
emit
(
"
\n
zzz_t_exporthash_%s"
,
traceExportHash
(
impPkg
,
""
/*regular pkg*/
))
err
=
traceEventImportCheckTmpl
.
Execute
(
text
,
struct
{
ImportSpec
*
traceImport
ExportHash
string
}{
timport
,
traceExportHash
(
impPkg
,
""
/*regular package*/
)})
text
.
emit
(
""
)
// import individual events
for
_
,
event
:=
range
impPkg
.
Eventv
{
for
_
,
event
:=
range
impPkg
.
Eventv
{
needPkg
.
Add
(
event
.
NeedPkgv
()
...
)
needPkg
.
Add
(
event
.
NeedPkgv
()
...
)
importedEvent
:=
traceImported
{
importedEvent
:=
traceImported
{
...
...
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/pkg1c.go
View file @
19c9d587
...
@@ -16,6 +16,6 @@ import "C"
...
@@ -16,6 +16,6 @@ import "C"
//trace:event traceHello()
//trace:event traceHello()
func
Hello
()
{
func
Hello
()
{
traceHello
()
//
traceHello()
C
.
hello
()
C
.
hello
()
}
}
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/ztrace.go.ok
View file @
19c9d587
...
@@ -117,3 +117,6 @@ func traceURLParsed_Attach(pg *tracing.ProbeGroup, probe func(u *url.URL)) *trac
...
@@ -117,3 +117,6 @@ func traceURLParsed_Attach(pg *tracing.ProbeGroup, probe func(u *url.URL)) *trac
tracing
.
AttachProbe
(
pg
,
(**
tracing
.
Probe
)(
unsafe
.
Pointer
(&
_traceURLParsed
)),
&
p
.
Probe
)
tracing
.
AttachProbe
(
pg
,
(**
tracing
.
Probe
)(
unsafe
.
Pointer
(&
_traceURLParsed
)),
&
p
.
Probe
)
return
&
p
.
Probe
return
&
p
.
Probe
}
}
//
trace
export
signature
func
_trace_exporthash_965fa599dc3a61119faba1eacf8493973c5d87ad
()
{}
go/xcommon/tracing/cmd/gotrace/testdata/src/b/pkg2/ztrace.go.ok
View file @
19c9d587
...
@@ -38,8 +38,16 @@ func traceDoSomething_Attach(pg *tracing.ProbeGroup, probe func(i, j int, q stri
...
@@ -38,8 +38,16 @@ func traceDoSomething_Attach(pg *tracing.ProbeGroup, probe func(i, j int, q stri
return
&
p
.
Probe
return
&
p
.
Probe
}
}
//
trace
export
signature
func
_trace_exporthash_80ddfc2f6c72bdf357dedbb2f0bbec85e93106fc
()
{}
//
traceimport
:
"a/pkg1"
//
traceimport
:
"a/pkg1"
//
go
:
linkname
pkg1_trace_exporthash
a
/
pkg1
.
_trace_exporthash_965fa599dc3a61119faba1eacf8493973c5d87ad
func
pkg1_trace_exporthash
()
func
init
()
{
pkg1_trace_exporthash
()
}
//
rerun
"gotrace gen"
if
you
see
link
failure
here
//
go
:
linkname
pkg1_traceDoSomething_Attach
a
/
pkg1
.
traceDoSomething_Attach
//
go
:
linkname
pkg1_traceDoSomething_Attach
a
/
pkg1
.
traceDoSomething_Attach
func
pkg1_traceDoSomething_Attach
(*
tracing
.
ProbeGroup
,
func
(
topic
string
))
*
tracing
.
Probe
func
pkg1_traceDoSomething_Attach
(*
tracing
.
ProbeGroup
,
func
(
topic
string
))
*
tracing
.
Probe
...
...
go/xcommon/tracing/cmd/gotrace/testdata/src/c/pkg3/ztrace_test.go.ok
View file @
19c9d587
...
@@ -13,6 +13,11 @@ import (
...
@@ -13,6 +13,11 @@ import (
//
traceimport
:
aaa1
"a/pkg1"
//
traceimport
:
aaa1
"a/pkg1"
//
go
:
linkname
aaa1_trace_exporthash
a
/
pkg1
.
_trace_exporthash_965fa599dc3a61119faba1eacf8493973c5d87ad
func
aaa1_trace_exporthash
()
func
init
()
{
aaa1_trace_exporthash
()
}
//
rerun
"gotrace gen"
if
you
see
link
failure
here
//
go
:
linkname
aaa1_traceDoSomething_Attach
a
/
pkg1
.
traceDoSomething_Attach
//
go
:
linkname
aaa1_traceDoSomething_Attach
a
/
pkg1
.
traceDoSomething_Attach
func
aaa1_traceDoSomething_Attach
(*
tracing
.
ProbeGroup
,
func
(
topic
string
))
*
tracing
.
Probe
func
aaa1_traceDoSomething_Attach
(*
tracing
.
ProbeGroup
,
func
(
topic
string
))
*
tracing
.
Probe
...
...
go/xcommon/tracing/cmd/gotrace/testdata/src/c/pkg3/ztrace_x_test.go.ok
View file @
19c9d587
...
@@ -10,5 +10,10 @@ import (
...
@@ -10,5 +10,10 @@ import (
//
traceimport
:
"b/pkg2"
//
traceimport
:
"b/pkg2"
//
go
:
linkname
pkg2_trace_exporthash
b
/
pkg2
.
_trace_exporthash_80ddfc2f6c72bdf357dedbb2f0bbec85e93106fc
func
pkg2_trace_exporthash
()
func
init
()
{
pkg2_trace_exporthash
()
}
//
rerun
"gotrace gen"
if
you
see
link
failure
here
//
go
:
linkname
pkg2_traceDoSomething_Attach
b
/
pkg2
.
traceDoSomething_Attach
//
go
:
linkname
pkg2_traceDoSomething_Attach
b
/
pkg2
.
traceDoSomething_Attach
func
pkg2_traceDoSomething_Attach
(*
tracing
.
ProbeGroup
,
func
(
i
,
j
int
,
q
string
))
*
tracing
.
Probe
func
pkg2_traceDoSomething_Attach
(*
tracing
.
ProbeGroup
,
func
(
i
,
j
int
,
q
string
))
*
tracing
.
Probe
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