37int system_mmap(
void **base,
int *
fd,
const char *file,
size_t shm_size,
size_t shm_off,
int truncate)
41 *
fd = open(file, O_CREAT | O_RDWR, S_IRWXU);
43 *
fd = shm_open(file, O_CREAT | O_RDWR, S_IRWXU);
50 if (ftruncate(*
fd, shm_size) )
55 *base = mmap(*base, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, *
fd, shm_off);
57 *base = mmap(*base, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED, *
fd, shm_off);
60 if (MAP_FAILED == *base) {
104 char *pos = strdup(bt_sym);
105 size_t bt_sym_len = strlen(bt_sym);
107 for (temp = pos; *temp != 0; temp++) {
117 char *exe = malloc(bt_sym_len);
118 char *symbol = malloc(bt_sym_len);
119 char *addr = malloc(bt_sym_len);
121 sprintf(symbol,
"NO_SYMB");
122 sprintf(addr,
"NO_ADDR");
124 sscanf(pos,
"%s %s %s", exe, symbol, addr);
126 if (strcmp(addr,
"NO_SYMB") == 0) {
130 sprintf(symbol,
"NO_SYMB");
133 if (cwidths[0] < strlen(exe)) cwidths[0] = strlen(exe);
134 if (cwidths[1] < strlen(addr)) cwidths[1] = strlen(addr);
135 if (cwidths[2] < strlen(symbol)) cwidths[2] = strlen(symbol);
138 dest += sprintf(dest,
"%*s %*s %s", cwidths[0], exe, cwidths[1], addr, symbol);
160 int cwidths[3] = { 6, 6, 8 };
163 bt_size = backtrace(bt, bt_size);
169 bt_syms = backtrace_symbols(bt, bt_size);
172 for (bt_indx = bt_size - 1; bt_indx != skip; bt_indx--)
176 sprintf(dest,
"\n\n" FMT FMT FMT,
MID(cwidths[0],
"Binary"),
MID(cwidths[1],
"Location"),
MID(cwidths[2],
178 for (bt_indx = bt_size - 1; bt_indx != skip; bt_indx--) {
int system_mmap(void **base, int *fd, const char *file, size_t shm_size, size_t shm_off, int truncate)