aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c110
1 files changed, 55 insertions, 55 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f36d24a02445..7acc03e8f3b2 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -132,18 +132,18 @@ static void perf_session__delete_threads(struct perf_session *session)
132 132
133static void perf_session_env__delete(struct perf_session_env *env) 133static void perf_session_env__delete(struct perf_session_env *env)
134{ 134{
135 free(env->hostname); 135 zfree(&env->hostname);
136 free(env->os_release); 136 zfree(&env->os_release);
137 free(env->version); 137 zfree(&env->version);
138 free(env->arch); 138 zfree(&env->arch);
139 free(env->cpu_desc); 139 zfree(&env->cpu_desc);
140 free(env->cpuid); 140 zfree(&env->cpuid);
141 141
142 free(env->cmdline); 142 zfree(&env->cmdline);
143 free(env->sibling_cores); 143 zfree(&env->sibling_cores);
144 free(env->sibling_threads); 144 zfree(&env->sibling_threads);
145 free(env->numa_nodes); 145 zfree(&env->numa_nodes);
146 free(env->pmu_mappings); 146 zfree(&env->pmu_mappings);
147} 147}
148 148
149void perf_session__delete(struct perf_session *session) 149void perf_session__delete(struct perf_session *session)
@@ -247,27 +247,6 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
247 } 247 }
248} 248}
249 249
250void mem_bswap_32(void *src, int byte_size)
251{
252 u32 *m = src;
253 while (byte_size > 0) {
254 *m = bswap_32(*m);
255 byte_size -= sizeof(u32);
256 ++m;
257 }
258}
259
260void mem_bswap_64(void *src, int byte_size)
261{
262 u64 *m = src;
263
264 while (byte_size > 0) {
265 *m = bswap_64(*m);
266 byte_size -= sizeof(u64);
267 ++m;
268 }
269}
270
271static void swap_sample_id_all(union perf_event *event, void *data) 250static void swap_sample_id_all(union perf_event *event, void *data)
272{ 251{
273 void *end = (void *) event + event->header.size; 252 void *end = (void *) event + event->header.size;
@@ -851,6 +830,7 @@ static struct machine *
851 struct perf_sample *sample) 830 struct perf_sample *sample)
852{ 831{
853 const u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 832 const u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
833 struct machine *machine;
854 834
855 if (perf_guest && 835 if (perf_guest &&
856 ((cpumode == PERF_RECORD_MISC_GUEST_KERNEL) || 836 ((cpumode == PERF_RECORD_MISC_GUEST_KERNEL) ||
@@ -863,7 +843,11 @@ static struct machine *
863 else 843 else
864 pid = sample->pid; 844 pid = sample->pid;
865 845
866 return perf_session__findnew_machine(session, pid); 846 machine = perf_session__find_machine(session, pid);
847 if (!machine)
848 machine = perf_session__findnew_machine(session,
849 DEFAULT_GUEST_KERNEL_ID);
850 return machine;
867 } 851 }
868 852
869 return &session->machines.host; 853 return &session->machines.host;
@@ -1158,7 +1142,7 @@ static int __perf_session__process_pipe_events(struct perf_session *session,
1158 void *buf = NULL; 1142 void *buf = NULL;
1159 int skip = 0; 1143 int skip = 0;
1160 u64 head; 1144 u64 head;
1161 int err; 1145 ssize_t err;
1162 void *p; 1146 void *p;
1163 1147
1164 perf_tool__fill_defaults(tool); 1148 perf_tool__fill_defaults(tool);
@@ -1400,7 +1384,7 @@ bool perf_session__has_traces(struct perf_session *session, const char *msg)
1400{ 1384{
1401 struct perf_evsel *evsel; 1385 struct perf_evsel *evsel;
1402 1386
1403 list_for_each_entry(evsel, &session->evlist->entries, node) { 1387 evlist__for_each(session->evlist, evsel) {
1404 if (evsel->attr.type == PERF_TYPE_TRACEPOINT) 1388 if (evsel->attr.type == PERF_TYPE_TRACEPOINT)
1405 return true; 1389 return true;
1406 } 1390 }
@@ -1458,7 +1442,7 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
1458 1442
1459 ret += events_stats__fprintf(&session->stats, fp); 1443 ret += events_stats__fprintf(&session->stats, fp);
1460 1444
1461 list_for_each_entry(pos, &session->evlist->entries, node) { 1445 evlist__for_each(session->evlist, pos) {
1462 ret += fprintf(fp, "%s stats:\n", perf_evsel__name(pos)); 1446 ret += fprintf(fp, "%s stats:\n", perf_evsel__name(pos));
1463 ret += events_stats__fprintf(&pos->hists.stats, fp); 1447 ret += events_stats__fprintf(&pos->hists.stats, fp);
1464 } 1448 }
@@ -1480,35 +1464,30 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
1480{ 1464{
1481 struct perf_evsel *pos; 1465 struct perf_evsel *pos;
1482 1466
1483 list_for_each_entry(pos, &session->evlist->entries, node) { 1467 evlist__for_each(session->evlist, pos) {
1484 if (pos->attr.type == type) 1468 if (pos->attr.type == type)
1485 return pos; 1469 return pos;
1486 } 1470 }
1487 return NULL; 1471 return NULL;
1488} 1472}
1489 1473
1490void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event, 1474void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
1491 struct perf_sample *sample, struct machine *machine, 1475 struct addr_location *al,
1492 unsigned int print_opts, unsigned int stack_depth) 1476 unsigned int print_opts, unsigned int stack_depth)
1493{ 1477{
1494 struct addr_location al;
1495 struct callchain_cursor_node *node; 1478 struct callchain_cursor_node *node;
1496 int print_ip = print_opts & PRINT_IP_OPT_IP; 1479 int print_ip = print_opts & PRINT_IP_OPT_IP;
1497 int print_sym = print_opts & PRINT_IP_OPT_SYM; 1480 int print_sym = print_opts & PRINT_IP_OPT_SYM;
1498 int print_dso = print_opts & PRINT_IP_OPT_DSO; 1481 int print_dso = print_opts & PRINT_IP_OPT_DSO;
1499 int print_symoffset = print_opts & PRINT_IP_OPT_SYMOFFSET; 1482 int print_symoffset = print_opts & PRINT_IP_OPT_SYMOFFSET;
1500 int print_oneline = print_opts & PRINT_IP_OPT_ONELINE; 1483 int print_oneline = print_opts & PRINT_IP_OPT_ONELINE;
1484 int print_srcline = print_opts & PRINT_IP_OPT_SRCLINE;
1501 char s = print_oneline ? ' ' : '\t'; 1485 char s = print_oneline ? ' ' : '\t';
1502 1486
1503 if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) {
1504 error("problem processing %d event, skipping it.\n",
1505 event->header.type);
1506 return;
1507 }
1508
1509 if (symbol_conf.use_callchain && sample->callchain) { 1487 if (symbol_conf.use_callchain && sample->callchain) {
1488 struct addr_location node_al;
1510 1489
1511 if (machine__resolve_callchain(machine, evsel, al.thread, 1490 if (machine__resolve_callchain(al->machine, evsel, al->thread,
1512 sample, NULL, NULL, 1491 sample, NULL, NULL,
1513 PERF_MAX_STACK_DEPTH) != 0) { 1492 PERF_MAX_STACK_DEPTH) != 0) {
1514 if (verbose) 1493 if (verbose)
@@ -1517,20 +1496,31 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
1517 } 1496 }
1518 callchain_cursor_commit(&callchain_cursor); 1497 callchain_cursor_commit(&callchain_cursor);
1519 1498
1499 if (print_symoffset)
1500 node_al = *al;
1501
1520 while (stack_depth) { 1502 while (stack_depth) {
1503 u64 addr = 0;
1504
1521 node = callchain_cursor_current(&callchain_cursor); 1505 node = callchain_cursor_current(&callchain_cursor);
1522 if (!node) 1506 if (!node)
1523 break; 1507 break;
1524 1508
1509 if (node->sym && node->sym->ignore)
1510 goto next;
1511
1525 if (print_ip) 1512 if (print_ip)
1526 printf("%c%16" PRIx64, s, node->ip); 1513 printf("%c%16" PRIx64, s, node->ip);
1527 1514
1515 if (node->map)
1516 addr = node->map->map_ip(node->map, node->ip);
1517
1528 if (print_sym) { 1518 if (print_sym) {
1529 printf(" "); 1519 printf(" ");
1530 if (print_symoffset) { 1520 if (print_symoffset) {
1531 al.addr = node->ip; 1521 node_al.addr = addr;
1532 al.map = node->map; 1522 node_al.map = node->map;
1533 symbol__fprintf_symname_offs(node->sym, &al, stdout); 1523 symbol__fprintf_symname_offs(node->sym, &node_al, stdout);
1534 } else 1524 } else
1535 symbol__fprintf_symname(node->sym, stdout); 1525 symbol__fprintf_symname(node->sym, stdout);
1536 } 1526 }
@@ -1541,32 +1531,42 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
1541 printf(")"); 1531 printf(")");
1542 } 1532 }
1543 1533
1534 if (print_srcline)
1535 map__fprintf_srcline(node->map, addr, "\n ",
1536 stdout);
1537
1544 if (!print_oneline) 1538 if (!print_oneline)
1545 printf("\n"); 1539 printf("\n");
1546 1540
1547 callchain_cursor_advance(&callchain_cursor);
1548
1549 stack_depth--; 1541 stack_depth--;
1542next:
1543 callchain_cursor_advance(&callchain_cursor);
1550 } 1544 }
1551 1545
1552 } else { 1546 } else {
1547 if (al->sym && al->sym->ignore)
1548 return;
1549
1553 if (print_ip) 1550 if (print_ip)
1554 printf("%16" PRIx64, sample->ip); 1551 printf("%16" PRIx64, sample->ip);
1555 1552
1556 if (print_sym) { 1553 if (print_sym) {
1557 printf(" "); 1554 printf(" ");
1558 if (print_symoffset) 1555 if (print_symoffset)
1559 symbol__fprintf_symname_offs(al.sym, &al, 1556 symbol__fprintf_symname_offs(al->sym, al,
1560 stdout); 1557 stdout);
1561 else 1558 else
1562 symbol__fprintf_symname(al.sym, stdout); 1559 symbol__fprintf_symname(al->sym, stdout);
1563 } 1560 }
1564 1561
1565 if (print_dso) { 1562 if (print_dso) {
1566 printf(" ("); 1563 printf(" (");
1567 map__fprintf_dsoname(al.map, stdout); 1564 map__fprintf_dsoname(al->map, stdout);
1568 printf(")"); 1565 printf(")");
1569 } 1566 }
1567
1568 if (print_srcline)
1569 map__fprintf_srcline(al->map, al->addr, "\n ", stdout);
1570 } 1570 }
1571} 1571}
1572 1572