summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2023-02-24 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2023-02-24 08:00:00 +0000
commit7ef922a485f89103ef693d0a9465aa3bfeb99ebc (patch)
treefdf69b65fbe6ee8018c9f3ce43a83cbb1af37765
parente88e5e9ae6da68f22d15f9be3193b1412ac9aa02 (diff)
downloadstrace-7ef922a485f89103ef693d0a9465aa3bfeb99ebc.tar.gz
Fix build on alpha
Workaround a bug in glibc headers that fail to provide si_trapno field in their definition of siginfo_t on alpha. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=30173 Resolves: https://github.com/strace/strace/issues/220 * configure.ac (AC_CHECK_MEMBERS): Add siginfo_t.si_trapno. * src/printsiginfo.c [ALPHA]: Guard use of si_trapno with HAVE_SIGINFO_T_SI_TRAPNO. * tests/ptrace.c [ALPHA]: Likewise. * NEWS: Mention this fix.
-rw-r--r--NEWS3
-rw-r--r--configure.ac1
-rw-r--r--src/printsiginfo.c9
-rw-r--r--tests/ptrace.c8
4 files changed, 13 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index 75b140b31..574290483 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,9 @@ Noteworthy changes in release ?.? (????-??-??)
MEMBARRIER_*, NFT_*, NTF_*, and V4L2_* constants.
* Updated lists of ioctl commands from Linux 6.2.
+* Bug fixes
+ * Fixed build on alpha architecture.
+
Noteworthy changes in release 6.1 (2022-12-12)
==============================================
diff --git a/configure.ac b/configure.ac
index 68555bcb2..0012576a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -431,6 +431,7 @@ AC_CHECK_MEMBERS(m4_normalize([
siginfo_t.si_timerid,
siginfo_t.si_overrun,
siginfo_t.si_pkey,
+ siginfo_t.si_trapno,
siginfo_t.si_addr_lsb,
siginfo_t.si_lower,
siginfo_t.si_upper,
diff --git a/src/printsiginfo.c b/src/printsiginfo.c
index 3923b9045..49b31fc05 100644
--- a/src/printsiginfo.c
+++ b/src/printsiginfo.c
@@ -168,7 +168,7 @@ print_si_info(struct tcb *tcp, const siginfo_t *sip)
case SIGFPE:
tprint_struct_next();
PRINT_FIELD_PTR(*sip, si_addr);
-#ifdef ALPHA
+#if defined ALPHA && defined HAVE_SIGINFO_T_SI_TRAPNO
tprint_struct_next();
PRINT_FIELD_XVAL_D(*sip, si_trapno, alpha_trap_codes,
"GEN_???");
@@ -214,15 +214,16 @@ print_si_info(struct tcb *tcp, const siginfo_t *sip)
case SIGTRAP:
tprint_struct_next();
PRINT_FIELD_PTR(*sip, si_addr);
-#if defined(ALPHA) || defined(HAVE_SIGINFO_T_SI_PERF_DATA)
+#if (defined ALPHA && defined HAVE_SIGINFO_T_SI_TRAPNO) \
+ || defined HAVE_SIGINFO_T_SI_PERF_DATA
switch (sip->si_code) {
-# ifdef ALPHA
+# if defined ALPHA && defined HAVE_SIGINFO_T_SI_TRAPNO
case TRAP_UNK:
tprint_struct_next();
PRINT_FIELD_XVAL_D(*sip, si_trapno,
alpha_trap_codes, "GEN_???");
break;
-# endif /* ALPHA */
+# endif /* ALPHA && HAVE_SIGINFO_T_SI_TRAPNO */
# ifdef HAVE_SIGINFO_T_SI_PERF_DATA
case TRAP_PERF:
tprint_struct_next();
diff --git a/tests/ptrace.c b/tests/ptrace.c
index d6bc03773..be7ef64fa 100644
--- a/tests/ptrace.c
+++ b/tests/ptrace.c
@@ -1836,7 +1836,7 @@ main(void)
{ ARG_XLAT_KNOWN(0x4, "TRAP_HWBKPT") },
#endif
{ ARG_XLAT_KNOWN(0x5, "TRAP_UNK"), ""
-#ifdef __alpha__
+#if defined __alpha__ && defined HAVE_SIGINFO_T_SI_TRAPNO
", si_trapno=0 /* GEN_??? */"
},
{ ARG_XLAT_KNOWN(0x5, "TRAP_UNK"),
@@ -1847,7 +1847,7 @@ main(void)
", si_trapno=-26 /* GEN_??? */" },
{ ARG_XLAT_KNOWN(0x5, "TRAP_UNK"), ""
", si_trapno=-1234567890 /* GEN_??? */"
-#endif /* __alpha__ */
+#endif /* __alpha__ && HAVE_SIGINFO_T_SI_TRAPNO */
},
{ ARG_XLAT_KNOWN(0x6, "TRAP_PERF"), ""
#ifdef HAVE_SIGINFO_T_SI_PERF_DATA
@@ -1917,7 +1917,7 @@ main(void)
switch (sip->si_code) {
case 5: /* TRAP_UNK */
-#ifdef __alpha__
+#if defined __alpha__ && defined HAVE_SIGINFO_T_SI_TRAPNO
sip->si_trapno = trap_unk_vecs[trap_unk_pos];
#endif
trap_unk_pos = (trap_unk_pos + 1)
@@ -1981,7 +1981,7 @@ main(void)
do_ptrace(PTRACE_SETSIGINFO, pid, bad_request, (uintptr_t) sip);
printf("ptrace(" XLAT_FMT ", %d, %#lx, {si_signo=" XLAT_FMT_U
", si_code=" XLAT_FMT ", si_errno=" XLAT_FMT_U ", si_addr=%p"
-#ifdef __alpha__
+#if defined __alpha__ && defined HAVE_SIGINFO_T_SI_TRAPNO
", si_trapno=" XLAT_KNOWN(-7, "GEN_FLTINE")
#endif
"}) = %s\n",