int diag_describe(diag_output_t *o, diag_context_t *c) { char buf[256]; char *outch; char *lastoutch = buf + sizeof buf - 1; outch = buf; outch = add_string(outch, lastoutch, "Process id: ", NULL); outch = add_int(outch, lastoutch, (long long)getpid(), 10); if (o->output_mode == DIAG_WRITE_FD) { outch = add_string(outch, lastoutch, "\n", NULL); write(o->outfile, buf, strlen(buf)); } else { o->output_fn(o->user_data, buf); } outch = buf; outch = add_string(outch, lastoutch, "Fatal signal: ", NULL); outch = add_int(outch, lastoutch, (long long)c->signal, 10); if (o->output_mode == DIAG_WRITE_FD) { outch = add_string(outch, lastoutch, "\n", NULL); write(o->outfile, buf, strlen(buf)); } else { o->output_fn(o->user_data, buf); } if (c->info && c->info->si_addr) { outch = buf; if (c->signal == SIGSEGV) { outch = add_string(outch, lastoutch, "Invalid memory address: ", NULL); } else { outch = add_string(outch, lastoutch, "Faulting instruction: ", NULL); } outch = add_pointer(outch, lastoutch, c->info->si_addr); if (o->output_mode == DIAG_WRITE_FD) { outch = add_string(outch, lastoutch, "\n", NULL); write(o->outfile, buf, strlen(buf)); } else { o->output_fn(o->user_data, buf); } } return 0; }
static bool alloc_next(KHRN_FMEM_T *fmem) { uint32_t *block; //vcos_assert(fmem->cle_pos + GAP <= (uint8_t *)fmem->junk_pos); block = (uint32_t *)khrn_nmem_group_alloc_master(&fmem->nmem_group); if (!block) return false; add_byte(&fmem->cle_pos, KHRN_HW_INSTR_BRANCH); add_pointer(&fmem->cle_pos, block); fmem->cle_pos = (uint8_t *)block; fmem->junk_pos = block + (KHRN_NMEM_GROUP_BLOCK_SIZE/4); return true; }