Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+154 -153
+7 -7
tools/perf/builtin-script.c
··· 317 317 318 318 output[type].print_ip_opts = 0; 319 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 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 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 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 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 574 printf("\n"); 575 575 } else { 576 576 printf(" "); 577 - if (print_opts & PRINT_IP_OPT_SRCLINE) { 577 + if (print_opts & EVSEL__PRINT_SRCLINE) { 578 578 print_srcline_last = true; 579 - print_opts &= ~PRINT_IP_OPT_SRCLINE; 579 + print_opts &= ~EVSEL__PRINT_SRCLINE; 580 580 } 581 581 } 582 582 perf_evsel__fprintf_sym(evsel, sample, al, 0, print_opts,
+3 -3
tools/perf/builtin-trace.c
··· 2119 2119 { 2120 2120 struct addr_location al; 2121 2121 /* TODO: user-configurable print_opts */ 2122 - const unsigned int print_opts = PRINT_IP_OPT_SYM | 2123 - PRINT_IP_OPT_DSO | 2124 - PRINT_IP_OPT_UNKNOWN_AS_ADDR; 2122 + const unsigned int print_opts = EVSEL__PRINT_SYM | 2123 + EVSEL__PRINT_DSO | 2124 + EVSEL__PRINT_UNKNOWN_AS_ADDR; 2125 2125 2126 2126 if (sample->callchain == NULL) 2127 2127 return 0;
+131
tools/perf/util/evsel.c
··· 2343 2343 return ++printed; 2344 2344 } 2345 2345 2346 + int 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--; 2422 + next: 2423 + callchain_cursor_advance(&callchain_cursor); 2424 + } 2425 + } 2426 + 2427 + return printed; 2428 + } 2429 + 2430 + int 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 + 2346 2477 bool perf_evsel__fallback(struct perf_evsel *evsel, int err, 2347 2478 char *msg, size_t msgsize) 2348 2479 {
+13
tools/perf/util/evsel.h
··· 387 387 int perf_evsel__fprintf(struct perf_evsel *evsel, 388 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 + 390 398 int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, 391 399 struct perf_sample *sample, 392 400 struct addr_location *al, int left_alignment, 393 401 unsigned int print_opts, 394 402 unsigned int stack_depth, FILE *fp); 403 + 404 + int 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); 395 408 396 409 bool perf_evsel__fallback(struct perf_evsel *evsel, int err, 397 410 char *msg, size_t msgsize);
-130
tools/perf/util/session.c
··· 1953 1953 return NULL; 1954 1954 } 1955 1955 1956 - int 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--; 2032 - next: 2033 - callchain_cursor_advance(&callchain_cursor); 2034 - } 2035 - } 2036 - 2037 - return printed; 2038 - } 2039 - 2040 - int 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 - 2086 1956 int perf_session__cpu_bitmap(struct perf_session *session, 2087 1957 const char *cpu_list, unsigned long *cpu_bitmap) 2088 1958 {
-13
tools/perf/util/session.h
··· 36 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 - 47 39 struct perf_tool; 48 40 49 41 struct perf_session *perf_session__new(struct perf_data_file *file, ··· 96 104 97 105 struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, 98 106 unsigned int type); 99 - 100 - int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample, 101 - struct addr_location *al, int left_alignment, 102 - unsigned int print_opts, unsigned int stack_depth, 103 - FILE *fp); 104 107 105 108 int perf_session__cpu_bitmap(struct perf_session *session, 106 109 const char *cpu_list, unsigned long *cpu_bitmap);