summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/control/pprof.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2019-12-07 01:04:20 +0000
committergVisor bot <gvisor-bot@google.com>2019-12-07 01:04:20 +0000
commit5648c029a4358d4c2803fba978a3d86cae894766 (patch)
treea0a94433bbc41f3115568149160976c5bd459d89 /pkg/sentry/control/pprof.go
parente880bc78798d9abe8554f82dc2106e6fd85ffc5e (diff)
parent371e210b83c244d8828ad2fa1b3d7cef15fbf463 (diff)
Merge release-20191129.0-18-g371e210 (automated)
Diffstat (limited to 'pkg/sentry/control/pprof.go')
-rw-r--r--pkg/sentry/control/pprof.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/pkg/sentry/control/pprof.go b/pkg/sentry/control/pprof.go
index 1f78d54a2..e1f2fea60 100644
--- a/pkg/sentry/control/pprof.go
+++ b/pkg/sentry/control/pprof.go
@@ -22,6 +22,7 @@ import (
"sync"
"gvisor.dev/gvisor/pkg/fd"
+ "gvisor.dev/gvisor/pkg/sentry/kernel"
"gvisor.dev/gvisor/pkg/urpc"
)
@@ -56,6 +57,9 @@ type Profile struct {
// traceFile is the current execution trace output file.
traceFile *fd.FD
+
+ // Kernel is the kernel under profile.
+ Kernel *kernel.Kernel
}
// StartCPUProfile is an RPC stub which starts recording the CPU profile in a
@@ -147,6 +151,9 @@ func (p *Profile) StartTrace(o *ProfileOpts, _ *struct{}) error {
return err
}
+ // Ensure all trace contexts are registered.
+ p.Kernel.RebuildTraceContexts()
+
p.traceFile = output
return nil
}
@@ -158,9 +165,15 @@ func (p *Profile) StopTrace(_, _ *struct{}) error {
defer p.mu.Unlock()
if p.traceFile == nil {
- return errors.New("Execution tracing not start")
+ return errors.New("Execution tracing not started")
}
+ // Similarly to the case above, if tasks have not ended traces, we will
+ // lose information. Thus we need to rebuild the tasks in order to have
+ // complete information. This will not lose information if multiple
+ // traces are overlapping.
+ p.Kernel.RebuildTraceContexts()
+
trace.Stop()
p.traceFile.Close()
p.traceFile = nil