2009-04-20 21:00:56 +08:00
|
|
|
#ifndef GIT_COMPAT_UTIL_H
|
|
|
|
#define GIT_COMPAT_UTIL_H
|
|
|
|
|
|
|
|
#ifndef FLEX_ARRAY
|
|
|
|
/*
|
|
|
|
* See if our compiler is known to support flexible array members.
|
|
|
|
*/
|
|
|
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
|
|
|
# define FLEX_ARRAY /* empty */
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
# if (__GNUC__ >= 3)
|
|
|
|
# define FLEX_ARRAY /* empty */
|
|
|
|
# else
|
|
|
|
# define FLEX_ARRAY 0 /* older GNU extension */
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Otherwise, default to safer but a bit wasteful traditional style
|
|
|
|
*/
|
|
|
|
#ifndef FLEX_ARRAY
|
|
|
|
# define FLEX_ARRAY 1
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define TYPEOF(x) (__typeof__(x))
|
|
|
|
#else
|
|
|
|
#define TYPEOF(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits))))
|
|
|
|
#define HAS_MULTI_BITS(i) ((i) & ((i) - 1)) /* checks if an integer has more than 1 bit set */
|
|
|
|
|
|
|
|
/* Approximation of the length of the decimal representation of this type. */
|
|
|
|
#define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)
|
|
|
|
|
|
|
|
#define _ALL_SOURCE 1
|
|
|
|
#define _BSD_SOURCE 1
|
2014-09-12 10:10:17 +08:00
|
|
|
/* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */
|
|
|
|
#define _DEFAULT_SOURCE 1
|
2010-04-03 21:19:26 +08:00
|
|
|
#define HAS_BOOL
|
2009-04-20 21:00:56 +08:00
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/stat.h>
|
2009-07-22 00:20:22 +08:00
|
|
|
#include <sys/statfs.h>
|
2009-04-20 21:00:56 +08:00
|
|
|
#include <fcntl.h>
|
2010-04-03 21:19:26 +08:00
|
|
|
#include <stdbool.h>
|
2009-04-20 21:00:56 +08:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
2015-12-08 12:21:42 +08:00
|
|
|
#include <term.h>
|
2009-04-20 21:00:56 +08:00
|
|
|
#include <errno.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <fnmatch.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <regex.h>
|
|
|
|
#include <utime.h>
|
|
|
|
#include <sys/wait.h>
|
2014-09-16 02:54:34 +08:00
|
|
|
#include <poll.h>
|
2009-04-20 21:00:56 +08:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <inttypes.h>
|
2014-07-29 21:21:58 +08:00
|
|
|
#include <linux/kernel.h>
|
2012-09-11 06:14:58 +08:00
|
|
|
#include <linux/magic.h>
|
2014-04-26 03:31:02 +08:00
|
|
|
#include <linux/types.h>
|
2010-05-22 22:25:40 +08:00
|
|
|
#include <sys/ttydefaults.h>
|
2015-09-02 15:56:43 +08:00
|
|
|
#include <api/fs/tracing_path.h>
|
2013-06-19 09:02:30 +08:00
|
|
|
#include <termios.h>
|
2013-12-09 21:18:39 +08:00
|
|
|
#include <linux/bitops.h>
|
2014-08-11 16:50:02 +08:00
|
|
|
#include <termios.h>
|
2009-08-12 16:19:53 +08:00
|
|
|
|
2009-11-24 03:51:08 +08:00
|
|
|
extern const char *graph_line;
|
|
|
|
extern const char *graph_dotted_line;
|
2016-02-24 23:13:42 +08:00
|
|
|
extern const char *spaces;
|
|
|
|
extern const char *dots;
|
perf buildid: add perfconfig option to specify buildid cache dir
This patch adds the ability to specify an alternate directory to store the
buildid cache (buildids, copy of binaries). By default, it is hardcoded to
$HOME/.debug. This directory contains immutable data. The layout of the
directory is such that no conflicts in filenames are possible. A modification
in a file, yields a different buildid and thus a different location in the
subdir hierarchy.
You may want to put the buildid cache elsewhere because of disk space
limitation or simply to share the cache between users. It is also useful for
remote collect vs. local analysis of profiles.
This patch adds a new config option to the perfconfig file. Under the tag
'buildid', there is a dir option. For instance, if you have:
$ cat /etc/perfconfig
[buildid]
dir = /var/cache/perf-buildid
All buildids and binaries are be saved in the directory specified. The perf
record, buildid-list, buildid-cache, report, annotate, and archive commands
will it to pull information out.
The option can be set in the system-wide perfconfig file or in the
$HOME/.perfconfig file.
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <4c055fb7.df0ce30a.5f0d.ffffae52@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-06-02 03:25:01 +08:00
|
|
|
extern char buildid_dir[];
|
2009-11-24 03:51:08 +08:00
|
|
|
|
2009-04-20 21:00:56 +08:00
|
|
|
/* On most systems <limits.h> would have given us this, but
|
|
|
|
* not on some systems (e.g. GNU/Hurd).
|
|
|
|
*/
|
|
|
|
#ifndef PATH_MAX
|
|
|
|
#define PATH_MAX 4096
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PRIuMAX
|
|
|
|
#define PRIuMAX "llu"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PRIu32
|
|
|
|
#define PRIu32 "u"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PRIx32
|
|
|
|
#define PRIx32 "x"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PATH_SEP
|
|
|
|
#define PATH_SEP ':'
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef STRIP_EXTENSION
|
|
|
|
#define STRIP_EXTENSION ""
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef has_dos_drive_prefix
|
|
|
|
#define has_dos_drive_prefix(path) 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef is_dir_sep
|
|
|
|
#define is_dir_sep(c) ((c) == '/')
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define NORETURN __attribute__((__noreturn__))
|
|
|
|
#else
|
|
|
|
#define NORETURN
|
|
|
|
#ifndef __attribute__
|
|
|
|
#define __attribute__(x)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2013-09-13 14:27:43 +08:00
|
|
|
#define PERF_GTK_DSO "libperf-gtk.so"
|
|
|
|
|
2009-04-20 21:00:56 +08:00
|
|
|
/* General helper functions */
|
2016-03-24 02:06:35 +08:00
|
|
|
void usage(const char *err) NORETURN;
|
|
|
|
void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
|
|
|
|
int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
|
|
|
|
void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
|
2009-04-20 21:00:56 +08:00
|
|
|
|
2016-03-24 02:06:35 +08:00
|
|
|
void set_warning_routine(void (*routine)(const char *err, va_list params));
|
2009-04-20 21:00:56 +08:00
|
|
|
|
2016-03-24 02:06:35 +08:00
|
|
|
int prefixcmp(const char *str, const char *prefix);
|
|
|
|
void set_buildid_dir(const char *dir);
|
2009-04-20 21:00:56 +08:00
|
|
|
|
|
|
|
#ifdef __GLIBC_PREREQ
|
|
|
|
#if __GLIBC_PREREQ(2, 1)
|
|
|
|
#define HAVE_STRCHRNUL
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_STRCHRNUL
|
|
|
|
#define strchrnul gitstrchrnul
|
|
|
|
static inline char *gitstrchrnul(const char *s, int c)
|
|
|
|
{
|
|
|
|
while (*s && *s != c)
|
|
|
|
s++;
|
|
|
|
return (char *)s;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-20 21:22:22 +08:00
|
|
|
/*
|
|
|
|
* Wrappers:
|
|
|
|
*/
|
2016-03-24 02:06:35 +08:00
|
|
|
void *xrealloc(void *ptr, size_t size) __attribute__((weak));
|
2009-05-27 15:10:38 +08:00
|
|
|
|
2010-03-17 06:05:21 +08:00
|
|
|
|
2009-11-24 22:05:16 +08:00
|
|
|
static inline void *zalloc(size_t size)
|
|
|
|
{
|
|
|
|
return calloc(1, size);
|
|
|
|
}
|
|
|
|
|
2013-12-27 04:41:15 +08:00
|
|
|
#define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
|
|
|
|
|
2009-04-20 21:00:56 +08:00
|
|
|
/* Sane ctype - no locale, and works with signed chars */
|
|
|
|
#undef isascii
|
|
|
|
#undef isspace
|
|
|
|
#undef isdigit
|
2009-11-11 11:51:07 +08:00
|
|
|
#undef isxdigit
|
2009-04-20 21:00:56 +08:00
|
|
|
#undef isalpha
|
2009-08-17 22:18:08 +08:00
|
|
|
#undef isprint
|
2009-04-20 21:00:56 +08:00
|
|
|
#undef isalnum
|
2012-02-10 09:10:15 +08:00
|
|
|
#undef islower
|
|
|
|
#undef isupper
|
2009-04-20 21:00:56 +08:00
|
|
|
#undef tolower
|
|
|
|
#undef toupper
|
2010-03-17 06:05:21 +08:00
|
|
|
|
perf trace: Support interrupted syscalls
Using the same strategies as in the tmp.perf/trace2, i.e. the 'trace'
tool implemented by tglx, just updated to the current codebase.
Example:
[root@sandy linux]# perf trace usleep 1 | tail
2.003: mmap(addr: 0, len: 4096, prot: 3, flags: 34, fd: 4294967295, off: 0 ) = -2128396288
2.017: mmap(addr: 0, len: 4096, prot: 3, flags: 34, fd: 4294967295, off: 0 ) = -2128400384
2.029: arch_prctl(option: 4098, arg2: 140146949441280, arg3: 140146949435392, arg4: 34, arg5: 4294967295) = 0
2.084: mprotect(start: 208741634048, len: 16384, prot: 1 ) = 0
2.098: mprotect(start: 208735956992, len: 4096, prot: 1 ) = 0
2.122: munmap(addr: 140146949447680, len: 91882 ) = 0
2.359: brk(brk: 0 ) = 28987392
2.371: brk(brk: 29122560 ) = 29122560
2.490: nanosleep(rqtp: 140735694241504, rmtp: 0 ) = 0
2.507: exit_group(error_code: 0
[root@sandy linux]#
For now the timestamp and duration are always on, will be selectable.
Also if multiple threads are being monitored, its tid will appear.
The ret output continues to be interpreted a la strace.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-ly9ulroru4my5isn0xe9gr0m@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2012-10-07 05:43:19 +08:00
|
|
|
#ifndef NSEC_PER_MSEC
|
|
|
|
#define NSEC_PER_MSEC 1000000L
|
|
|
|
#endif
|
|
|
|
|
2013-06-04 09:50:29 +08:00
|
|
|
int parse_nsec_time(const char *str, u64 *ptime);
|
|
|
|
|
2009-04-20 21:00:56 +08:00
|
|
|
extern unsigned char sane_ctype[256];
|
2009-06-18 15:44:20 +08:00
|
|
|
#define GIT_SPACE 0x01
|
|
|
|
#define GIT_DIGIT 0x02
|
|
|
|
#define GIT_ALPHA 0x04
|
|
|
|
#define GIT_GLOB_SPECIAL 0x08
|
|
|
|
#define GIT_REGEX_SPECIAL 0x10
|
|
|
|
#define GIT_PRINT_EXTRA 0x20
|
|
|
|
#define GIT_PRINT 0x3E
|
2009-04-20 21:00:56 +08:00
|
|
|
#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
|
|
|
|
#define isascii(x) (((x) & ~0x7f) == 0)
|
|
|
|
#define isspace(x) sane_istest(x,GIT_SPACE)
|
|
|
|
#define isdigit(x) sane_istest(x,GIT_DIGIT)
|
2009-11-11 11:51:07 +08:00
|
|
|
#define isxdigit(x) \
|
|
|
|
(sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G')
|
2009-04-20 21:00:56 +08:00
|
|
|
#define isalpha(x) sane_istest(x,GIT_ALPHA)
|
|
|
|
#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
|
2009-06-18 15:44:20 +08:00
|
|
|
#define isprint(x) sane_istest(x,GIT_PRINT)
|
2013-03-30 03:14:43 +08:00
|
|
|
#define islower(x) (sane_istest(x,GIT_ALPHA) && (x & 0x20))
|
|
|
|
#define isupper(x) (sane_istest(x,GIT_ALPHA) && !(x & 0x20))
|
2009-04-20 21:00:56 +08:00
|
|
|
#define tolower(x) sane_case((unsigned char)(x), 0x20)
|
|
|
|
#define toupper(x) sane_case((unsigned char)(x), 0)
|
|
|
|
|
|
|
|
static inline int sane_case(int x, int high)
|
|
|
|
{
|
|
|
|
if (sane_istest(x, GIT_ALPHA))
|
|
|
|
x = (x & ~0x20) | high;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
perf record: Introduce a symtab cache
Now a cache will be created in a ~/.debug debuginfo like
hierarchy, so that at the end of a 'perf record' session all the
binaries (with build-ids) involved get collected and indexed by
their build-ids, so that perf report can find them.
This is interesting when developing software where you want to
do a 'perf diff' with the previous build and opens avenues for
lots more interesting tools, like a 'perf diff --graph' that
takes more than two binaries into account.
Tunables for collecting just the symtabs can be added if one
doesn't want to have the full binary, but having the full binary
allows things like 'perf rerecord' or other tools that can
re-run the tests by having access to the exact binary in some
perf.data file, so it may well be interesting to keep the full
binary there.
Space consumption is minimised by trying to use hard links, a
'perf cache' tool to manage the space used, a la ccache is
required to purge older entries.
With this in place it will be possible also to introduce new
commands, 'perf archive' and 'perf restore' (or some more
suitable and future proof names) to create a cpio/tar file with
the perf data and the files in the cache that _had_ perf hits of
interest.
There are more aspects to polish, like finding the right vmlinux
file to cache, etc, but this is enough for a first step.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1261957026-15580-10-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-12-28 07:37:06 +08:00
|
|
|
int mkdir_p(char *path, mode_t mode);
|
2015-05-18 08:30:17 +08:00
|
|
|
int rm_rf(char *path);
|
perf record: Introduce a symtab cache
Now a cache will be created in a ~/.debug debuginfo like
hierarchy, so that at the end of a 'perf record' session all the
binaries (with build-ids) involved get collected and indexed by
their build-ids, so that perf report can find them.
This is interesting when developing software where you want to
do a 'perf diff' with the previous build and opens avenues for
lots more interesting tools, like a 'perf diff --graph' that
takes more than two binaries into account.
Tunables for collecting just the symtabs can be added if one
doesn't want to have the full binary, but having the full binary
allows things like 'perf rerecord' or other tools that can
re-run the tests by having access to the exact binary in some
perf.data file, so it may well be interesting to keep the full
binary there.
Space consumption is minimised by trying to use hard links, a
'perf cache' tool to manage the space used, a la ccache is
required to purge older entries.
With this in place it will be possible also to introduce new
commands, 'perf archive' and 'perf restore' (or some more
suitable and future proof names) to create a cpio/tar file with
the perf data and the files in the cache that _had_ perf hits of
interest.
There are more aspects to polish, like finding the right vmlinux
file to cache, etc, but this is enough for a first step.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1261957026-15580-10-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-12-28 07:37:06 +08:00
|
|
|
int copyfile(const char *from, const char *to);
|
2013-10-14 18:43:41 +08:00
|
|
|
int copyfile_mode(const char *from, const char *to, mode_t mode);
|
2015-05-18 08:30:18 +08:00
|
|
|
int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size);
|
perf record: Introduce a symtab cache
Now a cache will be created in a ~/.debug debuginfo like
hierarchy, so that at the end of a 'perf record' session all the
binaries (with build-ids) involved get collected and indexed by
their build-ids, so that perf report can find them.
This is interesting when developing software where you want to
do a 'perf diff' with the previous build and opens avenues for
lots more interesting tools, like a 'perf diff --graph' that
takes more than two binaries into account.
Tunables for collecting just the symtabs can be added if one
doesn't want to have the full binary, but having the full binary
allows things like 'perf rerecord' or other tools that can
re-run the tests by having access to the exact binary in some
perf.data file, so it may well be interesting to keep the full
binary there.
Space consumption is minimised by trying to use hard links, a
'perf cache' tool to manage the space used, a la ccache is
required to purge older entries.
With this in place it will be possible also to introduce new
commands, 'perf archive' and 'perf restore' (or some more
suitable and future proof names) to create a cpio/tar file with
the perf data and the files in the cache that _had_ perf hits of
interest.
There are more aspects to polish, like finding the right vmlinux
file to cache, etc, but this is enough for a first step.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1261957026-15580-10-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-12-28 07:37:06 +08:00
|
|
|
|
2010-04-03 21:19:26 +08:00
|
|
|
s64 perf_atoll(const char *str);
|
|
|
|
char **argv_split(const char *str, int *argcp);
|
|
|
|
void argv_free(char **argv);
|
|
|
|
bool strglobmatch(const char *str, const char *pat);
|
|
|
|
bool strlazymatch(const char *str, const char *pat);
|
2015-05-08 09:03:35 +08:00
|
|
|
static inline bool strisglob(const char *str)
|
|
|
|
{
|
|
|
|
return strpbrk(str, "*?[") != NULL;
|
|
|
|
}
|
2011-06-27 15:27:15 +08:00
|
|
|
int strtailcmp(const char *s1, const char *s2);
|
2012-10-28 05:18:31 +08:00
|
|
|
char *strxfrchar(char *s, char from, char to);
|
2010-05-15 01:19:35 +08:00
|
|
|
unsigned long convert_unit(unsigned long value, char *unit);
|
2013-11-28 18:30:14 +08:00
|
|
|
ssize_t readn(int fd, void *buf, size_t n);
|
2013-11-28 18:30:16 +08:00
|
|
|
ssize_t writen(int fd, void *buf, size_t n);
|
2010-04-03 21:19:26 +08:00
|
|
|
|
2012-01-05 00:54:20 +08:00
|
|
|
struct perf_event_attr;
|
|
|
|
|
|
|
|
void event_attr_init(struct perf_event_attr *attr);
|
|
|
|
|
2010-04-03 21:19:26 +08:00
|
|
|
#define _STR(x) #x
|
|
|
|
#define STR(x) _STR(x)
|
|
|
|
|
2012-04-20 00:15:24 +08:00
|
|
|
size_t hex_width(u64 v);
|
2012-10-28 05:18:30 +08:00
|
|
|
int hex2u64(const char *ptr, u64 *val);
|
2012-04-20 00:15:24 +08:00
|
|
|
|
2013-01-22 17:09:41 +08:00
|
|
|
char *ltrim(char *s);
|
2012-06-08 05:23:31 +08:00
|
|
|
char *rtrim(char *s);
|
|
|
|
|
2016-04-07 15:11:11 +08:00
|
|
|
static inline char *trim(char *s)
|
|
|
|
{
|
|
|
|
return ltrim(rtrim(s));
|
|
|
|
}
|
|
|
|
|
2012-08-08 10:32:05 +08:00
|
|
|
void dump_stack(void);
|
2015-02-25 02:34:23 +08:00
|
|
|
void sighandler_dump_stack(int sig);
|
2012-08-08 10:32:05 +08:00
|
|
|
|
2012-10-07 01:57:10 +08:00
|
|
|
extern unsigned int page_size;
|
2014-05-31 04:10:05 +08:00
|
|
|
extern int cacheline_size;
|
2012-10-07 01:57:10 +08:00
|
|
|
|
2013-09-01 18:36:13 +08:00
|
|
|
struct parse_tag {
|
|
|
|
char tag;
|
|
|
|
int mult;
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned long parse_tag_value(const char *str, struct parse_tag *tags);
|
2013-09-11 13:09:28 +08:00
|
|
|
|
|
|
|
#define SRCLINE_UNKNOWN ((char *) "??:0")
|
|
|
|
|
2014-07-29 21:21:58 +08:00
|
|
|
static inline int path__join(char *bf, size_t size,
|
|
|
|
const char *path1, const char *path2)
|
|
|
|
{
|
|
|
|
return scnprintf(bf, size, "%s%s%s", path1, path1[0] ? "/" : "", path2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int path__join3(char *bf, size_t size,
|
|
|
|
const char *path1, const char *path2,
|
|
|
|
const char *path3)
|
|
|
|
{
|
|
|
|
return scnprintf(bf, size, "%s%s%s%s%s",
|
|
|
|
path1, path1[0] ? "/" : "",
|
|
|
|
path2, path2[0] ? "/" : "", path3);
|
|
|
|
}
|
|
|
|
|
2013-09-11 13:09:30 +08:00
|
|
|
struct dso;
|
2014-11-13 10:05:27 +08:00
|
|
|
struct symbol;
|
2013-09-11 13:09:30 +08:00
|
|
|
|
2015-08-08 06:24:05 +08:00
|
|
|
extern bool srcline_full_filename;
|
2014-12-16 14:19:06 +08:00
|
|
|
char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
|
2014-11-13 10:05:27 +08:00
|
|
|
bool show_sym);
|
2015-09-02 02:47:19 +08:00
|
|
|
char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
|
|
|
|
bool show_sym, bool unwind_inlines);
|
2013-09-11 13:09:28 +08:00
|
|
|
void free_srcline(char *srcline);
|
2013-10-18 03:33:43 +08:00
|
|
|
|
2013-12-11 20:36:23 +08:00
|
|
|
int perf_event_paranoid(void);
|
2013-12-07 06:25:51 +08:00
|
|
|
|
2013-12-11 20:36:32 +08:00
|
|
|
void mem_bswap_64(void *src, int byte_size);
|
|
|
|
void mem_bswap_32(void *src, int byte_size);
|
|
|
|
|
2013-12-07 06:25:51 +08:00
|
|
|
const char *get_filename_for_perf_kvm(void);
|
2014-08-01 23:46:54 +08:00
|
|
|
bool find_process(const char *name);
|
perf tools: Add gzip decompression support for kernel module
Now my Archlinux box shows module symbols correctly.
Before:
$ perf report --stdio
Failed to open /tmp/perf-3477.map, continuing without symbols
no symbols found in /usr/bin/date, maybe install a debug package?
No kallsyms or vmlinux with build-id 7b4ea0a49ae2111925857099aaf05c3246ff33e0 was found
[drm] with build id 7b4ea0a49ae2111925857099aaf05c3246ff33e0 not found, continuing without symbols
No kallsyms or vmlinux with build-id edd931629094b660ca9dec09a1b635c8d87aa2ee was found
[jbd2] with build id edd931629094b660ca9dec09a1b635c8d87aa2ee not found, continuing without symbols
No kallsyms or vmlinux with build-id a7b1eada671c34933e5610bb920b2ca4945a82c3 was found
[ext4] with build id a7b1eada671c34933e5610bb920b2ca4945a82c3 not found, continuing without symbols
No kallsyms or vmlinux with build-id d69511fa3e5840e770336ef45b06c83fef8d74e3 was found
[scsi_mod] with build id d69511fa3e5840e770336ef45b06c83fef8d74e3 not found, continuing without symbols
No kallsyms or vmlinux with build-id af0430af13461af058770ee9b87afc07922c2e77 was found
[libata] with build id af0430af13461af058770ee9b87afc07922c2e77 not found, continuing without symbols
No kallsyms or vmlinux with build-id aaeedff8160ce631a5f0333591c6ff291201d29f was found
[libahci] with build id aaeedff8160ce631a5f0333591c6ff291201d29f not found, continuing without symbols
No kallsyms or vmlinux with build-id c57907712becaf662dc4981824bb372c0441d605 was found
[mac80211] with build id c57907712becaf662dc4981824bb372c0441d605 not found, continuing without symbols
No kallsyms or vmlinux with build-id e0589077cc0ec8c3e4c40eb9f2d9e69d236bee8f was found
[iwldvm] with build id e0589077cc0ec8c3e4c40eb9f2d9e69d236bee8f not found, continuing without symbols
No kallsyms or vmlinux with build-id 2d86086bf136bf374a2f029cf85a48194f9b950b was found
[cfg80211] with build id 2d86086bf136bf374a2f029cf85a48194f9b950b not found, continuing without symbols
No kallsyms or vmlinux with build-id 4493c48599bdb3d91d0f8db5150e0be33fdd9221 was found
[iwlwifi] with build id 4493c48599bdb3d91d0f8db5150e0be33fdd9221 not found, continuing without symbols
...
#
# Overhead Command Shared Object Symbol
# ........ ............... ....................... ........................................................
#
0.03% swapper [ext4] [k] 0x000000000000fe2e
0.03% swapper [kernel.kallsyms] [k] account_entity_enqueue
0.03% swapper [ext4] [k] 0x000000000000fc2b
0.03% irq/50-iwlwifi [iwlwifi] [k] 0x000000000000200b
0.03% swapper [kernel.kallsyms] [k] ktime_add_safe
0.03% swapper [kernel.kallsyms] [k] elv_completed_request
0.03% swapper [libata] [k] 0x0000000000003997
0.03% swapper [libahci] [k] 0x0000000000001f25
0.03% swapper [kernel.kallsyms] [k] rb_next
0.03% swapper [kernel.kallsyms] [k] blk_finish_request
0.03% swapper [ext4] [k] 0x0000000000010248
0.00% perf [kernel.kallsyms] [k] native_write_msr_safe
After:
$ perf report --stdio
Failed to open /tmp/perf-3477.map, continuing without symbols
no symbols found in /usr/bin/tr, maybe install a debug package?
...
#
# Overhead Command Shared Object Symbol
# ........ ............... ........................... ......................................................
#
0.04% kworker/u16:3 [ext4] [k] ext4_read_block_bitmap
0.03% kworker/u16:0 [mac80211] [k] ieee80211_sta_reset_beacon_monitor
0.02% irq/50-iwlwifi [mac80211] [k] ieee80211_get_bssid
0.02% firefox [e1000e] [k] __ew32_prepare
0.02% swapper [libahci] [k] ahci_handle_port_interrupt
0.02% emacs libglib-2.0.so.0.4000.0 [.] g_mutex_unlock
0.02% swapper [e1000e] [k] e1000_clean_tx_irq
0.02% dwm [kernel.kallsyms] [k] __schedule
0.02% gnome-terminal- [vdso] [.] __vdso_clock_gettime
0.02% swapper [e1000e] [k] e1000_alloc_rx_buffers
0.02% irq/50-iwlwifi [mac80211] [k] ieee80211_rx
0.01% firefox [vdso] [.] __vdso_gettimeofday
0.01% irq/50-iwlwifi [iwlwifi] [k] iwl_pcie_rxq_restock.part.13
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/87h9yexshi.fsf@sejong.aot.lge.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-10-31 15:51:38 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_ZLIB_SUPPORT
|
|
|
|
int gzip_decompress_to_file(const char *input, int output_fd);
|
|
|
|
#endif
|
|
|
|
|
2015-01-29 20:29:39 +08:00
|
|
|
#ifdef HAVE_LZMA_SUPPORT
|
|
|
|
int lzma_decompress_to_file(const char *input, int output_fd);
|
|
|
|
#endif
|
|
|
|
|
perf tools: Asprintf like functions to format integer filter expression
char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints);
char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints);
Example of output formatted with those functions:
# ./tp_filter 6 12 2015
asprintf_expr_in_ints: id == 6 || id == 12 || id == 2015
asprintf_expr_not_in_ints: id != 6 && id != 12 && id != 2015
#
It'll be used with, for instance, perf_evsel__set_filter_in_ints(), that
will be used in turn to ask the kernel to filter out all raw_syscalls:*
except for the ones specified by the user via:
$ perf trace -e some,list,of,syscalls
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-jt07vfp6bd8y50c05j1t7hrn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-07-03 04:48:23 +08:00
|
|
|
char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);
|
|
|
|
|
|
|
|
static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)
|
|
|
|
{
|
|
|
|
return asprintf_expr_inout_ints(var, true, nints, ints);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline char *asprintf_expr_not_in_ints(const char *var, size_t nints, int *ints)
|
|
|
|
{
|
|
|
|
return asprintf_expr_inout_ints(var, false, nints, ints);
|
|
|
|
}
|
|
|
|
|
2015-08-07 03:44:52 +08:00
|
|
|
int get_stack_size(const char *str, unsigned long *_size);
|
|
|
|
|
2015-11-06 21:55:35 +08:00
|
|
|
int fetch_kernel_version(unsigned int *puint,
|
|
|
|
char *str, size_t str_sz);
|
2015-11-06 21:58:09 +08:00
|
|
|
#define KVER_VERSION(x) (((x) >> 16) & 0xff)
|
|
|
|
#define KVER_PATCHLEVEL(x) (((x) >> 8) & 0xff)
|
|
|
|
#define KVER_SUBLEVEL(x) ((x) & 0xff)
|
|
|
|
#define KVER_FMT "%d.%d.%d"
|
|
|
|
#define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x)
|
2015-11-06 21:55:35 +08:00
|
|
|
|
2016-01-07 19:41:53 +08:00
|
|
|
const char *perf_tip(const char *dirpath);
|
2016-01-20 19:56:32 +08:00
|
|
|
bool is_regular_file(const char *file);
|
2016-01-25 17:56:13 +08:00
|
|
|
int fetch_current_timestamp(char *buf, size_t sz);
|
2016-01-07 19:41:53 +08:00
|
|
|
|
2016-02-24 19:20:44 +08:00
|
|
|
enum binary_printer_ops {
|
|
|
|
BINARY_PRINT_DATA_BEGIN,
|
|
|
|
BINARY_PRINT_LINE_BEGIN,
|
|
|
|
BINARY_PRINT_ADDR,
|
|
|
|
BINARY_PRINT_NUM_DATA,
|
|
|
|
BINARY_PRINT_NUM_PAD,
|
|
|
|
BINARY_PRINT_SEP,
|
|
|
|
BINARY_PRINT_CHAR_DATA,
|
|
|
|
BINARY_PRINT_CHAR_PAD,
|
|
|
|
BINARY_PRINT_LINE_END,
|
|
|
|
BINARY_PRINT_DATA_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (*print_binary_t)(enum binary_printer_ops,
|
|
|
|
unsigned int val,
|
|
|
|
void *extra);
|
|
|
|
|
|
|
|
void print_binary(unsigned char *data, size_t len,
|
|
|
|
size_t bytes_per_line, print_binary_t printer,
|
|
|
|
void *extra);
|
2013-02-20 23:32:31 +08:00
|
|
|
#endif /* GIT_COMPAT_UTIL_H */
|