diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2009-12-23 15:17:56 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-23 15:17:56 -0500 |
commit | 9e916f58650cd66bea0318b029b2f73542a5705d (patch) | |
tree | c45d678dd97cc654cea7728d73e4d083babc4faf | |
parent | 616a84bd7e25f228a5d0380bbee6bae0ae1f5588 (diff) | |
parent | aa1e3f9bd5b74e8427f931e5e7dcdda5096b3fd2 (diff) |
Merge branch 'trace-cmd' into trace-view
-rw-r--r-- | parse-events.c | 303 | ||||
-rw-r--r-- | trace-input.c | 26 | ||||
-rw-r--r-- | trace-read.c | 4 | ||||
-rw-r--r-- | trace-util.c | 3 |
4 files changed, 244 insertions, 92 deletions
diff --git a/parse-events.c b/parse-events.c index 9bbb401..9f88472 100644 --- a/parse-events.c +++ b/parse-events.c | |||
@@ -47,6 +47,18 @@ void breakpoint(void) | |||
47 | x++; | 47 | x++; |
48 | } | 48 | } |
49 | 49 | ||
50 | struct print_arg *alloc_arg(void) | ||
51 | { | ||
52 | struct print_arg *arg; | ||
53 | |||
54 | arg = malloc_or_die(sizeof(*arg)); | ||
55 | if (!arg) | ||
56 | return NULL; | ||
57 | memset(arg, 0, sizeof(*arg)); | ||
58 | |||
59 | return arg; | ||
60 | } | ||
61 | |||
50 | struct cmdline { | 62 | struct cmdline { |
51 | char *comm; | 63 | char *comm; |
52 | int pid; | 64 | int pid; |
@@ -195,8 +207,7 @@ static int add_new_comm(struct pevent *pevent, char *comm, int pid) | |||
195 | * @pid: the pid to map the command line to | 207 | * @pid: the pid to map the command line to |
196 | * | 208 | * |
197 | * This adds a mapping to search for command line names with | 209 | * This adds a mapping to search for command line names with |
198 | * a given pid. Note, the comm that is given is stored and | 210 | * a given pid. The comm is duplicated. |
199 | * a duplicate is not made. | ||
200 | */ | 211 | */ |
201 | int pevent_register_comm(struct pevent *pevent, char *comm, int pid) | 212 | int pevent_register_comm(struct pevent *pevent, char *comm, int pid) |
202 | { | 213 | { |
@@ -206,7 +217,7 @@ int pevent_register_comm(struct pevent *pevent, char *comm, int pid) | |||
206 | return add_new_comm(pevent, comm, pid); | 217 | return add_new_comm(pevent, comm, pid); |
207 | 218 | ||
208 | item = malloc_or_die(sizeof(*item)); | 219 | item = malloc_or_die(sizeof(*item)); |
209 | item->comm = comm; | 220 | item->comm = strdup(comm); |
210 | item->pid = pid; | 221 | item->pid = pid; |
211 | item->next = pevent->cmdlist; | 222 | item->next = pevent->cmdlist; |
212 | 223 | ||
@@ -344,7 +355,7 @@ const char *pevent_find_function(struct pevent *pevent, unsigned long long addr) | |||
344 | * @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) |
345 | * | 356 | * |
346 | * This registers a function name with an address and module. | 357 | * This registers a function name with an address and module. |
347 | * The @func passed in is stored and a copy is not made. | 358 | * The @func passed in is duplicated. |
348 | */ | 359 | */ |
349 | int pevent_register_function(struct pevent *pevent, char *func, | 360 | int pevent_register_function(struct pevent *pevent, char *func, |
350 | unsigned long long addr, char *mod) | 361 | unsigned long long addr, char *mod) |
@@ -354,8 +365,11 @@ int pevent_register_function(struct pevent *pevent, char *func, | |||
354 | item = malloc_or_die(sizeof(*item)); | 365 | item = malloc_or_die(sizeof(*item)); |
355 | 366 | ||
356 | item->next = pevent->funclist; | 367 | item->next = pevent->funclist; |
357 | item->func = func; | 368 | item->func = strdup(func); |
358 | item->mod = mod; | 369 | if (mod) |
370 | item->mod = strdup(mod); | ||
371 | else | ||
372 | item->mod = NULL; | ||
359 | item->addr = addr; | 373 | item->addr = addr; |
360 | 374 | ||
361 | pevent->funclist = item; | 375 | pevent->funclist = item; |
@@ -464,7 +478,7 @@ find_printk(struct pevent *pevent, unsigned long long addr) | |||
464 | * @addr: the address the string was located at | 478 | * @addr: the address the string was located at |
465 | * | 479 | * |
466 | * 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. |
467 | * The @fmt is used in storage and a duplicate is not made. | 481 | * The @fmt passed in is duplicated. |
468 | */ | 482 | */ |
469 | int pevent_register_print_string(struct pevent *pevent, char *fmt, | 483 | int pevent_register_print_string(struct pevent *pevent, char *fmt, |
470 | unsigned long long addr) | 484 | unsigned long long addr) |
@@ -475,7 +489,7 @@ int pevent_register_print_string(struct pevent *pevent, char *fmt, | |||
475 | 489 | ||
476 | item->next = pevent->printklist; | 490 | item->next = pevent->printklist; |
477 | pevent->printklist = item; | 491 | pevent->printklist = item; |
478 | item->printk = fmt; | 492 | item->printk = strdup(fmt); |
479 | item->addr = addr; | 493 | item->addr = addr; |
480 | 494 | ||
481 | pevent->printk_count++; | 495 | pevent->printk_count++; |
@@ -545,6 +559,19 @@ static int event_item_type(enum event_type type) | |||
545 | } | 559 | } |
546 | } | 560 | } |
547 | 561 | ||
562 | static void free_flag_sym(struct print_flag_sym *fsym) | ||
563 | { | ||
564 | struct print_flag_sym *next; | ||
565 | |||
566 | while (fsym) { | ||
567 | next = fsym->next; | ||
568 | free(fsym->value); | ||
569 | free(fsym->str); | ||
570 | free(fsym); | ||
571 | fsym = next; | ||
572 | } | ||
573 | } | ||
574 | |||
548 | static void free_arg(struct print_arg *arg) | 575 | static void free_arg(struct print_arg *arg) |
549 | { | 576 | { |
550 | if (!arg) | 577 | if (!arg) |
@@ -552,13 +579,37 @@ static void free_arg(struct print_arg *arg) | |||
552 | 579 | ||
553 | switch (arg->type) { | 580 | switch (arg->type) { |
554 | case PRINT_ATOM: | 581 | case PRINT_ATOM: |
555 | if (arg->atom.atom) | 582 | free(arg->atom.atom); |
556 | free(arg->atom.atom); | ||
557 | break; | 583 | break; |
584 | case PRINT_FIELD: | ||
585 | free(arg->field.name); | ||
586 | break; | ||
587 | case PRINT_FLAGS: | ||
588 | free_arg(arg->flags.field); | ||
589 | free(arg->flags.delim); | ||
590 | free_flag_sym(arg->flags.flags); | ||
591 | break; | ||
592 | case PRINT_SYMBOL: | ||
593 | free_arg(arg->symbol.field); | ||
594 | free_flag_sym(arg->symbol.symbols); | ||
595 | break; | ||
596 | case PRINT_TYPE: | ||
597 | free(arg->typecast.type); | ||
598 | free_arg(arg->typecast.item); | ||
599 | break; | ||
600 | case PRINT_STRING: | ||
601 | free(arg->string.string); | ||
602 | break; | ||
603 | case PRINT_DYNAMIC_ARRAY: | ||
604 | free(arg->dynarray.index); | ||
605 | break; | ||
606 | case PRINT_OP: | ||
607 | free(arg->op.op); | ||
608 | free_arg(arg->op.left); | ||
609 | free_arg(arg->op.right); | ||
610 | |||
558 | case PRINT_NULL: | 611 | case PRINT_NULL: |
559 | case PRINT_FIELD ... PRINT_OP: | ||
560 | default: | 612 | default: |
561 | /* todo */ | ||
562 | break; | 613 | break; |
563 | } | 614 | } |
564 | 615 | ||
@@ -813,6 +864,7 @@ static enum event_type read_token(char **tok) | |||
813 | } | 864 | } |
814 | 865 | ||
815 | /* not reached */ | 866 | /* not reached */ |
867 | *tok = NULL; | ||
816 | return EVENT_NONE; | 868 | return EVENT_NONE; |
817 | } | 869 | } |
818 | 870 | ||
@@ -825,11 +877,12 @@ static enum event_type read_token_item(char **tok) | |||
825 | type = __read_token(tok); | 877 | type = __read_token(tok); |
826 | if (type != EVENT_SPACE && type != EVENT_NEWLINE) | 878 | if (type != EVENT_SPACE && type != EVENT_NEWLINE) |
827 | return type; | 879 | return type; |
828 | |||
829 | free_token(*tok); | 880 | free_token(*tok); |
881 | *tok = NULL; | ||
830 | } | 882 | } |
831 | 883 | ||
832 | /* not reached */ | 884 | /* not reached */ |
885 | *tok = NULL; | ||
833 | return EVENT_NONE; | 886 | return EVENT_NONE; |
834 | } | 887 | } |
835 | 888 | ||
@@ -999,8 +1052,9 @@ static int event_read_fields(struct event_format *event, struct format_field **f | |||
999 | } | 1052 | } |
1000 | 1053 | ||
1001 | if (test_type_token(type, token, EVENT_OP, ":") < 0) | 1054 | if (test_type_token(type, token, EVENT_OP, ":") < 0) |
1002 | return -1; | 1055 | goto fail; |
1003 | 1056 | ||
1057 | free_token(token); | ||
1004 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 1058 | if (read_expect_type(EVENT_ITEM, &token) < 0) |
1005 | goto fail; | 1059 | goto fail; |
1006 | 1060 | ||
@@ -1031,6 +1085,7 @@ static int event_read_fields(struct event_format *event, struct format_field **f | |||
1031 | strlen(last_token) + 2); | 1085 | strlen(last_token) + 2); |
1032 | strcat(field->type, " "); | 1086 | strcat(field->type, " "); |
1033 | strcat(field->type, last_token); | 1087 | strcat(field->type, last_token); |
1088 | free(last_token); | ||
1034 | } else | 1089 | } else |
1035 | field->type = last_token; | 1090 | field->type = last_token; |
1036 | last_token = token; | 1091 | last_token = token; |
@@ -1245,12 +1300,9 @@ process_cond(struct event_format *event, struct print_arg *top, char **tok) | |||
1245 | enum event_type type; | 1300 | enum event_type type; |
1246 | char *token = NULL; | 1301 | char *token = NULL; |
1247 | 1302 | ||
1248 | arg = malloc_or_die(sizeof(*arg)); | 1303 | arg = alloc_arg(); |
1249 | memset(arg, 0, sizeof(*arg)); | 1304 | left = alloc_arg(); |
1250 | 1305 | right = alloc_arg(); | |
1251 | left = malloc_or_die(sizeof(*left)); | ||
1252 | |||
1253 | right = malloc_or_die(sizeof(*right)); | ||
1254 | 1306 | ||
1255 | arg->type = PRINT_OP; | 1307 | arg->type = PRINT_OP; |
1256 | arg->op.left = left; | 1308 | arg->op.left = left; |
@@ -1272,6 +1324,7 @@ process_cond(struct event_format *event, struct print_arg *top, char **tok) | |||
1272 | 1324 | ||
1273 | out_free: | 1325 | out_free: |
1274 | free_token(*tok); | 1326 | free_token(*tok); |
1327 | *tok = NULL; | ||
1275 | free(right); | 1328 | free(right); |
1276 | free(left); | 1329 | free(left); |
1277 | free_arg(arg); | 1330 | free_arg(arg); |
@@ -1285,8 +1338,7 @@ process_array(struct event_format *event, struct print_arg *top, char **tok) | |||
1285 | enum event_type type; | 1338 | enum event_type type; |
1286 | char *token = NULL; | 1339 | char *token = NULL; |
1287 | 1340 | ||
1288 | arg = malloc_or_die(sizeof(*arg)); | 1341 | arg = alloc_arg(); |
1289 | memset(arg, 0, sizeof(*arg)); | ||
1290 | 1342 | ||
1291 | *tok = NULL; | 1343 | *tok = NULL; |
1292 | type = process_arg(event, arg, &token); | 1344 | type = process_arg(event, arg, &token); |
@@ -1303,6 +1355,7 @@ process_array(struct event_format *event, struct print_arg *top, char **tok) | |||
1303 | 1355 | ||
1304 | out_free: | 1356 | out_free: |
1305 | free_token(*tok); | 1357 | free_token(*tok); |
1358 | *tok = NULL; | ||
1306 | free_arg(arg); | 1359 | free_arg(arg); |
1307 | return EVENT_ERROR; | 1360 | return EVENT_ERROR; |
1308 | } | 1361 | } |
@@ -1385,7 +1438,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
1385 | /* handle single op */ | 1438 | /* handle single op */ |
1386 | if (token[1]) { | 1439 | if (token[1]) { |
1387 | die("bad op token %s", token); | 1440 | die("bad op token %s", token); |
1388 | return EVENT_ERROR; | 1441 | goto out_free; |
1389 | } | 1442 | } |
1390 | switch (token[0]) { | 1443 | switch (token[0]) { |
1391 | case '!': | 1444 | case '!': |
@@ -1394,22 +1447,24 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
1394 | break; | 1447 | break; |
1395 | default: | 1448 | default: |
1396 | warning("bad op token %s", token); | 1449 | warning("bad op token %s", token); |
1397 | return EVENT_ERROR; | 1450 | goto out_free; |
1451 | |||
1398 | } | 1452 | } |
1399 | 1453 | ||
1400 | /* make an empty left */ | 1454 | /* make an empty left */ |
1401 | left = malloc_or_die(sizeof(*left)); | 1455 | left = alloc_arg(); |
1402 | left->type = PRINT_NULL; | 1456 | left->type = PRINT_NULL; |
1403 | arg->op.left = left; | 1457 | arg->op.left = left; |
1404 | 1458 | ||
1405 | right = malloc_or_die(sizeof(*right)); | 1459 | right = alloc_arg(); |
1406 | arg->op.right = right; | 1460 | arg->op.right = right; |
1407 | 1461 | ||
1462 | free_token(token); | ||
1408 | type = process_arg(event, right, tok); | 1463 | type = process_arg(event, right, tok); |
1409 | 1464 | ||
1410 | } else if (strcmp(token, "?") == 0) { | 1465 | } else if (strcmp(token, "?") == 0) { |
1411 | 1466 | ||
1412 | left = malloc_or_die(sizeof(*left)); | 1467 | left = alloc_arg(); |
1413 | /* copy the top arg to the left */ | 1468 | /* copy the top arg to the left */ |
1414 | *left = *arg; | 1469 | *left = *arg; |
1415 | 1470 | ||
@@ -1436,7 +1491,7 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
1436 | strcmp(token, "==") == 0 || | 1491 | strcmp(token, "==") == 0 || |
1437 | strcmp(token, "!=") == 0) { | 1492 | strcmp(token, "!=") == 0) { |
1438 | 1493 | ||
1439 | left = malloc_or_die(sizeof(*left)); | 1494 | left = alloc_arg(); |
1440 | 1495 | ||
1441 | /* copy the top arg to the left */ | 1496 | /* copy the top arg to the left */ |
1442 | *left = *arg; | 1497 | *left = *arg; |
@@ -1447,8 +1502,6 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
1447 | 1502 | ||
1448 | set_op_prio(arg); | 1503 | set_op_prio(arg); |
1449 | 1504 | ||
1450 | right = malloc_or_die(sizeof(*right)); | ||
1451 | |||
1452 | type = read_token_item(&token); | 1505 | type = read_token_item(&token); |
1453 | *tok = token; | 1506 | *tok = token; |
1454 | 1507 | ||
@@ -1458,21 +1511,22 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
1458 | if (left->type != PRINT_ATOM) | 1511 | if (left->type != PRINT_ATOM) |
1459 | die("bad pointer type"); | 1512 | die("bad pointer type"); |
1460 | left->atom.atom = realloc(left->atom.atom, | 1513 | left->atom.atom = realloc(left->atom.atom, |
1461 | sizeof(left->atom.atom) + 3); | 1514 | strlen(left->atom.atom) + 3); |
1462 | strcat(left->atom.atom, " *"); | 1515 | strcat(left->atom.atom, " *"); |
1516 | free(arg->op.op); | ||
1463 | *arg = *left; | 1517 | *arg = *left; |
1464 | free(left); | 1518 | free(left); |
1465 | 1519 | ||
1466 | return type; | 1520 | return type; |
1467 | } | 1521 | } |
1468 | 1522 | ||
1523 | right = alloc_arg(); | ||
1469 | type = process_arg_token(event, right, tok, type); | 1524 | type = process_arg_token(event, right, tok, type); |
1470 | |||
1471 | arg->op.right = right; | 1525 | arg->op.right = right; |
1472 | 1526 | ||
1473 | } else if (strcmp(token, "[") == 0) { | 1527 | } else if (strcmp(token, "[") == 0) { |
1474 | 1528 | ||
1475 | left = malloc_or_die(sizeof(*left)); | 1529 | left = alloc_arg(); |
1476 | *left = *arg; | 1530 | *left = *arg; |
1477 | 1531 | ||
1478 | arg->type = PRINT_OP; | 1532 | arg->type = PRINT_OP; |
@@ -1480,13 +1534,14 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
1480 | arg->op.left = left; | 1534 | arg->op.left = left; |
1481 | 1535 | ||
1482 | arg->op.prio = 0; | 1536 | arg->op.prio = 0; |
1537 | |||
1483 | type = process_array(event, arg, tok); | 1538 | type = process_array(event, arg, tok); |
1484 | 1539 | ||
1485 | } else { | 1540 | } else { |
1486 | warning("unknown op '%s'", token); | 1541 | warning("unknown op '%s'", token); |
1487 | event->flags |= EVENT_FL_FAILED; | 1542 | event->flags |= EVENT_FL_FAILED; |
1488 | /* the arg is now the left side */ | 1543 | /* the arg is now the left side */ |
1489 | return EVENT_NONE; | 1544 | goto out_free; |
1490 | } | 1545 | } |
1491 | 1546 | ||
1492 | if (type == EVENT_OP) { | 1547 | if (type == EVENT_OP) { |
@@ -1502,6 +1557,11 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok) | |||
1502 | } | 1557 | } |
1503 | 1558 | ||
1504 | return type; | 1559 | return type; |
1560 | |||
1561 | out_free: | ||
1562 | free_token(token); | ||
1563 | *tok = NULL; | ||
1564 | return EVENT_ERROR; | ||
1505 | } | 1565 | } |
1506 | 1566 | ||
1507 | static enum event_type | 1567 | static enum event_type |
@@ -1513,10 +1573,10 @@ process_entry(struct event_format *event __unused, struct print_arg *arg, | |||
1513 | char *token; | 1573 | char *token; |
1514 | 1574 | ||
1515 | if (read_expected(EVENT_OP, "->") < 0) | 1575 | if (read_expected(EVENT_OP, "->") < 0) |
1516 | return EVENT_ERROR; | 1576 | goto out_err; |
1517 | 1577 | ||
1518 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 1578 | if (read_expect_type(EVENT_ITEM, &token) < 0) |
1519 | goto fail; | 1579 | goto out_free; |
1520 | field = token; | 1580 | field = token; |
1521 | 1581 | ||
1522 | arg->type = PRINT_FIELD; | 1582 | arg->type = PRINT_FIELD; |
@@ -1527,8 +1587,10 @@ process_entry(struct event_format *event __unused, struct print_arg *arg, | |||
1527 | 1587 | ||
1528 | return type; | 1588 | return type; |
1529 | 1589 | ||
1530 | fail: | 1590 | out_free: |
1531 | free_token(token); | 1591 | free_token(token); |
1592 | out_err: | ||
1593 | *tok = NULL; | ||
1532 | return EVENT_ERROR; | 1594 | return EVENT_ERROR; |
1533 | } | 1595 | } |
1534 | 1596 | ||
@@ -1775,7 +1837,7 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char ** | |||
1775 | enum event_type type; | 1837 | enum event_type type; |
1776 | struct print_arg *arg = NULL; | 1838 | struct print_arg *arg = NULL; |
1777 | struct print_flag_sym *field; | 1839 | struct print_flag_sym *field; |
1778 | char *token = NULL; | 1840 | char *token = *tok; |
1779 | char *value; | 1841 | char *value; |
1780 | 1842 | ||
1781 | do { | 1843 | do { |
@@ -1784,7 +1846,7 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char ** | |||
1784 | if (test_type_token(type, token, EVENT_OP, "{")) | 1846 | if (test_type_token(type, token, EVENT_OP, "{")) |
1785 | break; | 1847 | break; |
1786 | 1848 | ||
1787 | arg = malloc_or_die(sizeof(*arg)); | 1849 | arg = alloc_arg(); |
1788 | 1850 | ||
1789 | free_token(token); | 1851 | free_token(token); |
1790 | type = process_arg(event, arg, &token); | 1852 | type = process_arg(event, arg, &token); |
@@ -1797,6 +1859,9 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char ** | |||
1797 | value = arg_eval(arg); | 1859 | value = arg_eval(arg); |
1798 | field->value = strdup(value); | 1860 | field->value = strdup(value); |
1799 | 1861 | ||
1862 | free_arg(arg); | ||
1863 | arg = alloc_arg(); | ||
1864 | |||
1800 | free_token(token); | 1865 | free_token(token); |
1801 | type = process_arg(event, arg, &token); | 1866 | type = process_arg(event, arg, &token); |
1802 | if (test_type_token(type, token, EVENT_OP, "}")) | 1867 | if (test_type_token(type, token, EVENT_OP, "}")) |
@@ -1820,6 +1885,7 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char ** | |||
1820 | out_free: | 1885 | out_free: |
1821 | free_arg(arg); | 1886 | free_arg(arg); |
1822 | free_token(token); | 1887 | free_token(token); |
1888 | *tok = NULL; | ||
1823 | 1889 | ||
1824 | return EVENT_ERROR; | 1890 | return EVENT_ERROR; |
1825 | } | 1891 | } |
@@ -1835,13 +1901,14 @@ process_flags(struct event_format *event, struct print_arg *arg, char **tok) | |||
1835 | arg->type = PRINT_FLAGS; | 1901 | arg->type = PRINT_FLAGS; |
1836 | 1902 | ||
1837 | if (read_expected_item(EVENT_DELIM, "(") < 0) | 1903 | if (read_expected_item(EVENT_DELIM, "(") < 0) |
1838 | return EVENT_ERROR; | 1904 | goto out_err; |
1839 | 1905 | ||
1840 | field = malloc_or_die(sizeof(*field)); | 1906 | field = alloc_arg(); |
1841 | 1907 | ||
1842 | type = process_arg(event, field, &token); | 1908 | type = process_arg(event, field, &token); |
1843 | if (test_type_token(type, token, EVENT_DELIM, ",")) | 1909 | if (test_type_token(type, token, EVENT_DELIM, ",")) |
1844 | goto out_free; | 1910 | goto out_free; |
1911 | free_token(token); | ||
1845 | 1912 | ||
1846 | arg->flags.field = field; | 1913 | arg->flags.field = field; |
1847 | 1914 | ||
@@ -1862,8 +1929,10 @@ process_flags(struct event_format *event, struct print_arg *arg, char **tok) | |||
1862 | type = read_token_item(tok); | 1929 | type = read_token_item(tok); |
1863 | return type; | 1930 | return type; |
1864 | 1931 | ||
1865 | out_free: | 1932 | out_free: |
1866 | free_token(token); | 1933 | free_token(token); |
1934 | out_err: | ||
1935 | *tok = NULL; | ||
1867 | return EVENT_ERROR; | 1936 | return EVENT_ERROR; |
1868 | } | 1937 | } |
1869 | 1938 | ||
@@ -1878,9 +1947,9 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok) | |||
1878 | arg->type = PRINT_SYMBOL; | 1947 | arg->type = PRINT_SYMBOL; |
1879 | 1948 | ||
1880 | if (read_expected_item(EVENT_DELIM, "(") < 0) | 1949 | if (read_expected_item(EVENT_DELIM, "(") < 0) |
1881 | return EVENT_ERROR; | 1950 | goto out_err; |
1882 | 1951 | ||
1883 | field = malloc_or_die(sizeof(*field)); | 1952 | field = alloc_arg(); |
1884 | 1953 | ||
1885 | type = process_arg(event, field, &token); | 1954 | type = process_arg(event, field, &token); |
1886 | if (test_type_token(type, token, EVENT_DELIM, ",")) | 1955 | if (test_type_token(type, token, EVENT_DELIM, ",")) |
@@ -1896,8 +1965,10 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok) | |||
1896 | type = read_token_item(tok); | 1965 | type = read_token_item(tok); |
1897 | return type; | 1966 | return type; |
1898 | 1967 | ||
1899 | out_free: | 1968 | out_free: |
1900 | free_token(token); | 1969 | free_token(token); |
1970 | out_err: | ||
1971 | *tok = NULL; | ||
1901 | return EVENT_ERROR; | 1972 | return EVENT_ERROR; |
1902 | } | 1973 | } |
1903 | 1974 | ||
@@ -1912,7 +1983,7 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** | |||
1912 | arg->type = PRINT_DYNAMIC_ARRAY; | 1983 | arg->type = PRINT_DYNAMIC_ARRAY; |
1913 | 1984 | ||
1914 | if (read_expected_item(EVENT_DELIM, "(") < 0) | 1985 | if (read_expected_item(EVENT_DELIM, "(") < 0) |
1915 | return EVENT_ERROR; | 1986 | goto out_err; |
1916 | 1987 | ||
1917 | /* | 1988 | /* |
1918 | * The item within the parenthesis is another field that holds | 1989 | * The item within the parenthesis is another field that holds |
@@ -1921,19 +1992,19 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** | |||
1921 | type = read_token(&token); | 1992 | type = read_token(&token); |
1922 | *tok = token; | 1993 | *tok = token; |
1923 | if (type != EVENT_ITEM) | 1994 | if (type != EVENT_ITEM) |
1924 | return EVENT_ERROR; | 1995 | goto out_free; |
1925 | 1996 | ||
1926 | /* Find the field */ | 1997 | /* Find the field */ |
1927 | 1998 | ||
1928 | field = pevent_find_field(event, token); | 1999 | field = pevent_find_field(event, token); |
1929 | if (!field) | 2000 | if (!field) |
1930 | return EVENT_ERROR; | 2001 | goto out_free; |
1931 | 2002 | ||
1932 | arg->dynarray.field = field; | 2003 | arg->dynarray.field = field; |
1933 | arg->dynarray.index = 0; | 2004 | arg->dynarray.index = 0; |
1934 | 2005 | ||
1935 | if (read_expected(EVENT_DELIM, ")") < 0) | 2006 | if (read_expected(EVENT_DELIM, ")") < 0) |
1936 | return EVENT_ERROR; | 2007 | goto out_free; |
1937 | 2008 | ||
1938 | type = read_token_item(&token); | 2009 | type = read_token_item(&token); |
1939 | *tok = token; | 2010 | *tok = token; |
@@ -1941,7 +2012,7 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** | |||
1941 | return type; | 2012 | return type; |
1942 | 2013 | ||
1943 | free_token(token); | 2014 | free_token(token); |
1944 | arg = malloc_or_die(sizeof(*arg)); | 2015 | arg = alloc_arg(); |
1945 | type = process_arg(event, arg, &token); | 2016 | type = process_arg(event, arg, &token); |
1946 | if (type == EVENT_ERROR) | 2017 | if (type == EVENT_ERROR) |
1947 | goto out_free; | 2018 | goto out_free; |
@@ -1953,8 +2024,11 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char ** | |||
1953 | type = read_token_item(tok); | 2024 | type = read_token_item(tok); |
1954 | return type; | 2025 | return type; |
1955 | 2026 | ||
1956 | out_free: | 2027 | out_free: |
1957 | free(arg); | 2028 | free(arg); |
2029 | free_token(token); | ||
2030 | out_err: | ||
2031 | *tok = NULL; | ||
1958 | return EVENT_ERROR; | 2032 | return EVENT_ERROR; |
1959 | } | 2033 | } |
1960 | 2034 | ||
@@ -1968,18 +2042,16 @@ process_paren(struct event_format *event, struct print_arg *arg, char **tok) | |||
1968 | type = process_arg(event, arg, &token); | 2042 | type = process_arg(event, arg, &token); |
1969 | 2043 | ||
1970 | if (type == EVENT_ERROR) | 2044 | if (type == EVENT_ERROR) |
1971 | return EVENT_ERROR; | 2045 | goto out_free; |
1972 | 2046 | ||
1973 | if (type == EVENT_OP) | 2047 | if (type == EVENT_OP) |
1974 | type = process_op(event, arg, &token); | 2048 | type = process_op(event, arg, &token); |
1975 | 2049 | ||
1976 | if (type == EVENT_ERROR) | 2050 | if (type == EVENT_ERROR) |
1977 | return EVENT_ERROR; | 2051 | goto out_free; |
1978 | 2052 | ||
1979 | if (test_type_token(type, token, EVENT_DELIM, ")")) { | 2053 | if (test_type_token(type, token, EVENT_DELIM, ")")) |
1980 | free_token(token); | 2054 | goto out_free; |
1981 | return EVENT_ERROR; | ||
1982 | } | ||
1983 | 2055 | ||
1984 | free_token(token); | 2056 | free_token(token); |
1985 | type = read_token_item(&token); | 2057 | type = read_token_item(&token); |
@@ -1997,8 +2069,7 @@ process_paren(struct event_format *event, struct print_arg *arg, char **tok) | |||
1997 | if (arg->type != PRINT_ATOM) | 2069 | if (arg->type != PRINT_ATOM) |
1998 | die("previous needed to be PRINT_ATOM"); | 2070 | die("previous needed to be PRINT_ATOM"); |
1999 | 2071 | ||
2000 | item_arg = malloc_or_die(sizeof(*item_arg)); | 2072 | item_arg = alloc_arg(); |
2001 | memset(item_arg, 0, sizeof(*item_arg)); | ||
2002 | 2073 | ||
2003 | arg->type = PRINT_TYPE; | 2074 | arg->type = PRINT_TYPE; |
2004 | arg->typecast.type = arg->atom.atom; | 2075 | arg->typecast.type = arg->atom.atom; |
@@ -2009,6 +2080,11 @@ process_paren(struct event_format *event, struct print_arg *arg, char **tok) | |||
2009 | 2080 | ||
2010 | *tok = token; | 2081 | *tok = token; |
2011 | return type; | 2082 | return type; |
2083 | |||
2084 | out_free: | ||
2085 | free_token(token); | ||
2086 | *tok = NULL; | ||
2087 | return EVENT_ERROR; | ||
2012 | } | 2088 | } |
2013 | 2089 | ||
2014 | 2090 | ||
@@ -2019,24 +2095,27 @@ process_str(struct event_format *event __unused, struct print_arg *arg, char **t | |||
2019 | char *token; | 2095 | char *token; |
2020 | 2096 | ||
2021 | if (read_expected(EVENT_DELIM, "(") < 0) | 2097 | if (read_expected(EVENT_DELIM, "(") < 0) |
2022 | return EVENT_ERROR; | 2098 | goto out_err; |
2023 | 2099 | ||
2024 | if (read_expect_type(EVENT_ITEM, &token) < 0) | 2100 | if (read_expect_type(EVENT_ITEM, &token) < 0) |
2025 | goto fail; | 2101 | goto out_free; |
2026 | 2102 | ||
2027 | arg->type = PRINT_STRING; | 2103 | arg->type = PRINT_STRING; |
2028 | arg->string.string = token; | 2104 | arg->string.string = token; |
2029 | arg->string.offset = -1; | 2105 | arg->string.offset = -1; |
2030 | 2106 | ||
2031 | if (read_expected(EVENT_DELIM, ")") < 0) | 2107 | if (read_expected(EVENT_DELIM, ")") < 0) |
2032 | return EVENT_ERROR; | 2108 | goto out_err; |
2033 | 2109 | ||
2034 | type = read_token(&token); | 2110 | type = read_token(&token); |
2035 | *tok = token; | 2111 | *tok = token; |
2036 | 2112 | ||
2037 | return type; | 2113 | return type; |
2038 | fail: | 2114 | |
2115 | out_free: | ||
2039 | free_token(token); | 2116 | free_token(token); |
2117 | out_err: | ||
2118 | *tok = NULL; | ||
2040 | return EVENT_ERROR; | 2119 | return EVENT_ERROR; |
2041 | } | 2120 | } |
2042 | 2121 | ||
@@ -2104,9 +2183,7 @@ process_arg_token(struct event_format *event, struct print_arg *arg, | |||
2104 | arg->op.op = token; | 2183 | arg->op.op = token; |
2105 | arg->op.left = NULL; | 2184 | arg->op.left = NULL; |
2106 | type = process_op(event, arg, &token); | 2185 | type = process_op(event, arg, &token); |
2107 | if (type == EVENT_ERROR) | 2186 | /* return error type if errored */ |
2108 | return type; | ||
2109 | |||
2110 | break; | 2187 | break; |
2111 | 2188 | ||
2112 | case EVENT_ERROR ... EVENT_NEWLINE: | 2189 | case EVENT_ERROR ... EVENT_NEWLINE: |
@@ -2127,17 +2204,16 @@ static int event_read_print_args(struct event_format *event, struct print_arg ** | |||
2127 | 2204 | ||
2128 | do { | 2205 | do { |
2129 | if (type == EVENT_NEWLINE) { | 2206 | if (type == EVENT_NEWLINE) { |
2130 | free_token(token); | ||
2131 | type = read_token_item(&token); | 2207 | type = read_token_item(&token); |
2132 | continue; | 2208 | continue; |
2133 | } | 2209 | } |
2134 | 2210 | ||
2135 | arg = malloc_or_die(sizeof(*arg)); | 2211 | arg = alloc_arg(); |
2136 | memset(arg, 0, sizeof(*arg)); | ||
2137 | 2212 | ||
2138 | type = process_arg(event, arg, &token); | 2213 | type = process_arg(event, arg, &token); |
2139 | 2214 | ||
2140 | if (type == EVENT_ERROR) { | 2215 | if (type == EVENT_ERROR) { |
2216 | free_token(token); | ||
2141 | free_arg(arg); | 2217 | free_arg(arg); |
2142 | return -1; | 2218 | return -1; |
2143 | } | 2219 | } |
@@ -2147,6 +2223,7 @@ static int event_read_print_args(struct event_format *event, struct print_arg ** | |||
2147 | 2223 | ||
2148 | if (type == EVENT_OP) { | 2224 | if (type == EVENT_OP) { |
2149 | type = process_op(event, arg, &token); | 2225 | type = process_op(event, arg, &token); |
2226 | free_token(token); | ||
2150 | list = &arg->next; | 2227 | list = &arg->next; |
2151 | continue; | 2228 | continue; |
2152 | } | 2229 | } |
@@ -2160,7 +2237,7 @@ static int event_read_print_args(struct event_format *event, struct print_arg ** | |||
2160 | break; | 2237 | break; |
2161 | } while (type != EVENT_NONE); | 2238 | } while (type != EVENT_NONE); |
2162 | 2239 | ||
2163 | if (type != EVENT_NONE) | 2240 | if (type != EVENT_NONE && type != EVENT_ERROR) |
2164 | free_token(token); | 2241 | free_token(token); |
2165 | 2242 | ||
2166 | return args; | 2243 | return args; |
@@ -2790,7 +2867,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc | |||
2790 | /* | 2867 | /* |
2791 | * The first arg is the IP pointer. | 2868 | * The first arg is the IP pointer. |
2792 | */ | 2869 | */ |
2793 | args = malloc_or_die(sizeof(*args)); | 2870 | args = alloc_arg(); |
2794 | arg = args; | 2871 | arg = args; |
2795 | arg->next = NULL; | 2872 | arg->next = NULL; |
2796 | next = &arg->next; | 2873 | next = &arg->next; |
@@ -2840,7 +2917,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc | |||
2840 | } | 2917 | } |
2841 | val = pevent_read_number(pevent, bptr, ls); | 2918 | val = pevent_read_number(pevent, bptr, ls); |
2842 | bptr += ls; | 2919 | bptr += ls; |
2843 | arg = malloc_or_die(sizeof(*arg)); | 2920 | arg = alloc_arg(); |
2844 | arg->next = NULL; | 2921 | arg->next = NULL; |
2845 | arg->type = PRINT_ATOM; | 2922 | arg->type = PRINT_ATOM; |
2846 | arg->atom.atom = malloc_or_die(32); | 2923 | arg->atom.atom = malloc_or_die(32); |
@@ -2849,7 +2926,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc | |||
2849 | next = &arg->next; | 2926 | next = &arg->next; |
2850 | break; | 2927 | break; |
2851 | case 's': | 2928 | case 's': |
2852 | arg = malloc_or_die(sizeof(*arg)); | 2929 | arg = alloc_arg(); |
2853 | arg->next = NULL; | 2930 | arg->next = NULL; |
2854 | arg->type = PRINT_STRING; | 2931 | arg->type = PRINT_STRING; |
2855 | arg->string.string = strdup(bptr); | 2932 | arg->string.string = strdup(bptr); |
@@ -2872,11 +2949,7 @@ static void free_args(struct print_arg *args) | |||
2872 | while (args) { | 2949 | while (args) { |
2873 | next = args->next; | 2950 | next = args->next; |
2874 | 2951 | ||
2875 | if (args->type == PRINT_ATOM) | 2952 | free_arg(args); |
2876 | free(args->atom.atom); | ||
2877 | else | ||
2878 | free(args->string.string); | ||
2879 | free(args); | ||
2880 | args = next; | 2953 | args = next; |
2881 | } | 2954 | } |
2882 | } | 2955 | } |
@@ -3646,8 +3719,7 @@ int pevent_parse_event(struct pevent *pevent, | |||
3646 | 3719 | ||
3647 | list = &event->print_fmt.args; | 3720 | list = &event->print_fmt.args; |
3648 | for (field = event->format.fields; field; field = field->next) { | 3721 | for (field = event->format.fields; field; field = field->next) { |
3649 | arg = malloc_or_die(sizeof(*arg)); | 3722 | arg = alloc_arg(); |
3650 | memset(arg, 0, sizeof(*arg)); | ||
3651 | *list = arg; | 3723 | *list = arg; |
3652 | list = &arg->next; | 3724 | list = &arg->next; |
3653 | arg->type = PRINT_FIELD; | 3725 | arg->type = PRINT_FIELD; |
@@ -3729,9 +3801,23 @@ struct pevent *pevent_alloc(void) | |||
3729 | return pevent; | 3801 | return pevent; |
3730 | } | 3802 | } |
3731 | 3803 | ||
3804 | static 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 | |||
3732 | static void free_formats(struct format *format) | 3817 | static void free_formats(struct format *format) |
3733 | { | 3818 | { |
3734 | /* IMPLEMENT ME */ | 3819 | free_format_fields(format->common_fields); |
3820 | free_format_fields(format->fields); | ||
3735 | } | 3821 | } |
3736 | 3822 | ||
3737 | static void free_event(struct event_format *event) | 3823 | static void free_event(struct event_format *event) |
@@ -3743,6 +3829,8 @@ static void free_event(struct event_format *event) | |||
3743 | 3829 | ||
3744 | free(event->print_fmt.format); | 3830 | free(event->print_fmt.format); |
3745 | free_args(event->print_fmt.args); | 3831 | free_args(event->print_fmt.args); |
3832 | |||
3833 | free(event); | ||
3746 | } | 3834 | } |
3747 | 3835 | ||
3748 | /** | 3836 | /** |
@@ -3752,13 +3840,52 @@ static void free_event(struct event_format *event) | |||
3752 | void pevent_free(struct pevent *pevent) | 3840 | void pevent_free(struct pevent *pevent) |
3753 | { | 3841 | { |
3754 | struct event_format *event, *next_event; | 3842 | struct event_format *event, *next_event; |
3843 | struct cmdline_list *cmdlist = pevent->cmdlist, *cmdnext; | ||
3844 | struct func_list *funclist = pevent->funclist, *funcnext; | ||
3845 | struct printk_list *printklist = pevent->printklist, *printknext; | ||
3846 | int i; | ||
3847 | |||
3848 | if (pevent->cmdlines) { | ||
3849 | for (i = 0; i < pevent->cmdline_count; i++) | ||
3850 | free(pevent->cmdlines[i].comm); | ||
3851 | free(pevent->cmdlines); | ||
3852 | } | ||
3853 | |||
3854 | while (cmdlist) { | ||
3855 | cmdnext = cmdlist->next; | ||
3856 | free(cmdlist->comm); | ||
3857 | free(cmdlist); | ||
3858 | cmdlist = cmdnext; | ||
3859 | } | ||
3755 | 3860 | ||
3756 | free(pevent->cmdlines); | 3861 | if (pevent->func_map) { |
3757 | free(pevent->cmdlist); | 3862 | for (i = 0; i < pevent->func_count; i++) { |
3758 | free(pevent->func_map); | 3863 | free(pevent->func_map[i].func); |
3759 | free(pevent->funclist); | 3864 | free(pevent->func_map[i].mod); |
3760 | free(pevent->printk_map); | 3865 | } |
3761 | free(pevent->printklist); | 3866 | free(pevent->func_map); |
3867 | } | ||
3868 | |||
3869 | while (funclist) { | ||
3870 | funcnext = funclist->next; | ||
3871 | free(funclist->func); | ||
3872 | free(funclist->mod); | ||
3873 | free(funclist); | ||
3874 | funclist = funcnext; | ||
3875 | } | ||
3876 | |||
3877 | if (pevent->printk_map) { | ||
3878 | for (i = 0; i < pevent->printk_count; i++) | ||
3879 | free(pevent->printk_map[i].printk); | ||
3880 | free(pevent->printk_map); | ||
3881 | } | ||
3882 | |||
3883 | while (printklist) { | ||
3884 | printknext = printklist->next; | ||
3885 | free(printklist->printk); | ||
3886 | free(printklist); | ||
3887 | printklist = printknext; | ||
3888 | } | ||
3762 | 3889 | ||
3763 | free(pevent->events); | 3890 | free(pevent->events); |
3764 | 3891 | ||
@@ -3767,4 +3894,6 @@ void pevent_free(struct pevent *pevent) | |||
3767 | 3894 | ||
3768 | free_event(event); | 3895 | free_event(event); |
3769 | } | 3896 | } |
3897 | |||
3898 | free(pevent); | ||
3770 | } | 3899 | } |
diff --git a/trace-input.c b/trace-input.c index c55e94f..72a604e 100644 --- a/trace-input.c +++ b/trace-input.c | |||
@@ -139,7 +139,7 @@ static char *read_string(struct tracecmd_input *handle) | |||
139 | str[size] = 0; | 139 | str[size] = 0; |
140 | } else { | 140 | } else { |
141 | size = i + 1; | 141 | size = i + 1; |
142 | str = malloc(i); | 142 | str = malloc(size); |
143 | if (!str) | 143 | if (!str) |
144 | return NULL; | 144 | return NULL; |
145 | memcpy(str, buf, i); | 145 | memcpy(str, buf, i); |
@@ -369,13 +369,14 @@ static int read_proc_kallsyms(struct tracecmd_input *handle) | |||
369 | if (size < 0) | 369 | if (size < 0) |
370 | return -1; | 370 | return -1; |
371 | 371 | ||
372 | buf = malloc(size); | 372 | buf = malloc(size+1); |
373 | if (!buf) | 373 | if (!buf) |
374 | return -1; | 374 | return -1; |
375 | if (do_read_check(handle, buf, size)){ | 375 | if (do_read_check(handle, buf, size)){ |
376 | free(buf); | 376 | free(buf); |
377 | return -1; | 377 | return -1; |
378 | } | 378 | } |
379 | buf[size] = 0; | ||
379 | 380 | ||
380 | parse_proc_kallsyms(pevent, buf, size); | 381 | parse_proc_kallsyms(pevent, buf, size); |
381 | 382 | ||
@@ -517,6 +518,13 @@ static void free_page(struct tracecmd_input *handle, int cpu) | |||
517 | handle->cpu_data[cpu].page = NULL; | 518 | handle->cpu_data[cpu].page = NULL; |
518 | } | 519 | } |
519 | 520 | ||
521 | static void free_read_page(struct tracecmd_input *handle, int cpu) | ||
522 | { | ||
523 | free_page(handle, cpu); | ||
524 | if (handle->read_page) | ||
525 | free(handle->cpu_data[cpu].read_page); | ||
526 | } | ||
527 | |||
520 | /* | 528 | /* |
521 | * Page is mapped, now read in the page header info. | 529 | * Page is mapped, now read in the page header info. |
522 | */ | 530 | */ |
@@ -1334,13 +1342,14 @@ int tracecmd_init_data(struct tracecmd_input *handle) | |||
1334 | size = read8(handle); | 1342 | size = read8(handle); |
1335 | if (size < 0) | 1343 | if (size < 0) |
1336 | return -1; | 1344 | return -1; |
1337 | cmdlines = malloc(size); | 1345 | cmdlines = malloc(size + 1); |
1338 | if (!cmdlines) | 1346 | if (!cmdlines) |
1339 | return -1; | 1347 | return -1; |
1340 | if (do_read_check(handle, cmdlines, size)) { | 1348 | if (do_read_check(handle, cmdlines, size)) { |
1341 | free(cmdlines); | 1349 | free(cmdlines); |
1342 | return -1; | 1350 | return -1; |
1343 | } | 1351 | } |
1352 | cmdlines[size] = 0; | ||
1344 | parse_cmdlines(pevent, cmdlines, size); | 1353 | parse_cmdlines(pevent, cmdlines, size); |
1345 | free(cmdlines); | 1354 | free(cmdlines); |
1346 | 1355 | ||
@@ -1483,8 +1492,17 @@ struct tracecmd_input *tracecmd_open(const char *file) | |||
1483 | 1492 | ||
1484 | void tracecmd_close(struct tracecmd_input *handle) | 1493 | void tracecmd_close(struct tracecmd_input *handle) |
1485 | { | 1494 | { |
1486 | /* TODO FREE EVERYTHING!!! %%%% MEMORY LEAK!!! %%%% */ | 1495 | int cpu; |
1496 | |||
1497 | if (!handle) | ||
1498 | return; | ||
1499 | |||
1500 | for (cpu = 0; cpu < handle->cpus; cpu++) | ||
1501 | free_read_page(handle, cpu); | ||
1502 | free(handle->cpu_data); | ||
1503 | |||
1487 | close(handle->fd); | 1504 | close(handle->fd); |
1505 | pevent_free(handle->pevent); | ||
1488 | free(handle); | 1506 | free(handle); |
1489 | } | 1507 | } |
1490 | 1508 | ||
diff --git a/trace-read.c b/trace-read.c index a7cac1e..f2c7de2 100644 --- a/trace-read.c +++ b/trace-read.c | |||
@@ -287,7 +287,7 @@ void trace_report (int argc, char **argv) | |||
287 | int show_endian = 0; | 287 | int show_endian = 0; |
288 | int show_page_size = 0; | 288 | int show_page_size = 0; |
289 | int show_printk = 0; | 289 | int show_printk = 0; |
290 | int latency_format; | 290 | int latency_format = 0; |
291 | int show_events = 0; | 291 | int show_events = 0; |
292 | int print_events = 0; | 292 | int print_events = 0; |
293 | int c; | 293 | int c; |
@@ -412,5 +412,7 @@ void trace_report (int argc, char **argv) | |||
412 | 412 | ||
413 | read_data_info(handle); | 413 | read_data_info(handle); |
414 | 414 | ||
415 | tracecmd_close(handle); | ||
416 | |||
415 | return; | 417 | return; |
416 | } | 418 | } |
diff --git a/trace-util.c b/trace-util.c index c3d89c6..d5be6ed 100644 --- a/trace-util.c +++ b/trace-util.c | |||
@@ -89,6 +89,7 @@ void parse_cmdlines(struct pevent *pevent, | |||
89 | sscanf(line, "%d %as", &pid, | 89 | sscanf(line, "%d %as", &pid, |
90 | (float *)(void *)&comm); /* workaround gcc warning */ | 90 | (float *)(void *)&comm); /* workaround gcc warning */ |
91 | pevent_register_comm(pevent, comm, pid); | 91 | pevent_register_comm(pevent, comm, pid); |
92 | free(comm); | ||
92 | line = strtok_r(NULL, "\n", &next); | 93 | line = strtok_r(NULL, "\n", &next); |
93 | } | 94 | } |
94 | } | 95 | } |
@@ -121,6 +122,8 @@ void parse_proc_kallsyms(struct pevent *pevent, | |||
121 | mod[strlen(mod) - 1] = 0; | 122 | mod[strlen(mod) - 1] = 0; |
122 | 123 | ||
123 | pevent_register_function(pevent, func, addr, mod); | 124 | pevent_register_function(pevent, func, addr, mod); |
125 | free(func); | ||
126 | free(mod); | ||
124 | 127 | ||
125 | line = strtok_r(NULL, "\n", &next); | 128 | line = strtok_r(NULL, "\n", &next); |
126 | } | 129 | } |