diff options
| -rw-r--r-- | parse-events.c | 14 | ||||
| -rw-r--r-- | parse-events.h | 2 | ||||
| -rw-r--r-- | trace-graph.c | 2 |
3 files changed, 13 insertions, 5 deletions
diff --git a/parse-events.c b/parse-events.c index a959ebc..beab8f3 100644 --- a/parse-events.c +++ b/parse-events.c | |||
| @@ -225,8 +225,13 @@ static int add_new_comm(struct pevent *pevent, char *comm, int pid) | |||
| 225 | const struct cmdline *cmdline; | 225 | const struct cmdline *cmdline; |
| 226 | struct cmdline key; | 226 | struct cmdline key; |
| 227 | 227 | ||
| 228 | if (!pid) | 228 | if (!comm) |
| 229 | die("malloc comm"); | ||
| 230 | |||
| 231 | if (!pid) { | ||
| 232 | free(comm); | ||
| 229 | return 0; | 233 | return 0; |
| 234 | } | ||
| 230 | 235 | ||
| 231 | /* avoid duplicates */ | 236 | /* avoid duplicates */ |
| 232 | key.pid = pid; | 237 | key.pid = pid; |
| @@ -246,6 +251,7 @@ static int add_new_comm(struct pevent *pevent, char *comm, int pid) | |||
| 246 | 251 | ||
| 247 | cmdlines[pevent->cmdline_count].pid = pid; | 252 | cmdlines[pevent->cmdline_count].pid = pid; |
| 248 | cmdlines[pevent->cmdline_count].comm = comm; | 253 | cmdlines[pevent->cmdline_count].comm = comm; |
| 254 | if (cmdlines[pevent->cmdline_count].comm) | ||
| 249 | pevent->cmdline_count++; | 255 | pevent->cmdline_count++; |
| 250 | 256 | ||
| 251 | qsort(cmdlines, pevent->cmdline_count, sizeof(*cmdlines), cmdline_cmp); | 257 | qsort(cmdlines, pevent->cmdline_count, sizeof(*cmdlines), cmdline_cmp); |
| @@ -263,15 +269,17 @@ static int add_new_comm(struct pevent *pevent, char *comm, int pid) | |||
| 263 | * This adds a mapping to search for command line names with | 269 | * This adds a mapping to search for command line names with |
| 264 | * a given pid. The comm is duplicated. | 270 | * a given pid. The comm is duplicated. |
| 265 | */ | 271 | */ |
| 266 | int pevent_register_comm(struct pevent *pevent, char *comm, int pid) | 272 | int pevent_register_comm(struct pevent *pevent, const char *comm, int pid) |
| 267 | { | 273 | { |
| 268 | struct cmdline_list *item; | 274 | struct cmdline_list *item; |
| 269 | 275 | ||
| 270 | if (pevent->cmdlines) | 276 | if (pevent->cmdlines) |
| 271 | return add_new_comm(pevent, comm, pid); | 277 | return add_new_comm(pevent, strdup(comm), pid); |
| 272 | 278 | ||
| 273 | item = malloc_or_die(sizeof(*item)); | 279 | item = malloc_or_die(sizeof(*item)); |
| 274 | item->comm = strdup(comm); | 280 | item->comm = strdup(comm); |
| 281 | if (!item->comm) | ||
| 282 | die("malloc comm"); | ||
| 275 | item->pid = pid; | 283 | item->pid = pid; |
| 276 | item->next = pevent->cmdlist; | 284 | item->next = pevent->cmdlist; |
| 277 | 285 | ||
diff --git a/parse-events.h b/parse-events.h index 38ddf95..4732acf 100644 --- a/parse-events.h +++ b/parse-events.h | |||
| @@ -428,7 +428,7 @@ enum trace_flag_type { | |||
| 428 | TRACE_FLAG_SOFTIRQ = 0x10, | 428 | TRACE_FLAG_SOFTIRQ = 0x10, |
| 429 | }; | 429 | }; |
| 430 | 430 | ||
| 431 | int pevent_register_comm(struct pevent *pevent, char *comm, int pid); | 431 | int pevent_register_comm(struct pevent *pevent, const char *comm, int pid); |
| 432 | int pevent_register_function(struct pevent *pevent, char *name, | 432 | int pevent_register_function(struct pevent *pevent, char *name, |
| 433 | unsigned long long addr, char *mod); | 433 | unsigned long long addr, char *mod); |
| 434 | int pevent_register_print_string(struct pevent *pevent, char *fmt, | 434 | int pevent_register_print_string(struct pevent *pevent, char *fmt, |
diff --git a/trace-graph.c b/trace-graph.c index 7225880..2ddd283 100644 --- a/trace-graph.c +++ b/trace-graph.c | |||
| @@ -1134,7 +1134,7 @@ int trace_graph_check_sched_switch(struct graph_info *ginfo, | |||
| 1134 | */ | 1134 | */ |
| 1135 | if (!pevent_pid_is_registered(ginfo->pevent, *pid)) | 1135 | if (!pevent_pid_is_registered(ginfo->pevent, *pid)) |
| 1136 | pevent_register_comm(ginfo->pevent, | 1136 | pevent_register_comm(ginfo->pevent, |
| 1137 | strdup(*comm), *pid); | 1137 | *comm, *pid); |
| 1138 | } | 1138 | } |
| 1139 | 1139 | ||
| 1140 | return ret; | 1140 | return ret; |
