brintos

brintos / llvm-project-archived public Read only

0
0
Text · 936 B · df31322 Raw
28 lines · c
1#include <stdio.h>2#include <stdarg.h>3 4#ifndef __SANITIZER_COMMON_PRINT_ADDRESS_H__5#  define __SANITIZER_COMMON_PRINT_ADDRESS_H__6 7void print_address(const char *str, int n, ...) {8  fprintf(stderr, "%s", str);9  va_list ap;10  va_start(ap, n);11  while (n--) {12    void *p = va_arg(ap, void *);13#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) ||   \14    defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64) ||          \15    defined(__loongarch_lp64)16    // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not17    // match to the format used in the diagnotic message.18    fprintf(stderr, "0x%012lx ", (unsigned long) p);19#elif defined(__i386__) || defined(__arm__)20    fprintf(stderr, "0x%08lx ", (unsigned long) p);21#elif defined(__mips64)22    fprintf(stderr, "0x%010lx ", (unsigned long) p);23#endif24  }25  fprintf(stderr, "\n");26}27 28#endif // __SANITIZER_COMMON_PRINT_ADDRESS_H__