From c840022ef1b691dbb155ac3c0b0372348f71b49d Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Thu, 17 Dec 2009 21:01:28 -0500 Subject: trace-cmd: Add pevent_pid_is_registered() Add the function pevent_pid_is_registered() that returns 1 if the given pid has a cmdline mapped to it, and 0 otherwise. Signed-off-by: Steven Rostedt --- parse-events.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'parse-events.c') diff --git a/parse-events.c b/parse-events.c index 1a2c7ca..424b367 100644 --- a/parse-events.c +++ b/parse-events.c @@ -119,6 +119,36 @@ static char *find_cmdline(struct pevent *pevent, int pid) return "<...>"; } +/** + * pevent_pid_is_registered - return if a pid has a cmdline registered + * @pevent: handle for the pevent + * @pid: The pid to check if it has a cmdline registered with. + * + * Returns 1 if the pid has a cmdline mapped to it + * 0 otherwise. + */ +int pevent_pid_is_registered(struct pevent *pevent, int pid) +{ + const struct cmdline *comm; + struct cmdline key; + + if (!pid) + return 1; + + + if (!pevent->cmdlines) + cmdline_init(pevent); + + key.pid = pid; + + comm = bsearch(&key, pevent->cmdlines, pevent->cmdline_count, + sizeof(*pevent->cmdlines), cmdline_cmp); + + if (comm) + return 1; + return 0; +} + /** * pevent_register_comm - register a pid / comm mapping * @pevent: handle for the pevent -- cgit v1.2.2