summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-05-14 08:10:43 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-19 22:51:42 +0200
commit572bbf28ccd1cd5f8e4f17a38d0fbd989b1d56bf (patch)
tree1cc736a0f0fcfe96d4226b6cedfce9d80a62ca54 /Userland/Libraries/LibC
parent8b2ace0326bceb28bdf80c0a09e8297acf39df97 (diff)
downloadserenity-572bbf28ccd1cd5f8e4f17a38d0fbd989b1d56bf.zip
Kernel+LibC: Add support for filtering profiling events
This adds the -t command-line argument for the profile tool. Using this argument you can filter which event types you want in your profile.
Diffstat (limited to 'Userland/Libraries/LibC')
-rw-r--r--Userland/Libraries/LibC/serenity.cpp4
-rw-r--r--Userland/Libraries/LibC/serenity.h26
2 files changed, 16 insertions, 14 deletions
diff --git a/Userland/Libraries/LibC/serenity.cpp b/Userland/Libraries/LibC/serenity.cpp
index 1b59675dd7..0f112ca0ae 100644
--- a/Userland/Libraries/LibC/serenity.cpp
+++ b/Userland/Libraries/LibC/serenity.cpp
@@ -30,9 +30,9 @@ int module_unload(const char* name, size_t name_length)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
-int profiling_enable(pid_t pid)
+int profiling_enable(pid_t pid, uint64_t event_mask)
{
- int rc = syscall(SC_profiling_enable, pid);
+ int rc = syscall(SC_profiling_enable, pid, event_mask);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
diff --git a/Userland/Libraries/LibC/serenity.h b/Userland/Libraries/LibC/serenity.h
index 72282cf449..acc94f6b40 100644
--- a/Userland/Libraries/LibC/serenity.h
+++ b/Userland/Libraries/LibC/serenity.h
@@ -17,7 +17,7 @@ int disown(pid_t);
int module_load(const char* path, size_t path_length);
int module_unload(const char* name, size_t name_length);
-int profiling_enable(pid_t);
+int profiling_enable(pid_t, uint64_t);
int profiling_disable(pid_t);
int profiling_free_buffer(pid_t);
@@ -76,19 +76,21 @@ int futex(uint32_t* userspace_address, int futex_op, uint32_t value, const struc
int purge(int mode);
enum {
- PERF_EVENT_SAMPLE,
- PERF_EVENT_MALLOC,
- PERF_EVENT_FREE,
- PERF_EVENT_MMAP,
- PERF_EVENT_MUNMAP,
- PERF_EVENT_PROCESS_CREATE,
- PERF_EVENT_PROCESS_EXEC,
- PERF_EVENT_PROCESS_EXIT,
- PERF_EVENT_THREAD_CREATE,
- PERF_EVENT_THREAD_EXIT,
- PERF_EVENT_CONTEXT_SWITCH,
+ PERF_EVENT_SAMPLE = 1,
+ PERF_EVENT_MALLOC = 2,
+ PERF_EVENT_FREE = 4,
+ PERF_EVENT_MMAP = 8,
+ PERF_EVENT_MUNMAP = 16,
+ PERF_EVENT_PROCESS_CREATE = 32,
+ PERF_EVENT_PROCESS_EXEC = 64,
+ PERF_EVENT_PROCESS_EXIT = 128,
+ PERF_EVENT_THREAD_CREATE = 256,
+ PERF_EVENT_THREAD_EXIT = 512,
+ PERF_EVENT_CONTEXT_SWITCH = 1024,
};
+#define PERF_EVENT_MASK_ALL (~0ull)
+
int perf_event(int type, uintptr_t arg1, uintptr_t arg2);
int get_stack_bounds(uintptr_t* user_stack_base, size_t* user_stack_size);