summaryrefslogtreecommitdiff
path: root/Userland/profile.cpp
AgeCommit message (Collapse)Author
2020-02-22profile: Allow launching a command with profiling enabledAndreas Kling
You can now profile a program from start to finish by doing: $ profile -c "cat /etc/passwd" The old "enable or disable profiling for a PID" mode is accessible via: $ profile -p <PID> -e # Enable profiling for PID $ profile -p <PID> -d # Disable profiling for PID The generated profile is available via /proc/profile like before. This is far from perfect, but it at least makes profiling a lot nicer to use since you don't have to hurry and attach to something when you want to profile the whole thing anyway.
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-12-11Kernel: Implement a simple process time profilerAndreas Kling
The kernel now supports basic profiling of all the threads in a process by calling profiling_enable(pid_t). You finish the profiling by calling profiling_disable(pid_t). This all works by recording thread stacks when the timer interrupt fires and the current thread is in a process being profiled. Note that symbolication is deferred until profiling_disable() to avoid adding more noise than necessary to the profile. A simple "/bin/profile" command is included here that can be used to start/stop profiling like so: $ profile 10 on ... wait ... $ profile 10 off After a profile has been recorded, it can be fetched in /proc/profile There are various limits (or "bugs") on this mechanism at the moment: - Only one process can be profiled at a time. - We allocate 8MB for the samples, if you use more space, things will not work, and probably break a bit. - Things will probably fall apart if the profiled process dies during profiling, or while extracing /proc/profile