summaryrefslogtreecommitdiff
path: root/test/tsan/test.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsan/test.h')
-rw-r--r--test/tsan/test.h36
1 files changed, 14 insertions, 22 deletions
diff --git a/test/tsan/test.h b/test/tsan/test.h
index aa4d81b10..e7ffefdcf 100644
--- a/test/tsan/test.h
+++ b/test/tsan/test.h
@@ -5,6 +5,7 @@
#include <dlfcn.h>
#include <stddef.h>
#include <sched.h>
+#include <stdarg.h>
#ifdef __APPLE__
#include <mach/mach_time.h>
@@ -39,30 +40,21 @@ void barrier_wait(invisible_barrier_t *barrier) {
// Default instance of the barrier, but a test can declare more manually.
invisible_barrier_t barrier;
-void print_address(void *address) {
-// On FreeBSD, the %p conversion specifier works as 0x%x and thus does not match
-// to the format used in the diagnotic message.
-#ifdef __x86_64__
- fprintf(stderr, "0x%012lx", (unsigned long) address);
+void print_address(const char *str, int n, ...) {
+ fprintf(stderr, "%s", str);
+ va_list ap;
+ va_start(ap, n);
+ while (n--) {
+ void *p = va_arg(ap, void *);
+#if defined(__x86_64__) || defined(__aarch64__)
+ // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not
+ // match to the format used in the diagnotic message.
+ fprintf(stderr, "0x%012lx ", (unsigned long) p);
#elif defined(__mips64)
- fprintf(stderr, "0x%010lx", (unsigned long) address);
-#elif defined(__aarch64__)
- // AArch64 currently has 3 different VMA (39, 42, and 48 bits) and it requires
- // different pointer size to match the diagnostic message.
- const char *format = 0;
- unsigned long vma = (unsigned long)__builtin_frame_address(0);
- vma = 64 - __builtin_clzll(vma);
- if (vma == 39)
- format = "0x%010lx";
- else if (vma == 42)
- format = "0x%011lx";
- else {
- fprintf(stderr, "unsupported vma: %lu\n", vma);
- exit(1);
- }
-
- fprintf(stderr, format, (unsigned long) address);
+ fprintf(stderr, "0x%010lx ", (unsigned long) p);
#endif
+ }
+ fprintf(stderr, "\n");
}
#ifdef __APPLE__