aboutsummaryrefslogtreecommitdiffstats
path: root/parse-events.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse-events.c')
-rw-r--r--parse-events.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/parse-events.c b/parse-events.c
index 82477a7..9f88472 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -207,8 +207,7 @@ static int add_new_comm(struct pevent *pevent, char *comm, int pid)
207 * @pid: the pid to map the command line to 207 * @pid: the pid to map the command line to
208 * 208 *
209 * This adds a mapping to search for command line names with 209 * This adds a mapping to search for command line names with
210 * a given pid. Note, the comm that is given is stored and 210 * a given pid. The comm is duplicated.
211 * a duplicate is not made.
212 */ 211 */
213int pevent_register_comm(struct pevent *pevent, char *comm, int pid) 212int pevent_register_comm(struct pevent *pevent, char *comm, int pid)
214{ 213{
@@ -218,7 +217,7 @@ int pevent_register_comm(struct pevent *pevent, char *comm, int pid)
218 return add_new_comm(pevent, comm, pid); 217 return add_new_comm(pevent, comm, pid);
219 218
220 item = malloc_or_die(sizeof(*item)); 219 item = malloc_or_die(sizeof(*item));
221 item->comm = comm; 220 item->comm = strdup(comm);
222 item->pid = pid; 221 item->pid = pid;
223 item->next = pevent->cmdlist; 222 item->next = pevent->cmdlist;
224 223
@@ -356,7 +355,7 @@ const char *pevent_find_function(struct pevent *pevent, unsigned long long addr)
356 * @mod: the kernel module the function may be in (NULL for none) 355 * @mod: the kernel module the function may be in (NULL for none)
357 * 356 *
358 * This registers a function name with an address and module. 357 * This registers a function name with an address and module.
359 * The @func passed in is stored and a copy is not made. 358 * The @func passed in is duplicated.
360 */ 359 */
361int pevent_register_function(struct pevent *pevent, char *func, 360int pevent_register_function(struct pevent *pevent, char *func,
362 unsigned long long addr, char *mod) 361 unsigned long long addr, char *mod)
@@ -366,8 +365,11 @@ int pevent_register_function(struct pevent *pevent, char *func,
366 item = malloc_or_die(sizeof(*item)); 365 item = malloc_or_die(sizeof(*item));
367 366
368 item->next = pevent->funclist; 367 item->next = pevent->funclist;
369 item->func = func; 368 item->func = strdup(func);
370 item->mod = mod; 369 if (mod)
370 item->mod = strdup(mod);
371 else
372 item->mod = NULL;
371 item->addr = addr; 373 item->addr = addr;
372 374
373 pevent->funclist = item; 375 pevent->funclist = item;
@@ -476,7 +478,7 @@ find_printk(struct pevent *pevent, unsigned long long addr)
476 * @addr: the address the string was located at 478 * @addr: the address the string was located at
477 * 479 *
478 * This registers a string by the address it was stored in the kernel. 480 * This registers a string by the address it was stored in the kernel.
479 * The @fmt is used in storage and a duplicate is not made. 481 * The @fmt passed in is duplicated.
480 */ 482 */
481int pevent_register_print_string(struct pevent *pevent, char *fmt, 483int pevent_register_print_string(struct pevent *pevent, char *fmt,
482 unsigned long long addr) 484 unsigned long long addr)
@@ -487,7 +489,7 @@ int pevent_register_print_string(struct pevent *pevent, char *fmt,
487 489
488 item->next = pevent->printklist; 490 item->next = pevent->printklist;
489 pevent->printklist = item; 491 pevent->printklist = item;
490 item->printk = fmt; 492 item->printk = strdup(fmt);
491 item->addr = addr; 493 item->addr = addr;
492 494
493 pevent->printk_count++; 495 pevent->printk_count++;
@@ -3799,9 +3801,23 @@ struct pevent *pevent_alloc(void)
3799 return pevent; 3801 return pevent;
3800} 3802}
3801 3803
3804static void free_format_fields(struct format_field *field)
3805{
3806 struct format_field *next;
3807
3808 while (field) {
3809 next = field->next;
3810 free(field->type);
3811 free(field->name);
3812 free(field);
3813 field = next;
3814 }
3815}
3816
3802static void free_formats(struct format *format) 3817static void free_formats(struct format *format)
3803{ 3818{
3804 /* IMPLEMENT ME */ 3819 free_format_fields(format->common_fields);
3820 free_format_fields(format->fields);
3805} 3821}
3806 3822
3807static void free_event(struct event_format *event) 3823static void free_event(struct event_format *event)
@@ -3813,6 +3829,8 @@ static void free_event(struct event_format *event)
3813 3829
3814 free(event->print_fmt.format); 3830 free(event->print_fmt.format);
3815 free_args(event->print_fmt.args); 3831 free_args(event->print_fmt.args);
3832
3833 free(event);
3816} 3834}
3817 3835
3818/** 3836/**
@@ -3876,4 +3894,6 @@ void pevent_free(struct pevent *pevent)
3876 3894
3877 free_event(event); 3895 free_event(event);
3878 } 3896 }
3897
3898 free(pevent);
3879} 3899}