| 4165 | file. Return NULL on failure. */ |
| 4166 | |
| 4167 | static struct dwarf_data * |
| 4168 | build_dwarf_data (struct backtrace_state *state, |
| 4169 | uintptr_t base_address, |
| 4170 | const struct dwarf_sections *dwarf_sections, |
| 4171 | int is_bigendian, |
| 4172 | struct dwarf_data *altlink, |
| 4173 | backtrace_error_callback error_callback, |
| 4174 | void *data) |
| 4175 | { |
| 4176 | struct unit_addrs_vector addrs_vec; |
| 4177 | struct unit_addrs *addrs; |
| 4178 | size_t addrs_count; |
| 4179 | struct unit_vector units_vec; |
| 4180 | struct unit **units; |
| 4181 | size_t units_count; |
| 4182 | struct dwarf_data *fdata; |
| 4183 | |
| 4184 | if (!build_address_map (state, base_address, dwarf_sections, is_bigendian, |
| 4185 | altlink, error_callback, data, &addrs_vec, |
| 4186 | &units_vec)) |
| 4187 | return NULL; |
| 4188 | |
| 4189 | if (!backtrace_vector_release (state, &addrs_vec.vec, error_callback, data)) |
| 4190 | return NULL; |
| 4191 | if (!backtrace_vector_release (state, &units_vec.vec, error_callback, data)) |
| 4192 | return NULL; |
| 4193 | addrs = (struct unit_addrs *) addrs_vec.vec.base; |
| 4194 | units = (struct unit **) units_vec.vec.base; |
| 4195 | addrs_count = addrs_vec.count; |
| 4196 | units_count = units_vec.count; |
| 4197 | backtrace_qsort (addrs, addrs_count, sizeof (struct unit_addrs), |
| 4198 | unit_addrs_compare); |
| 4199 | /* No qsort for units required, already sorted. */ |
| 4200 | |
| 4201 | fdata = ((struct dwarf_data *) |
| 4202 | backtrace_alloc (state, sizeof (struct dwarf_data), |
| 4203 | error_callback, data)); |
| 4204 | if (fdata == NULL) |
| 4205 | return NULL; |
| 4206 | |
| 4207 | fdata->next = NULL; |
| 4208 | fdata->altlink = altlink; |
| 4209 | fdata->base_address = base_address; |
| 4210 | fdata->addrs = addrs; |
| 4211 | fdata->addrs_count = addrs_count; |
| 4212 | fdata->units = units; |
| 4213 | fdata->units_count = units_count; |
| 4214 | fdata->dwarf_sections = *dwarf_sections; |
| 4215 | fdata->is_bigendian = is_bigendian; |
| 4216 | memset (&fdata->fvec, 0, sizeof fdata->fvec); |
| 4217 | |
| 4218 | return fdata; |
| 4219 | } |
| 4220 | |
| 4221 | /* Build our data structures from the DWARF sections for a module. |
| 4222 | Set FILELINE_FN and STATE->FILELINE_DATA. Return 1 on success, 0 |
no test coverage detected