| 2414 | on success, 0 on failure. */ |
| 2415 | |
| 2416 | static int |
| 2417 | build_address_map (struct backtrace_state *state, uintptr_t base_address, |
| 2418 | const struct dwarf_sections *dwarf_sections, |
| 2419 | int is_bigendian, struct dwarf_data *altlink, |
| 2420 | backtrace_error_callback error_callback, void *data, |
| 2421 | struct unit_addrs_vector *addrs, |
| 2422 | struct unit_vector *unit_vec) |
| 2423 | { |
| 2424 | struct dwarf_buf info; |
| 2425 | struct backtrace_vector units; |
| 2426 | size_t units_count; |
| 2427 | size_t i; |
| 2428 | struct unit **pu; |
| 2429 | size_t unit_offset = 0; |
| 2430 | |
| 2431 | memset (&addrs->vec, 0, sizeof addrs->vec); |
| 2432 | memset (&unit_vec->vec, 0, sizeof unit_vec->vec); |
| 2433 | addrs->count = 0; |
| 2434 | unit_vec->count = 0; |
| 2435 | |
| 2436 | /* Read through the .debug_info section. FIXME: Should we use the |
| 2437 | .debug_aranges section? gdb and addr2line don't use it, but I'm |
| 2438 | not sure why. */ |
| 2439 | |
| 2440 | info.name = ".debug_info"; |
| 2441 | info.start = dwarf_sections->data[DEBUG_INFO]; |
| 2442 | info.buf = info.start; |
| 2443 | info.left = dwarf_sections->size[DEBUG_INFO]; |
| 2444 | info.is_bigendian = is_bigendian; |
| 2445 | info.error_callback = error_callback; |
| 2446 | info.data = data; |
| 2447 | info.reported_underflow = 0; |
| 2448 | |
| 2449 | memset (&units, 0, sizeof units); |
| 2450 | units_count = 0; |
| 2451 | |
| 2452 | while (info.left > 0) |
| 2453 | { |
| 2454 | const unsigned char *unit_data_start; |
| 2455 | uint64_t len; |
| 2456 | int is_dwarf64; |
| 2457 | struct dwarf_buf unit_buf; |
| 2458 | int version; |
| 2459 | int unit_type; |
| 2460 | uint64_t abbrev_offset; |
| 2461 | int addrsize; |
| 2462 | struct unit *u; |
| 2463 | enum dwarf_tag unit_tag; |
| 2464 | |
| 2465 | if (info.reported_underflow) |
| 2466 | goto fail; |
| 2467 | |
| 2468 | unit_data_start = info.buf; |
| 2469 | |
| 2470 | len = read_initial_length (&info, &is_dwarf64); |
| 2471 | unit_buf = info; |
| 2472 | unit_buf.left = len; |
| 2473 |
no test coverage detected