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
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
fe1ca6f5
Commit
fe1ca6f5
authored
Jun 30, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
36adb807
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
3 deletions
+50
-3
go/xcommon/tracing/cmd/gotrace/gotrace.go
go/xcommon/tracing/cmd/gotrace/gotrace.go
+50
-3
No files found.
go/xcommon/tracing/cmd/gotrace/gotrace.go
View file @
fe1ca6f5
...
...
@@ -274,13 +274,14 @@ func (te *traceEvent) Argv() string {
return
strings
.
Join
(
argv
,
", "
)
}
// ArgvTyped returns argument list with types qualified relative to original package
// ArgvTyped returns argument list with types
// types are qualified relative to original package
func
(
te
*
traceEvent
)
ArgvTyped
()
string
{
return
te
.
ArgvTypedRelativeTo
(
te
.
Pkg
)
}
// ArgvTypedRelativeTo returns argument list with types qualified relative to specified package
func
(
te
*
traceEvent
)
ArgvTypedRelativeTo
(
pkg
*
types
.
Package
)
string
{
//format.Node(&buf, fset, te.FuncDecl.Type.Params)
argv
:=
[]
string
{}
// default qualifier - relative to original package
...
...
@@ -459,6 +460,52 @@ func (s StrSet) Itemv() []string {
// buildCtx is build context for discovering packages
// cwd is "current" directory for resolving local imports (e.g. packages like "./some/package")
func
tracegen
(
pkgpath
string
,
buildCtx
*
build
.
Context
,
cwd
string
)
error
{
// XXX ignore build tags?
bpkg
,
err
:=
buildCtx
.
Import
(
pkgpath
,
cwd
,
0
)
if
err
!=
nil
{
return
err
}
// canonical package path e.g. "." -> "path/to/package"
pkgpath
=
bpkg
.
ImportPath
// XXX reject on .InvalidGoFiles ?
fset
:=
token
.
NewFileSet
()
// XXX -> Package?
filev
:=
[]
*
ast
.
File
{}
// parse go and cgo sources
for
_
,
fgo
:=
range
append
(
bpkg
.
GoFiles
,
bpkg
.
CgoFiles
...
)
{
fpath
:=
bpkg
.
Dir
+
"/"
+
fgo
// don't load what should be generated by us. reasons:
// - code generated could be wrong with older version of the
// tool - it should not prevent from regenerating.
// - generated code imports packages which might be not there
// yet in gopath (lab.nexedi.com/kirr/go123/tracing)
if
strings
.
HasPrefix
(
fgo
,
"ztrace"
)
{
// if it is there but not created by us - complain
err
=
checkCanWrite
(
fpath
)
if
err
!=
nil
{
return
err
}
continue
}
f
,
err
:=
parser
.
ParseFile
(
fset
,
fpath
,
nil
,
parser
.
ParseComments
)
if
err
!=
nil
{
return
err
}
filev
=
append
(
filev
,
f
)
}
return
nil
// XXX test-only with .TestGoFiles .XTestGoFiles
// XXX typechecking is much slower than parsing + we don't need to
// load anything except the package in question
// TODO -> use just AST parsing for loading?
...
...
@@ -485,7 +532,7 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
}
pkgdir
:=
filepath
.
Dir
(
lprog
.
Fset
.
File
(
pkgi
.
Files
[
0
]
.
Pos
())
.
Name
())
pkgpath
=
pkgi
.
Pkg
.
Path
()
// e.g. "." -> "path/to/package"
pkgpath
=
pkgi
.
Pkg
.
Path
()
//println("pkgpath", pkgpath)
//println("pkgdir", pkgdir)
//return nil
...
...
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