summaryrefslogtreecommitdiff
path: root/src/defs.h
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2021-09-06 16:45:31 +0200
committerEugene Syromyatnikov <evgsyr@gmail.com>2021-10-08 03:50:14 +0200
commit0ca0f07f964077657988234879d95285153e53b0 (patch)
treea0536e8072d79c3fb615ce0f578707977f43b1ff /src/defs.h
parent5e0ef82427984cd5f164b9f9f1eb08db2f5d295a (diff)
downloadstrace-0ca0f07f964077657988234879d95285153e53b0.tar.gz
Provide a routine for printing syscall name from nr/audit_arch pair
The pair of raw syscall number and AUDIT_ARCH_* is used by kernel to describe syscall for userspace in increasing number of places, so it is deemed advisable to provide information about syscall name to user when possible. This commit defines such a routine, syscall_name_arch, along with PRINT_FIELD_SYSCALL_NAME macro that enables syscall name printing inside structures. While we are here, let's consolidate syscall_name* routines in a separate file. * src/Makefile.am (libstrace_a_SOURCES): Add syscall_name.c. * src/defs.h (syscall_name_arch): New declaration. (struct audit_arch_t): Moved from filter_seccomp.c. (audit_arch_vec): New declaration. * src/filter_seccomp.c [PERSONALITY0_AUDIT_ARCH]: Remove <linux/audit.h>, "xlat/elf_em.h", and "xlat/audit_arch.h" includes. (struct audit_arch_t): Move it to defs.h (audit_arch_vec): Move it to src/syscall_name.c. * src/print_fields.h (PRINT_FIELD_SYSCALL_NAME): New macro. * src/syscall.c (syscall_name): Move it to src/syscall_name.c. * src/syscall_name.c: New file. * src/linux/generic/nr_prefix.c [PERSONALITY0_AUDIT_ARCH] (nr_prefix): Make the function available. * src/linux/ia64/arch_defs_.h: Include "syscallent_base_nr.h" to make PERSONALITY0_AUDIT_ARCH definition usable.
Diffstat (limited to 'src/defs.h')
-rw-r--r--src/defs.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/defs.h b/src/defs.h
index cfccbfc5d..06b904c1f 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -573,6 +573,23 @@ extern kernel_ulong_t get_rt_sigframe_addr(struct tcb *);
*/
extern const char *syscall_name(kernel_ulong_t scno);
/**
+ * Convert a pair of (raw) syscall number and arch (defined by an AUDIT_ARCH_*
+ * constant) to the corresponding syscall name. So far works only for arches
+ * that are present in personalities supported by strace binary.
+ *
+ * @param nr Raw syscall number.
+ * @param arch AUDIT_ARCH_* constant that identifies the architecture.
+ * @param prefix If arch corresponds to current personality (and the argument
+ * is non-NULL), an appropriate __NR_* constant prefix
+ * is to be stored at the address pointed by the argument.
+ * If arch corresponds to a different personality, or syscall
+ * name has not been found, NULL is stored.
+ * @return String literal corresponding to the syscall number in case
+ * the latter is valid; NULL otherwise.
+ */
+extern const char *syscall_name_arch(kernel_ulong_t nr, unsigned int arch,
+ const char **prefix);
+/**
* Convert a syscall name to the corresponding (shuffled) syscall number.
*
* @param s Syscall name.
@@ -1793,6 +1810,13 @@ extern const unsigned int nsyscall_vec[SUPPORTED_PERSONALITIES];
extern const struct_sysent *const sysent_vec[SUPPORTED_PERSONALITIES];
extern struct inject_opts *inject_vec[SUPPORTED_PERSONALITIES];
+struct audit_arch_t {
+ unsigned int arch; /* AUDIT_ARCH_* */
+ unsigned int flag;
+};
+
+extern const struct audit_arch_t audit_arch_vec[SUPPORTED_PERSONALITIES];
+
# ifdef ENABLE_COVERAGE_GCOV
# ifdef HAVE_GCOV_H
# include <gcov.h>