static void expand (struct mempool *pool) { size_t size; char *mem; size = pool->chunk_size; GET_MEMORY (mem, size); if (!mem) { size = UNW_ALIGN(pool->obj_size, pg_size); GET_MEMORY (mem, size); if (!mem) { /* last chance: try to allocate one object from the SOS memory */ size = pool->obj_size; mem = sos_alloc (size); } } add_memory (pool, mem, size, pool->obj_size); }
static int get_kernel_table (unw_dyn_info_t *di) { struct ia64_table_entry *ktab, *etab; size_t size; Debug (16, "getting kernel table"); size = getunwind (NULL, 0); ktab = sos_alloc (size); if (!ktab) { Dprintf (__FILE__".%s: failed to allocate %zu bytes", __FUNCTION__, size); return -UNW_ENOMEM; } getunwind (ktab, size); /* Determine length of kernel's unwind table & relocate its entries. */ for (etab = ktab; etab->start_offset; ++etab) etab->info_offset += (uint64_t) ktab; di->format = UNW_INFO_FORMAT_TABLE; di->gp = 0; di->start_ip = ktab[0].start_offset; di->end_ip = etab[-1].end_offset; di->u.ti.name_ptr = (unw_word_t) "<kernel>"; di->u.ti.segbase = 0; di->u.ti.table_len = ((char *) etab - (char *) ktab) / sizeof (unw_word_t); di->u.ti.table_data = (unw_word_t *) ktab; Debug (16, "found table `%s': [%lx-%lx) segbase=%lx len=%lu\n", (char *) di->u.ti.name_ptr, di->start_ip, di->end_ip, di->u.ti.segbase, di->u.ti.table_len); return 0; }