• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdio.h>
2 #include <stdarg.h>
3 
print_address(const char * str,int n,...)4 void print_address(const char *str, int n, ...) {
5   fprintf(stderr, "%s", str);
6   va_list ap;
7   va_start(ap, n);
8   while (n--) {
9     void *p = va_arg(ap, void *);
10 #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
11     defined(__s390x__)
12     // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not
13     // match to the format used in the diagnotic message.
14     fprintf(stderr, "0x%012lx ", (unsigned long) p);
15 #elif defined(__i386__) || defined(__arm__)
16     fprintf(stderr, "0x%08lx ", (unsigned long) p);
17 #elif defined(__mips64)
18     fprintf(stderr, "0x%010lx ", (unsigned long) p);
19 #endif
20   }
21   fprintf(stderr, "\n");
22 }
23