-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathlog.c
60 lines (49 loc) · 1.11 KB
/
log.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#ifndef ANDROID
#include <execinfo.h>
#endif
#include "log.h"
int o_debug = 0;
#ifdef ANDROID
void bugsnag_log(const char *fmt, ...)
{
char buf[4096];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
void bugsnag_leave_breadcrumb_log(const char *buf);
bugsnag_leave_breadcrumb_log(buf);
}
#endif
void hexdump(const void *addr, size_t len)
{
unsigned char buff[33];
unsigned char *pc = (unsigned char*)addr;
if (!len) {
return;
}
size_t i = 0;
for (i = 0; i < len; i++) {
if ((i % 32) == 0) {
if (i != 0) {
fprintf(stderr, " %s\n", buff);
}
fprintf(stderr, " %04zx ", i);
}
fprintf(stderr, " %02x", pc[i]);
buff[i % 32] = isprint(pc[i]) ? pc[i] : '.';
buff[(i % 32) + 1] = '\0';
}
while ((i % 32) != 0) {
fprintf(stderr, " ");
i++;
}
fprintf(stderr, " %s\n", buff);
}