summaryrefslogtreecommitdiff
path: root/tests/xet_robust_list.c
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2016-12-11 18:50:53 +0300
committerDmitry V. Levin <ldv@altlinux.org>2016-12-26 15:29:06 +0000
commit3b4612b3ac908c5618b8fa4b6fd1e700fd11f2a6 (patch)
tree2fc8c62a06ffa26842a347a27cb8d77976449e09 /tests/xet_robust_list.c
parent762b155643019fa7824adcc8bd90247f57c91bf4 (diff)
downloadstrace-3b4612b3ac908c5618b8fa4b6fd1e700fd11f2a6.tar.gz
Print indirect pointers as pointers
Originally, printnum_long_int was used, but it prints NULL incorrectly. * defs.h (DECL_PRINTNUM_ADDR): New macro. (DECL_PRINTNUM_ADDR(int), DECL_PRINTNUM_ADDR(int64)): New prototypes. [!current_wordsize] (printnum_addr_long_int): New prototype. [!current_wordsize] (printnum_ptr): Use it. [current_wordsize > 4] (printnum_ptr): Use printnum_addr_int64. [current_wordsize == 4] (printnum_ptr) Use printnum_addr_int. * util.c (DEF_PRINTNUM_ADDR): New macro. (DEF_PRINTNUM_ADDR(int, unsigned int), DEF_PRINTNUM_ADDR(int64, uint64_t)): New macro instantiations that provide printnum_addr_int and printnum_addr_int64, accordingly. [!current_wordsize] (printnum_addr_long_int): New function. * xet_robust_list.c (sprintaddr): New function. (main): Use it, update expected output. * tests/ipc_sem.c (main): Update expected output. Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Diffstat (limited to 'tests/xet_robust_list.c')
-rw-r--r--tests/xet_robust_list.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/xet_robust_list.c b/tests/xet_robust_list.c
index f8349303e..211dec459 100644
--- a/tests/xet_robust_list.c
+++ b/tests/xet_robust_list.c
@@ -33,6 +33,19 @@
# include <stdio.h>
# include <unistd.h>
+static const char *
+sprintaddr(void *addr)
+{
+ static char buf[sizeof(addr) * 2 + sizeof("0x")];
+
+ if (!addr)
+ return "NULL";
+ else
+ snprintf(buf, sizeof(buf), "%p", addr);
+
+ return buf;
+}
+
int
main(void)
{
@@ -43,8 +56,8 @@ main(void)
if (syscall(__NR_get_robust_list, long_pid, p_head, p_len))
perror_msg_and_skip("get_robust_list");
- printf("get_robust_list(%d, [%#lx], [%lu]) = 0\n",
- (int) pid, (unsigned long) *p_head, (unsigned long) *p_len);
+ printf("get_robust_list(%d, [%s], [%lu]) = 0\n",
+ (int) pid, sprintaddr(*p_head), (unsigned long) *p_len);
void *head = tail_alloc(*p_len);
if (syscall(__NR_set_robust_list, head, *p_len))
@@ -54,8 +67,8 @@ main(void)
if (syscall(__NR_get_robust_list, long_pid, p_head, p_len))
perror_msg_and_skip("get_robust_list");
- printf("get_robust_list(%d, [%#lx], [%lu]) = 0\n",
- (int) pid, (unsigned long) *p_head, (unsigned long) *p_len);
+ printf("get_robust_list(%d, [%s], [%lu]) = 0\n",
+ (int) pid, sprintaddr(*p_head), (unsigned long) *p_len);
puts("+++ exited with 0 +++");
return 0;