aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-04-12 14:16:15 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-04-13 09:11:52 -0400
commite20ab86e51218f9949f41fb39a6c4f63b662f135 (patch)
tree4cad61b420c17ab788c6a34834306d484a0bd410
parent73643bb6a21c85509c7ae4c316f502c5a19cce65 (diff)
perf evsel: Move some methods from session.[ch] to evsel.[ch]
Those were converted to be evsel methods long ago, move the source to where it belongs. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Milian Wolff <milian.wolff@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-vja8rjmkw3gd5ungaeyb5s2j@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-script.c14
-rw-r--r--tools/perf/builtin-trace.c6
-rw-r--r--tools/perf/util/evsel.c131
-rw-r--r--tools/perf/util/evsel.h13
-rw-r--r--tools/perf/util/session.c130
-rw-r--r--tools/perf/util/session.h13
6 files changed, 154 insertions, 153 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index ddd5b79e94c2..838c0bc38105 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -317,19 +317,19 @@ static void set_print_ip_opts(struct perf_event_attr *attr)
317 317
318 output[type].print_ip_opts = 0; 318 output[type].print_ip_opts = 0;
319 if (PRINT_FIELD(IP)) 319 if (PRINT_FIELD(IP))
320 output[type].print_ip_opts |= PRINT_IP_OPT_IP; 320 output[type].print_ip_opts |= EVSEL__PRINT_IP;
321 321
322 if (PRINT_FIELD(SYM)) 322 if (PRINT_FIELD(SYM))
323 output[type].print_ip_opts |= PRINT_IP_OPT_SYM; 323 output[type].print_ip_opts |= EVSEL__PRINT_SYM;
324 324
325 if (PRINT_FIELD(DSO)) 325 if (PRINT_FIELD(DSO))
326 output[type].print_ip_opts |= PRINT_IP_OPT_DSO; 326 output[type].print_ip_opts |= EVSEL__PRINT_DSO;
327 327
328 if (PRINT_FIELD(SYMOFFSET)) 328 if (PRINT_FIELD(SYMOFFSET))
329 output[type].print_ip_opts |= PRINT_IP_OPT_SYMOFFSET; 329 output[type].print_ip_opts |= EVSEL__PRINT_SYMOFFSET;
330 330
331 if (PRINT_FIELD(SRCLINE)) 331 if (PRINT_FIELD(SRCLINE))
332 output[type].print_ip_opts |= PRINT_IP_OPT_SRCLINE; 332 output[type].print_ip_opts |= EVSEL__PRINT_SRCLINE;
333} 333}
334 334
335/* 335/*
@@ -574,9 +574,9 @@ static void print_sample_bts(struct perf_sample *sample,
574 printf("\n"); 574 printf("\n");
575 } else { 575 } else {
576 printf(" "); 576 printf(" ");
577 if (print_opts & PRINT_IP_OPT_SRCLINE) { 577 if (print_opts & EVSEL__PRINT_SRCLINE) {
578 print_srcline_last = true; 578 print_srcline_last = true;
579 print_opts &= ~PRINT_IP_OPT_SRCLINE; 579 print_opts &= ~EVSEL__PRINT_SRCLINE;
580 } 580 }
581 } 581 }
582 perf_evsel__fprintf_sym(evsel, sample, al, 0, print_opts, 582 perf_evsel__fprintf_sym(evsel, sample, al, 0, print_opts,
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index a6e05e1bb350..b842ddd3ad0c 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2119,9 +2119,9 @@ static int trace__fprintf_callchain(struct trace *trace, struct perf_evsel *evse
2119{ 2119{
2120 struct addr_location al; 2120 struct addr_location al;
2121 /* TODO: user-configurable print_opts */ 2121 /* TODO: user-configurable print_opts */
2122 const unsigned int print_opts = PRINT_IP_OPT_SYM | 2122 const unsigned int print_opts = EVSEL__PRINT_SYM |
2123 PRINT_IP_OPT_DSO | 2123 EVSEL__PRINT_DSO |
2124 PRINT_IP_OPT_UNKNOWN_AS_ADDR; 2124 EVSEL__PRINT_UNKNOWN_AS_ADDR;
2125 2125
2126 if (sample->callchain == NULL) 2126 if (sample->callchain == NULL)
2127 return 0; 2127 return 0;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d475a4ec8b57..6e86598682be 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2343,6 +2343,137 @@ out:
2343 return ++printed; 2343 return ++printed;
2344} 2344}
2345 2345
2346int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *sample,
2347 struct addr_location *al, int left_alignment,
2348 unsigned int print_opts, unsigned int stack_depth,
2349 FILE *fp)
2350{
2351 int printed = 0;
2352 struct callchain_cursor_node *node;
2353 int print_ip = print_opts & EVSEL__PRINT_IP;
2354 int print_sym = print_opts & EVSEL__PRINT_SYM;
2355 int print_dso = print_opts & EVSEL__PRINT_DSO;
2356 int print_symoffset = print_opts & EVSEL__PRINT_SYMOFFSET;
2357 int print_oneline = print_opts & EVSEL__PRINT_ONELINE;
2358 int print_srcline = print_opts & EVSEL__PRINT_SRCLINE;
2359 int print_unknown_as_addr = print_opts & EVSEL__PRINT_UNKNOWN_AS_ADDR;
2360 char s = print_oneline ? ' ' : '\t';
2361
2362 if (sample->callchain) {
2363 struct addr_location node_al;
2364
2365 if (thread__resolve_callchain(al->thread, evsel,
2366 sample, NULL, NULL,
2367 stack_depth) != 0) {
2368 if (verbose)
2369 error("Failed to resolve callchain. Skipping\n");
2370 return printed;
2371 }
2372 callchain_cursor_commit(&callchain_cursor);
2373
2374 if (print_symoffset)
2375 node_al = *al;
2376
2377 while (stack_depth) {
2378 u64 addr = 0;
2379
2380 node = callchain_cursor_current(&callchain_cursor);
2381 if (!node)
2382 break;
2383
2384 if (node->sym && node->sym->ignore)
2385 goto next;
2386
2387 printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
2388
2389 if (print_ip)
2390 printed += fprintf(fp, "%c%16" PRIx64, s, node->ip);
2391
2392 if (node->map)
2393 addr = node->map->map_ip(node->map, node->ip);
2394
2395 if (print_sym) {
2396 printed += fprintf(fp, " ");
2397 node_al.addr = addr;
2398 node_al.map = node->map;
2399
2400 if (print_symoffset) {
2401 printed += __symbol__fprintf_symname_offs(node->sym, &node_al,
2402 print_unknown_as_addr, fp);
2403 } else {
2404 printed += __symbol__fprintf_symname(node->sym, &node_al,
2405 print_unknown_as_addr, fp);
2406 }
2407 }
2408
2409 if (print_dso) {
2410 printed += fprintf(fp, " (");
2411 printed += map__fprintf_dsoname(node->map, fp);
2412 printed += fprintf(fp, ")");
2413 }
2414
2415 if (print_srcline)
2416 printed += map__fprintf_srcline(node->map, addr, "\n ", fp);
2417
2418 if (!print_oneline)
2419 printed += fprintf(fp, "\n");
2420
2421 stack_depth--;
2422next:
2423 callchain_cursor_advance(&callchain_cursor);
2424 }
2425 }
2426
2427 return printed;
2428}
2429
2430int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample,
2431 struct addr_location *al, int left_alignment,
2432 unsigned int print_opts, unsigned int stack_depth,
2433 FILE *fp)
2434{
2435 int printed = 0;
2436 int print_ip = print_opts & EVSEL__PRINT_IP;
2437 int print_sym = print_opts & EVSEL__PRINT_SYM;
2438 int print_dso = print_opts & EVSEL__PRINT_DSO;
2439 int print_symoffset = print_opts & EVSEL__PRINT_SYMOFFSET;
2440 int print_srcline = print_opts & EVSEL__PRINT_SRCLINE;
2441 int print_unknown_as_addr = print_opts & EVSEL__PRINT_UNKNOWN_AS_ADDR;
2442
2443 if (symbol_conf.use_callchain && sample->callchain) {
2444 printed += perf_evsel__fprintf_callchain(evsel, sample, al, left_alignment,
2445 print_opts, stack_depth, fp);
2446 } else if (!(al->sym && al->sym->ignore)) {
2447 printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
2448
2449 if (print_ip)
2450 printed += fprintf(fp, "%16" PRIx64, sample->ip);
2451
2452 if (print_sym) {
2453 printed += fprintf(fp, " ");
2454 if (print_symoffset) {
2455 printed += __symbol__fprintf_symname_offs(al->sym, al,
2456 print_unknown_as_addr, fp);
2457 } else {
2458 printed += __symbol__fprintf_symname(al->sym, al,
2459 print_unknown_as_addr, fp);
2460 }
2461 }
2462
2463 if (print_dso) {
2464 printed += fprintf(fp, " (");
2465 printed += map__fprintf_dsoname(al->map, fp);
2466 printed += fprintf(fp, ")");
2467 }
2468
2469 if (print_srcline)
2470 printed += map__fprintf_srcline(al->map, al->addr, "\n ", fp);
2471 }
2472
2473 return printed;
2474}
2475
2476
2346bool perf_evsel__fallback(struct perf_evsel *evsel, int err, 2477bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
2347 char *msg, size_t msgsize) 2478 char *msg, size_t msgsize)
2348{ 2479{
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 1bd6c2e02dfa..36edd3c91d5c 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -387,12 +387,25 @@ struct perf_attr_details {
387int perf_evsel__fprintf(struct perf_evsel *evsel, 387int perf_evsel__fprintf(struct perf_evsel *evsel,
388 struct perf_attr_details *details, FILE *fp); 388 struct perf_attr_details *details, FILE *fp);
389 389
390#define EVSEL__PRINT_IP (1<<0)
391#define EVSEL__PRINT_SYM (1<<1)
392#define EVSEL__PRINT_DSO (1<<2)
393#define EVSEL__PRINT_SYMOFFSET (1<<3)
394#define EVSEL__PRINT_ONELINE (1<<4)
395#define EVSEL__PRINT_SRCLINE (1<<5)
396#define EVSEL__PRINT_UNKNOWN_AS_ADDR (1<<6)
397
390int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, 398int perf_evsel__fprintf_callchain(struct perf_evsel *evsel,
391 struct perf_sample *sample, 399 struct perf_sample *sample,
392 struct addr_location *al, int left_alignment, 400 struct addr_location *al, int left_alignment,
393 unsigned int print_opts, 401 unsigned int print_opts,
394 unsigned int stack_depth, FILE *fp); 402 unsigned int stack_depth, FILE *fp);
395 403
404int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample,
405 struct addr_location *al, int left_alignment,
406 unsigned int print_opts, unsigned int stack_depth,
407 FILE *fp);
408
396bool perf_evsel__fallback(struct perf_evsel *evsel, int err, 409bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
397 char *msg, size_t msgsize); 410 char *msg, size_t msgsize);
398int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target, 411int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 0516d06a2741..91d4528d71fa 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1953,136 +1953,6 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
1953 return NULL; 1953 return NULL;
1954} 1954}
1955 1955
1956int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *sample,
1957 struct addr_location *al, int left_alignment,
1958 unsigned int print_opts, unsigned int stack_depth,
1959 FILE *fp)
1960{
1961 int printed = 0;
1962 struct callchain_cursor_node *node;
1963 int print_ip = print_opts & PRINT_IP_OPT_IP;
1964 int print_sym = print_opts & PRINT_IP_OPT_SYM;
1965 int print_dso = print_opts & PRINT_IP_OPT_DSO;
1966 int print_symoffset = print_opts & PRINT_IP_OPT_SYMOFFSET;
1967 int print_oneline = print_opts & PRINT_IP_OPT_ONELINE;
1968 int print_srcline = print_opts & PRINT_IP_OPT_SRCLINE;
1969 int print_unknown_as_addr = print_opts & PRINT_IP_OPT_UNKNOWN_AS_ADDR;
1970 char s = print_oneline ? ' ' : '\t';
1971
1972 if (sample->callchain) {
1973 struct addr_location node_al;
1974
1975 if (thread__resolve_callchain(al->thread, evsel,
1976 sample, NULL, NULL,
1977 stack_depth) != 0) {
1978 if (verbose)
1979 error("Failed to resolve callchain. Skipping\n");
1980 return printed;
1981 }
1982 callchain_cursor_commit(&callchain_cursor);
1983
1984 if (print_symoffset)
1985 node_al = *al;
1986
1987 while (stack_depth) {
1988 u64 addr = 0;
1989
1990 node = callchain_cursor_current(&callchain_cursor);
1991 if (!node)
1992 break;
1993
1994 if (node->sym && node->sym->ignore)
1995 goto next;
1996
1997 printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
1998
1999 if (print_ip)
2000 printed += fprintf(fp, "%c%16" PRIx64, s, node->ip);
2001
2002 if (node->map)
2003 addr = node->map->map_ip(node->map, node->ip);
2004
2005 if (print_sym) {
2006 printed += fprintf(fp, " ");
2007 node_al.addr = addr;
2008 node_al.map = node->map;
2009
2010 if (print_symoffset) {
2011 printed += __symbol__fprintf_symname_offs(node->sym, &node_al,
2012 print_unknown_as_addr, fp);
2013 } else {
2014 printed += __symbol__fprintf_symname(node->sym, &node_al,
2015 print_unknown_as_addr, fp);
2016 }
2017 }
2018
2019 if (print_dso) {
2020 printed += fprintf(fp, " (");
2021 printed += map__fprintf_dsoname(node->map, fp);
2022 printed += fprintf(fp, ")");
2023 }
2024
2025 if (print_srcline)
2026 printed += map__fprintf_srcline(node->map, addr, "\n ", fp);
2027
2028 if (!print_oneline)
2029 printed += fprintf(fp, "\n");
2030
2031 stack_depth--;
2032next:
2033 callchain_cursor_advance(&callchain_cursor);
2034 }
2035 }
2036
2037 return printed;
2038}
2039
2040int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample,
2041 struct addr_location *al, int left_alignment,
2042 unsigned int print_opts, unsigned int stack_depth,
2043 FILE *fp)
2044{
2045 int printed = 0;
2046 int print_ip = print_opts & PRINT_IP_OPT_IP;
2047 int print_sym = print_opts & PRINT_IP_OPT_SYM;
2048 int print_dso = print_opts & PRINT_IP_OPT_DSO;
2049 int print_symoffset = print_opts & PRINT_IP_OPT_SYMOFFSET;
2050 int print_srcline = print_opts & PRINT_IP_OPT_SRCLINE;
2051 int print_unknown_as_addr = print_opts & PRINT_IP_OPT_UNKNOWN_AS_ADDR;
2052
2053 if (symbol_conf.use_callchain && sample->callchain) {
2054 printed += perf_evsel__fprintf_callchain(evsel, sample, al, left_alignment,
2055 print_opts, stack_depth, fp);
2056 } else if (!(al->sym && al->sym->ignore)) {
2057 printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
2058
2059 if (print_ip)
2060 printed += fprintf(fp, "%16" PRIx64, sample->ip);
2061
2062 if (print_sym) {
2063 printed += fprintf(fp, " ");
2064 if (print_symoffset) {
2065 printed += __symbol__fprintf_symname_offs(al->sym, al,
2066 print_unknown_as_addr, fp);
2067 } else {
2068 printed += __symbol__fprintf_symname(al->sym, al,
2069 print_unknown_as_addr, fp);
2070 }
2071 }
2072
2073 if (print_dso) {
2074 printed += fprintf(fp, " (");
2075 printed += map__fprintf_dsoname(al->map, fp);
2076 printed += fprintf(fp, ")");
2077 }
2078
2079 if (print_srcline)
2080 printed += map__fprintf_srcline(al->map, al->addr, "\n ", fp);
2081 }
2082
2083 return printed;
2084}
2085
2086int perf_session__cpu_bitmap(struct perf_session *session, 1956int perf_session__cpu_bitmap(struct perf_session *session,
2087 const char *cpu_list, unsigned long *cpu_bitmap) 1957 const char *cpu_list, unsigned long *cpu_bitmap)
2088{ 1958{
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 4257fac56618..4bd758553450 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -36,14 +36,6 @@ struct perf_session {
36 struct perf_tool *tool; 36 struct perf_tool *tool;
37}; 37};
38 38
39#define PRINT_IP_OPT_IP (1<<0)
40#define PRINT_IP_OPT_SYM (1<<1)
41#define PRINT_IP_OPT_DSO (1<<2)
42#define PRINT_IP_OPT_SYMOFFSET (1<<3)
43#define PRINT_IP_OPT_ONELINE (1<<4)
44#define PRINT_IP_OPT_SRCLINE (1<<5)
45#define PRINT_IP_OPT_UNKNOWN_AS_ADDR (1<<6)
46
47struct perf_tool; 39struct perf_tool;
48 40
49struct perf_session *perf_session__new(struct perf_data_file *file, 41struct perf_session *perf_session__new(struct perf_data_file *file,
@@ -105,11 +97,6 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp);
105struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, 97struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
106 unsigned int type); 98 unsigned int type);
107 99
108int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample,
109 struct addr_location *al, int left_alignment,
110 unsigned int print_opts, unsigned int stack_depth,
111 FILE *fp);
112
113int perf_session__cpu_bitmap(struct perf_session *session, 100int perf_session__cpu_bitmap(struct perf_session *session,
114 const char *cpu_list, unsigned long *cpu_bitmap); 101 const char *cpu_list, unsigned long *cpu_bitmap);
115 102