summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-03-23 14:06:34 +0200
committerPaul Buetow <paul@buetow.org>2025-03-23 14:06:34 +0200
commitacb50fbc6f5ea2b97613593c7aea21304f3fb459 (patch)
treec3de35dbf87a8a4733f43873a25378d9c1766869 /internal
parent5417e99f8e54121cddbff9296131e7f0fb1001a9 (diff)
add flags from fdinfo info
add other warning about vanished pid
Diffstat (limited to 'internal')
-rw-r--r--internal/eventloop.go4
-rw-r--r--internal/file/file.go31
-rw-r--r--internal/flamegraph/collapsed.go1
3 files changed, 29 insertions, 7 deletions
diff --git a/internal/eventloop.go b/internal/eventloop.go
index 60ea01a..ae3f887 100644
--- a/internal/eventloop.go
+++ b/internal/eventloop.go
@@ -171,7 +171,9 @@ func (e *eventLoop) syscallEnter(enterEv event.Event) {
// Only, when we have a comm name
if _, ok := e.comms[tid]; ok {
e.enterEvs[tid] = event.NewPair(enterEv)
- // TODO } else { .... what if not? }
+ } else {
+ // Probably not an issue.
+ fmt.Println("WARN: No comm name for", enterEv, "process probably already vanished?")
}
}
}
diff --git a/internal/file/file.go b/internal/file/file.go
index da498ce..7d9d7e8 100644
--- a/internal/file/file.go
+++ b/internal/file/file.go
@@ -16,22 +16,38 @@ type File interface {
}
type FdFile struct {
- fd int32
- name string
- Flags int32
+ fd int32
+ name string
+ Flags int32
+ flagsFromFdInfo bool
}
func NewFd(fd int32, name []byte, flags int32) FdFile {
- return FdFile{fd, stringValue(name), flags}
+ return FdFile{
+ fd: fd,
+ name: stringValue(name),
+ Flags: flags,
+ }
}
func NewFdWithPid(fd int32, pid uint32) FdFile {
linkName, err := os.Readlink(fmt.Sprintf("/proc/%d/fd/%d", pid, fd))
if err != nil {
- return FdFile{fd, "?", -1}
+ return FdFile{
+ fd: fd,
+ name: "?",
+ Flags: -1,
+ flagsFromFdInfo: true,
+ }
}
+
flags, _ := readFlagsFromFdInfo(fd, pid)
- return FdFile{fd, linkName, flags}
+ return FdFile{
+ fd: fd,
+ name: linkName,
+ Flags: flags,
+ flagsFromFdInfo: true,
+ }
}
func readFlagsFromFdInfo(fd int32, pid uint32) (int32, error) {
@@ -71,6 +87,9 @@ func (f FdFile) String() string {
sb.WriteString(",")
sb.WriteString(f.FlagsString())
sb.WriteString(")")
+ if f.flagsFromFdInfo {
+ sb.WriteString(" flags from fd info")
+ }
}
return sb.String()
diff --git a/internal/flamegraph/collapsed.go b/internal/flamegraph/collapsed.go
index 2a4c7f0..3d2724e 100644
--- a/internal/flamegraph/collapsed.go
+++ b/internal/flamegraph/collapsed.go
@@ -23,6 +23,7 @@ func (c *counter) merge(other counter) {
// traceid, path is by default set in this order
// store an intermediate format which then can be converted to the others...
// e.g. path ¶ traceid ¶ comm ¶ pid ¶ tid ¶ flags ¶ counter
+// counter can also have bytes (for reads and writes)
type collapsed map[string]map[types.TraceId]counter
// TODO: Unit test this