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
e592a53a
Commit
e592a53a
authored
Jul 04, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
49274b42
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
7 deletions
+30
-7
go/xcommon/tracing/cmd/gotrace/gotrace.go
go/xcommon/tracing/cmd/gotrace/gotrace.go
+4
-1
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
+8
-6
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/pkg1c.go
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/pkg1c.go
+18
-0
No files found.
go/xcommon/tracing/cmd/gotrace/gotrace.go
View file @
e592a53a
...
...
@@ -188,6 +188,7 @@ func (p *Package) parseTraceEvent(srcfile *ast.File, pos token.Position, text st
// packageTrace returns tracing information about a package
func
packageTrace
(
prog
*
loader
.
Program
,
pkgi
*
loader
.
PackageInfo
)
(
*
Package
,
error
)
{
fmt
.
Println
(
"package trace:"
,
pkgi
.
Pkg
.
Path
())
// prepare Package with typechecker ready to typecheck trace files
// (to get trace func argument types)
tconf
:=
&
types
.
Config
{
...
...
@@ -226,10 +227,11 @@ func packageTrace(prog *loader.Program, pkgi *loader.PackageInfo) (*Package, err
// go through files of the original package and process //trace: directives
for
_
,
file
:=
range
pkgi
.
Files
{
// ast.File
fmt
.
Println
(
"
\t
file:"
,
prog
.
Fset
.
Position
(
file
.
Pos
()))
for
_
,
commgroup
:=
range
file
.
Comments
{
// ast.CommentGroup
for
_
,
comment
:=
range
commgroup
.
List
{
// ast.Comment
pos
:=
prog
.
Fset
.
Position
(
comment
.
Slash
)
//
fmt.Printf("%v %q\n", pos, comment.Text)
fmt
.
Printf
(
"%v %q
\n
"
,
pos
,
comment
.
Text
)
// only directives starting from beginning of line
if
pos
.
Column
!=
1
{
...
...
@@ -248,6 +250,7 @@ func packageTrace(prog *loader.Program, pkgi *loader.PackageInfo) (*Package, err
directive
,
arg
:=
textv
[
0
],
textv
[
1
]
switch
directive
{
case
"//trace:event"
:
fmt
.
Println
(
"*"
,
textv
)
event
,
err
:=
p
.
parseTraceEvent
(
file
,
pos
,
arg
)
if
err
!=
nil
{
return
nil
,
err
...
...
go/xcommon/tracing/cmd/gotrace/gotrace_test.go
View file @
e592a53a
...
...
@@ -128,15 +128,17 @@ func TestGoTraceGen(t *testing.T) {
// test build context with GOPATH set to work tree
var
tBuildCtx
=
&
build
.
Context
{
GOARCH
:
"amd64"
,
GOOS
:
"linux"
,
GOROOT
:
runtime
.
GOROOT
(),
GOPATH
:
work
,
Compiler
:
runtime
.
Compiler
,
GOARCH
:
"amd64"
,
GOOS
:
"linux"
,
GOROOT
:
runtime
.
GOROOT
(),
GOPATH
:
work
,
CgoEnabled
:
true
,
Compiler
:
runtime
.
Compiler
,
}
// XXX autodetect (go list ?)
testv
:=
[]
string
{
"a/pkg1"
,
"b/pkg2"
,
"c/pkg3"
,
"d/pkg4"
}
//testv := []string{"a/pkg1", "b/pkg2", "c/pkg3", "d/pkg4"}
testv
:=
[]
string
{
"a/pkg1"
}
for
_
,
tpkg
:=
range
testv
{
err
=
tracegen
(
tpkg
,
tBuildCtx
,
""
/* = local imorts disabled */
)
...
...
go/xcommon/tracing/cmd/gotrace/testdata/src/a/pkg1/pkg1c.go
0 → 100644
View file @
e592a53a
package
pkg1
/*
#include <stdio.h>
void hello() {
printf("Hello World (from C)\n");
}
*/
import
"C"
// trace event defined in a cgo file
//trace:event traceHello()
func
Hello
()
{
traceHello
()
C
.
hello
()
}
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