Commit 883f4def authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'perf-core-for-mingo-4.21-20181218' of...

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

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

- Implement BPF based syscall filtering in 'perf trace', using BPF maps and
  the augmented_raw_syscalls.c BPF proggie (Arnaldo Carvalho de Melo)

- Allow specifying in .perfconfig a set of events use in 'perf trace' in
  addition to any other specified from the command line. This initially
  will be used to always use the augmented_raw_syscalls.o precompiled
  BPF program for getting pointer contents. (Arnaldo Carvalho de Melo)

- Allow fine grained control about how the syscall output should be
  formatted. This will be used to allow producing the same output produced
  by the 'strace' tool, to then use in regression tests comparing the
  output of 'perf trace' with the one produced from 'strace' (Arnaldo Carvalho de Melo)

- Beautify the renameat2 olddirfd, newdirfd and flags arguments (Arnaldo Carvalho de Melo)

- Beautify arch_prctl 'code' syscall arg (Arnaldo Carvalho de Melo)

- Beautify fadvise64 'advice' syscall arg (Arnaldo Carvalho de Melo)

- Relax checks on perf-PID.map ownership, resulting in symbols in
  executable anonymous maps setup by JITs in things like node.js to
  be resolved in a 'perf top' session run by root without the need
  for --force to be used (Arnaldo Carvalho de Melo)

- Update asm-generic/unistd.h copy (Arnaldo Carvalho de Melo)

- Do not use the first and last symbols when setting up address filters in
  auxtrace, this fails when we don't have a symbol table, filter the entire
  area based on the dso size. (Adrian Hunter)

- Do not use kernel headers to build libsubcmd, we shouldn't use
  anything from outside tools/, fixes the build with the Android NDK (Arnaldo Carvalho de Melo)

- Add several prototypes for systems lacking those, such as open_memstream(),
  sigqueue(), fixing warnings building with Android's bionic libc that were
  preventing the use of -Werror there (Arnaldo Carvalho de Melo)

- Use LDFLAGS in the libtraceevent build commands, allowing developers
  to override its values (Jiri Olsa)

- Link libperf-jvmti.so with LDFLAGS variable, allowing distro
  packages to propagate its settings when building this library (Jiri Olsa)

- cs-etm (ARM CoreSight) fixes: (Leo Yan)

  - Correct packets swapping in cs_etm__flush()
  - Avoid stale branch samples when flush packet
  - Remove unused 'trace_on' in cs_etm_decoder
  - Refactor enumeration cs_etm_sample_type
  - Rename CS_ETM_TRACE_ON to CS_ETM_DISCONTINUITY
  - Treat NO_SYNC element as trace discontinuity
  - Treat EO_TRACE element as trace discontinuity
  - Generate branch sample for exception packet

- Use shebangs in the 'perf test' shell scripts, making them identifiable as
  shell scripts (Michael Petlan)

- Avoid segfaults caused by negated options in 'perf stat' (Michael Petlan)

