summaryrefslogtreecommitdiff
path: root/Userland/profile.cpp
blob: b8d50820c3948deac98acfa7320284f8e90cbb81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <serenity.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char** argv)
{
    if (argc != 3) {
        printf("usage: profile <pid> <on|off>\n");
        return 0;
    }

    pid_t pid = atoi(argv[1]);
    bool enabled = !strcmp(argv[2], "on");

    if (enabled) {
        if (profiling_enable(pid) < 0) {
            perror("profiling_enable");
            return 1;
        }
        return 0;
    }

    if (profiling_disable(pid) < 0) {
        perror("profiling_disable");
        return 1;
    }
    return 0;
}