提交 07590a7d 编写于 作者: I Ingo Molnar

Merge tag 'perf-core-for-mingo-4.12-20170419' of...

Merge tag 'perf-core-for-mingo-4.12-20170419' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core cleanups from Arnaldo Carvalho de Melo:

 - Introduce new header files out of the hodge-podge that util/util.h
   became, trying to disentangle the includes hell that all C projects
   end up growing. This should help in build times, as changes to
   seemingly unrelated files (util.h included tons of headers) won't
   trigger a rebuild of most object files.

 - Use equivalent facilities found in the kernel source code base
   originated tools/include/ header files, such as __stringify(),
   ARRAY_SIZE, that has extra checks (__must_be_array()), etc.

 - For that get some more files from the kernel sources, like
   include/linux/bug.h, some just with the bits needed at this time.

 - Use the headers where facilities declared in them are used, such
   as PRIxu(32,64) macros (inttypes.h), errno defines (errno.h), etc.

 - Remove various leftovers from the initial code base we copied from
   git.git: FLEX_ARRAY, etc.
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
#ifndef _TOOLS_PERF_LINUX_BUG_H
#define _TOOLS_PERF_LINUX_BUG_H
/* Force a compilation error if condition is true, but also produce a
result (of value 0 and type size_t), so the expression can be used
e.g. in a structure initializer (or where-ever else comma expressions
aren't permitted). */
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
#endif /* _TOOLS_PERF_LINUX_BUG_H */
...@@ -16,3 +16,6 @@ ...@@ -16,3 +16,6 @@
#if GCC_VERSION >= 40300 #if GCC_VERSION >= 40300
# define __compiletime_error(message) __attribute__((error(message))) # define __compiletime_error(message) __attribute__((error(message)))
#endif /* GCC_VERSION >= 40300 */ #endif /* GCC_VERSION >= 40300 */
/* &a[0] degrades to a pointer: a different type from an array */
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
# define __always_inline inline __attribute__((always_inline)) # define __always_inline inline __attribute__((always_inline))
#endif #endif
/* Are two types/vars the same type (ignoring qualifiers)? */
#ifndef __same_type
# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
#endif
#ifdef __ANDROID__ #ifdef __ANDROID__
/* /*
* FIXME: Big hammer to get rid of tons of: * FIXME: Big hammer to get rid of tons of:
......
...@@ -13,10 +13,6 @@ ...@@ -13,10 +13,6 @@
#include <linux/hash.h> #include <linux/hash.h>
#include <linux/log2.h> #include <linux/log2.h>
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
#define DEFINE_HASHTABLE(name, bits) \ #define DEFINE_HASHTABLE(name, bits) \
struct hlist_head name[1 << (bits)] = \ struct hlist_head name[1 << (bits)] = \
{ [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT } { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
#include <assert.h> #include <assert.h>
#include <linux/compiler.h>
#ifndef UINT_MAX #ifndef UINT_MAX
#define UINT_MAX (~0U) #define UINT_MAX (~0U)
...@@ -76,6 +77,8 @@ ...@@ -76,6 +77,8 @@
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
int scnprintf(char * buf, size_t size, const char * fmt, ...); int scnprintf(char * buf, size_t size, const char * fmt, ...);
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
/* /*
* This looks more complex than it should be. But we need to * This looks more complex than it should be. But we need to
* get the type for the ~ right in round_down (it needs to be * get the type for the ~ right in round_down (it needs to be
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#ifndef _TOOLS_LINUX_LOG2_H #ifndef _TOOLS_LINUX_LOG2_H
#define _TOOLS_LINUX_LOG2_H #define _TOOLS_LINUX_LOG2_H
#include <linux/bitops.h>
#include <linux/types.h>
/* /*
* non-constant log of base 2 calculators * non-constant log of base 2 calculators
* - the arch may override these in asm/bitops.h if they can be implemented * - the arch may override these in asm/bitops.h if they can be implemented
......
#include <ctype.h>
#include "symbol/kallsyms.h" #include "symbol/kallsyms.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
......
...@@ -36,8 +36,7 @@ ...@@ -36,8 +36,7 @@
#include "warn.h" #include "warn.h"
#include <linux/hashtable.h> #include <linux/hashtable.h>
#include <linux/kernel.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define STATE_FP_SAVED 0x1 #define STATE_FP_SAVED 0x1
#define STATE_FP_SETUP 0x2 #define STATE_FP_SETUP 0x2
......
...@@ -31,11 +31,10 @@ ...@@ -31,11 +31,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <subcmd/exec-cmd.h> #include <subcmd/exec-cmd.h>
#include <subcmd/pager.h> #include <subcmd/pager.h>
#include <linux/kernel.h>
#include "builtin.h" #include "builtin.h"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
struct cmd_struct { struct cmd_struct {
const char *name; const char *name;
int (*fn)(int, const char **); int (*fn)(int, const char **);
......
...@@ -64,6 +64,7 @@ tools/include/linux/bitops.h ...@@ -64,6 +64,7 @@ tools/include/linux/bitops.h
tools/include/linux/compiler.h tools/include/linux/compiler.h
tools/include/linux/compiler-gcc.h tools/include/linux/compiler-gcc.h
tools/include/linux/coresight-pmu.h tools/include/linux/coresight-pmu.h
tools/include/linux/bug.h
tools/include/linux/filter.h tools/include/linux/filter.h
tools/include/linux/hash.h tools/include/linux/hash.h
tools/include/linux/kernel.h tools/include/linux/kernel.h
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
*/ */
#include <stddef.h> #include <stddef.h>
#include <linux/stringify.h>
#include <dwarf-regs.h> #include <dwarf-regs.h>
struct pt_regs_dwarfnum { struct pt_regs_dwarfnum {
...@@ -16,10 +17,9 @@ struct pt_regs_dwarfnum { ...@@ -16,10 +17,9 @@ struct pt_regs_dwarfnum {
unsigned int dwarfnum; unsigned int dwarfnum;
}; };
#define STR(s) #s
#define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num}
#define GPR_DWARFNUM_NAME(num) \ #define GPR_DWARFNUM_NAME(num) \
{.name = STR(%r##num), .dwarfnum = num} {.name = __stringify(%r##num), .dwarfnum = num}
#define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0}
/* /*
......
...@@ -8,9 +8,11 @@ ...@@ -8,9 +8,11 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <errno.h>
#include <stddef.h> #include <stddef.h>
#include <dwarf-regs.h> #include <dwarf-regs.h>
#include <linux/ptrace.h> /* for struct user_pt_regs */ #include <linux/ptrace.h> /* for struct user_pt_regs */
#include <linux/stringify.h>
#include "util.h" #include "util.h"
struct pt_regs_dwarfnum { struct pt_regs_dwarfnum {
...@@ -20,7 +22,7 @@ struct pt_regs_dwarfnum { ...@@ -20,7 +22,7 @@ struct pt_regs_dwarfnum {
#define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num}
#define GPR_DWARFNUM_NAME(num) \ #define GPR_DWARFNUM_NAME(num) \
{.name = STR(%x##num), .dwarfnum = num} {.name = __stringify(%x##num), .dwarfnum = num}
#define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0}
#define DWARFNUM2OFFSET(index) \ #define DWARFNUM2OFFSET(index) \
(index * sizeof((struct user_pt_regs *)0)->regs[0]) (index * sizeof((struct user_pt_regs *)0)->regs[0])
......
#include <errno.h>
#ifndef REMOTE_UNWIND_LIBUNWIND #ifndef REMOTE_UNWIND_LIBUNWIND
#include <errno.h>
#include <libunwind.h> #include <libunwind.h>
#include "perf_regs.h" #include "perf_regs.h"
#include "../../util/unwind.h" #include "../../util/unwind.h"
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "../util/util.h" #include "../util/util.h"
#include "../util/debug.h" #include "../util/debug.h"
#include "sane_ctype.h"
const char *const arm_triplets[] = { const char *const arm_triplets[] = {
"arm-eabi-", "arm-eabi-",
"arm-linux-androideabi-", "arm-linux-androideabi-",
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <dwarf-regs.h> #include <dwarf-regs.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/stringify.h>
#include "util.h" #include "util.h"
struct pt_regs_dwarfnum { struct pt_regs_dwarfnum {
...@@ -24,10 +25,10 @@ struct pt_regs_dwarfnum { ...@@ -24,10 +25,10 @@ struct pt_regs_dwarfnum {
}; };
#define REG_DWARFNUM_NAME(r, num) \ #define REG_DWARFNUM_NAME(r, num) \
{.name = STR(%)STR(r), .dwarfnum = num, \ {.name = __stringify(%)__stringify(r), .dwarfnum = num, \
.ptregs_offset = offsetof(struct pt_regs, r)} .ptregs_offset = offsetof(struct pt_regs, r)}
#define GPR_DWARFNUM_NAME(num) \ #define GPR_DWARFNUM_NAME(num) \
{.name = STR(%gpr##num), .dwarfnum = num, \ {.name = __stringify(%gpr##num), .dwarfnum = num, \
.ptregs_offset = offsetof(struct pt_regs, gpr[num])} .ptregs_offset = offsetof(struct pt_regs, gpr[num])}
#define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0, .ptregs_offset = 0} #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0, .ptregs_offset = 0}
......
#include <errno.h>
#include "util/kvm-stat.h" #include "util/kvm-stat.h"
#include "util/parse-events.h" #include "util/parse-events.h"
#include "util/debug.h" #include "util/debug.h"
......
#include <errno.h>
#include <string.h> #include <string.h>
#include <regex.h> #include <regex.h>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* as published by the Free Software Foundation. * as published by the Free Software Foundation.
*/ */
#include <errno.h>
#include "../../util/kvm-stat.h" #include "../../util/kvm-stat.h"
#include <asm/sie.h> #include <asm/sie.h>
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "arch-tests.h" #include "arch-tests.h"
#include <sys/mman.h> #include <sys/mman.h>
#include <errno.h>
#include <string.h> #include <string.h>
static pid_t spawn(void) static pid_t spawn(void)
......
#include <errno.h>
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <linux/types.h> #include <linux/types.h>
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* *
*/ */
#include <errno.h>
#include <stdbool.h> #include <stdbool.h>
#include "../../util/header.h" #include "../../util/header.h"
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* *
*/ */
#include <errno.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/bitops.h> #include <linux/bitops.h>
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* *
*/ */
#include <errno.h>
#include <stdbool.h> #include <stdbool.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
......
#include <errno.h>
#include "../../util/kvm-stat.h" #include "../../util/kvm-stat.h"
#include <asm/svm.h> #include <asm/svm.h>
#include <asm/vmx.h> #include <asm/vmx.h>
......
#include <errno.h>
#include <string.h> #include <string.h>
#include <regex.h> #include <regex.h>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include "../util/header.h" #include "../util/header.h"
#include "../util/cloexec.h" #include "../util/cloexec.h"
#include "../util/string2.h"
#include "bench.h" #include "bench.h"
#include "mem-memcpy-arch.h" #include "mem-memcpy-arch.h"
#include "mem-memset-arch.h" #include "mem-memset-arch.h"
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* numa: Simulate NUMA-sensitive workload and measure their NUMA performance * numa: Simulate NUMA-sensitive workload and measure their NUMA performance
*/ */
#include <inttypes.h>
/* For the CLR_() macros */ /* For the CLR_() macros */
#include <pthread.h> #include <pthread.h>
...@@ -30,6 +31,7 @@ ...@@ -30,6 +31,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <sys/types.h> #include <sys/types.h>
#include <linux/kernel.h>
#include <linux/time64.h> #include <linux/time64.h>
#include <numa.h> #include <numa.h>
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "util/block-range.h" #include "util/block-range.h"
#include <dlfcn.h> #include <dlfcn.h>
#include <errno.h>
#include <linux/bitmap.h> #include <linux/bitmap.h>
struct perf_annotate { struct perf_annotate {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h>
#include <unistd.h> #include <unistd.h>
#include "builtin.h" #include "builtin.h"
#include "perf.h" #include "perf.h"
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "util/session.h" #include "util/session.h"
#include "util/symbol.h" #include "util/symbol.h"
#include "util/data.h" #include "util/data.h"
#include <errno.h>
static int sysfs__fprintf_build_id(FILE *fp) static int sysfs__fprintf_build_id(FILE *fp)
{ {
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* Dick Fowles <fowles@inreach.com> * Dick Fowles <fowles@inreach.com>
* Joe Mario <jmario@redhat.com> * Joe Mario <jmario@redhat.com>
*/ */
#include <errno.h>
#include <inttypes.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/stringify.h> #include <linux/stringify.h>
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "util/data.h" #include "util/data.h"
#include "util/config.h" #include "util/config.h"
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
......
...@@ -9,12 +9,14 @@ ...@@ -9,12 +9,14 @@
#include "builtin.h" #include "builtin.h"
#include "perf.h" #include "perf.h"
#include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include "debug.h" #include "debug.h"
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include <api/fs/tracing_path.h>
#include "evlist.h" #include "evlist.h"
#include "target.h" #include "target.h"
#include "cpumap.h" #include "cpumap.h"
......
...@@ -12,16 +12,18 @@ ...@@ -12,16 +12,18 @@
#include <subcmd/run-command.h> #include <subcmd/run-command.h>
#include <subcmd/help.h> #include <subcmd/help.h>
#include "util/debug.h" #include "util/debug.h"
#include <linux/kernel.h>
#include <errno.h>
static struct man_viewer_list { static struct man_viewer_list {
struct man_viewer_list *next; struct man_viewer_list *next;
char name[FLEX_ARRAY]; char name[0];
} *man_viewer_list; } *man_viewer_list;
static struct man_viewer_info_list { static struct man_viewer_info_list {
struct man_viewer_info_list *next; struct man_viewer_info_list *next;
const char *info; const char *info;
char name[FLEX_ARRAY]; char name[0];
} *man_viewer_info_list; } *man_viewer_info_list;
enum help_format { enum help_format {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include <linux/list.h> #include <linux/list.h>
#include <errno.h>
struct perf_inject { struct perf_inject {
struct perf_tool tool; struct perf_tool tool;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* *
* Released under the GPL v2. (and only v2, not any later version) * Released under the GPL v2. (and only v2, not any later version)
*/ */
#include <inttypes.h>
#include "builtin.h" #include "builtin.h"
#include <linux/compiler.h> #include <linux/compiler.h>
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
......
...@@ -20,11 +20,16 @@ ...@@ -20,11 +20,16 @@
#include "util/debug.h" #include "util/debug.h"
#include <linux/kernel.h>
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/string.h> #include <linux/string.h>
#include <errno.h>
#include <inttypes.h>
#include <locale.h> #include <locale.h>
#include <regex.h> #include <regex.h>
#include "sane_ctype.h"
static int kmem_slab; static int kmem_slab;
static int kmem_page; static int kmem_page;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "util/evsel.h" #include "util/evsel.h"
#include "util/evlist.h" #include "util/evlist.h"
#include "util/term.h"
#include "util/util.h" #include "util/util.h"
#include "util/cache.h" #include "util/cache.h"
#include "util/symbol.h" #include "util/symbol.h"
...@@ -24,7 +25,10 @@ ...@@ -24,7 +25,10 @@
#include <sys/timerfd.h> #include <sys/timerfd.h>
#endif #endif
#include <linux/kernel.h>
#include <linux/time64.h> #include <linux/time64.h>
#include <errno.h>
#include <inttypes.h>
#include <termios.h> #include <termios.h>
#include <semaphore.h> #include <semaphore.h>
#include <pthread.h> #include <pthread.h>
......
#include <errno.h>
#include <inttypes.h>
#include "builtin.h" #include "builtin.h"
#include "perf.h" #include "perf.h"
...@@ -26,6 +28,7 @@ ...@@ -26,6 +28,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/hash.h> #include <linux/hash.h>
#include <linux/kernel.h>
static struct perf_session *session; static struct perf_session *session;
......
#include <inttypes.h>
#include "builtin.h" #include "builtin.h"
#include "perf.h" #include "perf.h"
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#include "util/perf-hooks.h" #include "util/perf-hooks.h"
#include "asm/bug.h" #include "asm/bug.h"
#include <errno.h>
#include <inttypes.h>
#include <unistd.h> #include <unistd.h>
#include <sched.h> #include <sched.h>
#include <sys/mman.h> #include <sys/mman.h>
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include "util/symbol.h" #include "util/symbol.h"
#include "util/callchain.h" #include "util/callchain.h"
#include "util/strlist.h"
#include "util/values.h" #include "util/values.h"
#include "perf.h" #include "perf.h"
...@@ -40,6 +39,9 @@ ...@@ -40,6 +39,9 @@
#include "util/auxtrace.h" #include "util/auxtrace.h"
#include <dlfcn.h> #include <dlfcn.h>
#include <errno.h>
#include <inttypes.h>
#include <regex.h>
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include <linux/stringify.h> #include <linux/stringify.h>
......
...@@ -22,16 +22,21 @@ ...@@ -22,16 +22,21 @@
#include "util/debug.h" #include "util/debug.h"
#include <linux/kernel.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <inttypes.h>
#include <errno.h>
#include <semaphore.h> #include <semaphore.h>
#include <pthread.h> #include <pthread.h>
#include <math.h> #include <math.h>
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include <linux/time64.h> #include <linux/time64.h>
#include "sane_ctype.h"
#define PR_SET_NAME 15 /* Set process name */ #define PR_SET_NAME 15 /* Set process name */
#define MAX_CPUS 4096 #define MAX_CPUS 4096
#define COMM_LEN 20 #define COMM_LEN 20
......
...@@ -21,14 +21,22 @@ ...@@ -21,14 +21,22 @@
#include "util/cpumap.h" #include "util/cpumap.h"
#include "util/thread_map.h" #include "util/thread_map.h"
#include "util/stat.h" #include "util/stat.h"
#include "util/string2.h"
#include "util/thread-stack.h" #include "util/thread-stack.h"
#include "util/time-utils.h" #include "util/time-utils.h"
#include "print_binary.h"
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include <linux/kernel.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/time64.h> #include <linux/time64.h>
#include "asm/bug.h" #include "asm/bug.h"
#include "util/mem-events.h" #include "util/mem-events.h"
#include "util/dump-insn.h" #include "util/dump-insn.h"
#include <dirent.h>
#include <errno.h>
#include <inttypes.h>
#include "sane_ctype.h"
static char const *script_name; static char const *script_name;
static char const *generate_script_lang; static char const *generate_script_lang;
......
...@@ -64,15 +64,20 @@ ...@@ -64,15 +64,20 @@
#include "util/session.h" #include "util/session.h"
#include "util/tool.h" #include "util/tool.h"
#include "util/group.h" #include "util/group.h"
#include "util/string2.h"
#include "asm/bug.h" #include "asm/bug.h"
#include <linux/time64.h> #include <linux/time64.h>
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <inttypes.h>
#include <locale.h> #include <locale.h>
#include <math.h> #include <math.h>
#include "sane_ctype.h"
#define DEFAULT_SEPARATOR " " #define DEFAULT_SEPARATOR " "
#define CNTR_NOT_SUPPORTED "<not supported>" #define CNTR_NOT_SUPPORTED "<not supported>"
#define CNTR_NOT_COUNTED "<not counted>" #define CNTR_NOT_COUNTED "<not counted>"
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
* of the License. * of the License.
*/ */
#include <errno.h>
#include <inttypes.h>
#include <traceevent/event-parse.h> #include <traceevent/event-parse.h>
#include "builtin.h" #include "builtin.h"
...@@ -23,11 +25,11 @@ ...@@ -23,11 +25,11 @@
#include "util/cache.h" #include "util/cache.h"
#include "util/evlist.h" #include "util/evlist.h"
#include "util/evsel.h" #include "util/evsel.h"
#include <linux/kernel.h>
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/time64.h> #include <linux/time64.h>
#include "util/symbol.h" #include "util/symbol.h"
#include "util/callchain.h" #include "util/callchain.h"
#include "util/strlist.h"
#include "perf.h" #include "perf.h"
#include "util/header.h" #include "util/header.h"
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "util/cpumap.h" #include "util/cpumap.h"
#include "util/xyarray.h" #include "util/xyarray.h"
#include "util/sort.h" #include "util/sort.h"
#include "util/term.h"
#include "util/intlist.h" #include "util/intlist.h"
#include "util/parse-branch-options.h" #include "util/parse-branch-options.h"
#include "arch/common.h" #include "arch/common.h"
...@@ -72,6 +73,8 @@ ...@@ -72,6 +73,8 @@
#include <linux/time64.h> #include <linux/time64.h>
#include <linux/types.h> #include <linux/types.h>
#include "sane_ctype.h"
static volatile int done; static volatile int done;
#define HEADER_LINE_NR 5 #define HEADER_LINE_NR 5
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "util/evlist.h" #include "util/evlist.h"
#include <subcmd/exec-cmd.h> #include <subcmd/exec-cmd.h>
#include "util/machine.h" #include "util/machine.h"
#include "util/path.h"
#include "util/session.h" #include "util/session.h"
#include "util/thread.h" #include "util/thread.h"
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
...@@ -36,19 +37,26 @@ ...@@ -36,19 +37,26 @@
#include "util/parse-events.h" #include "util/parse-events.h"
#include "util/bpf-loader.h" #include "util/bpf-loader.h"
#include "callchain.h" #include "callchain.h"
#include "print_binary.h"
#include "string2.h"
#include "syscalltbl.h" #include "syscalltbl.h"
#include "rb_resort.h" #include "rb_resort.h"
#include <errno.h>
#include <inttypes.h>
#include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/filter.h> #include <linux/filter.h>
#include <linux/audit.h> #include <linux/audit.h>
#include <linux/kernel.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/time64.h> #include <linux/time64.h>
#include "sane_ctype.h"
#ifndef O_CLOEXEC #ifndef O_CLOEXEC
# define O_CLOEXEC 02000000 # define O_CLOEXEC 02000000
#endif #endif
......
...@@ -19,9 +19,11 @@ ...@@ -19,9 +19,11 @@
#include "util/debug.h" #include "util/debug.h"
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include <api/fs/tracing_path.h> #include <api/fs/tracing_path.h>
#include <errno.h>
#include <pthread.h> #include <pthread.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <linux/kernel.h>
const char perf_usage_string[] = const char perf_usage_string[] =
"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]"; "perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
...@@ -327,16 +329,6 @@ static void handle_internal_command(int argc, const char **argv) ...@@ -327,16 +329,6 @@ static void handle_internal_command(int argc, const char **argv)
{ {
const char *cmd = argv[0]; const char *cmd = argv[0];
unsigned int i; unsigned int i;
static const char ext[] = STRIP_EXTENSION;
if (sizeof(ext) > 1) {
i = strlen(argv[0]) - strlen(ext);
if (i > 0 && !strcmp(argv[0] + i, ext)) {
char *argv0 = strdup(argv[0]);
argv[0] = cmd = argv0;
argv0[i] = '\0';
}
}
/* Turn "perf cmd --help" into "perf help cmd" */ /* Turn "perf cmd --help" into "perf help cmd" */
if (argc > 1 && !strcmp(argv[1], "--help")) { if (argc > 1 && !strcmp(argv[1], "--help")) {
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
* permissions. All the event text files are stored there. * permissions. All the event text files are stored there.
*/ */
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <linux/types.h> #include <linux/types.h>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <sys/prctl.h> #include <sys/prctl.h>
#include "tests.h" #include "tests.h"
#include "debug.h" #include "debug.h"
#include <errno.h>
#define NR_ITERS 111 #define NR_ITERS 111
......
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <sys/epoll.h> #include <sys/epoll.h>
#include <util/util.h> #include <util/util.h>
...@@ -5,6 +6,7 @@ ...@@ -5,6 +6,7 @@
#include <util/evlist.h> #include <util/evlist.h>
#include <linux/bpf.h> #include <linux/bpf.h>
#include <linux/filter.h> #include <linux/filter.h>
#include <linux/kernel.h>
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include <bpf/bpf.h> #include <bpf/bpf.h>
#include "tests.h" #include "tests.h"
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* *
* Builtin regression testing command: ever growing number of sanity tests * Builtin regression testing command: ever growing number of sanity tests
*/ */
#include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include "builtin.h" #include "builtin.h"
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
#include "color.h" #include "color.h"
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include "symbol.h" #include "symbol.h"
#include <linux/kernel.h>
static bool dont_fork; static bool dont_fork;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "debug.h" #include "debug.h"
#include "util.h" #include "util.h"
#include "c++/clang-c.h" #include "c++/clang-c.h"
#include <linux/kernel.h>
static struct { static struct {
int (*func)(void); int (*func)(void);
......
#include <errno.h>
#include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <inttypes.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
#include <string.h> #include <string.h>
#include "parse-events.h" #include "parse-events.h"
...@@ -16,6 +18,8 @@ ...@@ -16,6 +18,8 @@
#include "tests.h" #include "tests.h"
#include "sane_ctype.h"
#define BUFSZ 1024 #define BUFSZ 1024
#define READLEN 128 #define READLEN 128
......
#include <dirent.h>
#include <stdlib.h> #include <stdlib.h>
#include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
......
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/types.h> #include <linux/types.h>
#include <inttypes.h>
#include <unistd.h> #include <unistd.h>
#include "tests.h" #include "tests.h"
#include "debug.h" #include "debug.h"
......
#include <linux/compiler.h> #include <linux/compiler.h>
#include <errno.h>
#include <inttypes.h>
#include <string.h> #include <string.h>
#include "tests.h" #include "tests.h"
#include "evlist.h" #include "evlist.h"
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include "parse-events.h" #include "parse-events.h"
#include "tests.h" #include "tests.h"
#include "debug.h" #include "debug.h"
#include <errno.h>
#include <linux/kernel.h>
static int perf_evsel__roundtrip_cache_name_test(void) static int perf_evsel__roundtrip_cache_name_test(void)
{ {
......
#include <inttypes.h>
#include "perf.h" #include "perf.h"
#include "util/debug.h" #include "util/debug.h"
#include "util/symbol.h" #include "util/symbol.h"
...@@ -7,6 +8,7 @@ ...@@ -7,6 +8,7 @@
#include "util/machine.h" #include "util/machine.h"
#include "util/thread.h" #include "util/thread.h"
#include "tests/hists_common.h" #include "tests/hists_common.h"
#include <linux/kernel.h>
static struct { static struct {
u32 pid; u32 pid;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "util/parse-events.h" #include "util/parse-events.h"
#include "tests/tests.h" #include "tests/tests.h"
#include "tests/hists_common.h" #include "tests/hists_common.h"
#include <linux/kernel.h>
struct sample { struct sample {
u32 pid; u32 pid;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "util/parse-events.h" #include "util/parse-events.h"
#include "tests/tests.h" #include "tests/tests.h"
#include "tests/hists_common.h" #include "tests/hists_common.h"
#include <linux/kernel.h>
struct sample { struct sample {
u32 pid; u32 pid;
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "thread.h" #include "thread.h"
#include "parse-events.h" #include "parse-events.h"
#include "hists_common.h" #include "hists_common.h"
#include <errno.h>
#include <linux/kernel.h>
struct sample { struct sample {
u32 pid; u32 pid;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "util/parse-events.h" #include "util/parse-events.h"
#include "tests/tests.h" #include "tests/tests.h"
#include "tests/hists_common.h" #include "tests/hists_common.h"
#include <linux/kernel.h>
struct sample { struct sample {
u32 cpu; u32 cpu;
......
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/kernel.h>
#include "tests.h" #include "tests.h"
#include "debug.h" #include "debug.h"
#include "util.h" #include "print_binary.h"
int test__is_printable_array(int subtest __maybe_unused) int test__is_printable_array(int subtest __maybe_unused)
{ {
......
#include <errno.h>
#include <inttypes.h>
/* For the CLR_() macros */ /* For the CLR_() macros */
#include <pthread.h> #include <pthread.h>
...@@ -7,6 +9,7 @@ ...@@ -7,6 +9,7 @@
#include "cpumap.h" #include "cpumap.h"
#include "tests.h" #include "tests.h"
#include <linux/err.h> #include <linux/err.h>
#include <linux/kernel.h>
/* /*
* This test will generate random numbers of calls to some getpid syscalls, * This test will generate random numbers of calls to some getpid syscalls,
......
#include <inttypes.h>
#include <unistd.h> #include <unistd.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/types.h> #include <sys/types.h>
...@@ -11,6 +12,7 @@ ...@@ -11,6 +12,7 @@
#include "thread_map.h" #include "thread_map.h"
#include "symbol.h" #include "symbol.h"
#include "thread.h" #include "thread.h"
#include "util.h"
#define THREADS 4 #define THREADS 4
......
#include <errno.h>
#include <inttypes.h>
/* For the CPU_* macros */ /* For the CPU_* macros */
#include <pthread.h> #include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include <linux/err.h> #include <linux/err.h>
#include <api/fs/tracing_path.h>
#include "evsel.h" #include "evsel.h"
#include "tests.h" #include "tests.h"
#include "thread_map.h" #include "thread_map.h"
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "thread_map.h" #include "thread_map.h"
#include "tests.h" #include "tests.h"
#include "debug.h" #include "debug.h"
#include <errno.h>
#ifndef O_DIRECTORY #ifndef O_DIRECTORY
#define O_DIRECTORY 00200000 #define O_DIRECTORY 00200000
......
#include <errno.h>
#include <inttypes.h>
#include <api/fs/tracing_path.h> #include <api/fs/tracing_path.h>
#include <linux/err.h> #include <linux/err.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "thread_map.h" #include "thread_map.h"
#include "evsel.h" #include "evsel.h"
#include "debug.h" #include "debug.h"
......
#include "parse-events.h" #include "parse-events.h"
#include "evsel.h" #include "evsel.h"
#include "evlist.h" #include "evlist.h"
...@@ -6,8 +5,12 @@ ...@@ -6,8 +5,12 @@
#include "tests.h" #include "tests.h"
#include "debug.h" #include "debug.h"
#include "util.h" #include "util.h"
#include <dirent.h>
#include <errno.h>
#include <linux/kernel.h>
#include <linux/hw_breakpoint.h> #include <linux/hw_breakpoint.h>
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include <api/fs/tracing_path.h>
#define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
......
#include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <stddef.h> #include <stddef.h>
......
#include <errno.h>
#include <inttypes.h>
/* For the CLR_() macros */ /* For the CLR_() macros */
#include <pthread.h> #include <pthread.h>
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "pmu.h" #include "pmu.h"
#include "util.h" #include "util.h"
#include "tests.h" #include "tests.h"
#include <errno.h>
#include <linux/kernel.h>
/* Simulated format definitions. */ /* Simulated format definitions. */
static struct test_format { static struct test_format {
......
#include <stdbool.h> #include <stdbool.h>
#include <inttypes.h>
#include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include "util.h" #include "util.h"
......
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <sys/epoll.h> #include <sys/epoll.h>
#include <util/util.h> #include <util/util.h>
......
#include <errno.h>
#include <inttypes.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
......
#include <sys/time.h> #include <sys/time.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <errno.h>
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "cpumap.h" #include "cpumap.h"
#include "tests.h" #include "tests.h"
#include <errno.h>
#include <signal.h> #include <signal.h>
static int exited; static int exited;
......
#include <inttypes.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/types.h> #include <linux/types.h>
#include "tests.h" #include "tests.h"
......
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <inttypes.h>
#include <string.h> #include <string.h>
#include "map.h" #include "map.h"
#include "symbol.h" #include "symbol.h"
......
#include "../util.h" #include "../util.h"
#include "../string2.h"
#include "../config.h" #include "../config.h"
#include "../../perf.h" #include "../../perf.h"
#include "libslang.h" #include "libslang.h"
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
#include "helpline.h" #include "helpline.h"
#include "keysyms.h" #include "keysyms.h"
#include "../color.h" #include "../color.h"
#include "sane_ctype.h"
static int ui_browser__percent_color(struct ui_browser *browser, static int ui_browser__percent_color(struct ui_browser *browser,
double percent, bool current) double percent, bool current)
......
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
#include "../../util/symbol.h" #include "../../util/symbol.h"
#include "../../util/evsel.h" #include "../../util/evsel.h"
#include "../../util/config.h" #include "../../util/config.h"
#include <inttypes.h>
#include <pthread.h> #include <pthread.h>
#include <linux/kernel.h>
#include <sys/ttydefaults.h>
struct disasm_line_samples { struct disasm_line_samples {
double percent; double percent;
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "util/header.h" #include "util/header.h"
#include "util/session.h" #include "util/session.h"
#include <sys/ttydefaults.h>
static void ui_browser__argv_write(struct ui_browser *browser, static void ui_browser__argv_write(struct ui_browser *browser,
void *entry, int row) void *entry, int row)
{ {
......
#include <dirent.h>
#include <errno.h>
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <sys/ttydefaults.h>
#include "../../util/evsel.h" #include "../../util/evsel.h"
#include "../../util/evlist.h" #include "../../util/evlist.h"
...@@ -18,6 +22,10 @@ ...@@ -18,6 +22,10 @@
#include "../ui.h" #include "../ui.h"
#include "map.h" #include "map.h"
#include "annotate.h" #include "annotate.h"
#include "srcline.h"
#include "string2.h"
#include "sane_ctype.h"
extern void hist_browser__init_hpp(void); extern void hist_browser__init_hpp(void);
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "../keysyms.h" #include "../keysyms.h"
#include "map.h" #include "map.h"
#include "sane_ctype.h"
struct map_browser { struct map_browser {
struct ui_browser b; struct ui_browser b;
struct map *map; struct map *map;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "util/annotate.h" #include "util/annotate.h"
#include "util/evsel.h" #include "util/evsel.h"
#include "ui/helpline.h" #include "ui/helpline.h"
#include <inttypes.h>
enum { enum {
ANN_COL__PERCENT, ANN_COL__PERCENT,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "../sort.h" #include "../sort.h"
#include "../hist.h" #include "../hist.h"
#include "../helpline.h" #include "../helpline.h"
#include "../string2.h"
#include "gtk.h" #include "gtk.h"
#define MAX_COLUMNS 32 #define MAX_COLUMNS 32
......
#include <inttypes.h>
#include <math.h> #include <math.h>
#include <linux/compiler.h> #include <linux/compiler.h>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "../util/cache.h" #include "../util/cache.h"
#include "../util/debug.h" #include "../util/debug.h"
#include "../util/hist.h" #include "../util/hist.h"
#include "../util/util.h"
pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
void *perf_gtk_handle; void *perf_gtk_handle;
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
#include "../../util/hist.h" #include "../../util/hist.h"
#include "../../util/sort.h" #include "../../util/sort.h"
#include "../../util/evsel.h" #include "../../util/evsel.h"
#include "../../util/srcline.h"
#include "../../util/string2.h"
#include "../../util/sane_ctype.h"
static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin) static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
{ {
......
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <stdbool.h> #include <stdbool.h>
#include <linux/kernel.h>
#ifdef HAVE_BACKTRACE_SUPPORT #ifdef HAVE_BACKTRACE_SUPPORT
#include <execinfo.h> #include <execinfo.h>
#endif #endif
......
...@@ -16,6 +16,7 @@ libperf-y += llvm-utils.o ...@@ -16,6 +16,7 @@ libperf-y += llvm-utils.o
libperf-y += parse-events.o libperf-y += parse-events.o
libperf-y += perf_regs.o libperf-y += perf_regs.o
libperf-y += path.o libperf-y += path.o
libperf-y += print_binary.o
libperf-y += rbtree.o libperf-y += rbtree.o
libperf-y += libstring.o libperf-y += libstring.o
libperf-y += bitmap.o libperf-y += bitmap.o
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
* Released under the GPL v2. (and only v2, not any later version) * Released under the GPL v2. (and only v2, not any later version)
*/ */
#include <errno.h>
#include <inttypes.h>
#include "util.h" #include "util.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "sort.h" #include "sort.h"
...@@ -18,12 +20,16 @@ ...@@ -18,12 +20,16 @@
#include "annotate.h" #include "annotate.h"
#include "evsel.h" #include "evsel.h"
#include "block-range.h" #include "block-range.h"
#include "string2.h"
#include "arch/common.h" #include "arch/common.h"
#include <regex.h> #include <regex.h>
#include <pthread.h> #include <pthread.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/kernel.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include "sane_ctype.h"
const char *disassembler_style; const char *disassembler_style;
const char *objdump_path; const char *objdump_path;
static regex_t file_lineno; static regex_t file_lineno;
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
* *
*/ */
#include <inttypes.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <stdbool.h> #include <stdbool.h>
#include <ctype.h>
#include <string.h> #include <string.h>
#include <limits.h> #include <limits.h>
#include <errno.h> #include <errno.h>
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
#include "cpumap.h" #include "cpumap.h"
#include "thread_map.h" #include "thread_map.h"
#include "asm/bug.h" #include "asm/bug.h"
#include "symbol/kallsyms.h"
#include "auxtrace.h" #include "auxtrace.h"
#include <linux/hash.h> #include <linux/hash.h>
...@@ -59,6 +58,9 @@ ...@@ -59,6 +58,9 @@
#include "intel-pt.h" #include "intel-pt.h"
#include "intel-bts.h" #include "intel-bts.h"
#include "sane_ctype.h"
#include "symbol/kallsyms.h"
int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
struct auxtrace_mmap_params *mp, struct auxtrace_mmap_params *mp,
void *userpg, int fd) void *userpg, int fd)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define __PERF_AUXTRACE_H #define __PERF_AUXTRACE_H
#include <sys/types.h> #include <sys/types.h>
#include <errno.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <linux/list.h> #include <linux/list.h>
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#include <bpf/libbpf.h> #include <bpf/libbpf.h>
#include <bpf/bpf.h> #include <bpf/bpf.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/kernel.h>
#include <linux/string.h> #include <linux/string.h>
#include <errno.h>
#include "perf.h" #include "perf.h"
#include "debug.h" #include "debug.h"
#include "bpf-loader.h" #include "bpf-loader.h"
...@@ -17,6 +19,7 @@ ...@@ -17,6 +19,7 @@
#include "probe-event.h" #include "probe-event.h"
#include "probe-finder.h" // for MAX_PROBES #include "probe-finder.h" // for MAX_PROBES
#include "parse-events.h" #include "parse-events.h"
#include "strfilter.h"
#include "llvm-utils.h" #include "llvm-utils.h"
#include "c++/clang-c.h" #include "c++/clang-c.h"
......
...@@ -85,6 +85,8 @@ int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err, ...@@ -85,6 +85,8 @@ int bpf__strerror_setup_stdout(struct perf_evlist *evlist, int err,
char *buf, size_t size); char *buf, size_t size);
#else #else
#include <errno.h>
static inline struct bpf_object * static inline struct bpf_object *
bpf__prepare_load(const char *filename __maybe_unused, bpf__prepare_load(const char *filename __maybe_unused,
bool source __maybe_unused) bool source __maybe_unused)
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "bpf-loader.h" #include "bpf-loader.h"
#include "bpf-prologue.h" #include "bpf-prologue.h"
#include "probe-finder.h" #include "probe-finder.h"
#include <errno.h>
#include <dwarf-regs.h> #include <dwarf-regs.h>
#include <linux/filter.h> #include <linux/filter.h>
......
...@@ -18,6 +18,8 @@ int bpf__gen_prologue(struct probe_trace_arg *args, int nargs, ...@@ -18,6 +18,8 @@ int bpf__gen_prologue(struct probe_trace_arg *args, int nargs,
struct bpf_insn *new_prog, size_t *new_cnt, struct bpf_insn *new_prog, size_t *new_cnt,
size_t cnt_space); size_t cnt_space);
#else #else
#include <errno.h>
static inline int static inline int
bpf__gen_prologue(struct probe_trace_arg *args __maybe_unused, bpf__gen_prologue(struct probe_trace_arg *args __maybe_unused,
int nargs __maybe_unused, int nargs __maybe_unused,
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
* Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <acme@redhat.com> * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <acme@redhat.com>
*/ */
#include "util.h" #include "util.h"
#include <dirent.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include "build-id.h" #include "build-id.h"
#include "event.h" #include "event.h"
...@@ -17,8 +19,11 @@ ...@@ -17,8 +19,11 @@
#include "tool.h" #include "tool.h"
#include "header.h" #include "header.h"
#include "vdso.h" #include "vdso.h"
#include "path.h"
#include "probe-file.h" #include "probe-file.h"
#include "strlist.h"
#include "sane_ctype.h"
static bool no_buildid_cache; static bool no_buildid_cache;
...@@ -447,14 +452,14 @@ void disable_buildid_cache(void) ...@@ -447,14 +452,14 @@ void disable_buildid_cache(void)
} }
static bool lsdir_bid_head_filter(const char *name __maybe_unused, static bool lsdir_bid_head_filter(const char *name __maybe_unused,
struct dirent *d __maybe_unused) struct dirent *d)
{ {
return (strlen(d->d_name) == 2) && return (strlen(d->d_name) == 2) &&
isxdigit(d->d_name[0]) && isxdigit(d->d_name[1]); isxdigit(d->d_name[0]) && isxdigit(d->d_name[1]);
} }
static bool lsdir_bid_tail_filter(const char *name __maybe_unused, static bool lsdir_bid_tail_filter(const char *name __maybe_unused,
struct dirent *d __maybe_unused) struct dirent *d)
{ {
int i = 0; int i = 0;
while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3) while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3)
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1) #define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1)
#include "tool.h" #include "tool.h"
#include "strlist.h"
#include <linux/types.h> #include <linux/types.h>
extern struct perf_tool build_id__mark_dso_hit_ops; extern struct perf_tool build_id__mark_dso_hit_ops;
...@@ -34,6 +33,9 @@ char *build_id_cache__origname(const char *sbuild_id); ...@@ -34,6 +33,9 @@ char *build_id_cache__origname(const char *sbuild_id);
char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size); char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size);
char *build_id_cache__cachedir(const char *sbuild_id, const char *name, char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
bool is_kallsyms, bool is_vdso); bool is_kallsyms, bool is_vdso);
struct strlist;
struct strlist *build_id_cache__list_all(bool validonly); struct strlist *build_id_cache__list_all(bool validonly);
char *build_id_cache__complement(const char *incomplete_sbuild_id); char *build_id_cache__complement(const char *incomplete_sbuild_id);
int build_id_cache__list_build_ids(const char *pathname, int build_id_cache__list_build_ids(const char *pathname,
......
...@@ -20,6 +20,7 @@ extern int perf_clang__compile_bpf(const char *filename, ...@@ -20,6 +20,7 @@ extern int perf_clang__compile_bpf(const char *filename,
size_t *p_obj_buf_sz); size_t *p_obj_buf_sz);
#else #else
#include <errno.h>
static inline void perf_clang__init(void) { } static inline void perf_clang__init(void) { }
static inline void perf_clang__cleanup(void) { } static inline void perf_clang__cleanup(void) { }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* *
*/ */
#include <inttypes.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "evsel.h" #include "evsel.h"
#include "cgroup.h" #include "cgroup.h"
#include "evlist.h" #include "evlist.h"
#include <linux/stringify.h>
int nr_cgroups; int nr_cgroups;
...@@ -27,8 +28,8 @@ cgroupfs_find_mountpoint(char *buf, size_t maxlen) ...@@ -27,8 +28,8 @@ cgroupfs_find_mountpoint(char *buf, size_t maxlen)
path_v1[0] = '\0'; path_v1[0] = '\0';
path_v2[0] = '\0'; path_v2[0] = '\0';
while (fscanf(fp, "%*s %"STR(PATH_MAX)"s %"STR(PATH_MAX)"s %" while (fscanf(fp, "%*s %"__stringify(PATH_MAX)"s %"__stringify(PATH_MAX)"s %"
STR(PATH_MAX)"s %*d %*d\n", __stringify(PATH_MAX)"s %*d %*d\n",
mountpoint, type, tokens) == 3) { mountpoint, type, tokens) == 3) {
if (!path_v1[0] && !strcmp(type, "cgroup")) { if (!path_v1[0] && !strcmp(type, "cgroup")) {
......
#include <errno.h>
#include <sched.h> #include <sched.h>
#include "util.h" #include "util.h"
#include "../perf.h" #include "../perf.h"
......
#include "comm.h" #include "comm.h"
#include "util.h" #include "util.h"
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <linux/refcount.h> #include <linux/refcount.h>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* Copyright (C) Johannes Schindelin, 2005 * Copyright (C) Johannes Schindelin, 2005
* *
*/ */
#include <errno.h>
#include "util.h" #include "util.h"
#include "cache.h" #include "cache.h"
#include <subcmd/exec-cmd.h> #include <subcmd/exec-cmd.h>
...@@ -15,6 +16,8 @@ ...@@ -15,6 +16,8 @@
#include "util/llvm-utils.h" /* perf_llvm_config */ #include "util/llvm-utils.h" /* perf_llvm_config */
#include "config.h" #include "config.h"
#include "sane_ctype.h"
#define MAXNAME (256) #define MAXNAME (256)
#define DEBUG_CACHE_DIR ".debug" #define DEBUG_CACHE_DIR ".debug"
......
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include "evsel.h" #include "evsel.h"
#include "counts.h" #include "counts.h"
#include "util.h"
struct perf_counts *perf_counts__new(int ncpus, int nthreads) struct perf_counts *perf_counts__new(int ncpus, int nthreads)
{ {
......
...@@ -3,11 +3,14 @@ ...@@ -3,11 +3,14 @@
#include "../perf.h" #include "../perf.h"
#include "cpumap.h" #include "cpumap.h"
#include <assert.h> #include <assert.h>
#include <dirent.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include "asm/bug.h" #include "asm/bug.h"
#include "sane_ctype.h"
static int max_cpu_num; static int max_cpu_num;
static int max_present_cpu_num; static int max_present_cpu_num;
static int max_node_num; static int max_node_num;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* No surprises, and works with signed and unsigned chars. * No surprises, and works with signed and unsigned chars.
*/ */
#include "util.h" #include "sane_ctype.h"
enum { enum {
S = GIT_SPACE, S = GIT_SPACE,
......
...@@ -7,7 +7,10 @@ ...@@ -7,7 +7,10 @@
* Released under the GPL v2. (and only v2, not any later version) * Released under the GPL v2. (and only v2, not any later version)
*/ */
#include <errno.h>
#include <inttypes.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/kernel.h>
#include <babeltrace/ctf-writer/writer.h> #include <babeltrace/ctf-writer/writer.h>
#include <babeltrace/ctf-writer/clock.h> #include <babeltrace/ctf-writer/clock.h>
#include <babeltrace/ctf-writer/stream.h> #include <babeltrace/ctf-writer/stream.h>
...@@ -27,6 +30,7 @@ ...@@ -27,6 +30,7 @@
#include "evsel.h" #include "evsel.h"
#include "machine.h" #include "machine.h"
#include "config.h" #include "config.h"
#include "sane_ctype.h"
#define pr_N(n, fmt, ...) \ #define pr_N(n, fmt, ...) \
eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__) eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "../perf.h" #include "../perf.h"
#include <inttypes.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
...@@ -12,9 +13,12 @@ ...@@ -12,9 +13,12 @@
#include "color.h" #include "color.h"
#include "event.h" #include "event.h"
#include "debug.h" #include "debug.h"
#include "print_binary.h"
#include "util.h" #include "util.h"
#include "target.h" #include "target.h"
#include "sane_ctype.h"
int verbose; int verbose;
bool dump_trace = false, quiet = false; bool dump_trace = false, quiet = false;
int debug_ordered_events; int debug_ordered_events;
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "demangle-java.h" #include "demangle-java.h"
#include "sane_ctype.h"
enum { enum {
MODE_PREFIX = 0, MODE_PREFIX = 0,
MODE_CLASS = 1, MODE_CLASS = 1,
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "evlist.h" #include "evlist.h"
#include "evsel.h" #include "evsel.h"
#include "pmu.h" #include "pmu.h"
#include <errno.h>
static int static int
perf_evsel__apply_drv_configs(struct perf_evsel *evsel, perf_evsel__apply_drv_configs(struct perf_evsel *evsel,
......
#include <asm/bug.h> #include <asm/bug.h>
#include <linux/kernel.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <errno.h>
#include "path.h"
#include "symbol.h" #include "symbol.h"
#include "dso.h" #include "dso.h"
#include "machine.h" #include "machine.h"
#include "auxtrace.h" #include "auxtrace.h"
#include "util.h" #include "util.h"
#include "debug.h" #include "debug.h"
#include "string2.h"
#include "vdso.h" #include "vdso.h"
static const char * const debuglink_paths[] = { static const char * const debuglink_paths[] = {
......
...@@ -17,10 +17,13 @@ ...@@ -17,10 +17,13 @@
* *
*/ */
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
#include "util.h" #include "util.h"
#include "debug.h" #include "debug.h"
#include "dwarf-aux.h" #include "dwarf-aux.h"
#include "string2.h"
/** /**
* cu_find_realpath - Find the realpath of the target file * cu_find_realpath - Find the realpath of the target file
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <debug.h> #include <debug.h>
#include <dwarf-regs.h> #include <dwarf-regs.h>
#include <elf.h> #include <elf.h>
#include <linux/kernel.h>
#ifndef EM_AARCH64 #ifndef EM_AARCH64
#define EM_AARCH64 183 /* ARM 64 bit */ #define EM_AARCH64 183 /* ARM 64 bit */
......
#include "cpumap.h" #include "cpumap.h"
#include "env.h" #include "env.h"
#include "util.h" #include "util.h"
#include <errno.h>
struct perf_env perf_env; struct perf_env perf_env;
......
#include <dirent.h>
#include <errno.h>
#include <inttypes.h>
#include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */
#include <api/fs/fs.h> #include <api/fs/fs.h>
...@@ -6,10 +10,11 @@ ...@@ -6,10 +10,11 @@
#include "hist.h" #include "hist.h"
#include "machine.h" #include "machine.h"
#include "sort.h" #include "sort.h"
#include "string.h" #include "string2.h"
#include "strlist.h" #include "strlist.h"
#include "thread.h" #include "thread.h"
#include "thread_map.h" #include "thread_map.h"
#include "sane_ctype.h"
#include "symbol/kallsyms.h" #include "symbol/kallsyms.h"
#include "asm/bug.h" #include "asm/bug.h"
#include "stat.h" #include "stat.h"
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
*/ */
#include "util.h" #include "util.h"
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include <errno.h>
#include <inttypes.h>
#include <poll.h> #include <poll.h>
#include "cpumap.h" #include "cpumap.h"
#include "thread_map.h" #include "thread_map.h"
......
#ifndef __PERF_EVLIST_H #ifndef __PERF_EVLIST_H
#define __PERF_EVLIST_H 1 #define __PERF_EVLIST_H 1
#include <linux/kernel.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include <linux/list.h> #include <linux/list.h>
#include <api/fd/array.h> #include <api/fd/array.h>
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
*/ */
#include <byteswap.h> #include <byteswap.h>
#include <errno.h>
#include <inttypes.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <api/fs/tracing_path.h> #include <api/fs/tracing_path.h>
#include <traceevent/event-parse.h> #include <traceevent/event-parse.h>
...@@ -30,6 +32,8 @@ ...@@ -30,6 +32,8 @@
#include "stat.h" #include "stat.h"
#include "util/parse-branch-options.h" #include "util/parse-branch-options.h"
#include "sane_ctype.h"
static struct { static struct {
bool sample_id_all; bool sample_id_all;
bool exclude_guest; bool exclude_guest;
......
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#include <traceevent/event-parse.h> #include <traceevent/event-parse.h>
#include "evsel.h" #include "evsel.h"
#include "callchain.h" #include "callchain.h"
#include "map.h" #include "map.h"
#include "strlist.h"
#include "symbol.h" #include "symbol.h"
static int comma_fprintf(FILE *fp, bool *first, const char *fmt, ...) static int comma_fprintf(FILE *fp, bool *first, const char *fmt, ...)
......
#include <errno.h>
#include <inttypes.h>
#include "util.h" #include "util.h"
#include "string2.h"
#include <sys/types.h> #include <sys/types.h>
#include <byteswap.h> #include <byteswap.h>
#include <unistd.h> #include <unistd.h>
...@@ -26,6 +29,8 @@ ...@@ -26,6 +29,8 @@
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include "asm/bug.h" #include "asm/bug.h"
#include "sane_ctype.h"
/* /*
* magic2 = "PERFILE2" * magic2 = "PERFILE2"
* must be a numerical value to let the endianness * must be a numerical value to let the endianness
......
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
#include "evlist.h" #include "evlist.h"
#include "evsel.h" #include "evsel.h"
#include "annotate.h" #include "annotate.h"
#include "srcline.h"
#include "ui/progress.h" #include "ui/progress.h"
#include <errno.h>
#include <math.h> #include <math.h>
static bool hists__filter_entry_by_dso(struct hists *hists, static bool hists__filter_entry_by_dso(struct hists *hists,
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
*/ */
#include <endian.h> #include <endian.h>
#include <errno.h>
#include <byteswap.h> #include <byteswap.h>
#include <inttypes.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/bitops.h> #include <linux/bitops.h>
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* *
*/ */
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#include <errno.h> #include <errno.h>
......
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#include <sys/types.h> #include <sys/types.h>
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -9,13 +10,13 @@ ...@@ -9,13 +10,13 @@
#include <byteswap.h> #include <byteswap.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <linux/stringify.h>
#include "util.h" #include "util.h"
#include "event.h" #include "event.h"
#include "debug.h" #include "debug.h"
#include "evlist.h" #include "evlist.h"
#include "symbol.h" #include "symbol.h"
#include "strlist.h"
#include <elf.h> #include <elf.h>
#include "tsc.h" #include "tsc.h"
...@@ -25,6 +26,8 @@ ...@@ -25,6 +26,8 @@
#include "genelf.h" #include "genelf.h"
#include "../builtin.h" #include "../builtin.h"
#include "sane_ctype.h"
struct jit_buf_desc { struct jit_buf_desc {
struct perf_data_file *output; struct perf_data_file *output;
struct perf_session *session; struct perf_session *session;
...@@ -181,7 +184,7 @@ jit_open(struct jit_buf_desc *jd, const char *name) ...@@ -181,7 +184,7 @@ jit_open(struct jit_buf_desc *jd, const char *name)
jd->use_arch_timestamp); jd->use_arch_timestamp);
if (header.version > JITHEADER_VERSION) { if (header.version > JITHEADER_VERSION) {
pr_err("wrong jitdump version %u, expected " STR(JITHEADER_VERSION), pr_err("wrong jitdump version %u, expected " __stringify(JITHEADER_VERSION),
header.version); header.version);
goto error; goto error;
} }
......
#include <errno.h>
#include <lzma.h> #include <lzma.h>
#include <stdio.h> #include <stdio.h>
#include <linux/compiler.h> #include <linux/compiler.h>
......
#include <dirent.h>
#include <errno.h>
#include <inttypes.h>
#include <regex.h>
#include "callchain.h" #include "callchain.h"
#include "debug.h" #include "debug.h"
#include "event.h" #include "event.h"
...@@ -10,11 +14,13 @@ ...@@ -10,11 +14,13 @@
#include "thread.h" #include "thread.h"
#include "vdso.h" #include "vdso.h"
#include <stdbool.h> #include <stdbool.h>
#include <symbol/kallsyms.h>
#include "unwind.h" #include "unwind.h"
#include "linux/hash.h" #include "linux/hash.h"
#include "asm/bug.h" #include "asm/bug.h"
#include "sane_ctype.h"
#include <symbol/kallsyms.h>
static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock); static void __machine__remove_thread(struct machine *machine, struct thread *th, bool lock);
static void dsos__init(struct dsos *dsos) static void dsos__init(struct dsos *dsos)
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
#include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */
#include "map.h" #include "map.h"
#include "thread.h" #include "thread.h"
#include "strlist.h"
#include "vdso.h" #include "vdso.h"
#include "build-id.h" #include "build-id.h"
#include "util.h" #include "util.h"
#include "debug.h" #include "debug.h"
#include "machine.h" #include "machine.h"
#include <linux/string.h> #include <linux/string.h>
#include "srcline.h"
#include "unwind.h" #include "unwind.h"
static void __maps__insert(struct maps *maps, struct map *map); static void __maps__insert(struct maps *maps, struct map *map);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include <linux/kernel.h>
#include "mem-events.h" #include "mem-events.h"
#include "debug.h" #include "debug.h"
#include "symbol.h" #include "symbol.h"
......
#include <errno.h>
#include <inttypes.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/string.h> #include <linux/string.h>
......
#include <linux/hw_breakpoint.h> #include <linux/hw_breakpoint.h>
#include <linux/err.h> #include <linux/err.h>
#include "util.h" #include <dirent.h>
#include <errno.h>
#include "term.h"
#include "../perf.h" #include "../perf.h"
#include "evlist.h" #include "evlist.h"
#include "evsel.h" #include "evsel.h"
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include "parse-events.h" #include "parse-events.h"
#include <subcmd/exec-cmd.h> #include <subcmd/exec-cmd.h>
#include "string.h" #include "string2.h"
#include "strlist.h"
#include "symbol.h" #include "symbol.h"
#include "cache.h" #include "cache.h"
#include "header.h" #include "header.h"
......
...@@ -11,8 +11,13 @@ ...@@ -11,8 +11,13 @@
* which is what it's designed for. * which is what it's designed for.
*/ */
#include "cache.h" #include "cache.h"
#include "util.h" #include "path.h"
#include <linux/kernel.h>
#include <limits.h> #include <limits.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
static char bad_path[] = "/bad-path/"; static char bad_path[] = "/bad-path/";
/* /*
...@@ -50,3 +55,24 @@ char *mkpath(const char *fmt, ...) ...@@ -50,3 +55,24 @@ char *mkpath(const char *fmt, ...)
return bad_path; return bad_path;
return cleanup_path(pathname); return cleanup_path(pathname);
} }
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);
}
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);
}
bool is_regular_file(const char *file)
{
struct stat st;
if (stat(file, &st))
return false;
return S_ISREG(st.st_mode);
}
#ifndef _PERF_PATH_H
#define _PERF_PATH_H
int path__join(char *bf, size_t size, const char *path1, const char *path2);
int path__join3(char *bf, size_t size, const char *path1, const char *path2, const char *path3);
bool is_regular_file(const char *file);
#endif /* _PERF_PATH_H */
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <setjmp.h> #include <setjmp.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/kernel.h>
#include "util/util.h" #include "util/util.h"
#include "util/debug.h" #include "util/debug.h"
#include "util/perf-hooks.h" #include "util/perf-hooks.h"
......
#include <linux/list.h> #include <linux/list.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <sys/types.h> #include <sys/types.h>
#include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
#include "header.h" #include "header.h"
#include "pmu-events/pmu-events.h" #include "pmu-events/pmu-events.h"
#include "cache.h" #include "cache.h"
#include "string2.h"
struct perf_pmu_format { struct perf_pmu_format {
char *name; char *name;
......
#include "print_binary.h"
#include <linux/log2.h>
#include "sane_ctype.h"
void print_binary(unsigned char *data, size_t len,
size_t bytes_per_line, print_binary_t printer,
void *extra)
{
size_t i, j, mask;
if (!printer)
return;
bytes_per_line = roundup_pow_of_two(bytes_per_line);
mask = bytes_per_line - 1;
printer(BINARY_PRINT_DATA_BEGIN, 0, extra);
for (i = 0; i < len; i++) {
if ((i & mask) == 0) {
printer(BINARY_PRINT_LINE_BEGIN, -1, extra);
printer(BINARY_PRINT_ADDR, i, extra);
}
printer(BINARY_PRINT_NUM_DATA, data[i], extra);
if (((i & mask) == mask) || i == len - 1) {
for (j = 0; j < mask-(i & mask); j++)
printer(BINARY_PRINT_NUM_PAD, -1, extra);
printer(BINARY_PRINT_SEP, i, extra);
for (j = i & ~mask; j <= i; j++)
printer(BINARY_PRINT_CHAR_DATA, data[j], extra);
for (j = 0; j < mask-(i & mask); j++)
printer(BINARY_PRINT_CHAR_PAD, i, extra);
printer(BINARY_PRINT_LINE_END, -1, extra);
}
}
printer(BINARY_PRINT_DATA_END, -1, extra);
}
int is_printable_array(char *p, unsigned int len)
{
unsigned int i;
if (!p || !len || p[len - 1] != 0)
return 0;
len--;
for (i = 0; i < len; i++) {
if (!isprint(p[i]) && !isspace(p[i]))
return 0;
}
return 1;
}
#ifndef PERF_PRINT_BINARY_H
#define PERF_PRINT_BINARY_H
#include <stddef.h>
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 op,
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);
int is_printable_array(char *p, unsigned int len);
#endif /* PERF_PRINT_BINARY_H */
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* *
*/ */
#include <inttypes.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
#include "util.h" #include "util.h"
#include "event.h" #include "event.h"
#include "strlist.h" #include "strlist.h"
#include "strfilter.h"
#include "debug.h" #include "debug.h"
#include "cache.h" #include "cache.h"
#include "color.h" #include "color.h"
...@@ -46,6 +48,9 @@ ...@@ -46,6 +48,9 @@
#include "probe-finder.h" #include "probe-finder.h"
#include "probe-file.h" #include "probe-file.h"
#include "session.h" #include "session.h"
#include "string2.h"
#include "sane_ctype.h"
#define PERFPROBE_GROUP "probe" #define PERFPROBE_GROUP "probe"
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#include <stdbool.h> #include <stdbool.h>
#include "intlist.h" #include "intlist.h"
#include "strlist.h"
#include "strfilter.h"
/* Probe related configurations */ /* Probe related configurations */
struct probe_conf { struct probe_conf {
...@@ -107,6 +105,8 @@ struct line_range { ...@@ -107,6 +105,8 @@ struct line_range {
struct intlist *line_list; /* Visible lines */ struct intlist *line_list; /* Visible lines */
}; };
struct strlist;
/* List of variables */ /* List of variables */
struct variable_list { struct variable_list {
struct probe_trace_point point; /* Actual probepoint */ struct probe_trace_point point; /* Actual probepoint */
...@@ -153,6 +153,9 @@ int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs); ...@@ -153,6 +153,9 @@ int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs);
int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs); int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs);
int show_probe_trace_events(struct perf_probe_event *pevs, int npevs); int show_probe_trace_events(struct perf_probe_event *pevs, int npevs);
void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs); void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs);
struct strfilter;
int del_perf_probe_events(struct strfilter *filter); int del_perf_probe_events(struct strfilter *filter);
int show_perf_probe_event(const char *group, const char *event, int show_perf_probe_event(const char *group, const char *event,
......
...@@ -14,10 +14,12 @@ ...@@ -14,10 +14,12 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
*/ */
#include <errno.h>
#include <sys/uio.h> #include <sys/uio.h>
#include "util.h" #include "util.h"
#include "event.h" #include "event.h"
#include "strlist.h" #include "strlist.h"
#include "strfilter.h"
#include "debug.h" #include "debug.h"
#include "cache.h" #include "cache.h"
#include "color.h" #include "color.h"
...@@ -28,6 +30,7 @@ ...@@ -28,6 +30,7 @@
#include "probe-file.h" #include "probe-file.h"
#include "session.h" #include "session.h"
#include "perf_regs.h" #include "perf_regs.h"
#include "string2.h"
/* 4096 - 2 ('\n' + '\0') */ /* 4096 - 2 ('\n' + '\0') */
#define MAX_CMDLEN 4094 #define MAX_CMDLEN 4094
......
#ifndef __PROBE_FILE_H #ifndef __PROBE_FILE_H
#define __PROBE_FILE_H #define __PROBE_FILE_H
#include "strlist.h"
#include "strfilter.h"
#include "probe-event.h" #include "probe-event.h"
struct strlist;
struct strfilter;
/* Cache of probe definitions */ /* Cache of probe definitions */
struct probe_cache_entry { struct probe_cache_entry {
struct list_head node; struct list_head node;
...@@ -41,6 +42,7 @@ int probe_file__open_both(int *kfd, int *ufd, int flag); ...@@ -41,6 +42,7 @@ int probe_file__open_both(int *kfd, int *ufd, int flag);
struct strlist *probe_file__get_namelist(int fd); struct strlist *probe_file__get_namelist(int fd);
struct strlist *probe_file__get_rawlist(int fd); struct strlist *probe_file__get_rawlist(int fd);
int probe_file__add_event(int fd, struct probe_trace_event *tev); int probe_file__add_event(int fd, struct probe_trace_event *tev);
int probe_file__del_events(int fd, struct strfilter *filter); int probe_file__del_events(int fd, struct strfilter *filter);
int probe_file__get_events(int fd, struct strfilter *filter, int probe_file__get_events(int fd, struct strfilter *filter,
struct strlist *plist); struct strlist *plist);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* *
*/ */
#include <inttypes.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -37,9 +38,11 @@ ...@@ -37,9 +38,11 @@
#include "debug.h" #include "debug.h"
#include "intlist.h" #include "intlist.h"
#include "util.h" #include "util.h"
#include "strlist.h"
#include "symbol.h" #include "symbol.h"
#include "probe-finder.h" #include "probe-finder.h"
#include "probe-file.h" #include "probe-file.h"
#include "string2.h"
/* Kprobe tracer basic type is up to u64 */ /* Kprobe tracer basic type is up to u64 */
#define MAX_BASIC_TYPE_BITS 64 #define MAX_BASIC_TYPE_BITS 64
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
#define _PROBE_FINDER_H #define _PROBE_FINDER_H
#include <stdbool.h> #include <stdbool.h>
#include "util.h"
#include "intlist.h" #include "intlist.h"
#include "probe-event.h" #include "probe-event.h"
#include "sane_ctype.h"
#define MAX_PROBE_BUFFER 1024 #define MAX_PROBE_BUFFER 1024
#define MAX_PROBES 128 #define MAX_PROBES 128
......
...@@ -21,6 +21,7 @@ util/cgroup.c ...@@ -21,6 +21,7 @@ util/cgroup.c
util/parse-branch-options.c util/parse-branch-options.c
util/rblist.c util/rblist.c
util/counts.c util/counts.c
util/print_binary.c
util/strlist.c util/strlist.c
util/trace-event.c util/trace-event.c
../lib/rbtree.c ../lib/rbtree.c
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "evsel.h" #include "evsel.h"
#include "event.h" #include "event.h"
#include "cpumap.h" #include "cpumap.h"
#include "print_binary.h"
#include "thread_map.h" #include "thread_map.h"
/* /*
......
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include "strbuf.h" #include "strbuf.h"
#include "quote.h" #include "quote.h"
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "evsel.h" #include "evsel.h"
#include "cpumap.h" #include "cpumap.h"
#include "parse-events.h" #include "parse-events.h"
#include <errno.h>
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include "util.h" #include "util.h"
#include "cloexec.h" #include "cloexec.h"
......
#ifndef _PERF_SANE_CTYPE_H
#define _PERF_SANE_CTYPE_H
extern const char *graph_line;
extern const char *graph_dotted_line;
extern const char *spaces;
extern const char *dots;
/* Sane ctype - no locale, and works with signed chars */
#undef isascii
#undef isspace
#undef isdigit
#undef isxdigit
#undef isalpha
#undef isprint
#undef isalnum
#undef islower
#undef isupper
#undef tolower
#undef toupper
extern unsigned char sane_ctype[256];
#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
#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)
#define isxdigit(x) \
(sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G')
#define isalpha(x) sane_istest(x,GIT_ALPHA)
#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
#define isprint(x) sane_istest(x,GIT_PRINT)
#define islower(x) (sane_istest(x,GIT_ALPHA) && (x & 0x20))
#define isupper(x) (sane_istest(x,GIT_ALPHA) && !(x & 0x20))
#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;
}
#endif /* _PERF_SANE_CTYPE_H */
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* *
*/ */
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <Python.h> #include <Python.h>
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -45,6 +46,7 @@ ...@@ -45,6 +46,7 @@
#include "../call-path.h" #include "../call-path.h"
#include "thread_map.h" #include "thread_map.h"
#include "cpumap.h" #include "cpumap.h"
#include "print_binary.h"
#include "stat.h" #include "stat.h"
PyMODINIT_FUNC initperf_trace_context(void); PyMODINIT_FUNC initperf_trace_context(void);
......
#include <errno.h>
#include <inttypes.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <traceevent/event-parse.h> #include <traceevent/event-parse.h>
#include <api/fs/fs.h> #include <api/fs/fs.h>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "thread.h" #include "thread.h"
#include "data.h" #include "data.h"
#include "ordered-events.h" #include "ordered-events.h"
#include <linux/kernel.h>
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
......
#include <errno.h>
#include <inttypes.h>
#include <regex.h>
#include <sys/mman.h> #include <sys/mman.h>
#include "sort.h" #include "sort.h"
#include "hist.h" #include "hist.h"
...@@ -5,8 +8,10 @@ ...@@ -5,8 +8,10 @@
#include "symbol.h" #include "symbol.h"
#include "evsel.h" #include "evsel.h"
#include "evlist.h" #include "evlist.h"
#include "strlist.h"
#include <traceevent/event-parse.h> #include <traceevent/event-parse.h>
#include "mem-events.h" #include "mem-events.h"
#include <linux/kernel.h>
regex_t parent_regex; regex_t parent_regex;
const char default_parent_pattern[] = "^sys_|^do_page_fault"; const char default_parent_pattern[] = "^sys_|^do_page_fault";
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define __PERF_SORT_H #define __PERF_SORT_H
#include "../builtin.h" #include "../builtin.h"
#include "util.h" #include <regex.h>
#include "color.h" #include "color.h"
#include <linux/list.h> #include <linux/list.h>
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "symbol.h" #include "symbol.h"
#include "string.h" #include "string.h"
#include "callchain.h" #include "callchain.h"
#include "strlist.h"
#include "values.h" #include "values.h"
#include "../perf.h" #include "../perf.h"
...@@ -21,6 +20,7 @@ ...@@ -21,6 +20,7 @@
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include "parse-events.h" #include "parse-events.h"
#include "hist.h" #include "hist.h"
#include "srcline.h"
#include "thread.h" #include "thread.h"
extern regex_t parent_regex; extern regex_t parent_regex;
......
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -8,6 +9,7 @@ ...@@ -8,6 +9,7 @@
#include "util/util.h" #include "util/util.h"
#include "util/debug.h" #include "util/debug.h"
#include "util/callchain.h" #include "util/callchain.h"
#include "srcline.h"
#include "symbol.h" #include "symbol.h"
......
#ifndef PERF_SRCLINE_H
#define PERF_SRCLINE_H
#include <linux/list.h>
#include <linux/types.h>
struct dso;
struct symbol;
extern bool srcline_full_filename;
char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
bool show_sym, bool show_addr);
char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
bool show_sym, bool show_addr, bool unwind_inlines);
void free_srcline(char *srcline);
#define SRCLINE_UNKNOWN ((char *) "??:0")
struct inline_list {
char *filename;
char *funcname;
unsigned int line_nr;
struct list_head list;
};
struct inline_node {
u64 addr;
struct list_head val;
};
struct inline_node *dso__parse_addr_inlines(struct dso *dso, u64 addr);
void inline_node__delete(struct inline_node *node);
#endif /* PERF_SRCLINE_H */
#include <errno.h>
#include <inttypes.h>
#include <math.h> #include <math.h>
#include "stat.h" #include "stat.h"
#include "evlist.h" #include "evlist.h"
......
#include "debug.h" #include "debug.h"
#include "util.h" #include "util.h"
#include <linux/kernel.h> #include <linux/kernel.h>
#include <errno.h>
int prefixcmp(const char *str, const char *prefix) int prefixcmp(const char *str, const char *prefix)
{ {
......
#include "util.h" #include "util.h"
#include "string.h" #include "string2.h"
#include "strfilter.h" #include "strfilter.h"
#include <errno.h>
#include "sane_ctype.h"
/* Operators */ /* Operators */
static const char *OP_and = "&"; /* Logical AND */ static const char *OP_and = "&"; /* Logical AND */
static const char *OP_or = "|"; /* Logical OR */ static const char *OP_or = "|"; /* Logical OR */
......
#include "util.h" #include "string2.h"
#include "linux/string.h" #include <linux/kernel.h>
#include <linux/string.h>
#include <stdlib.h>
#include "sane_ctype.h"
#define K 1024LL #define K 1024LL
/* /*
...@@ -99,8 +103,10 @@ static int count_argc(const char *str) ...@@ -99,8 +103,10 @@ static int count_argc(const char *str)
void argv_free(char **argv) void argv_free(char **argv)
{ {
char **p; char **p;
for (p = argv; *p; p++) for (p = argv; *p; p++) {
zfree(p); free(*p);
*p = NULL;
}
free(argv); free(argv);
} }
...@@ -120,7 +126,7 @@ void argv_free(char **argv) ...@@ -120,7 +126,7 @@ void argv_free(char **argv)
char **argv_split(const char *str, int *argcp) char **argv_split(const char *str, int *argcp)
{ {
int argc = count_argc(str); int argc = count_argc(str);
char **argv = zalloc(sizeof(*argv) * (argc+1)); char **argv = calloc(argc + 1, sizeof(*argv));
char **argvp; char **argvp;
if (argv == NULL) if (argv == NULL)
...@@ -377,7 +383,7 @@ char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints ...@@ -377,7 +383,7 @@ char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints
goto out_err_overflow; goto out_err_overflow;
if (i > 0) if (i > 0)
printed += snprintf(e + printed, size - printed, " %s ", or_and); printed += scnprintf(e + printed, size - printed, " %s ", or_and);
printed += scnprintf(e + printed, size - printed, printed += scnprintf(e + printed, size - printed,
"%s %s %d", var, eq_neq, ints[i]); "%s %s %d", var, eq_neq, ints[i]);
} }
......
#ifndef PERF_STRING_H
#define PERF_STRING_H
#include <linux/types.h>
#include <stddef.h>
#include <string.h>
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 strglobmatch_nocase(const char *str, const char *pat);
bool strlazymatch(const char *str, const char *pat);
static inline bool strisglob(const char *str)
{
return strpbrk(str, "*?[") != NULL;
}
int strtailcmp(const char *s1, const char *s2);
char *strxfrchar(char *s, char from, char to);
char *ltrim(char *s);
char *rtrim(char *s);
static inline char *trim(char *s)
{
return ltrim(rtrim(s));
}
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);
}
#endif /* PERF_STRING_H */
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
#include "demangle-rust.h" #include "demangle-rust.h"
#include "machine.h" #include "machine.h"
#include "vdso.h" #include "vdso.h"
#include <symbol/kallsyms.h>
#include "debug.h" #include "debug.h"
#include "sane_ctype.h"
#include <symbol/kallsyms.h>
#ifndef EM_AARCH64 #ifndef EM_AARCH64
#define EM_AARCH64 183 /* ARM 64 bit */ #define EM_AARCH64 183 /* ARM 64 bit */
......
#include "symbol.h" #include "symbol.h"
#include "util.h" #include "util.h"
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <linux/kernel.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/param.h> #include <sys/param.h>
...@@ -18,6 +19,8 @@ ...@@ -18,6 +19,8 @@
#include "strlist.h" #include "strlist.h"
#include "intlist.h" #include "intlist.h"
#include "header.h" #include "header.h"
#include "path.h"
#include "sane_ctype.h"
#include <elf.h> #include <elf.h>
#include <limits.h> #include <limits.h>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <libgen.h> #include <libgen.h>
#include "build-id.h" #include "build-id.h"
#include "event.h" #include "event.h"
#include "util.h" #include "path.h"
#ifdef HAVE_LIBELF_SUPPORT #ifdef HAVE_LIBELF_SUPPORT
#include <libelf.h> #include <libelf.h>
......
#include "util.h" #include "term.h"
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
void get_term_dimensions(struct winsize *ws) void get_term_dimensions(struct winsize *ws)
{ {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/list.h> #include <linux/list.h>
#include <errno.h>
#include "thread.h" #include "thread.h"
#include "event.h" #include "event.h"
#include "machine.h" #include "machine.h"
......
#include "../perf.h" #include "../perf.h"
#include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <linux/kernel.h>
#include "session.h" #include "session.h"
#include "thread.h" #include "thread.h"
#include "thread-stack.h" #include "thread-stack.h"
......
#include <dirent.h> #include <dirent.h>
#include <errno.h>
#include <limits.h> #include <limits.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -6,6 +7,7 @@ ...@@ -6,6 +7,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include "string2.h"
#include "strlist.h" #include "strlist.h"
#include <string.h> #include <string.h>
#include <api/fs/fs.h> #include <api/fs/fs.h>
......
...@@ -21,13 +21,14 @@ ...@@ -21,13 +21,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include <errno.h> #include <errno.h>
#include "../perf.h" #include "../perf.h"
#include "util.h" #include "util.h"
#include "trace-event.h" #include "trace-event.h"
#include "sane_ctype.h"
static int get_common_field(struct scripting_context *context, static int get_common_field(struct scripting_context *context,
int *offset, int *size, const char *type) int *offset, int *size, const char *type)
{ {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "event.h" #include "event.h"
#include "perf_regs.h" #include "perf_regs.h"
#include "callchain.h" #include "callchain.h"
#include "util.h"
static char *debuginfo_path; static char *debuginfo_path;
......
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
*/ */
#include <elf.h> #include <elf.h>
#include <errno.h>
#include <gelf.h> #include <gelf.h>
#include <fcntl.h> #include <fcntl.h>
#include <inttypes.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#ifdef HAVE_BACKTRACE_SUPPORT #ifdef HAVE_BACKTRACE_SUPPORT
#include <execinfo.h> #include <execinfo.h>
#endif #endif
#include <dirent.h>
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -712,16 +714,6 @@ const char *perf_tip(const char *dirpath) ...@@ -712,16 +714,6 @@ const char *perf_tip(const char *dirpath)
return tip; return tip;
} }
bool is_regular_file(const char *file)
{
struct stat st;
if (stat(file, &st))
return false;
return S_ISREG(st.st_mode);
}
int fetch_current_timestamp(char *buf, size_t sz) int fetch_current_timestamp(char *buf, size_t sz)
{ {
struct timeval tv; struct timeval tv;
...@@ -739,58 +731,6 @@ int fetch_current_timestamp(char *buf, size_t sz) ...@@ -739,58 +731,6 @@ int fetch_current_timestamp(char *buf, size_t sz)
return 0; return 0;
} }
void print_binary(unsigned char *data, size_t len,
size_t bytes_per_line, print_binary_t printer,
void *extra)
{
size_t i, j, mask;
if (!printer)
return;
bytes_per_line = roundup_pow_of_two(bytes_per_line);
mask = bytes_per_line - 1;
printer(BINARY_PRINT_DATA_BEGIN, 0, extra);
for (i = 0; i < len; i++) {
if ((i & mask) == 0) {
printer(BINARY_PRINT_LINE_BEGIN, -1, extra);
printer(BINARY_PRINT_ADDR, i, extra);
}
printer(BINARY_PRINT_NUM_DATA, data[i], extra);
if (((i & mask) == mask) || i == len - 1) {
for (j = 0; j < mask-(i & mask); j++)
printer(BINARY_PRINT_NUM_PAD, -1, extra);
printer(BINARY_PRINT_SEP, i, extra);
for (j = i & ~mask; j <= i; j++)
printer(BINARY_PRINT_CHAR_DATA, data[j], extra);
for (j = 0; j < mask-(i & mask); j++)
printer(BINARY_PRINT_CHAR_PAD, i, extra);
printer(BINARY_PRINT_LINE_END, -1, extra);
}
}
printer(BINARY_PRINT_DATA_END, -1, extra);
}
int is_printable_array(char *p, unsigned int len)
{
unsigned int i;
if (!p || !len || p[len - 1] != 0)
return 0;
len--;
for (i = 0; i < len; i++) {
if (!isprint(p[i]) && !isspace(p[i]))
return 0;
}
return 1;
}
int unit_number__scnprintf(char *buf, size_t size, u64 n) int unit_number__scnprintf(char *buf, size_t size, u64 n)
{ {
char unit[4] = "BKMG"; char unit[4] = "BKMG";
......
#ifndef GIT_COMPAT_UTIL_H #ifndef GIT_COMPAT_UTIL_H
#define 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 _ALL_SOURCE 1
#define _BSD_SOURCE 1 #define _BSD_SOURCE 1
/* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ /* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */
...@@ -53,73 +17,22 @@ ...@@ -53,73 +17,22 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <term.h>
#include <errno.h>
#include <limits.h> #include <limits.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h>
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
#include <signal.h> #include <signal.h>
#include <fnmatch.h>
#include <assert.h> #include <assert.h>
#include <regex.h>
#include <utime.h> #include <utime.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <poll.h> #include <poll.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <inttypes.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <sys/ttydefaults.h>
#include <api/fs/tracing_path.h>
#include <termios.h>
#include <linux/bitops.h>
#include <termios.h>
#include "strlist.h"
extern const char *graph_line;
extern const char *graph_dotted_line;
extern const char *spaces;
extern const char *dots;
extern char buildid_dir[];
/* 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 extern char buildid_dir[];
#define is_dir_sep(c) ((c) == '/')
#endif
#ifdef __GNUC__ #ifdef __GNUC__
#define NORETURN __attribute__((__noreturn__)) #define NORETURN __attribute__((__noreturn__))
...@@ -143,22 +56,6 @@ void set_warning_routine(void (*routine)(const char *err, va_list params)); ...@@ -143,22 +56,6 @@ void set_warning_routine(void (*routine)(const char *err, va_list params));
int prefixcmp(const char *str, const char *prefix); int prefixcmp(const char *str, const char *prefix);
void set_buildid_dir(const char *dir); void set_buildid_dir(const char *dir);
#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
static inline void *zalloc(size_t size) static inline void *zalloc(size_t size)
{ {
return calloc(1, size); return calloc(1, size);
...@@ -166,47 +63,8 @@ static inline void *zalloc(size_t size) ...@@ -166,47 +63,8 @@ static inline void *zalloc(size_t size)
#define zfree(ptr) ({ free(*ptr); *ptr = NULL; }) #define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
/* Sane ctype - no locale, and works with signed chars */ struct dirent;
#undef isascii struct strlist;
#undef isspace
#undef isdigit
#undef isxdigit
#undef isalpha
#undef isprint
#undef isalnum
#undef islower
#undef isupper
#undef tolower
#undef toupper
extern unsigned char sane_ctype[256];
#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
#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)
#define isxdigit(x) \
(sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G')
#define isalpha(x) sane_istest(x,GIT_ALPHA)
#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
#define isprint(x) sane_istest(x,GIT_PRINT)
#define islower(x) (sane_istest(x,GIT_ALPHA) && (x & 0x20))
#define isupper(x) (sane_istest(x,GIT_ALPHA) && !(x & 0x20))
#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;
}
int mkdir_p(char *path, mode_t mode); int mkdir_p(char *path, mode_t mode);
int rm_rf(const char *path); int rm_rf(const char *path);
...@@ -216,18 +74,6 @@ int copyfile(const char *from, const char *to); ...@@ -216,18 +74,6 @@ int copyfile(const char *from, const char *to);
int copyfile_mode(const char *from, const char *to, mode_t mode); int copyfile_mode(const char *from, const char *to, mode_t mode);
int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size); int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size);
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 strglobmatch_nocase(const char *str, const char *pat);
bool strlazymatch(const char *str, const char *pat);
static inline bool strisglob(const char *str)
{
return strpbrk(str, "*?[") != NULL;
}
int strtailcmp(const char *s1, const char *s2);
char *strxfrchar(char *s, char from, char to);
unsigned long convert_unit(unsigned long value, char *unit); unsigned long convert_unit(unsigned long value, char *unit);
ssize_t readn(int fd, void *buf, size_t n); ssize_t readn(int fd, void *buf, size_t n);
ssize_t writen(int fd, void *buf, size_t n); ssize_t writen(int fd, void *buf, size_t n);
...@@ -236,20 +82,9 @@ struct perf_event_attr; ...@@ -236,20 +82,9 @@ struct perf_event_attr;
void event_attr_init(struct perf_event_attr *attr); void event_attr_init(struct perf_event_attr *attr);
#define _STR(x) #x
#define STR(x) _STR(x)
size_t hex_width(u64 v); size_t hex_width(u64 v);
int hex2u64(const char *ptr, u64 *val); int hex2u64(const char *ptr, u64 *val);
char *ltrim(char *s);
char *rtrim(char *s);
static inline char *trim(char *s)
{
return ltrim(rtrim(s));
}
void dump_stack(void); void dump_stack(void);
void sighandler_dump_stack(int sig); void sighandler_dump_stack(int sig);
...@@ -265,33 +100,6 @@ struct parse_tag { ...@@ -265,33 +100,6 @@ struct parse_tag {
unsigned long parse_tag_value(const char *str, struct parse_tag *tags); unsigned long parse_tag_value(const char *str, struct parse_tag *tags);
#define SRCLINE_UNKNOWN ((char *) "??:0")
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);
}
struct dso;
struct symbol;
extern bool srcline_full_filename;
char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
bool show_sym, bool show_addr);
char *__get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
bool show_sym, bool show_addr, bool unwind_inlines);
void free_srcline(char *srcline);
int perf_event_paranoid(void); int perf_event_paranoid(void);
void mem_bswap_64(void *src, int byte_size); void mem_bswap_64(void *src, int byte_size);
...@@ -308,18 +116,6 @@ int gzip_decompress_to_file(const char *input, int output_fd); ...@@ -308,18 +116,6 @@ int gzip_decompress_to_file(const char *input, int output_fd);
int lzma_decompress_to_file(const char *input, int output_fd); int lzma_decompress_to_file(const char *input, int output_fd);
#endif #endif
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);
}
int get_stack_size(const char *str, unsigned long *_size); int get_stack_size(const char *str, unsigned long *_size);
int fetch_kernel_version(unsigned int *puint, int fetch_kernel_version(unsigned int *puint,
...@@ -331,53 +127,14 @@ int fetch_kernel_version(unsigned int *puint, ...@@ -331,53 +127,14 @@ int fetch_kernel_version(unsigned int *puint,
#define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x) #define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x)
const char *perf_tip(const char *dirpath); const char *perf_tip(const char *dirpath);
bool is_regular_file(const char *file);
int fetch_current_timestamp(char *buf, size_t sz); int fetch_current_timestamp(char *buf, size_t sz);
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);
#ifndef HAVE_SCHED_GETCPU_SUPPORT #ifndef HAVE_SCHED_GETCPU_SUPPORT
int sched_getcpu(void); int sched_getcpu(void);
#endif #endif
int is_printable_array(char *p, unsigned int len);
int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz); int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz);
int unit_number__scnprintf(char *buf, size_t size, u64 n); int unit_number__scnprintf(char *buf, size_t size, u64 n);
struct inline_list {
char *filename;
char *funcname;
unsigned int line_nr;
struct list_head list;
};
struct inline_node {
u64 addr;
struct list_head val;
};
struct inline_node *dso__parse_addr_inlines(struct dso *dso, u64 addr);
void inline_node__delete(struct inline_node *node);
#endif /* GIT_COMPAT_UTIL_H */ #endif /* GIT_COMPAT_UTIL_H */
#include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册