- Fix processing of dereferenced args in bprintk events in libtracevent (Steven Rostedt)
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents ca46afdb 89a09489
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _ASM_X86_PRCTL_H
#define _ASM_X86_PRCTL_H
#define ARCH_SET_GS 0x1001
#define ARCH_SET_FS 0x1002
#define ARCH_GET_FS 0x1003
#define ARCH_GET_GS 0x1004
#define ARCH_GET_CPUID 0x1011
#define ARCH_SET_CPUID 0x1012
#define ARCH_MAP_VDSO_X32 0x2001
#define ARCH_MAP_VDSO_32 0x2002
#define ARCH_MAP_VDSO_64 0x2003
#endif /* _ASM_X86_PRCTL_H */
...@@ -760,8 +760,10 @@ __SYSCALL(__NR_rseq, sys_rseq) ...@@ -760,8 +760,10 @@ __SYSCALL(__NR_rseq, sys_rseq)
#define __NR_ftruncate __NR3264_ftruncate #define __NR_ftruncate __NR3264_ftruncate
#define __NR_lseek __NR3264_lseek #define __NR_lseek __NR3264_lseek
#define __NR_sendfile __NR3264_sendfile #define __NR_sendfile __NR3264_sendfile
#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
#define __NR_newfstatat __NR3264_fstatat #define __NR_newfstatat __NR3264_fstatat
#define __NR_fstat __NR3264_fstat #define __NR_fstat __NR3264_fstat
#endif
#define __NR_mmap __NR3264_mmap #define __NR_mmap __NR3264_mmap
#define __NR_fadvise64 __NR3264_fadvise64 #define __NR_fadvise64 __NR3264_fadvise64
#ifdef __NR3264_stat #ifdef __NR3264_stat
...@@ -776,8 +778,10 @@ __SYSCALL(__NR_rseq, sys_rseq) ...@@ -776,8 +778,10 @@ __SYSCALL(__NR_rseq, sys_rseq)
#define __NR_ftruncate64 __NR3264_ftruncate #define __NR_ftruncate64 __NR3264_ftruncate
#define __NR_llseek __NR3264_lseek #define __NR_llseek __NR3264_lseek
#define __NR_sendfile64 __NR3264_sendfile #define __NR_sendfile64 __NR3264_sendfile
#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64)
#define __NR_fstatat64 __NR3264_fstatat #define __NR_fstatat64 __NR3264_fstatat
#define __NR_fstat64 __NR3264_fstat #define __NR_fstat64 __NR3264_fstat
#endif
#define __NR_mmap2 __NR3264_mmap #define __NR_mmap2 __NR3264_mmap
#define __NR_fadvise64_64 __NR3264_fadvise64 #define __NR_fadvise64_64 __NR3264_fadvise64
#ifdef __NR3264_stat #ifdef __NR3264_stat
......
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef FADVISE_H_INCLUDED
#define FADVISE_H_INCLUDED
#define POSIX_FADV_NORMAL 0 /* No further special treatment. */
#define POSIX_FADV_RANDOM 1 /* Expect random page references. */
#define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
#define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
/*
* The advise values for POSIX_FADV_DONTNEED and POSIX_ADV_NOREUSE
* for s390-64 differ from the values for the rest of the world.
*/
#if defined(__s390x__)
#define POSIX_FADV_DONTNEED 6 /* Don't need these pages. */
#define POSIX_FADV_NOREUSE 7 /* Data will be accessed once. */
#else
#define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
#define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
#endif
#endif /* FADVISE_H_INCLUDED */
...@@ -36,8 +36,6 @@ endif ...@@ -36,8 +36,6 @@ endif
CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
CFLAGS += -I$(srctree)/tools/include/ CFLAGS += -I$(srctree)/tools/include/
CFLAGS += -I$(srctree)/include/uapi
CFLAGS += -I$(srctree)/include
SUBCMD_IN := $(OUTPUT)libsubcmd-in.o SUBCMD_IN := $(OUTPUT)libsubcmd-in.o
......
...@@ -177,7 +177,7 @@ $(TE_IN): force ...@@ -177,7 +177,7 @@ $(TE_IN): force
$(Q)$(MAKE) $(build)=libtraceevent $(Q)$(MAKE) $(build)=libtraceevent
$(OUTPUT)libtraceevent.so.$(EVENT_PARSE_VERSION): $(TE_IN) $(OUTPUT)libtraceevent.so.$(EVENT_PARSE_VERSION): $(TE_IN)
$(QUIET_LINK)$(CC) --shared $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@ $(QUIET_LINK)$(CC) --shared $(LDFLAGS) $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@
@ln -sf $(@F) $(OUTPUT)libtraceevent.so @ln -sf $(@F) $(OUTPUT)libtraceevent.so
@ln -sf $(@F) $(OUTPUT)libtraceevent.so.$(EP_VERSION) @ln -sf $(@F) $(OUTPUT)libtraceevent.so.$(EP_VERSION)
...@@ -196,7 +196,7 @@ $(PLUGINS_IN): force ...@@ -196,7 +196,7 @@ $(PLUGINS_IN): force
$(Q)$(MAKE) $(build)=$(plugin_obj) $(Q)$(MAKE) $(build)=$(plugin_obj)
$(OUTPUT)%.so: $(OUTPUT)%-in.o $(OUTPUT)%.so: $(OUTPUT)%-in.o
$(QUIET_LINK)$(CC) $(CFLAGS) -shared -nostartfiles -o $@ $^ $(QUIET_LINK)$(CC) $(CFLAGS) -shared $(LDFLAGS) -nostartfiles -o $@ $^
define make_version.h define make_version.h
(echo '/* This file is automatically generated. Do not modify. */'; \ (echo '/* This file is automatically generated. Do not modify. */'; \
......
...@@ -4973,6 +4973,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_e ...@@ -4973,6 +4973,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_e
if (arg->type == TEP_PRINT_BSTRING) { if (arg->type == TEP_PRINT_BSTRING) {
trace_seq_puts(s, arg->string.string); trace_seq_puts(s, arg->string.string);
arg = arg->next;
break; break;
} }
......
...@@ -521,6 +521,38 @@ diff.*:: ...@@ -521,6 +521,38 @@ diff.*::
Possible values are 'delta', 'delta-abs', 'ratio' and Possible values are 'delta', 'delta-abs', 'ratio' and
'wdiff'. Default is 'delta'. 'wdiff'. Default is 'delta'.
trace.*::
trace.add_events::
Allows adding a set of events to add to the ones specified
by the user, or use as a default one if none was specified.
The initial use case is to add augmented_raw_syscalls.o to
activate the 'perf trace' logic that looks for syscall
pointer contents after the normal tracepoint payload.
trace.args_alignment::
Number of columns to align the argument list, default is 70,
use 40 for the strace default, zero to no alignment.
trace.no_inherit::
Do not follow children threads.
trace.show_arg_names::
Should syscall argument names be printed? If not then trace.show_zeros
will be set.
trace.show_duration::
Show syscall duration.
trace.show_prefix::
If set to 'yes' will show common string prefixes in tables. The default
is to remove the common prefix in things like "MAP_SHARED", showing just "SHARED".
trace.show_timestamp::
Show syscall start timestamp.
trace.show_zeros::
Do not suppress syscall arguments that are equal to zero.
SEE ALSO SEE ALSO
-------- --------
linkperf:perf[1] linkperf:perf[1]
...@@ -205,6 +205,12 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs. ...@@ -205,6 +205,12 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
because the file may be huge. A time out is needed in such cases. because the file may be huge. A time out is needed in such cases.
This option sets the time out limit. The default value is 500 ms. This option sets the time out limit. The default value is 500 ms.
--sort-events::
Do sorting on batches of events, use when noticing out of order events that
may happen, for instance, when a thread gets migrated to a different CPU
while processing a syscall.
PAGEFAULTS PAGEFAULTS
---------- ----------
......
...@@ -294,6 +294,8 @@ ifndef NO_BIONIC ...@@ -294,6 +294,8 @@ ifndef NO_BIONIC
$(call feature_check,bionic) $(call feature_check,bionic)
ifeq ($(feature-bionic), 1) ifeq ($(feature-bionic), 1)
BIONIC := 1 BIONIC := 1
CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE
CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE
EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
endif endif
......
...@@ -396,6 +396,7 @@ SHELL = $(SHELL_PATH) ...@@ -396,6 +396,7 @@ SHELL = $(SHELL_PATH)
linux_uapi_dir := $(srctree)/tools/include/uapi/linux linux_uapi_dir := $(srctree)/tools/include/uapi/linux
asm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic asm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic
arch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/ arch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/
x86_arch_asm_uapi_dir := $(srctree)/tools/arch/x86/include/uapi/asm/
beauty_outdir := $(OUTPUT)trace/beauty/generated beauty_outdir := $(OUTPUT)trace/beauty/generated
beauty_ioctl_outdir := $(beauty_outdir)/ioctl beauty_ioctl_outdir := $(beauty_outdir)/ioctl
...@@ -409,6 +410,12 @@ _dummy := $(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_ou ...@@ -409,6 +410,12 @@ _dummy := $(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_ou
$(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl) $(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl)
$(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@ $(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@
fadvise_advice_array := $(beauty_outdir)/fadvise_advice_array.c
fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh
$(fadvise_advice_array): $(linux_uapi_dir)/in.h $(fadvise_advice_tbl)
$(Q)$(SHELL) '$(fadvise_advice_tbl)' $(linux_uapi_dir) > $@
pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c
asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh
...@@ -490,6 +497,18 @@ prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh ...@@ -490,6 +497,18 @@ prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh
$(prctl_option_array): $(prctl_hdr_dir)/prctl.h $(prctl_option_tbl) $(prctl_option_array): $(prctl_hdr_dir)/prctl.h $(prctl_option_tbl)
$(Q)$(SHELL) '$(prctl_option_tbl)' $(prctl_hdr_dir) > $@ $(Q)$(SHELL) '$(prctl_option_tbl)' $(prctl_hdr_dir) > $@
x86_arch_prctl_code_array := $(beauty_outdir)/x86_arch_prctl_code_array.c
x86_arch_prctl_code_tbl := $(srctree)/tools/perf/trace/beauty/x86_arch_prctl.sh
$(x86_arch_prctl_code_array): $(x86_arch_asm_uapi_dir)/prctl.h $(x86_arch_prctl_code_tbl)
$(Q)$(SHELL) '$(x86_arch_prctl_code_tbl)' $(x86_arch_asm_uapi_dir) > $@
rename_flags_array := $(beauty_outdir)/rename_flags_array.c
rename_flags_tbl := $(srctree)/tools/perf/trace/beauty/rename_flags.sh
$(rename_flags_array): $(linux_uapi_dir)/fs.h $(rename_flags_tbl)
$(Q)$(SHELL) '$(rename_flags_tbl)' $(linux_uapi_dir) > $@
arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c
arch_errno_hdr_dir := $(srctree)/tools arch_errno_hdr_dir := $(srctree)/tools
arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh
...@@ -592,6 +611,7 @@ __build-dir = $(subst $(OUTPUT),,$(dir $@)) ...@@ -592,6 +611,7 @@ __build-dir = $(subst $(OUTPUT),,$(dir $@))
build-dir = $(if $(__build-dir),$(__build-dir),.) build-dir = $(if $(__build-dir),$(__build-dir),.)
prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \
$(fadvise_advice_array) \
$(pkey_alloc_access_rights_array) \ $(pkey_alloc_access_rights_array) \
$(sndrv_pcm_ioctl_array) \ $(sndrv_pcm_ioctl_array) \
$(sndrv_ctl_ioctl_array) \ $(sndrv_ctl_ioctl_array) \
...@@ -604,6 +624,8 @@ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioc ...@@ -604,6 +624,8 @@ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioc
$(mount_flags_array) \ $(mount_flags_array) \
$(perf_ioctl_array) \ $(perf_ioctl_array) \
$(prctl_option_array) \ $(prctl_option_array) \
$(x86_arch_prctl_code_array) \
$(rename_flags_array) \
$(arch_errno_name_array) $(arch_errno_name_array)
$(OUTPUT)%.o: %.c prepare FORCE $(OUTPUT)%.o: %.c prepare FORCE
...@@ -647,7 +669,7 @@ $(LIBJVMTI_IN): FORCE ...@@ -647,7 +669,7 @@ $(LIBJVMTI_IN): FORCE
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN) $(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
$(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $< $(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
endif endif
$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h) $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
...@@ -887,6 +909,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea ...@@ -887,6 +909,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
$(OUTPUT)util/intel-pt-decoder/inat-tables.c \ $(OUTPUT)util/intel-pt-decoder/inat-tables.c \
$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
$(OUTPUT)pmu-events/pmu-events.c \ $(OUTPUT)pmu-events/pmu-events.c \
$(OUTPUT)$(fadvise_advice_array) \
$(OUTPUT)$(madvise_behavior_array) \ $(OUTPUT)$(madvise_behavior_array) \
$(OUTPUT)$(mmap_flags_array) \ $(OUTPUT)$(mmap_flags_array) \
$(OUTPUT)$(mount_flags_array) \ $(OUTPUT)$(mount_flags_array) \
...@@ -900,6 +923,8 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea ...@@ -900,6 +923,8 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
$(OUTPUT)$(vhost_virtio_ioctl_array) \ $(OUTPUT)$(vhost_virtio_ioctl_array) \
$(OUTPUT)$(perf_ioctl_array) \ $(OUTPUT)$(perf_ioctl_array) \
$(OUTPUT)$(prctl_option_array) \ $(OUTPUT)$(prctl_option_array) \
$(OUTPUT)$(x86_arch_prctl_code_array) \
$(OUTPUT)$(rename_flags_array) \
$(OUTPUT)$(arch_errno_name_array) $(OUTPUT)$(arch_errno_name_array)
$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
......
...@@ -196,6 +196,7 @@ int cmd_config(int argc, const char **argv) ...@@ -196,6 +196,7 @@ int cmd_config(int argc, const char **argv)
pr_err("Error: takes no arguments\n"); pr_err("Error: takes no arguments\n");
parse_options_usage(config_usage, config_options, "l", 1); parse_options_usage(config_usage, config_options, "l", 1);
} else { } else {
do_action_list:
if (show_config(set) < 0) { if (show_config(set) < 0) {
pr_err("Nothing configured, " pr_err("Nothing configured, "
"please check your %s \n", config_filename); "please check your %s \n", config_filename);
...@@ -204,10 +205,8 @@ int cmd_config(int argc, const char **argv) ...@@ -204,10 +205,8 @@ int cmd_config(int argc, const char **argv)
} }
break; break;
default: default:
if (!argc) { if (!argc)
usage_with_options(config_usage, config_options); goto do_action_list;
break;
}
for (i = 0; argv[i]; i++) { for (i = 0; argv[i]; i++) {
char *var, *value; char *var, *value;
......
...@@ -709,7 +709,7 @@ static int parse_metric_groups(const struct option *opt, ...@@ -709,7 +709,7 @@ static int parse_metric_groups(const struct option *opt,
return metricgroup__parse_groups(opt, str, &stat_config.metric_events); return metricgroup__parse_groups(opt, str, &stat_config.metric_events);
} }
static const struct option stat_options[] = { static struct option stat_options[] = {
OPT_BOOLEAN('T', "transaction", &transaction_run, OPT_BOOLEAN('T', "transaction", &transaction_run,
"hardware transaction statistics"), "hardware transaction statistics"),
OPT_CALLBACK('e', "event", &evsel_list, "event", OPT_CALLBACK('e', "event", &evsel_list, "event",
...@@ -1599,6 +1599,12 @@ int cmd_stat(int argc, const char **argv) ...@@ -1599,6 +1599,12 @@ int cmd_stat(int argc, const char **argv)
return -ENOMEM; return -ENOMEM;
parse_events__shrink_config_terms(); parse_events__shrink_config_terms();
/* String-parsing callback-based options would segfault when negated */
set_option_flag(stat_options, 'e', "event", PARSE_OPT_NONEG);
set_option_flag(stat_options, 'M', "metrics", PARSE_OPT_NONEG);
set_option_flag(stat_options, 'G', "cgroup", PARSE_OPT_NONEG);
argc = parse_options_subcommand(argc, argv, stat_options, stat_subcommands, argc = parse_options_subcommand(argc, argv, stat_options, stat_subcommands,
(const char **) stat_usage, (const char **) stat_usage,
PARSE_OPT_STOP_AT_NON_OPTION); PARSE_OPT_STOP_AT_NON_OPTION);
......
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
#include "util/data.h" #include "util/data.h"
#include "util/debug.h" #include "util/debug.h"
#ifdef LACKS_OPEN_MEMSTREAM_PROTOTYPE
FILE *open_memstream(char **ptr, size_t *sizeloc);
#endif
#define SUPPORT_OLD_POWER_EVENTS 1 #define SUPPORT_OLD_POWER_EVENTS 1
#define PWR_EVENT_EXIT -1 #define PWR_EVENT_EXIT -1
......
This diff is collapsed.
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
HEADERS=' HEADERS='
include/uapi/drm/drm.h include/uapi/drm/drm.h
include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
include/uapi/linux/fadvise.h
include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
include/uapi/linux/fs.h include/uapi/linux/fs.h
include/uapi/linux/kcmp.h include/uapi/linux/kcmp.h
...@@ -21,6 +22,7 @@ include/uapi/linux/hw_breakpoint.h ...@@ -21,6 +22,7 @@ include/uapi/linux/hw_breakpoint.h
arch/x86/include/asm/disabled-features.h arch/x86/include/asm/disabled-features.h
arch/x86/include/asm/required-features.h arch/x86/include/asm/required-features.h
arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
arch/x86/include/uapi/asm/prctl.h
arch/arm/include/uapi/asm/perf_regs.h arch/arm/include/uapi/asm/perf_regs.h
arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
arch/powerpc/include/uapi/asm/perf_regs.h arch/powerpc/include/uapi/asm/perf_regs.h
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
* code that will combine entry/exit in a strace like way. * code that will combine entry/exit in a strace like way.
*/ */
#include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <pid_filter.h> #include <pid_filter.h>
...@@ -26,6 +25,17 @@ struct bpf_map SEC("maps") __augmented_syscalls__ = { ...@@ -26,6 +25,17 @@ struct bpf_map SEC("maps") __augmented_syscalls__ = {
.max_entries = __NR_CPUS__, .max_entries = __NR_CPUS__,
}; };
struct syscall {
bool enabled;
};
struct bpf_map SEC("maps") syscalls = {
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(int),
.value_size = sizeof(struct syscall),
.max_entries = 512,
};
struct syscall_enter_args { struct syscall_enter_args {
unsigned long long common_tp_fields; unsigned long long common_tp_fields;
long syscall_nr; long syscall_nr;
...@@ -45,6 +55,7 @@ struct augmented_filename { ...@@ -45,6 +55,7 @@ struct augmented_filename {
}; };
#define SYS_OPEN 2 #define SYS_OPEN 2
#define SYS_ACCESS 21
#define SYS_OPENAT 257 #define SYS_OPENAT 257
pid_filter(pids_filtered); pid_filter(pids_filtered);
...@@ -56,6 +67,7 @@ int sys_enter(struct syscall_enter_args *args) ...@@ -56,6 +67,7 @@ int sys_enter(struct syscall_enter_args *args)
struct syscall_enter_args args; struct syscall_enter_args args;
struct augmented_filename filename; struct augmented_filename filename;
} augmented_args; } augmented_args;
struct syscall *syscall;
unsigned int len = sizeof(augmented_args); unsigned int len = sizeof(augmented_args);
const void *filename_arg = NULL; const void *filename_arg = NULL;
...@@ -63,6 +75,10 @@ int sys_enter(struct syscall_enter_args *args) ...@@ -63,6 +75,10 @@ int sys_enter(struct syscall_enter_args *args)
return 0; return 0;
probe_read(&augmented_args.args, sizeof(augmented_args.args), args); probe_read(&augmented_args.args, sizeof(augmented_args.args), args);
syscall = bpf_map_lookup_elem(&syscalls, &augmented_args.args.syscall_nr);
if (syscall == NULL || !syscall->enabled)
return 0;
/* /*
* Yonghong and Edward Cree sayz: * Yonghong and Edward Cree sayz:
* *
...@@ -104,6 +120,7 @@ int sys_enter(struct syscall_enter_args *args) ...@@ -104,6 +120,7 @@ int sys_enter(struct syscall_enter_args *args)
* after the ctx memory access to prevent their down stream merging. * after the ctx memory access to prevent their down stream merging.
*/ */
switch (augmented_args.args.syscall_nr) { switch (augmented_args.args.syscall_nr) {
case SYS_ACCESS:
case SYS_OPEN: filename_arg = (const void *)args->args[0]; case SYS_OPEN: filename_arg = (const void *)args->args[0];
__asm__ __volatile__("": : :"memory"); __asm__ __volatile__("": : :"memory");
break; break;
...@@ -131,7 +148,19 @@ int sys_enter(struct syscall_enter_args *args) ...@@ -131,7 +148,19 @@ int sys_enter(struct syscall_enter_args *args)
SEC("raw_syscalls:sys_exit") SEC("raw_syscalls:sys_exit")
int sys_exit(struct syscall_exit_args *args) int sys_exit(struct syscall_exit_args *args)
{ {
return !pid_filter__has(&pids_filtered, getpid()); struct syscall_exit_args exit_args;
struct syscall *syscall;
if (pid_filter__has(&pids_filtered, getpid()))
return 0;
probe_read(&exit_args, sizeof(exit_args), args);
syscall = bpf_map_lookup_elem(&syscalls, &exit_args.syscall_nr);
if (syscall == NULL || !syscall->enabled)
return 0;
return 1;
} }
license(GPL); license(GPL);
...@@ -55,4 +55,6 @@ int _version SEC("version") = LINUX_VERSION_CODE; ...@@ -55,4 +55,6 @@ int _version SEC("version") = LINUX_VERSION_CODE;
static int (*probe_read)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read; static int (*probe_read)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read;
static int (*probe_read_str)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read_str; static int (*probe_read_str)(void *dst, int size, const void *unsafe_addr) = (void *)BPF_FUNC_probe_read_str;
static int (*perf_event_output)(void *, struct bpf_map *, int, void *, unsigned long) = (void *)BPF_FUNC_perf_event_output;
#endif /* _PERF_BPF_H */ #endif /* _PERF_BPF_H */
...@@ -9,9 +9,6 @@ struct bpf_map SEC("maps") __bpf_stdout__ = { ...@@ -9,9 +9,6 @@ struct bpf_map SEC("maps") __bpf_stdout__ = {
.max_entries = __NR_CPUS__, .max_entries = __NR_CPUS__,
}; };
static int (*perf_event_output)(void *, struct bpf_map *, int, void *, unsigned long) =
(void *)BPF_FUNC_perf_event_output;
#define puts(from) \ #define puts(from) \
({ const int __len = sizeof(from); \ ({ const int __len = sizeof(from); \
char __from[__len] = from; \ char __from[__len] = from; \
......
...@@ -424,6 +424,9 @@ static const char *shell_test__description(char *description, size_t size, ...@@ -424,6 +424,9 @@ static const char *shell_test__description(char *description, size_t size,
if (!fp) if (!fp)
return NULL; return NULL;
/* Skip shebang */
while (fgetc(fp) != '\n');
description = fgets(description, size, fp); description = fgets(description, size, fp);
fclose(fp); fclose(fp);
......
#!/bin/sh
# Add vfs_getname probe to get syscall args filenames # Add vfs_getname probe to get syscall args filenames
# #
# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
......
#!/bin/sh
# probe libc's inet_pton & backtrace it with ping # probe libc's inet_pton & backtrace it with ping
# Installs a probe on libc's inet_pton function, that will use uprobes, # Installs a probe on libc's inet_pton function, that will use uprobes,
......
#!/bin/sh
# Use vfs_getname probe to get syscall args filenames # Use vfs_getname probe to get syscall args filenames
# Uses the 'perf test shell' library to add probe:vfs_getname to the system # Uses the 'perf test shell' library to add probe:vfs_getname to the system
......
#!/bin/sh
# Check open filename arg using perf trace + vfs_getname # Check open filename arg using perf trace + vfs_getname
# Uses the 'perf test shell' library to add probe:vfs_getname to the system # Uses the 'perf test shell' library to add probe:vfs_getname to the system
......
...@@ -7,7 +7,9 @@ endif ...@@ -7,7 +7,9 @@ endif
libperf-y += kcmp.o libperf-y += kcmp.o
libperf-y += mount_flags.o libperf-y += mount_flags.o
libperf-y += pkey_alloc.o libperf-y += pkey_alloc.o
libperf-y += arch_prctl.o
libperf-y += prctl.o libperf-y += prctl.o
libperf-y += renameat.o
libperf-y += sockaddr.o libperf-y += sockaddr.o
libperf-y += socket.o libperf-y += socket.o
libperf-y += statx.o libperf-y += statx.o
// SPDX-License-Identifier: LGPL-2.1
/*
* trace/beauty/arch_prctl.c
*
* Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
*/
#include "trace/beauty/beauty.h"
#include <linux/kernel.h>
#include "trace/beauty/generated/x86_arch_prctl_code_array.c"
static DEFINE_STRARRAY_OFFSET(x86_arch_prctl_codes_1, "ARCH_", x86_arch_prctl_codes_1_offset);
static DEFINE_STRARRAY_OFFSET(x86_arch_prctl_codes_2, "ARCH_", x86_arch_prctl_codes_2_offset);
static struct strarray *x86_arch_prctl_codes[] = {
&strarray__x86_arch_prctl_codes_1,
&strarray__x86_arch_prctl_codes_2,
};
static DEFINE_STRARRAYS(x86_arch_prctl_codes);
static size_t x86_arch_prctl__scnprintf_code(int option, char *bf, size_t size, bool show_prefix)
{
return strarrays__scnprintf(&strarrays__x86_arch_prctl_codes, bf, size, "%#x", show_prefix, option);
}
size_t syscall_arg__scnprintf_x86_arch_prctl_code(char *bf, size_t size, struct syscall_arg *arg)
{
unsigned long code = arg->val;
return x86_arch_prctl__scnprintf_code(code, bf, size, arg->show_string_prefix);
}
...@@ -9,26 +9,41 @@ ...@@ -9,26 +9,41 @@
struct strarray { struct strarray {
int offset; int offset;
int nr_entries; int nr_entries;
const char *prefix;
const char **entries; const char **entries;
}; };
#define DEFINE_STRARRAY(array) struct strarray strarray__##array = { \ #define DEFINE_STRARRAY(array, _prefix) struct strarray strarray__##array = { \
.nr_entries = ARRAY_SIZE(array), \ .nr_entries = ARRAY_SIZE(array), \
.entries = array, \ .entries = array, \
.prefix = _prefix, \
} }
#define DEFINE_STRARRAY_OFFSET(array, off) struct strarray strarray__##array = { \ #define DEFINE_STRARRAY_OFFSET(array, _prefix, off) struct strarray strarray__##array = { \
.offset = off, \ .offset = off, \
.nr_entries = ARRAY_SIZE(array), \ .nr_entries = ARRAY_SIZE(array), \
.entries = array, \ .entries = array, \
.prefix = _prefix, \
} }
size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const char *intfmt, int val); size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const char *intfmt, bool show_prefix, int val);
size_t strarray__scnprintf_flags(struct strarray *sa, char *bf, size_t size, unsigned long flags); size_t strarray__scnprintf_flags(struct strarray *sa, char *bf, size_t size, bool show_prefix, unsigned long flags);
struct trace; struct trace;
struct thread; struct thread;
struct strarrays {
int nr_entries;
struct strarray **entries;
};
#define DEFINE_STRARRAYS(array) struct strarrays strarrays__##array = { \
.nr_entries = ARRAY_SIZE(array), \
.entries = array, \
}
size_t strarrays__scnprintf(struct strarrays *sas, char *bf, size_t size, const char *intfmt, bool show_prefix, int val);
size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_t size); size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_t size);
extern struct strarray strarray__socket_families; extern struct strarray strarray__socket_families;
...@@ -66,6 +81,7 @@ struct augmented_arg { ...@@ -66,6 +81,7 @@ struct augmented_arg {
* @parm: private area, may be an strarray, for instance * @parm: private area, may be an strarray, for instance
* @idx: syscall arg idx (is this the first?) * @idx: syscall arg idx (is this the first?)
* @mask: a syscall arg may mask another arg, see syscall_arg__scnprintf_futex_op * @mask: a syscall arg may mask another arg, see syscall_arg__scnprintf_futex_op
* @show_string_prefix: When there is a common prefix in a string table, show it or not
*/ */
struct syscall_arg { struct syscall_arg {
...@@ -80,6 +96,7 @@ struct syscall_arg { ...@@ -80,6 +96,7 @@ struct syscall_arg {
void *parm; void *parm;
u8 idx; u8 idx;
u8 mask; u8 mask;
bool show_string_prefix;
}; };
unsigned long syscall_arg__val(struct syscall_arg *arg, u8 idx); unsigned long syscall_arg__val(struct syscall_arg *arg, u8 idx);
...@@ -93,6 +110,9 @@ size_t syscall_arg__scnprintf_fd(char *bf, size_t size, struct syscall_arg *arg) ...@@ -93,6 +110,9 @@ size_t syscall_arg__scnprintf_fd(char *bf, size_t size, struct syscall_arg *arg)
size_t syscall_arg__scnprintf_hex(char *bf, size_t size, struct syscall_arg *arg); size_t syscall_arg__scnprintf_hex(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_HEX syscall_arg__scnprintf_hex #define SCA_HEX syscall_arg__scnprintf_hex
size_t syscall_arg__scnprintf_ptr(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_PTR syscall_arg__scnprintf_ptr
size_t syscall_arg__scnprintf_int(char *bf, size_t size, struct syscall_arg *arg); size_t syscall_arg__scnprintf_int(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_INT syscall_arg__scnprintf_int #define SCA_INT syscall_arg__scnprintf_int
...@@ -135,6 +155,9 @@ size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf, size_t size, st ...@@ -135,6 +155,9 @@ size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf, size_t size, st
size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, struct syscall_arg *arg); size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags #define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags
size_t syscall_arg__scnprintf_x86_arch_prctl_code(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_X86_ARCH_PRCTL_CODE syscall_arg__scnprintf_x86_arch_prctl_code
size_t syscall_arg__scnprintf_prctl_option(char *bf, size_t size, struct syscall_arg *arg); size_t syscall_arg__scnprintf_prctl_option(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_PRCTL_OPTION syscall_arg__scnprintf_prctl_option #define SCA_PRCTL_OPTION syscall_arg__scnprintf_prctl_option
...@@ -144,6 +167,9 @@ size_t syscall_arg__scnprintf_prctl_arg2(char *bf, size_t size, struct syscall_a ...@@ -144,6 +167,9 @@ size_t syscall_arg__scnprintf_prctl_arg2(char *bf, size_t size, struct syscall_a
size_t syscall_arg__scnprintf_prctl_arg3(char *bf, size_t size, struct syscall_arg *arg); size_t syscall_arg__scnprintf_prctl_arg3(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_PRCTL_ARG3 syscall_arg__scnprintf_prctl_arg3 #define SCA_PRCTL_ARG3 syscall_arg__scnprintf_prctl_arg3
size_t syscall_arg__scnprintf_renameat2_flags(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_RENAMEAT2_FLAGS syscall_arg__scnprintf_renameat2_flags
size_t syscall_arg__scnprintf_sockaddr(char *bf, size_t size, struct syscall_arg *arg); size_t syscall_arg__scnprintf_sockaddr(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_SOCKADDR syscall_arg__scnprintf_sockaddr #define SCA_SOCKADDR syscall_arg__scnprintf_sockaddr
...@@ -156,7 +182,7 @@ size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_ ...@@ -156,7 +182,7 @@ size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_
size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg); size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_STATX_MASK syscall_arg__scnprintf_statx_mask #define SCA_STATX_MASK syscall_arg__scnprintf_statx_mask
size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size); size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix);
void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg, void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg,
size_t (*ret_scnprintf)(char *bf, size_t size, struct syscall_arg *arg)); size_t (*ret_scnprintf)(char *bf, size_t size, struct syscall_arg *arg));
......
...@@ -10,13 +10,14 @@ ...@@ -10,13 +10,14 @@
#include <sys/types.h> #include <sys/types.h>
#include <uapi/linux/sched.h> #include <uapi/linux/sched.h>
static size_t clone__scnprintf_flags(unsigned long flags, char *bf, size_t size) static size_t clone__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
{ {
const char *prefix = "CLONE_";
int printed = 0; int printed = 0;
#define P_FLAG(n) \ #define P_FLAG(n) \
if (flags & CLONE_##n) { \ if (flags & CLONE_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
flags &= ~CLONE_##n; \ flags &= ~CLONE_##n; \
} }
...@@ -70,5 +71,5 @@ size_t syscall_arg__scnprintf_clone_flags(char *bf, size_t size, struct syscall_ ...@@ -70,5 +71,5 @@ size_t syscall_arg__scnprintf_clone_flags(char *bf, size_t size, struct syscall_
if (!(flags & CLONE_SETTLS)) if (!(flags & CLONE_SETTLS))
arg->mask |= SCC_TLS; arg->mask |= SCC_TLS;
return clone__scnprintf_flags(flags, bf, size); return clone__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
} }
...@@ -13,13 +13,15 @@ ...@@ -13,13 +13,15 @@
static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg) static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "EFD_";
int printed = 0, flags = arg->val; int printed = 0, flags = arg->val;
if (flags == 0) if (flags == 0)
return scnprintf(bf, size, "NONE"); return scnprintf(bf, size, "NONE");
#define P_FLAG(n) \ #define P_FLAG(n) \
if (flags & EFD_##n) { \ if (flags & EFD_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
flags &= ~EFD_##n; \ flags &= ~EFD_##n; \
} }
......
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1
[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
printf "static const char *fadvise_advices[] = {\n"
regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+POSIX_FADV_(\w+)[[:space:]]+([[:digit:]]+)[[:space:]]+.*'
egrep $regex ${header_dir}/fadvise.h | \
sed -r "s/$regex/\2 \1/g" | \
sort | xargs printf "\t[%s] = \"%s\",\n" | \
grep -v "[6].*DONTNEED" | grep -v "[7].*NOREUSE"
printf "};\n"
# XXX Fix this properly:
# The grep 6/7 DONTNEED/NOREUSE are a hack to filter out the s/390 oddity See
# tools/include/uapi/linux/fadvise.h for details.
# Probably fix this when generating the string tables per arch so that We can
# reliably process on arch FOO a perf.data file collected by 'perf trace
# record' on arch BAR, e.g. collect on s/390 and process on x86.
...@@ -9,27 +9,28 @@ ...@@ -9,27 +9,28 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <uapi/linux/fcntl.h> #include <uapi/linux/fcntl.h>
static size_t fcntl__scnprintf_getfd(unsigned long val, char *bf, size_t size) static size_t fcntl__scnprintf_getfd(unsigned long val, char *bf, size_t size, bool show_prefix)
{ {
return scnprintf(bf, size, "%s", val ? "CLOEXEC" : "0"); return val ? scnprintf(bf, size, "%s", "0") :
scnprintf(bf, size, "%s%s", show_prefix ? "FD_" : "", "CLOEXEC");
} }
static size_t syscall_arg__scnprintf_fcntl_getfd(char *bf, size_t size, struct syscall_arg *arg) static size_t syscall_arg__scnprintf_fcntl_getfd(char *bf, size_t size, struct syscall_arg *arg)
{ {
return fcntl__scnprintf_getfd(arg->val, bf, size); return fcntl__scnprintf_getfd(arg->val, bf, size, arg->show_string_prefix);
} }
static size_t fcntl__scnprintf_getlease(unsigned long val, char *bf, size_t size) static size_t fcntl__scnprintf_getlease(unsigned long val, char *bf, size_t size, bool show_prefix)
{ {
static const char *fcntl_setlease[] = { "RDLCK", "WRLCK", "UNLCK", }; static const char *fcntl_setlease[] = { "RDLCK", "WRLCK", "UNLCK", };
static DEFINE_STRARRAY(fcntl_setlease); static DEFINE_STRARRAY(fcntl_setlease, "F_");
return strarray__scnprintf(&strarray__fcntl_setlease, bf, size, "%x", val); return strarray__scnprintf(&strarray__fcntl_setlease, bf, size, "%x", show_prefix, val);
} }
static size_t syscall_arg__scnprintf_fcntl_getlease(char *bf, size_t size, struct syscall_arg *arg) static size_t syscall_arg__scnprintf_fcntl_getlease(char *bf, size_t size, struct syscall_arg *arg)
{ {
return fcntl__scnprintf_getlease(arg->val, bf, size); return fcntl__scnprintf_getlease(arg->val, bf, size, arg->show_string_prefix);
} }
size_t syscall_arg__scnprintf_fcntl_cmd(char *bf, size_t size, struct syscall_arg *arg) size_t syscall_arg__scnprintf_fcntl_cmd(char *bf, size_t size, struct syscall_arg *arg)
...@@ -68,22 +69,23 @@ size_t syscall_arg__scnprintf_fcntl_cmd(char *bf, size_t size, struct syscall_ar ...@@ -68,22 +69,23 @@ size_t syscall_arg__scnprintf_fcntl_cmd(char *bf, size_t size, struct syscall_ar
size_t syscall_arg__scnprintf_fcntl_arg(char *bf, size_t size, struct syscall_arg *arg) size_t syscall_arg__scnprintf_fcntl_arg(char *bf, size_t size, struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
int cmd = syscall_arg__val(arg, 1); int cmd = syscall_arg__val(arg, 1);
if (cmd == F_DUPFD) if (cmd == F_DUPFD)
return syscall_arg__scnprintf_fd(bf, size, arg); return syscall_arg__scnprintf_fd(bf, size, arg);
if (cmd == F_SETFD) if (cmd == F_SETFD)
return fcntl__scnprintf_getfd(arg->val, bf, size); return fcntl__scnprintf_getfd(arg->val, bf, size, show_prefix);
if (cmd == F_SETFL) if (cmd == F_SETFL)
return open__scnprintf_flags(arg->val, bf, size); return open__scnprintf_flags(arg->val, bf, size, show_prefix);
if (cmd == F_SETOWN) if (cmd == F_SETOWN)
return syscall_arg__scnprintf_pid(bf, size, arg); return syscall_arg__scnprintf_pid(bf, size, arg);
if (cmd == F_SETLEASE) if (cmd == F_SETLEASE)
return fcntl__scnprintf_getlease(arg->val, bf, size); return fcntl__scnprintf_getlease(arg->val, bf, size, show_prefix);
/* /*
* We still don't grab the contents of pointers on entry or exit, * We still don't grab the contents of pointers on entry or exit,
* so just print them as hex numbers * so just print them as hex numbers
......
...@@ -22,13 +22,15 @@ ...@@ -22,13 +22,15 @@
size_t syscall_arg__scnprintf_flock(char *bf, size_t size, struct syscall_arg *arg) size_t syscall_arg__scnprintf_flock(char *bf, size_t size, struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "LOCK_";
int printed = 0, op = arg->val; int printed = 0, op = arg->val;
if (op == 0) if (op == 0)
return scnprintf(bf, size, "NONE"); return scnprintf(bf, size, "NONE");
#define P_CMD(cmd) \ #define P_CMD(cmd) \
if ((op & LOCK_##cmd) == LOCK_##cmd) { \ if ((op & LOCK_##cmd) == LOCK_##cmd) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #cmd); \
op &= ~LOCK_##cmd; \ op &= ~LOCK_##cmd; \
} }
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg) static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "FUTEX_";
enum syscall_futex_args { enum syscall_futex_args {
SCF_UADDR = (1 << 0), SCF_UADDR = (1 << 0),
SCF_OP = (1 << 1), SCF_OP = (1 << 1),
...@@ -32,7 +34,7 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct sysc ...@@ -32,7 +34,7 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct sysc
size_t printed = 0; size_t printed = 0;
switch (cmd) { switch (cmd) {
#define P_FUTEX_OP(n) case FUTEX_##n: printed = scnprintf(bf, size, #n); #define P_FUTEX_OP(n) case FUTEX_##n: printed = scnprintf(bf, size, "%s%s", show_prefix ? prefix : "", #n);
P_FUTEX_OP(WAIT); arg->mask |= SCF_VAL3|SCF_UADDR2; break; P_FUTEX_OP(WAIT); arg->mask |= SCF_VAL3|SCF_UADDR2; break;
P_FUTEX_OP(WAKE); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break; P_FUTEX_OP(WAKE); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
P_FUTEX_OP(FD); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break; P_FUTEX_OP(FD); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
...@@ -50,10 +52,10 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct sysc ...@@ -50,10 +52,10 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct sysc
} }
if (op & FUTEX_PRIVATE_FLAG) if (op & FUTEX_PRIVATE_FLAG)
printed += scnprintf(bf + printed, size - printed, "|PRIV"); printed += scnprintf(bf + printed, size - printed, "|%s%s", show_prefix ? prefix : "", "PRIVATE_FLAG");
if (op & FUTEX_CLOCK_REALTIME) if (op & FUTEX_CLOCK_REALTIME)
printed += scnprintf(bf + printed, size - printed, "|CLKRT"); printed += scnprintf(bf + printed, size - printed, "|%s%s", show_prefix ? prefix : "", "CLOCK_REALTIME");
return printed; return printed;
} }
......
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
static size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct syscall_arg *arg) static size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct syscall_arg *arg)
{ {
const char *prefix = "FUTEX_BITSET_";
unsigned int bitset = arg->val; unsigned int bitset = arg->val;
if (bitset == FUTEX_BITSET_MATCH_ANY) if (bitset == FUTEX_BITSET_MATCH_ANY)
return scnprintf(bf, size, "MATCH_ANY"); return scnprintf(bf, size, "%s%s", arg->show_string_prefix ? prefix : "", "MATCH_ANY");
return scnprintf(bf, size, "%#xd", bitset); return scnprintf(bf, size, "%#xd", bitset);
} }
......
...@@ -36,7 +36,7 @@ static size_t ioctl__scnprintf_tty_cmd(int nr, int dir, char *bf, size_t size) ...@@ -36,7 +36,7 @@ static size_t ioctl__scnprintf_tty_cmd(int nr, int dir, char *bf, size_t size)
"TIOCSERGWILD", "TIOCSERSWILD", "TIOCGLCKTRMIOS", "TIOCSLCKTRMIOS", "TIOCSERGWILD", "TIOCSERSWILD", "TIOCGLCKTRMIOS", "TIOCSLCKTRMIOS",
"TIOCSERGSTRUCT", "TIOCSERGETLSR", "TIOCSERGETMULTI", "TIOCSERSETMULTI", "TIOCSERGSTRUCT", "TIOCSERGETLSR", "TIOCSERGETMULTI", "TIOCSERSETMULTI",
"TIOCMIWAIT", "TIOCGICOUNT", }; "TIOCMIWAIT", "TIOCGICOUNT", };
static DEFINE_STRARRAY(ioctl_tty_cmd); static DEFINE_STRARRAY(ioctl_tty_cmd, "");
if (nr < strarray__ioctl_tty_cmd.nr_entries && strarray__ioctl_tty_cmd.entries[nr] != NULL) if (nr < strarray__ioctl_tty_cmd.nr_entries && strarray__ioctl_tty_cmd.entries[nr] != NULL)
return scnprintf(bf, size, "%s", strarray__ioctl_tty_cmd.entries[nr]); return scnprintf(bf, size, "%s", strarray__ioctl_tty_cmd.entries[nr]);
...@@ -47,7 +47,7 @@ static size_t ioctl__scnprintf_tty_cmd(int nr, int dir, char *bf, size_t size) ...@@ -47,7 +47,7 @@ static size_t ioctl__scnprintf_tty_cmd(int nr, int dir, char *bf, size_t size)
static size_t ioctl__scnprintf_drm_cmd(int nr, int dir, char *bf, size_t size) static size_t ioctl__scnprintf_drm_cmd(int nr, int dir, char *bf, size_t size)
{ {
#include "trace/beauty/generated/ioctl/drm_ioctl_array.c" #include "trace/beauty/generated/ioctl/drm_ioctl_array.c"
static DEFINE_STRARRAY(drm_ioctl_cmds); static DEFINE_STRARRAY(drm_ioctl_cmds, "");
if (nr < strarray__drm_ioctl_cmds.nr_entries && strarray__drm_ioctl_cmds.entries[nr] != NULL) if (nr < strarray__drm_ioctl_cmds.nr_entries && strarray__drm_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "DRM_%s", strarray__drm_ioctl_cmds.entries[nr]); return scnprintf(bf, size, "DRM_%s", strarray__drm_ioctl_cmds.entries[nr]);
...@@ -58,7 +58,7 @@ static size_t ioctl__scnprintf_drm_cmd(int nr, int dir, char *bf, size_t size) ...@@ -58,7 +58,7 @@ static size_t ioctl__scnprintf_drm_cmd(int nr, int dir, char *bf, size_t size)
static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, int dir, char *bf, size_t size) static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, int dir, char *bf, size_t size)
{ {
#include "trace/beauty/generated/ioctl/sndrv_pcm_ioctl_array.c" #include "trace/beauty/generated/ioctl/sndrv_pcm_ioctl_array.c"
static DEFINE_STRARRAY(sndrv_pcm_ioctl_cmds); static DEFINE_STRARRAY(sndrv_pcm_ioctl_cmds, "");
if (nr < strarray__sndrv_pcm_ioctl_cmds.nr_entries && strarray__sndrv_pcm_ioctl_cmds.entries[nr] != NULL) if (nr < strarray__sndrv_pcm_ioctl_cmds.nr_entries && strarray__sndrv_pcm_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "SNDRV_PCM_%s", strarray__sndrv_pcm_ioctl_cmds.entries[nr]); return scnprintf(bf, size, "SNDRV_PCM_%s", strarray__sndrv_pcm_ioctl_cmds.entries[nr]);
...@@ -69,7 +69,7 @@ static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, int dir, char *bf, size_t s ...@@ -69,7 +69,7 @@ static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, int dir, char *bf, size_t s
static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, int dir, char *bf, size_t size) static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, int dir, char *bf, size_t size)
{ {
#include "trace/beauty/generated/ioctl/sndrv_ctl_ioctl_array.c" #include "trace/beauty/generated/ioctl/sndrv_ctl_ioctl_array.c"
static DEFINE_STRARRAY(sndrv_ctl_ioctl_cmds); static DEFINE_STRARRAY(sndrv_ctl_ioctl_cmds, "");
if (nr < strarray__sndrv_ctl_ioctl_cmds.nr_entries && strarray__sndrv_ctl_ioctl_cmds.entries[nr] != NULL) if (nr < strarray__sndrv_ctl_ioctl_cmds.nr_entries && strarray__sndrv_ctl_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "SNDRV_CTL_%s", strarray__sndrv_ctl_ioctl_cmds.entries[nr]); return scnprintf(bf, size, "SNDRV_CTL_%s", strarray__sndrv_ctl_ioctl_cmds.entries[nr]);
...@@ -80,7 +80,7 @@ static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, int dir, char *bf, size_t s ...@@ -80,7 +80,7 @@ static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, int dir, char *bf, size_t s
static size_t ioctl__scnprintf_kvm_cmd(int nr, int dir, char *bf, size_t size) static size_t ioctl__scnprintf_kvm_cmd(int nr, int dir, char *bf, size_t size)
{ {
#include "trace/beauty/generated/ioctl/kvm_ioctl_array.c" #include "trace/beauty/generated/ioctl/kvm_ioctl_array.c"
static DEFINE_STRARRAY(kvm_ioctl_cmds); static DEFINE_STRARRAY(kvm_ioctl_cmds, "");
if (nr < strarray__kvm_ioctl_cmds.nr_entries && strarray__kvm_ioctl_cmds.entries[nr] != NULL) if (nr < strarray__kvm_ioctl_cmds.nr_entries && strarray__kvm_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "KVM_%s", strarray__kvm_ioctl_cmds.entries[nr]); return scnprintf(bf, size, "KVM_%s", strarray__kvm_ioctl_cmds.entries[nr]);
...@@ -91,8 +91,8 @@ static size_t ioctl__scnprintf_kvm_cmd(int nr, int dir, char *bf, size_t size) ...@@ -91,8 +91,8 @@ static size_t ioctl__scnprintf_kvm_cmd(int nr, int dir, char *bf, size_t size)
static size_t ioctl__scnprintf_vhost_virtio_cmd(int nr, int dir, char *bf, size_t size) static size_t ioctl__scnprintf_vhost_virtio_cmd(int nr, int dir, char *bf, size_t size)
{ {
#include "trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c" #include "trace/beauty/generated/ioctl/vhost_virtio_ioctl_array.c"
static DEFINE_STRARRAY(vhost_virtio_ioctl_cmds); static DEFINE_STRARRAY(vhost_virtio_ioctl_cmds, "");
static DEFINE_STRARRAY(vhost_virtio_ioctl_read_cmds); static DEFINE_STRARRAY(vhost_virtio_ioctl_read_cmds, "");
struct strarray *s = (dir & _IOC_READ) ? &strarray__vhost_virtio_ioctl_read_cmds : &strarray__vhost_virtio_ioctl_cmds; struct strarray *s = (dir & _IOC_READ) ? &strarray__vhost_virtio_ioctl_read_cmds : &strarray__vhost_virtio_ioctl_cmds;
if (nr < s->nr_entries && s->entries[nr] != NULL) if (nr < s->nr_entries && s->entries[nr] != NULL)
...@@ -104,7 +104,7 @@ static size_t ioctl__scnprintf_vhost_virtio_cmd(int nr, int dir, char *bf, size_ ...@@ -104,7 +104,7 @@ static size_t ioctl__scnprintf_vhost_virtio_cmd(int nr, int dir, char *bf, size_
static size_t ioctl__scnprintf_perf_cmd(int nr, int dir, char *bf, size_t size) static size_t ioctl__scnprintf_perf_cmd(int nr, int dir, char *bf, size_t size)
{ {
#include "trace/beauty/generated/ioctl/perf_ioctl_array.c" #include "trace/beauty/generated/ioctl/perf_ioctl_array.c"
static DEFINE_STRARRAY(perf_ioctl_cmds); static DEFINE_STRARRAY(perf_ioctl_cmds, "");
if (nr < strarray__perf_ioctl_cmds.nr_entries && strarray__perf_ioctl_cmds.entries[nr] != NULL) if (nr < strarray__perf_ioctl_cmds.nr_entries && strarray__perf_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "PERF_%s", strarray__perf_ioctl_cmds.entries[nr]); return scnprintf(bf, size, "PERF_%s", strarray__perf_ioctl_cmds.entries[nr]);
...@@ -112,8 +112,9 @@ static size_t ioctl__scnprintf_perf_cmd(int nr, int dir, char *bf, size_t size) ...@@ -112,8 +112,9 @@ static size_t ioctl__scnprintf_perf_cmd(int nr, int dir, char *bf, size_t size)
return scnprintf(bf, size, "(%#x, %#x, %#x)", 0xAE, nr, dir); return scnprintf(bf, size, "(%#x, %#x, %#x)", 0xAE, nr, dir);
} }
static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size) static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size, bool show_prefix)
{ {
const char *prefix = "_IOC_";
int dir = _IOC_DIR(cmd), int dir = _IOC_DIR(cmd),
type = _IOC_TYPE(cmd), type = _IOC_TYPE(cmd),
nr = _IOC_NR(cmd), nr = _IOC_NR(cmd),
...@@ -143,12 +144,14 @@ static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size) ...@@ -143,12 +144,14 @@ static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size)
printed += scnprintf(bf + printed, size - printed, "%c", '('); printed += scnprintf(bf + printed, size - printed, "%c", '(');
if (dir == _IOC_NONE) { if (dir == _IOC_NONE) {
printed += scnprintf(bf + printed, size - printed, "%s", "NONE"); printed += scnprintf(bf + printed, size - printed, "%s%s", show_prefix ? prefix : "", "NONE");
} else { } else {
if (dir & _IOC_READ) if (dir & _IOC_READ)
printed += scnprintf(bf + printed, size - printed, "%s", "READ"); printed += scnprintf(bf + printed, size - printed, "%s%s", show_prefix ? prefix : "", "READ");
if (dir & _IOC_WRITE) if (dir & _IOC_WRITE) {
printed += scnprintf(bf + printed, size - printed, "%s%s", dir & _IOC_READ ? "|" : "", "WRITE"); printed += scnprintf(bf + printed, size - printed, "%s%s%s", dir & _IOC_READ ? "|" : "",
show_prefix ? prefix : "", "WRITE");
}
} }
return printed + scnprintf(bf + printed, size - printed, ", %#x, %#x, %#x)", type, nr, sz); return printed + scnprintf(bf + printed, size - printed, ", %#x, %#x, %#x)", type, nr, sz);
...@@ -158,5 +161,5 @@ size_t syscall_arg__scnprintf_ioctl_cmd(char *bf, size_t size, struct syscall_ar ...@@ -158,5 +161,5 @@ size_t syscall_arg__scnprintf_ioctl_cmd(char *bf, size_t size, struct syscall_ar
{ {
unsigned long cmd = arg->val; unsigned long cmd = arg->val;
return ioctl__scnprintf_cmd(cmd, bf, size); return ioctl__scnprintf_cmd(cmd, bf, size, arg->show_string_prefix);
} }
...@@ -26,10 +26,10 @@ size_t syscall_arg__scnprintf_kcmp_idx(char *bf, size_t size, struct syscall_arg ...@@ -26,10 +26,10 @@ size_t syscall_arg__scnprintf_kcmp_idx(char *bf, size_t size, struct syscall_arg
return pid__scnprintf_fd(arg->trace, pid, fd, bf, size); return pid__scnprintf_fd(arg->trace, pid, fd, bf, size);
} }
static size_t kcmp__scnprintf_type(int type, char *bf, size_t size) static size_t kcmp__scnprintf_type(int type, char *bf, size_t size, bool show_prefix)
{ {
static DEFINE_STRARRAY(kcmp_types); static DEFINE_STRARRAY(kcmp_types, "KCMP_");
return strarray__scnprintf(&strarray__kcmp_types, bf, size, "%d", type); return strarray__scnprintf(&strarray__kcmp_types, bf, size, "%d", show_prefix, type);
} }
size_t syscall_arg__scnprintf_kcmp_type(char *bf, size_t size, struct syscall_arg *arg) size_t syscall_arg__scnprintf_kcmp_type(char *bf, size_t size, struct syscall_arg *arg)
...@@ -39,5 +39,5 @@ size_t syscall_arg__scnprintf_kcmp_type(char *bf, size_t size, struct syscall_ar ...@@ -39,5 +39,5 @@ size_t syscall_arg__scnprintf_kcmp_type(char *bf, size_t size, struct syscall_ar
if (type != KCMP_FILE) if (type != KCMP_FILE)
arg->mask |= (1 << 3) | (1 << 4); /* Ignore idx1 and idx2 */ arg->mask |= (1 << 3) | (1 << 4); /* Ignore idx1 and idx2 */
return kcmp__scnprintf_type(type, bf, size); return kcmp__scnprintf_type(type, bf, size, arg->show_string_prefix);
} }
...@@ -5,18 +5,20 @@ ...@@ -5,18 +5,20 @@
static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size,
struct syscall_arg *arg) struct syscall_arg *arg)
{ {
const char *prot_prefix = "PROT_";
int printed = 0, prot = arg->val; int printed = 0, prot = arg->val;
bool show_prefix = arg->show_string_prefix;
if (prot == PROT_NONE) if (prot == PROT_NONE)
return scnprintf(bf, size, "NONE"); return scnprintf(bf, size, "%sNONE", show_prefix ? prot_prefix : "");
#define P_MMAP_PROT(n) \ #define P_MMAP_PROT(n) \
if (prot & PROT_##n) { \ if (prot & PROT_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prot_prefix :"", #n); \
prot &= ~PROT_##n; \ prot &= ~PROT_##n; \
} }
P_MMAP_PROT(EXEC);
P_MMAP_PROT(READ); P_MMAP_PROT(READ);
P_MMAP_PROT(EXEC);
P_MMAP_PROT(WRITE); P_MMAP_PROT(WRITE);
P_MMAP_PROT(SEM); P_MMAP_PROT(SEM);
P_MMAP_PROT(GROWSDOWN); P_MMAP_PROT(GROWSDOWN);
...@@ -31,12 +33,12 @@ static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, ...@@ -31,12 +33,12 @@ static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size,
#define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot #define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot
static size_t mmap__scnprintf_flags(unsigned long flags, char *bf, size_t size) static size_t mmap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
{ {
#include "trace/beauty/generated/mmap_flags_array.c" #include "trace/beauty/generated/mmap_flags_array.c"
static DEFINE_STRARRAY(mmap_flags); static DEFINE_STRARRAY(mmap_flags, "MAP_");
return strarray__scnprintf_flags(&strarray__mmap_flags, bf, size, flags); return strarray__scnprintf_flags(&strarray__mmap_flags, bf, size, show_prefix, flags);
} }
static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,
...@@ -47,7 +49,7 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, ...@@ -47,7 +49,7 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,
if (flags & MAP_ANONYMOUS) if (flags & MAP_ANONYMOUS)
arg->mask |= (1 << 4) | (1 << 5); /* Mask 4th ('fd') and 5th ('offset') args, ignored */ arg->mask |= (1 << 4) | (1 << 5); /* Mask 4th ('fd') and 5th ('offset') args, ignored */
return mmap__scnprintf_flags(flags, bf, size); return mmap__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
} }
#define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags #define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags
...@@ -55,11 +57,13 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, ...@@ -55,11 +57,13 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,
static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size,
struct syscall_arg *arg) struct syscall_arg *arg)
{ {
const char *flags_prefix = "MREMAP_";
bool show_prefix = arg->show_string_prefix;
int printed = 0, flags = arg->val; int printed = 0, flags = arg->val;
#define P_MREMAP_FLAG(n) \ #define P_MREMAP_FLAG(n) \
if (flags & MREMAP_##n) { \ if (flags & MREMAP_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? flags_prefix : "", #n); \
flags &= ~MREMAP_##n; \ flags &= ~MREMAP_##n; \
} }
...@@ -78,7 +82,7 @@ static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, ...@@ -78,7 +82,7 @@ static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size,
static size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size) static size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size)
{ {
#include "trace/beauty/generated/madvise_behavior_array.c" #include "trace/beauty/generated/madvise_behavior_array.c"
static DEFINE_STRARRAY(madvise_advices); static DEFINE_STRARRAY(madvise_advices, "MADV_");
if (behavior < strarray__madvise_advices.nr_entries && strarray__madvise_advices.entries[behavior] != NULL) if (behavior < strarray__madvise_advices.nr_entries && strarray__madvise_advices.entries[behavior] != NULL)
return scnprintf(bf, size, "MADV_%s", strarray__madvise_advices.entries[behavior]); return scnprintf(bf, size, "MADV_%s", strarray__madvise_advices.entries[behavior]);
......
...@@ -22,11 +22,13 @@ ...@@ -22,11 +22,13 @@
static size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscall_arg *arg) static size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "S_";
int printed = 0, mode = arg->val; int printed = 0, mode = arg->val;
#define P_MODE(n) \ #define P_MODE(n) \
if ((mode & S_##n) == S_##n) { \ if ((mode & S_##n) == S_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
mode &= ~S_##n; \ mode &= ~S_##n; \
} }
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
#include <linux/log2.h> #include <linux/log2.h>
#include <sys/mount.h> #include <sys/mount.h>
static size_t mount__scnprintf_flags(unsigned long flags, char *bf, size_t size) static size_t mount__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
{ {
#include "trace/beauty/generated/mount_flags_array.c" #include "trace/beauty/generated/mount_flags_array.c"
static DEFINE_STRARRAY(mount_flags); static DEFINE_STRARRAY(mount_flags, "MS_");
return strarray__scnprintf_flags(&strarray__mount_flags, bf, size, flags); return strarray__scnprintf_flags(&strarray__mount_flags, bf, size, show_prefix, flags);
} }
unsigned long syscall_arg__mask_val_mount_flags(struct syscall_arg *arg __maybe_unused, unsigned long flags) unsigned long syscall_arg__mask_val_mount_flags(struct syscall_arg *arg __maybe_unused, unsigned long flags)
...@@ -39,5 +39,5 @@ size_t syscall_arg__scnprintf_mount_flags(char *bf, size_t size, struct syscall_ ...@@ -39,5 +39,5 @@ size_t syscall_arg__scnprintf_mount_flags(char *bf, size_t size, struct syscall_
{ {
unsigned long flags = arg->val; unsigned long flags = arg->val;
return mount__scnprintf_flags(flags, bf, size); return mount__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
} }
...@@ -21,13 +21,15 @@ ...@@ -21,13 +21,15 @@
static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size,
struct syscall_arg *arg) struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "MSG_";
int printed = 0, flags = arg->val; int printed = 0, flags = arg->val;
if (flags == 0) if (flags == 0)
return scnprintf(bf, size, "NONE"); return scnprintf(bf, size, "NONE");
#define P_MSG_FLAG(n) \ #define P_MSG_FLAG(n) \
if (flags & MSG_##n) { \ if (flags & MSG_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
flags &= ~MSG_##n; \ flags &= ~MSG_##n; \
} }
......
...@@ -22,15 +22,18 @@ ...@@ -22,15 +22,18 @@
#undef O_LARGEFILE #undef O_LARGEFILE
#define O_LARGEFILE 00100000 #define O_LARGEFILE 00100000
size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size) size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
{ {
const char *prefix = "O_";
int printed = 0; int printed = 0;
if ((flags & O_ACCMODE) == O_RDONLY)
printed = scnprintf(bf, size, "%s%s", show_prefix ? prefix : "", "RDONLY");
if (flags == 0) if (flags == 0)
return scnprintf(bf, size, "RDONLY"); return printed;
#define P_FLAG(n) \ #define P_FLAG(n) \
if (flags & O_##n) { \ if (flags & O_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
flags &= ~O_##n; \ flags &= ~O_##n; \
} }
...@@ -57,7 +60,7 @@ size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size) ...@@ -57,7 +60,7 @@ size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size)
#endif #endif
#ifdef O_DSYNC #ifdef O_DSYNC
if ((flags & O_SYNC) == O_SYNC) if ((flags & O_SYNC) == O_SYNC)
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", "SYNC"); printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", "SYNC");
else { else {
P_FLAG(DSYNC); P_FLAG(DSYNC);
} }
...@@ -81,5 +84,5 @@ size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, struct syscall_a ...@@ -81,5 +84,5 @@ size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, struct syscall_a
if (!(flags & O_CREAT)) if (!(flags & O_CREAT))
arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */ arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */
return open__scnprintf_flags(flags, bf, size); return open__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
} }
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size,
struct syscall_arg *arg) struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "PERF_";
int printed = 0, flags = arg->val; int printed = 0, flags = arg->val;
if (flags == 0) if (flags == 0)
...@@ -25,7 +27,7 @@ static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, ...@@ -25,7 +27,7 @@ static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size,
#define P_FLAG(n) \ #define P_FLAG(n) \
if (flags & PERF_FLAG_##n) { \ if (flags & PERF_FLAG_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
flags &= ~PERF_FLAG_##n; \ flags &= ~PERF_FLAG_##n; \
} }
......
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/log2.h> #include <linux/log2.h>
size_t strarray__scnprintf_flags(struct strarray *sa, char *bf, size_t size, unsigned long flags) size_t strarray__scnprintf_flags(struct strarray *sa, char *bf, size_t size, bool show_prefix, unsigned long flags)
{ {
int i, printed = 0; int i, printed = 0;
if (flags == 0) { if (flags == 0) {
const char *s = sa->entries[0]; const char *s = sa->entries[0];
if (s) if (s)
return scnprintf(bf, size, "%s", s); return scnprintf(bf, size, "%s%s", show_prefix ? sa->prefix : "", s);
return scnprintf(bf, size, "%d", 0); return scnprintf(bf, size, "%d", 0);
} }
...@@ -30,7 +30,7 @@ size_t strarray__scnprintf_flags(struct strarray *sa, char *bf, size_t size, uns ...@@ -30,7 +30,7 @@ size_t strarray__scnprintf_flags(struct strarray *sa, char *bf, size_t size, uns
printed += scnprintf(bf + printed, size - printed, "|"); printed += scnprintf(bf + printed, size - printed, "|");
if (sa->entries[i] != NULL) if (sa->entries[i] != NULL)
printed += scnprintf(bf + printed, size - printed, "%s", sa->entries[i]); printed += scnprintf(bf + printed, size - printed, "%s%s", show_prefix ? sa->prefix : "", sa->entries[i]);
else else
printed += scnprintf(bf + printed, size - printed, "0x%#", bit); printed += scnprintf(bf + printed, size - printed, "0x%#", bit);
} }
...@@ -38,17 +38,17 @@ size_t strarray__scnprintf_flags(struct strarray *sa, char *bf, size_t size, uns ...@@ -38,17 +38,17 @@ size_t strarray__scnprintf_flags(struct strarray *sa, char *bf, size_t size, uns
return printed; return printed;
} }
static size_t pkey_alloc__scnprintf_access_rights(int access_rights, char *bf, size_t size) static size_t pkey_alloc__scnprintf_access_rights(int access_rights, char *bf, size_t size, bool show_prefix)
{ {
#include "trace/beauty/generated/pkey_alloc_access_rights_array.c" #include "trace/beauty/generated/pkey_alloc_access_rights_array.c"
static DEFINE_STRARRAY(pkey_alloc_access_rights); static DEFINE_STRARRAY(pkey_alloc_access_rights, "PKEY_");
return strarray__scnprintf_flags(&strarray__pkey_alloc_access_rights, bf, size, access_rights); return strarray__scnprintf_flags(&strarray__pkey_alloc_access_rights, bf, size, show_prefix, access_rights);
} }
size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf, size_t size, struct syscall_arg *arg) size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf, size_t size, struct syscall_arg *arg)
{ {
unsigned long cmd = arg->val; unsigned long cmd = arg->val;
return pkey_alloc__scnprintf_access_rights(cmd, bf, size); return pkey_alloc__scnprintf_access_rights(cmd, bf, size, arg->show_string_prefix);
} }
...@@ -11,16 +11,16 @@ ...@@ -11,16 +11,16 @@
#include "trace/beauty/generated/prctl_option_array.c" #include "trace/beauty/generated/prctl_option_array.c"
static size_t prctl__scnprintf_option(int option, char *bf, size_t size) static size_t prctl__scnprintf_option(int option, char *bf, size_t size, bool show_prefix)
{ {
static DEFINE_STRARRAY(prctl_options); static DEFINE_STRARRAY(prctl_options, "PR_");
return strarray__scnprintf(&strarray__prctl_options, bf, size, "%d", option); return strarray__scnprintf(&strarray__prctl_options, bf, size, "%d", show_prefix, option);
} }
static size_t prctl__scnprintf_set_mm(int option, char *bf, size_t size) static size_t prctl__scnprintf_set_mm(int option, char *bf, size_t size, bool show_prefix)
{ {
static DEFINE_STRARRAY(prctl_set_mm_options); static DEFINE_STRARRAY(prctl_set_mm_options, "PR_SET_MM_");
return strarray__scnprintf(&strarray__prctl_set_mm_options, bf, size, "%d", option); return strarray__scnprintf(&strarray__prctl_set_mm_options, bf, size, "%d", show_prefix, option);
} }
size_t syscall_arg__scnprintf_prctl_arg2(char *bf, size_t size, struct syscall_arg *arg) size_t syscall_arg__scnprintf_prctl_arg2(char *bf, size_t size, struct syscall_arg *arg)
...@@ -28,7 +28,7 @@ size_t syscall_arg__scnprintf_prctl_arg2(char *bf, size_t size, struct syscall_a ...@@ -28,7 +28,7 @@ size_t syscall_arg__scnprintf_prctl_arg2(char *bf, size_t size, struct syscall_a
int option = syscall_arg__val(arg, 0); int option = syscall_arg__val(arg, 0);
if (option == PR_SET_MM) if (option == PR_SET_MM)
return prctl__scnprintf_set_mm(arg->val, bf, size); return prctl__scnprintf_set_mm(arg->val, bf, size, arg->show_string_prefix);
/* /*
* We still don't grab the contents of pointers on entry or exit, * We still don't grab the contents of pointers on entry or exit,
* so just print them as hex numbers * so just print them as hex numbers
...@@ -77,5 +77,5 @@ size_t syscall_arg__scnprintf_prctl_option(char *bf, size_t size, struct syscall ...@@ -77,5 +77,5 @@ size_t syscall_arg__scnprintf_prctl_option(char *bf, size_t size, struct syscall
if (option < ARRAY_SIZE(masks)) if (option < ARRAY_SIZE(masks))
arg->mask |= masks[option]; arg->mask |= masks[option];
return prctl__scnprintf_option(option, bf, size); return prctl__scnprintf_option(option, bf, size, arg->show_string_prefix);
} }
#!/bin/sh
# Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
# SPDX-License-Identifier: LGPL-2.1
[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/linux/
fs_header=${header_dir}/fs.h
printf "static const char *rename_flags[] = {\n"
regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+RENAME_([[:alnum:]_]+)[[:space:]]+\(1[[:space:]]*<<[[:space:]]*([[:xdigit:]]+)[[:space:]]*\)[[:space:]]*.*'
egrep -q $regex ${fs_header} && \
(egrep $regex ${fs_header} | \
sed -r "s/$regex/\2 \1/g" | \
xargs printf "\t[%d + 1] = \"%s\",\n")
printf "};\n"
// SPDX-License-Identifier: LGPL-2.1
// Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
#include "trace/beauty/beauty.h"
#include <uapi/linux/fs.h>
static size_t renameat2__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
{
#include "trace/beauty/generated/rename_flags_array.c"
static DEFINE_STRARRAY(rename_flags, "RENAME_");
return strarray__scnprintf_flags(&strarray__rename_flags, bf, size, show_prefix, flags);
}
size_t syscall_arg__scnprintf_renameat2_flags(char *bf, size_t size, struct syscall_arg *arg)
{
unsigned long flags = arg->val;
return renameat2__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
}
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size,
struct syscall_arg *arg) struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "SCHED_";
const char *policies[] = { const char *policies[] = {
"NORMAL", "FIFO", "RR", "BATCH", "ISO", "IDLE", "DEADLINE", "NORMAL", "FIFO", "RR", "BATCH", "ISO", "IDLE", "DEADLINE",
}; };
...@@ -26,13 +28,13 @@ static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, ...@@ -26,13 +28,13 @@ static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size,
policy &= SCHED_POLICY_MASK; policy &= SCHED_POLICY_MASK;
if (policy <= SCHED_DEADLINE) if (policy <= SCHED_DEADLINE)
printed = scnprintf(bf, size, "%s", policies[policy]); printed = scnprintf(bf, size, "%s%s", show_prefix ? prefix : "", policies[policy]);
else else
printed = scnprintf(bf, size, "%#x", policy); printed = scnprintf(bf, size, "%#x", policy);
#define P_POLICY_FLAG(n) \ #define P_POLICY_FLAG(n) \
if (flags & SCHED_##n) { \ if (flags & SCHED_##n) { \
printed += scnprintf(bf + printed, size - printed, "|%s", #n); \ printed += scnprintf(bf + printed, size - printed, "|%s%s", show_prefix ? prefix : "", #n); \
flags &= ~SCHED_##n; \ flags &= ~SCHED_##n; \
} }
......
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg) static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "SECOMP_SET_MODE_";
int op = arg->val; int op = arg->val;
size_t printed = 0; size_t printed = 0;
switch (op) { switch (op) {
#define P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break #define P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, "%s%s", show_prefix ? prefix : "", #n); break
P_SECCOMP_SET_MODE_OP(STRICT); P_SECCOMP_SET_MODE_OP(STRICT);
P_SECCOMP_SET_MODE_OP(FILTER); P_SECCOMP_SET_MODE_OP(FILTER);
#undef P_SECCOMP_SET_MODE_OP #undef P_SECCOMP_SET_MODE_OP
...@@ -31,11 +33,13 @@ static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct sy ...@@ -31,11 +33,13 @@ static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct sy
static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size,
struct syscall_arg *arg) struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "SECOMP_FILTER_FLAG_";
int printed = 0, flags = arg->val; int printed = 0, flags = arg->val;
#define P_FLAG(n) \ #define P_FLAG(n) \
if (flags & SECCOMP_FILTER_FLAG_##n) { \ if (flags & SECCOMP_FILTER_FLAG_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
flags &= ~SECCOMP_FILTER_FLAG_##n; \ flags &= ~SECCOMP_FILTER_FLAG_##n; \
} }
......
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg) static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "SIG";
int sig = arg->val; int sig = arg->val;
switch (sig) { switch (sig) {
#define P_SIGNUM(n) case SIG##n: return scnprintf(bf, size, #n) #define P_SIGNUM(n) case SIG##n: return scnprintf(bf, size, "%s%s", show_prefix ? prefix : "", #n)
P_SIGNUM(HUP); P_SIGNUM(HUP);
P_SIGNUM(INT); P_SIGNUM(INT);
P_SIGNUM(QUIT); P_SIGNUM(QUIT);
......
...@@ -15,7 +15,7 @@ static const char *socket_families[] = { ...@@ -15,7 +15,7 @@ static const char *socket_families[] = {
"BLUETOOTH", "IUCV", "RXRPC", "ISDN", "PHONET", "IEEE802154", "CAIF", "BLUETOOTH", "IUCV", "RXRPC", "ISDN", "PHONET", "IEEE802154", "CAIF",
"ALG", "NFC", "VSOCK", "ALG", "NFC", "VSOCK",
}; };
DEFINE_STRARRAY(socket_families); DEFINE_STRARRAY(socket_families, "PF_");
static size_t af_inet__scnprintf(struct sockaddr *sa, char *bf, size_t size) static size_t af_inet__scnprintf(struct sockaddr *sa, char *bf, size_t size)
{ {
...@@ -58,7 +58,7 @@ static size_t syscall_arg__scnprintf_augmented_sockaddr(struct syscall_arg *arg, ...@@ -58,7 +58,7 @@ static size_t syscall_arg__scnprintf_augmented_sockaddr(struct syscall_arg *arg,
char family[32]; char family[32];
size_t printed; size_t printed;
strarray__scnprintf(&strarray__socket_families, family, sizeof(family), "%d", sa->sa_family); strarray__scnprintf(&strarray__socket_families, family, sizeof(family), "%d", arg->show_string_prefix, sa->sa_family);
printed = scnprintf(bf, size, "{ .family: %s", family); printed = scnprintf(bf, size, "{ .family: %s", family);
if (sa->sa_family < ARRAY_SIZE(af_scnprintfs) && af_scnprintfs[sa->sa_family]) if (sa->sa_family < ARRAY_SIZE(af_scnprintfs) && af_scnprintfs[sa->sa_family])
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
static size_t socket__scnprintf_ipproto(int protocol, char *bf, size_t size) static size_t socket__scnprintf_ipproto(int protocol, char *bf, size_t size, bool show_prefix)
{ {
#include "trace/beauty/generated/socket_ipproto_array.c" #include "trace/beauty/generated/socket_ipproto_array.c"
static DEFINE_STRARRAY(socket_ipproto); static DEFINE_STRARRAY(socket_ipproto, "IPPROTO_");
return strarray__scnprintf(&strarray__socket_ipproto, bf, size, "%d", protocol); return strarray__scnprintf(&strarray__socket_ipproto, bf, size, "%d", show_prefix, protocol);
} }
size_t syscall_arg__scnprintf_socket_protocol(char *bf, size_t size, struct syscall_arg *arg) size_t syscall_arg__scnprintf_socket_protocol(char *bf, size_t size, struct syscall_arg *arg)
...@@ -22,7 +22,7 @@ size_t syscall_arg__scnprintf_socket_protocol(char *bf, size_t size, struct sysc ...@@ -22,7 +22,7 @@ size_t syscall_arg__scnprintf_socket_protocol(char *bf, size_t size, struct sysc
int domain = syscall_arg__val(arg, 0); int domain = syscall_arg__val(arg, 0);
if (domain == AF_INET || domain == AF_INET6) if (domain == AF_INET || domain == AF_INET6)
return socket__scnprintf_ipproto(arg->val, bf, size); return socket__scnprintf_ipproto(arg->val, bf, size, arg->show_string_prefix);
return syscall_arg__scnprintf_int(bf, size, arg); return syscall_arg__scnprintf_int(bf, size, arg);
} }
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg) static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "SOCK_";
size_t printed; size_t printed;
int type = arg->val, int type = arg->val,
flags = type & ~SOCK_TYPE_MASK; flags = type & ~SOCK_TYPE_MASK;
...@@ -29,7 +31,7 @@ static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct s ...@@ -29,7 +31,7 @@ static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct s
* Can't use a strarray, MIPS may override for ABI reasons. * Can't use a strarray, MIPS may override for ABI reasons.
*/ */
switch (type) { switch (type) {
#define P_SK_TYPE(n) case SOCK_##n: printed = scnprintf(bf, size, #n); break; #define P_SK_TYPE(n) case SOCK_##n: printed = scnprintf(bf, size, "%s%s", show_prefix ? prefix : "", #n); break;
P_SK_TYPE(STREAM); P_SK_TYPE(STREAM);
P_SK_TYPE(DGRAM); P_SK_TYPE(DGRAM);
P_SK_TYPE(RAW); P_SK_TYPE(RAW);
......
...@@ -13,13 +13,15 @@ ...@@ -13,13 +13,15 @@
size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg) size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "AT_";
int printed = 0, flags = arg->val; int printed = 0, flags = arg->val;
if (flags == 0) if (flags == 0)
return scnprintf(bf, size, "SYNC_AS_STAT"); return scnprintf(bf, size, "%s%s", show_prefix ? "AT_STATX_" : "", "SYNC_AS_STAT");
#define P_FLAG(n) \ #define P_FLAG(n) \
if (flags & AT_##n) { \ if (flags & AT_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
flags &= ~AT_##n; \ flags &= ~AT_##n; \
} }
...@@ -41,11 +43,13 @@ size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_ ...@@ -41,11 +43,13 @@ size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_
size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg) size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "STATX_";
int printed = 0, flags = arg->val; int printed = 0, flags = arg->val;
#define P_FLAG(n) \ #define P_FLAG(n) \
if (flags & STATX_##n) { \ if (flags & STATX_##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
flags &= ~STATX_##n; \ flags &= ~STATX_##n; \
} }
......
...@@ -5,11 +5,13 @@ ...@@ -5,11 +5,13 @@
static size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, static size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size,
struct syscall_arg *arg) struct syscall_arg *arg)
{ {
bool show_prefix = arg->show_string_prefix;
const char *prefix = "W";
int printed = 0, options = arg->val; int printed = 0, options = arg->val;
#define P_OPTION(n) \ #define P_OPTION(n) \
if (options & W##n) { \ if (options & W##n) { \
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : #n); \
options &= ~W##n; \ options &= ~W##n; \
} }
......
#!/bin/sh
# Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
# SPDX-License-Identifier: LGPL-2.1
[ $# -eq 1 ] && x86_header_dir=$1 || x86_header_dir=tools/arch/x86/include/uapi/asm/
prctl_arch_header=${x86_header_dir}/prctl.h
print_range () {
local idx=$1
local prefix=$2
local first_entry=$3
printf "#define x86_arch_prctl_codes_%d_offset %s\n" $idx $first_entry
printf "static const char *x86_arch_prctl_codes_%d[] = {\n" $idx
regex=`printf '^[[:space:]]*#[[:space:]]*define[[:space:]]+ARCH_([[:alnum:]_]+)[[:space:]]+(%s[[:xdigit:]]+).*' ${prefix}`
fmt="\t[%#x - ${first_entry}]= \"%s\",\n"
egrep -q $regex ${prctl_arch_header} && \
(egrep $regex ${prctl_arch_header} | \
sed -r "s/$regex/\2 \1/g" | \
xargs printf "$fmt")
printf "};\n\n"
}
print_range 1 0x1 0x1001
print_range 2 0x2 0x2001
...@@ -1983,17 +1983,14 @@ static int find_dso_sym(struct dso *dso, const char *sym_name, u64 *start, ...@@ -1983,17 +1983,14 @@ static int find_dso_sym(struct dso *dso, const char *sym_name, u64 *start,
static int addr_filter__entire_dso(struct addr_filter *filt, struct dso *dso) static int addr_filter__entire_dso(struct addr_filter *filt, struct dso *dso)
{ {
struct symbol *first_sym = dso__first_symbol(dso); if (dso__data_file_size(dso, NULL)) {
struct symbol *last_sym = dso__last_symbol(dso); pr_err("Failed to determine filter for %s\nCannot determine file size.\n",
if (!first_sym || !last_sym) {
pr_err("Failed to determine filter for %s\nNo symbols found.\n",
filt->filename); filt->filename);
return -EINVAL; return -EINVAL;
} }
filt->addr = first_sym->start; filt->addr = 0;
filt->size = last_sym->end - first_sym->start; filt->size = dso->data.file_size;
return 0; return 0;
} }
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
struct cs_etm_decoder { struct cs_etm_decoder {
void *data; void *data;
void (*packet_printer)(const char *msg); void (*packet_printer)(const char *msg);
bool trace_on;
dcd_tree_handle_t dcd_tree; dcd_tree_handle_t dcd_tree;
cs_etm_mem_cb_type mem_access; cs_etm_mem_cb_type mem_access;
ocsd_datapath_resp_t prev_return; ocsd_datapath_resp_t prev_return;
...@@ -291,8 +290,6 @@ static void cs_etm_decoder__clear_buffer(struct cs_etm_decoder *decoder) ...@@ -291,8 +290,6 @@ static void cs_etm_decoder__clear_buffer(struct cs_etm_decoder *decoder)
decoder->packet_buffer[i].instr_count = 0; decoder->packet_buffer[i].instr_count = 0;
decoder->packet_buffer[i].last_instr_taken_branch = false; decoder->packet_buffer[i].last_instr_taken_branch = false;
decoder->packet_buffer[i].last_instr_size = 0; decoder->packet_buffer[i].last_instr_size = 0;
decoder->packet_buffer[i].exc = false;
decoder->packet_buffer[i].exc_ret = false;
decoder->packet_buffer[i].cpu = INT_MIN; decoder->packet_buffer[i].cpu = INT_MIN;
} }
} }
...@@ -320,8 +317,6 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, ...@@ -320,8 +317,6 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder,
decoder->packet_buffer[et].sample_type = sample_type; decoder->packet_buffer[et].sample_type = sample_type;
decoder->packet_buffer[et].isa = CS_ETM_ISA_UNKNOWN; decoder->packet_buffer[et].isa = CS_ETM_ISA_UNKNOWN;
decoder->packet_buffer[et].exc = false;
decoder->packet_buffer[et].exc_ret = false;
decoder->packet_buffer[et].cpu = *((int *)inode->priv); decoder->packet_buffer[et].cpu = *((int *)inode->priv);
decoder->packet_buffer[et].start_addr = CS_ETM_INVAL_ADDR; decoder->packet_buffer[et].start_addr = CS_ETM_INVAL_ADDR;
decoder->packet_buffer[et].end_addr = CS_ETM_INVAL_ADDR; decoder->packet_buffer[et].end_addr = CS_ETM_INVAL_ADDR;
...@@ -391,11 +386,27 @@ cs_etm_decoder__buffer_range(struct cs_etm_decoder *decoder, ...@@ -391,11 +386,27 @@ cs_etm_decoder__buffer_range(struct cs_etm_decoder *decoder,
} }
static ocsd_datapath_resp_t static ocsd_datapath_resp_t
cs_etm_decoder__buffer_trace_on(struct cs_etm_decoder *decoder, cs_etm_decoder__buffer_discontinuity(struct cs_etm_decoder *decoder,
const uint8_t trace_chan_id) const uint8_t trace_chan_id)
{ {
return cs_etm_decoder__buffer_packet(decoder, trace_chan_id, return cs_etm_decoder__buffer_packet(decoder, trace_chan_id,
CS_ETM_TRACE_ON); CS_ETM_DISCONTINUITY);
}
static ocsd_datapath_resp_t
cs_etm_decoder__buffer_exception(struct cs_etm_decoder *decoder,
const uint8_t trace_chan_id)
{
return cs_etm_decoder__buffer_packet(decoder, trace_chan_id,
CS_ETM_EXCEPTION);
}
static ocsd_datapath_resp_t
cs_etm_decoder__buffer_exception_ret(struct cs_etm_decoder *decoder,
const uint8_t trace_chan_id)
{
return cs_etm_decoder__buffer_packet(decoder, trace_chan_id,
CS_ETM_EXCEPTION_RET);
} }
static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer(
...@@ -410,26 +421,25 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( ...@@ -410,26 +421,25 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer(
switch (elem->elem_type) { switch (elem->elem_type) {
case OCSD_GEN_TRC_ELEM_UNKNOWN: case OCSD_GEN_TRC_ELEM_UNKNOWN:
break; break;
case OCSD_GEN_TRC_ELEM_EO_TRACE:
case OCSD_GEN_TRC_ELEM_NO_SYNC: case OCSD_GEN_TRC_ELEM_NO_SYNC:
decoder->trace_on = false;
break;
case OCSD_GEN_TRC_ELEM_TRACE_ON: case OCSD_GEN_TRC_ELEM_TRACE_ON:
resp = cs_etm_decoder__buffer_trace_on(decoder, resp = cs_etm_decoder__buffer_discontinuity(decoder,
trace_chan_id); trace_chan_id);
decoder->trace_on = true;
break; break;
case OCSD_GEN_TRC_ELEM_INSTR_RANGE: case OCSD_GEN_TRC_ELEM_INSTR_RANGE:
resp = cs_etm_decoder__buffer_range(decoder, elem, resp = cs_etm_decoder__buffer_range(decoder, elem,
trace_chan_id); trace_chan_id);
break; break;
case OCSD_GEN_TRC_ELEM_EXCEPTION: case OCSD_GEN_TRC_ELEM_EXCEPTION:
decoder->packet_buffer[decoder->tail].exc = true; resp = cs_etm_decoder__buffer_exception(decoder,
trace_chan_id);
break; break;
case OCSD_GEN_TRC_ELEM_EXCEPTION_RET: case OCSD_GEN_TRC_ELEM_EXCEPTION_RET:
decoder->packet_buffer[decoder->tail].exc_ret = true; resp = cs_etm_decoder__buffer_exception_ret(decoder,
trace_chan_id);
break; break;
case OCSD_GEN_TRC_ELEM_PE_CONTEXT: case OCSD_GEN_TRC_ELEM_PE_CONTEXT:
case OCSD_GEN_TRC_ELEM_EO_TRACE:
case OCSD_GEN_TRC_ELEM_ADDR_NACC: case OCSD_GEN_TRC_ELEM_ADDR_NACC:
case OCSD_GEN_TRC_ELEM_TIMESTAMP: case OCSD_GEN_TRC_ELEM_TIMESTAMP:
case OCSD_GEN_TRC_ELEM_CYCLE_COUNT: case OCSD_GEN_TRC_ELEM_CYCLE_COUNT:
......
...@@ -23,9 +23,11 @@ struct cs_etm_buffer { ...@@ -23,9 +23,11 @@ struct cs_etm_buffer {
}; };
enum cs_etm_sample_type { enum cs_etm_sample_type {
CS_ETM_EMPTY = 0, CS_ETM_EMPTY,
CS_ETM_RANGE = 1 << 0, CS_ETM_RANGE,
CS_ETM_TRACE_ON = 1 << 1, CS_ETM_DISCONTINUITY,
CS_ETM_EXCEPTION,
CS_ETM_EXCEPTION_RET,
}; };
enum cs_etm_isa { enum cs_etm_isa {
...@@ -43,8 +45,6 @@ struct cs_etm_packet { ...@@ -43,8 +45,6 @@ struct cs_etm_packet {
u32 instr_count; u32 instr_count;
u8 last_instr_taken_branch; u8 last_instr_taken_branch;
u8 last_instr_size; u8 last_instr_size;
u8 exc;
u8 exc_ret;
int cpu; int cpu;
}; };
......
...@@ -562,8 +562,8 @@ static inline int cs_etm__t32_instr_size(struct cs_etm_queue *etmq, ...@@ -562,8 +562,8 @@ static inline int cs_etm__t32_instr_size(struct cs_etm_queue *etmq,
static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet) static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet)
{ {
/* Returns 0 for the CS_ETM_TRACE_ON packet */ /* Returns 0 for the CS_ETM_DISCONTINUITY packet */
if (packet->sample_type == CS_ETM_TRACE_ON) if (packet->sample_type == CS_ETM_DISCONTINUITY)
return 0; return 0;
return packet->start_addr; return packet->start_addr;
...@@ -572,8 +572,8 @@ static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet) ...@@ -572,8 +572,8 @@ static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet)
static inline static inline
u64 cs_etm__last_executed_instr(const struct cs_etm_packet *packet) u64 cs_etm__last_executed_instr(const struct cs_etm_packet *packet)
{ {
/* Returns 0 for the CS_ETM_TRACE_ON packet */ /* Returns 0 for the CS_ETM_DISCONTINUITY packet */
if (packet->sample_type == CS_ETM_TRACE_ON) if (packet->sample_type == CS_ETM_DISCONTINUITY)
return 0; return 0;
return packet->end_addr - packet->last_instr_size; return packet->end_addr - packet->last_instr_size;
...@@ -972,7 +972,7 @@ static int cs_etm__sample(struct cs_etm_queue *etmq) ...@@ -972,7 +972,7 @@ static int cs_etm__sample(struct cs_etm_queue *etmq)
bool generate_sample = false; bool generate_sample = false;
/* Generate sample for tracing on packet */ /* Generate sample for tracing on packet */
if (etmq->prev_packet->sample_type == CS_ETM_TRACE_ON) if (etmq->prev_packet->sample_type == CS_ETM_DISCONTINUITY)
generate_sample = true; generate_sample = true;
/* Generate sample for branch taken packet */ /* Generate sample for branch taken packet */
...@@ -1000,6 +1000,25 @@ static int cs_etm__sample(struct cs_etm_queue *etmq) ...@@ -1000,6 +1000,25 @@ static int cs_etm__sample(struct cs_etm_queue *etmq)
return 0; return 0;
} }
static int cs_etm__exception(struct cs_etm_queue *etmq)
{
/*
* When the exception packet is inserted, whether the last instruction
* in previous range packet is taken branch or not, we need to force
* to set 'prev_packet->last_instr_taken_branch' to true. This ensures
* to generate branch sample for the instruction range before the
* exception is trapped to kernel or before the exception returning.
*
* The exception packet includes the dummy address values, so don't
* swap PACKET with PREV_PACKET. This keeps PREV_PACKET to be useful
* for generating instruction and branch samples.
*/
if (etmq->prev_packet->sample_type == CS_ETM_RANGE)
etmq->prev_packet->last_instr_taken_branch = true;
return 0;
}
static int cs_etm__flush(struct cs_etm_queue *etmq) static int cs_etm__flush(struct cs_etm_queue *etmq)
{ {
int err = 0; int err = 0;
...@@ -1042,7 +1061,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) ...@@ -1042,7 +1061,7 @@ static int cs_etm__flush(struct cs_etm_queue *etmq)
} }
swap_packet: swap_packet:
if (etmq->etm->synth_opts.last_branch) { if (etm->sample_branches || etm->synth_opts.last_branch) {
/* /*
* Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for
* the next incoming packet. * the next incoming packet.
...@@ -1055,6 +1074,39 @@ static int cs_etm__flush(struct cs_etm_queue *etmq) ...@@ -1055,6 +1074,39 @@ static int cs_etm__flush(struct cs_etm_queue *etmq)
return err; return err;
} }
static int cs_etm__end_block(struct cs_etm_queue *etmq)
{
int err;
/*
* It has no new packet coming and 'etmq->packet' contains the stale
* packet which was set at the previous time with packets swapping;
* so skip to generate branch sample to avoid stale packet.
*
* For this case only flush branch stack and generate a last branch
* event for the branches left in the circular buffer at the end of
* the trace.
*/
if (etmq->etm->synth_opts.last_branch &&
etmq->prev_packet->sample_type == CS_ETM_RANGE) {
/*
* Use the address of the end of the last reported execution
* range.
*/
u64 addr = cs_etm__last_executed_instr(etmq->prev_packet);
err = cs_etm__synth_instruction_sample(
etmq, addr,
etmq->period_instructions);
if (err)
return err;
etmq->period_instructions = 0;
}
return 0;
}
static int cs_etm__run_decoder(struct cs_etm_queue *etmq) static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
{ {
struct cs_etm_auxtrace *etm = etmq->etm; struct cs_etm_auxtrace *etm = etmq->etm;
...@@ -1115,7 +1167,16 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) ...@@ -1115,7 +1167,16 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
*/ */
cs_etm__sample(etmq); cs_etm__sample(etmq);
break; break;
case CS_ETM_TRACE_ON: case CS_ETM_EXCEPTION:
case CS_ETM_EXCEPTION_RET:
/*
* If the exception packet is coming,
* make sure the previous instruction
* range packet to be handled properly.
*/
cs_etm__exception(etmq);
break;
case CS_ETM_DISCONTINUITY:
/* /*
* Discontinuity in trace, flush * Discontinuity in trace, flush
* previous branch stack * previous branch stack
...@@ -1137,7 +1198,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq) ...@@ -1137,7 +1198,7 @@ static int cs_etm__run_decoder(struct cs_etm_queue *etmq)
if (err == 0) if (err == 0)
/* Flush any remaining branch stack entries */ /* Flush any remaining branch stack entries */
err = cs_etm__flush(etmq); err = cs_etm__end_block(etmq);
} }
return err; return err;
......
...@@ -894,7 +894,7 @@ static ssize_t cached_read(struct dso *dso, struct machine *machine, ...@@ -894,7 +894,7 @@ static ssize_t cached_read(struct dso *dso, struct machine *machine,
return r; return r;
} }
static int data_file_size(struct dso *dso, struct machine *machine) int dso__data_file_size(struct dso *dso, struct machine *machine)
{ {
int ret = 0; int ret = 0;
struct stat st; struct stat st;
...@@ -943,7 +943,7 @@ static int data_file_size(struct dso *dso, struct machine *machine) ...@@ -943,7 +943,7 @@ static int data_file_size(struct dso *dso, struct machine *machine)
*/ */
off_t dso__data_size(struct dso *dso, struct machine *machine) off_t dso__data_size(struct dso *dso, struct machine *machine)
{ {
if (data_file_size(dso, machine)) if (dso__data_file_size(dso, machine))
return -1; return -1;
/* For now just estimate dso data size is close to file size */ /* For now just estimate dso data size is close to file size */
...@@ -953,7 +953,7 @@ off_t dso__data_size(struct dso *dso, struct machine *machine) ...@@ -953,7 +953,7 @@ off_t dso__data_size(struct dso *dso, struct machine *machine)
static ssize_t data_read_offset(struct dso *dso, struct machine *machine, static ssize_t data_read_offset(struct dso *dso, struct machine *machine,
u64 offset, u8 *data, ssize_t size) u64 offset, u8 *data, ssize_t size)
{ {
if (data_file_size(dso, machine)) if (dso__data_file_size(dso, machine))
return -1; return -1;
/* Check the offset sanity. */ /* Check the offset sanity. */
......
...@@ -322,6 +322,7 @@ int dso__data_get_fd(struct dso *dso, struct machine *machine); ...@@ -322,6 +322,7 @@ int dso__data_get_fd(struct dso *dso, struct machine *machine);
void dso__data_put_fd(struct dso *dso); void dso__data_put_fd(struct dso *dso);
void dso__data_close(struct dso *dso); void dso__data_close(struct dso *dso);
int dso__data_file_size(struct dso *dso, struct machine *machine);
off_t dso__data_size(struct dso *dso, struct machine *machine); off_t dso__data_size(struct dso *dso, struct machine *machine);
ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine, ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
u64 offset, u8 *data, ssize_t size); u64 offset, u8 *data, ssize_t size);
......
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/err.h> #include <linux/err.h>
#ifdef LACKS_SIGQUEUE_PROTOTYPE
int sigqueue(pid_t pid, int sig, const union sigval value);
#endif
#define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
#define SID(e, x, y) xyarray__entry(e->sample_id, x, y) #define SID(e, x, y) xyarray__entry(e->sample_id, x, y)
......
...@@ -2698,6 +2698,7 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full) ...@@ -2698,6 +2698,7 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)
struct perf_header *header = &session->header; struct perf_header *header = &session->header;
int fd = perf_data__fd(session->data); int fd = perf_data__fd(session->data);
struct stat st; struct stat st;
time_t stctime;
int ret, bit; int ret, bit;
hd.fp = fp; hd.fp = fp;
...@@ -2707,7 +2708,8 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full) ...@@ -2707,7 +2708,8 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)
if (ret == -1) if (ret == -1)
return -1; return -1;
fprintf(fp, "# captured on : %s", ctime(&st.st_ctime)); stctime = st.st_ctime;
fprintf(fp, "# captured on : %s", ctime(&stctime));
fprintf(fp, "# header version : %u\n", header->version); fprintf(fp, "# header version : %u\n", header->version);
fprintf(fp, "# data offset : %" PRIu64 "\n", header->data_offset); fprintf(fp, "# data offset : %" PRIu64 "\n", header->data_offset);
......
...@@ -506,7 +506,7 @@ static int s390_cpumsf_samples(struct s390_cpumsf_queue *sfq, u64 *ts) ...@@ -506,7 +506,7 @@ static int s390_cpumsf_samples(struct s390_cpumsf_queue *sfq, u64 *ts)
aux_ts = get_trailer_time(buf); aux_ts = get_trailer_time(buf);
if (!aux_ts) { if (!aux_ts) {
pr_err("[%#08" PRIx64 "] Invalid AUX trailer entry TOD clock base\n", pr_err("[%#08" PRIx64 "] Invalid AUX trailer entry TOD clock base\n",
sfq->buffer->data_offset); (s64)sfq->buffer->data_offset);
aux_ts = ~0ULL; aux_ts = ~0ULL;
goto out; goto out;
} }
......
...@@ -1537,17 +1537,6 @@ int dso__load(struct dso *dso, struct map *map) ...@@ -1537,17 +1537,6 @@ int dso__load(struct dso *dso, struct map *map)
dso->adjust_symbols = 0; dso->adjust_symbols = 0;
if (perfmap) { if (perfmap) {
struct stat st;
if (lstat(map_path, &st) < 0)
goto out;
if (!symbol_conf.force && st.st_uid && (st.st_uid != geteuid())) {
pr_warning("File %s not owned by current user or root, "
"ignoring it (use -f to override).\n", map_path);
goto out;
}
ret = dso__load_perf_map(map_path, dso); ret = dso__load_perf_map(map_path, dso);
dso->symtab_type = ret > 0 ? DSO_BINARY_TYPE__JAVA_JIT : dso->symtab_type = ret > 0 ? DSO_BINARY_TYPE__JAVA_JIT :
DSO_BINARY_TYPE__NOT_FOUND; DSO_BINARY_TYPE__NOT_FOUND;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment