2016-11-14 11:40:56 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2023-03-20 15:48:55 -07:00
|
|
|
#ifndef __SANITIZER_COMMON_PRINT_ADDRESS_H__
|
|
|
|
# define __SANITIZER_COMMON_PRINT_ADDRESS_H__
|
|
|
|
|
2016-11-14 11:40:56 +00:00
|
|
|
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 *);
|
2022-12-08 10:08:45 +08:00
|
|
|
#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
|
|
|
|
defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64) || \
|
|
|
|
defined(__loongarch_lp64)
|
2016-11-14 11:40:56 +00:00
|
|
|
// 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);
|
2017-04-11 14:58:26 +00:00
|
|
|
#elif defined(__i386__) || defined(__arm__)
|
2017-04-12 14:25:28 +00:00
|
|
|
fprintf(stderr, "0x%08lx ", (unsigned long) p);
|
2016-11-14 11:40:56 +00:00
|
|
|
#elif defined(__mips64)
|
|
|
|
fprintf(stderr, "0x%010lx ", (unsigned long) p);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
2023-03-20 15:48:55 -07:00
|
|
|
|
|
|
|
#endif // __SANITIZER_COMMON_PRINT_ADDRESS_H__
|