diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2018-10-07 05:34:36 +0200 |
---|---|---|
committer | Eugene Syromyatnikov <evgsyr@gmail.com> | 2022-09-02 17:55:13 +0200 |
commit | 429d9701b47746f0600dfff66f3466c531515fc0 (patch) | |
tree | e74b4d0725d6654883826288dc3f3405467e0cf3 | |
parent | c013f10fcbdf4a6fc0c8602e3ce1089c843eada3 (diff) | |
download | strace-429d9701b47746f0600dfff66f3466c531515fc0.tar.gz |
Add support for alternative error/signal names
There are some error and signal constants that are defined as a synonyms
for other errors/sugnals. Let's support their qualification.
* filter_qualify.c (struct alt_name): New type definition.
(alt_signames, alt_errnames): New variables.
(sigstr_to_uint): Check alt_signames for possible alternative signal
name usage.
(find_errno_by_name): Check alt_errnames for possible alternative error
name usage.
* linux/alpha/alt_errnoent.h: New file.
* linux/alpha/alt_signalent.h: Likewise.
* linux/alt_errnoent.h: Likewise.
* linux/alt_signalent.h: Likewise.
* linux/hppa/alt_errnoent.h: Likewise.
* linux/mips/alt_errnoent.h: Likewise.
* linux/mips/alt_signalent.h: Likewise.
* linux/powerpc/alt_errnoent.h: Likewise.
* linux/powerpc64/alt_errnoent.h: Likewise.
* linux/sparc/alt_errnoent.h: Likewise.
* linux/sparc/alt_signalent.h: Likewise.
* linux/sparc64/alt_signalent.h: Likewise.
* tests/qual_signal.test: Add some checks for alternative signal names.
-rw-r--r-- | src/Makefile.am | 13 | ||||
-rw-r--r-- | src/filter_qualify.c | 29 | ||||
-rw-r--r-- | src/linux/alpha/alt_errnoent.h | 2 | ||||
-rw-r--r-- | src/linux/alpha/alt_signalent.h | 4 | ||||
-rw-r--r-- | src/linux/alt_errnoent.h | 3 | ||||
-rw-r--r-- | src/linux/alt_signalent.h | 4 | ||||
-rw-r--r-- | src/linux/generic/alt_errnoent.h | 3 | ||||
-rw-r--r-- | src/linux/generic/alt_signalent.h | 4 | ||||
-rw-r--r-- | src/linux/hppa/alt_errnoent.h | 4 | ||||
-rw-r--r-- | src/linux/mips/alt_errnoent.h | 1 | ||||
-rw-r--r-- | src/linux/mips/alt_signalent.h | 4 | ||||
-rw-r--r-- | src/linux/powerpc/alt_errnoent.h | 2 | ||||
-rw-r--r-- | src/linux/powerpc64/alt_errnoent.h | 1 | ||||
-rw-r--r-- | src/linux/sparc/alt_errnoent.h | 1 | ||||
-rw-r--r-- | src/linux/sparc/alt_signalent.h | 4 | ||||
-rw-r--r-- | src/linux/sparc64/alt_errnoent.h | 1 | ||||
-rw-r--r-- | src/linux/sparc64/alt_signalent.h | 1 | ||||
-rwxr-xr-x | tests/qual_signal.test | 56 |
18 files changed, 135 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index e9fffa8c9..0c92e7a69 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -486,6 +486,8 @@ EXTRA_DIST = \ linux/aarch64/shuffle_scno.c \ linux/aarch64/syscallent.h \ linux/aarch64/syscallent1.h \ + linux/alpha/alt_errnoent.h \ + linux/alpha/alt_signalent.h \ linux/alpha/arch_defs_.h \ linux/alpha/arch_getrval2.c \ linux/alpha/arch_regs.c \ @@ -568,6 +570,8 @@ EXTRA_DIST = \ linux/csky/set_error.c \ linux/csky/set_scno.c \ linux/csky/syscallent.h \ + linux/generic/alt_errnoent.h \ + linux/generic/alt_signalent.h \ linux/generic/arch_fpregset.c \ linux/generic/arch_fpregset.h \ linux/generic/arch_kvm.c \ @@ -596,6 +600,7 @@ EXTRA_DIST = \ linux/generic/syscallent_base_nr.h \ linux/generic/userent.h \ linux/generic/userent0.h \ + linux/hppa/alt_errnoent.h \ linux/hppa/arch_defs_.h \ linux/hppa/arch_regs.c \ linux/hppa/arch_rt_sigframe.c \ @@ -707,6 +712,8 @@ EXTRA_DIST = \ linux/microblaze/set_scno.c \ linux/microblaze/syscallent.h \ linux/microblaze/userent.h \ + linux/mips/alt_errnoent.h \ + linux/mips/alt_signalent.h \ linux/mips/arch_defs_.h \ linux/mips/arch_getrval2.c \ linux/mips/arch_prstatus_regset.c \ @@ -755,6 +762,7 @@ EXTRA_DIST = \ linux/or1k/set_scno.c \ linux/or1k/syscallent.h \ linux/or1k/userent.h \ + linux/powerpc/alt_errnoent.h \ linux/powerpc/arch_defs_.h \ linux/powerpc/arch_fpregset.c \ linux/powerpc/arch_fpregset.h \ @@ -776,6 +784,7 @@ EXTRA_DIST = \ linux/powerpc/set_scno.c \ linux/powerpc/syscallent.h \ linux/powerpc/userent.h \ + linux/powerpc64/alt_errnoent.h \ linux/powerpc64/arch_defs_.h \ linux/powerpc64/arch_fpregset.c \ linux/powerpc64/arch_fpregset.h \ @@ -902,6 +911,8 @@ EXTRA_DIST = \ linux/sh64/set_scno.c \ linux/sh64/syscallent.h \ linux/sh64/userent.h \ + linux/sparc/alt_errnoent.h \ + linux/sparc/alt_signalent.h \ linux/sparc/arch_defs_.h \ linux/sparc/arch_getrval2.c \ linux/sparc/arch_prstatus_regset.c \ @@ -922,6 +933,8 @@ EXTRA_DIST = \ linux/sparc/signalent.h \ linux/sparc/syscallent.h \ linux/sparc/userent.h \ + linux/sparc64/alt_errnoent.h \ + linux/sparc64/alt_signalent.h \ linux/sparc64/arch_defs_.h \ linux/sparc64/arch_get_personality.c \ linux/sparc64/arch_getrval2.c \ diff --git a/src/filter_qualify.c b/src/filter_qualify.c index f3af3ad8f..4a7491f5f 100644 --- a/src/filter_qualify.c +++ b/src/filter_qualify.c @@ -38,6 +38,21 @@ struct inject_personality_data { uint16_t scno; }; +struct alt_name { + const char *syn; + const char *orig; +}; + +#define _(a_, b_) { (a_), (b_) } +static const struct alt_name alt_signames[] = { + #include "alt_signalent.h" +}; + +static const struct alt_name alt_errnames[] = { + #include "alt_signalent.h" +}; +#undef _ + static bool signame_eq(const char *needle, const char *straw) { @@ -58,6 +73,13 @@ signame_eq(const char *needle, const char *straw) static int sigstr_to_uint(const char *s) { + for (size_t i = 0; i < ARRAY_SIZE(alt_signames); i++) { + if (signame_eq(s, alt_signames[i].syn)) { + s = alt_signames[i].orig; + break; + } + } + if (*s >= '0' && *s <= '9') return string_to_uint_upto(s, nsig); @@ -127,6 +149,13 @@ decode_pid_str_to_uint(const char *str) static int find_errno_by_name(const char *name) { + for (unsigned int i = 0; i < ARRAY_SIZE(alt_errnames); ++i) { + if (!strcasecmp(name, alt_errnames[i].syn)) { + name = alt_errnames[i].orig; + break; + } + } + for (unsigned int i = 1; i < nerrnos; ++i) { if (errnoent[i] && (strcasecmp(name, errnoent[i]) == 0)) return i; diff --git a/src/linux/alpha/alt_errnoent.h b/src/linux/alpha/alt_errnoent.h new file mode 100644 index 000000000..1436e95a2 --- /dev/null +++ b/src/linux/alpha/alt_errnoent.h @@ -0,0 +1,2 @@ +_("EWOULDBLOCK", "EAGAIN"), +_("EDEADLOCK", "EDEADLK" ), diff --git a/src/linux/alpha/alt_signalent.h b/src/linux/alpha/alt_signalent.h new file mode 100644 index 000000000..03ca0cdc1 --- /dev/null +++ b/src/linux/alpha/alt_signalent.h @@ -0,0 +1,4 @@ +_("SIGPOLL", "SIGIO"), +_("SIGUNUSED", "31"), +_("SIGPWR", "SIGINFO"), +_("SIGIOT", "SIGABRT"), diff --git a/src/linux/alt_errnoent.h b/src/linux/alt_errnoent.h new file mode 100644 index 000000000..ad4a20905 --- /dev/null +++ b/src/linux/alt_errnoent.h @@ -0,0 +1,3 @@ +_("EWOULDBLOCK", "EAGAIN" ), +_("ENOTSUP", "EOPNOTSUPP"), +_("EDEADLOCK", "EDEADLK"), diff --git a/src/linux/alt_signalent.h b/src/linux/alt_signalent.h new file mode 100644 index 000000000..45e251183 --- /dev/null +++ b/src/linux/alt_signalent.h @@ -0,0 +1,4 @@ +_("SIGPOLL", "SIGIO"), +_("SIGUNUSED", "31"), +_("SIGINFO", "SIGPWR"), +_("SIGIOT", "SIGABRT"), diff --git a/src/linux/generic/alt_errnoent.h b/src/linux/generic/alt_errnoent.h new file mode 100644 index 000000000..ad4a20905 --- /dev/null +++ b/src/linux/generic/alt_errnoent.h @@ -0,0 +1,3 @@ +_("EWOULDBLOCK", "EAGAIN" ), +_("ENOTSUP", "EOPNOTSUPP"), +_("EDEADLOCK", "EDEADLK"), diff --git a/src/linux/generic/alt_signalent.h b/src/linux/generic/alt_signalent.h new file mode 100644 index 000000000..45e251183 --- /dev/null +++ b/src/linux/generic/alt_signalent.h @@ -0,0 +1,4 @@ +_("SIGPOLL", "SIGIO"), +_("SIGUNUSED", "31"), +_("SIGINFO", "SIGPWR"), +_("SIGIOT", "SIGABRT"), diff --git a/src/linux/hppa/alt_errnoent.h b/src/linux/hppa/alt_errnoent.h new file mode 100644 index 000000000..e6dc9a2c1 --- /dev/null +++ b/src/linux/hppa/alt_errnoent.h @@ -0,0 +1,4 @@ +_("EWOULDBLOCK", "EAGAIN"), +_("EDEADLOCK", "EDEADLK"), +_("EREFUSED", "ECONNREFUSED"), +_("ECANCELED", "ECANCELLED"), diff --git a/src/linux/mips/alt_errnoent.h b/src/linux/mips/alt_errnoent.h new file mode 100644 index 000000000..7f9188cc1 --- /dev/null +++ b/src/linux/mips/alt_errnoent.h @@ -0,0 +1 @@ +_("EWOULDBLOCK", "EAGAIN"), diff --git a/src/linux/mips/alt_signalent.h b/src/linux/mips/alt_signalent.h new file mode 100644 index 000000000..de1f0529d --- /dev/null +++ b/src/linux/mips/alt_signalent.h @@ -0,0 +1,4 @@ +_("SIGPOLL", "SIGIO"), +_("SIGUNUSED", "31"), +_("SIGINFO", "SIGPWR"), +_("SIGABRT, ""SIGIOT"), diff --git a/src/linux/powerpc/alt_errnoent.h b/src/linux/powerpc/alt_errnoent.h new file mode 100644 index 000000000..cc1994e26 --- /dev/null +++ b/src/linux/powerpc/alt_errnoent.h @@ -0,0 +1,2 @@ +_("EWOULDBLOCK", "EAGAIN"), +_("ENOTSUP", "EOPNOTSUPP"), diff --git a/src/linux/powerpc64/alt_errnoent.h b/src/linux/powerpc64/alt_errnoent.h new file mode 100644 index 000000000..09d0c5199 --- /dev/null +++ b/src/linux/powerpc64/alt_errnoent.h @@ -0,0 +1 @@ +#include "powerpc/alt_errnoent.h" diff --git a/src/linux/sparc/alt_errnoent.h b/src/linux/sparc/alt_errnoent.h new file mode 100644 index 000000000..7f9188cc1 --- /dev/null +++ b/src/linux/sparc/alt_errnoent.h @@ -0,0 +1 @@ +_("EWOULDBLOCK", "EAGAIN"), diff --git a/src/linux/sparc/alt_signalent.h b/src/linux/sparc/alt_signalent.h new file mode 100644 index 000000000..d93a45371 --- /dev/null +++ b/src/linux/sparc/alt_signalent.h @@ -0,0 +1,4 @@ +_("SIGPOLL", "SIGIO"), +_("SIGUNUSED", "31"), +_("SIGPWR", "SIGLOST"), +_("SIGIOT", "SIGABRT"), diff --git a/src/linux/sparc64/alt_errnoent.h b/src/linux/sparc64/alt_errnoent.h new file mode 100644 index 000000000..ade78c0c7 --- /dev/null +++ b/src/linux/sparc64/alt_errnoent.h @@ -0,0 +1 @@ +#include "sparc/alt_errnoent.h" diff --git a/src/linux/sparc64/alt_signalent.h b/src/linux/sparc64/alt_signalent.h new file mode 100644 index 000000000..6f0b14981 --- /dev/null +++ b/src/linux/sparc64/alt_signalent.h @@ -0,0 +1 @@ +#include "sparc/alt_signalent.h" diff --git a/tests/qual_signal.test b/tests/qual_signal.test index 1eeddd217..db2b2e46b 100755 --- a/tests/qual_signal.test +++ b/tests/qual_signal.test @@ -24,17 +24,27 @@ test_one_sig() match_diff "$LOG" "$EXP" } -test_sigs() +test_sigs_ex() { local first second sigs + first_id="$1"; shift first="$1"; shift + second_id="$1"; shift second="$1"; shift for sigs; do - test_one_sig "$sigs" 2 "$first" 15 "$second" + test_one_sig "$sigs" "$first_id" "$first" "$second_id" "$second" done } +test_sigs() +{ + local first + first="$1"; shift + + test_sigs_ex 2 "$first" 15 "$@" +} + test_sigs '' '' \ none '!all' \ CHLD SIGCHLD ALRM SIGALRM \ @@ -78,6 +88,48 @@ test_sigs SIGINT SIGTERM \ '!CHLD,SIGALRM' '!ALRM,SIGCHLD' \ '!9' '!9,4' '!9,4,11' '!4,CHLD,11,ALRM,9' +case "$STRACE_ARCH" in +alpha) + test_sigs '' '' \ + none '!all' \ + POLL UNUSED SIGPOLL SIGUNUSED \ + poll unused sigpoll sigunused \ + POLL,UNUSED SIGPOLL,UNUSED POLL,SIGUNUSED \ + unused,poll unused,sigpoll sigunused,poll + PWR IOT SIGPWR SIGIOT \ + pwr iot sigpwr sigiot \ + PWR,IOT PWR,SIGIOT SIGPWR,IOT \ + iot,pwr sigiot,pwr iot,siginfo + ;; + +*) + test_sigs_ex 29 '' 31 SIGSYS \ + UNUSED SIGUNUSED unused sigunused \ + '!POLL' '!SIGPOLL' '!POLL,IO' \ + '!poll' '!chld,sigpoll' '!sigalrm,poll' + test_sigs_ex 29 SIGIO 31 '' \ + POLL SIGPOLL poll sigpoll \ + '!UNUSED' '!SIGUNUSED' '!UNUSED,ALRM' \ + '!unused' '!unused,sigchld' '!sigunused,term' + test_sigs_ex 29 SIGIO 31 SIGSYS \ + POLL,UNUSED SIGPOLL,UNUSED POLL,SIGUNUSED \ + unused,poll unused,sigpoll sigunused,poll + + test_sigs_ex 30 '' 6 SIGABRT \ + IOT SIGIOT iot sigiot \ + '!INFO' '!SIGINFO' '!SIGINFO,POLL' \ + '!info' '!sigstop,info' '!siginfo,pipe' + test_sigs_ex 30 SIGPWR 6 '' \ + INFO SIGINFO info siginfo \ + '!IOT' '!SIGIOT' '!SIGFPE,IOT' \ + '!iot' '!sigiot,hup' '!iot,sigurg' + test_sigs_ex 30 SIGPWR 6 SIGABRT \ + INFO,IOT SIGINFO,SIGIOT \ + info,iot siginfo,sigiot + ;; +esac + + fail_with() { dump_log_and_fail_with \ |