Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladimir Barsukov
zGo
Commits
14e3a3b8
Commit
14e3a3b8
authored
Nov 18, 2023
by
Vladimir Barsukov
Browse files
add trace
parent
8fc95b40
Changes
1
Hide whitespace changes
Inline
Side-by-side
zdebug/zdebug.go
View file @
14e3a3b8
...
@@ -3,7 +3,9 @@ package zdebug
...
@@ -3,7 +3,9 @@ package zdebug
import
(
import
(
"fmt"
"fmt"
"git.barsukov.pro/barsukov/zgo/zjson"
"git.barsukov.pro/barsukov/zgo/zjson"
"git.barsukov.pro/barsukov/zgo/zutils"
"runtime"
"runtime"
"strings"
"time"
"time"
)
)
...
@@ -39,3 +41,24 @@ func NewMonitor(secs int) {
...
@@ -39,3 +41,24 @@ func NewMonitor(secs int) {
}
}
}()
}()
}
}
func
Trace
()
[]
string
{
var
out
[]
string
pc
:=
make
([]
uintptr
,
10
)
runtime
.
Callers
(
2
,
pc
)
for
i
:=
range
pc
{
if
f
:=
runtime
.
FuncForPC
(
pc
[
i
]);
f
!=
nil
{
file
,
line
:=
f
.
FileLine
(
pc
[
i
])
if
strings
.
Contains
(
file
,
"go/pkg"
)
{
continue
}
out
=
append
(
out
,
fmt
.
Sprintf
(
"%s:%d"
,
f
.
Name
(),
line
))
}
}
return
zutils
.
ArrayUnique
(
out
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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