aboutsummaryrefslogtreecommitdiffstats
path: root/parse-events.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-12-17 21:01:28 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-17 21:01:28 -0500
commitc840022ef1b691dbb155ac3c0b0372348f71b49d (patch)
tree21efc5cb204e4c248c1c66ab82935f8c686176f2 /parse-events.c
parent9333e51818b302c5510a1ce2c3c0c03874fcc1da (diff)
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 <rostedt@goodmis.org>
Diffstat (limited to 'parse-events.c')
-rw-r--r--parse-events.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/parse-events.c b/parse-events.c
index 1a2c7ca..424b367 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -120,6 +120,36 @@ static char *find_cmdline(struct pevent *pevent, int pid)
120} 120}
121 121
122/** 122/**
123 * pevent_pid_is_registered - return if a pid has a cmdline registered
124 * @pevent: handle for the pevent
125 * @pid: The pid to check if it has a cmdline registered with.
126 *
127 * Returns 1 if the pid has a cmdline mapped to it
128 * 0 otherwise.
129 */
130int pevent_pid_is_registered(struct pevent *pevent, int pid)
131{
132 const struct cmdline *comm;
133 struct cmdline key;
134
135 if (!pid)
136 return 1;
137
138
139 if (!pevent->cmdlines)
140 cmdline_init(pevent);
141
142 key.pid = pid;
143
144 comm = bsearch(&key, pevent->cmdlines, pevent->cmdline_count,
145 sizeof(*pevent->cmdlines), cmdline_cmp);
146
147 if (comm)
148 return 1;
149 return 0;
150}
151
152/**
123 * pevent_register_comm - register a pid / comm mapping 153 * pevent_register_comm - register a pid / comm mapping
124 * @pevent: handle for the pevent 154 * @pevent: handle for the pevent
125 * @comm: the command line to register 155 * @comm: the command line to register