mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
cli: Allow to get samples from single pid
perf lets you decide to only get events that concerns a single process and thus make sysprof profile this process instead of the whole system (it can happen that you don't really care about other processes that are just then noise). As a side effect, this allows sysprof to not run as root if you have the rights on the process you want to profile.
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
e14788c87e
commit
791fff95c3
@ -111,19 +111,38 @@ die (const char *err_msg)
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
static int opt_pid = -1;
|
||||
|
||||
static GOptionEntry entries[] =
|
||||
{
|
||||
{ "pid", 'p', 0, G_OPTION_ARG_INT, &opt_pid,
|
||||
"Make sysprof specific to a task", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
Application *app = g_new0 (Application, 1);
|
||||
Application *app;
|
||||
GOptionContext *context;
|
||||
GError *err;
|
||||
|
||||
err = NULL;
|
||||
|
||||
context = g_option_context_new ("- Sysprof");
|
||||
g_option_context_add_main_entries (context, entries, NULL);
|
||||
if (!g_option_context_parse (context, &argc, &argv, &err))
|
||||
{
|
||||
g_print ("Failed to parse options: %s\n", err->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
app = g_new0 (Application, 1);
|
||||
app->collector = collector_new (FALSE, NULL, NULL);
|
||||
app->outfile = g_strdup (argv[1]);
|
||||
app->main_loop = g_main_loop_new (NULL, 0);
|
||||
|
||||
err = NULL;
|
||||
|
||||
if (!collector_start (app->collector, &err))
|
||||
if (!collector_start (app->collector, (pid_t) opt_pid, &err))
|
||||
die (err->message);
|
||||
|
||||
if (argc < 2)
|
||||
|
||||
Reference in New Issue
Block a user