OLD | NEW |
1 /* DWARF 2 support. | 1 /* DWARF 2 support. |
2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, | 2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
3 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. | 3 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
4 | 4 |
5 Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions | 5 Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions |
6 (gavin@cygnus.com). | 6 (gavin@cygnus.com). |
7 | 7 |
8 From the dwarf2read.c header: | 8 From the dwarf2read.c header: |
9 Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology, | 9 Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology, |
10 Inc. with support from Florida State University (under contract | 10 Inc. with support from Florida State University (under contract |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 398 |
399 /* Function to create a new info hash table. It returns a pointer to the | 399 /* Function to create a new info hash table. It returns a pointer to the |
400 newly created table or NULL if there is any error. We need abfd | 400 newly created table or NULL if there is any error. We need abfd |
401 solely for memory allocation. */ | 401 solely for memory allocation. */ |
402 | 402 |
403 static struct info_hash_table * | 403 static struct info_hash_table * |
404 create_info_hash_table (bfd *abfd) | 404 create_info_hash_table (bfd *abfd) |
405 { | 405 { |
406 struct info_hash_table *hash_table; | 406 struct info_hash_table *hash_table; |
407 | 407 |
408 hash_table = (struct info_hash_table *) | 408 hash_table = ((struct info_hash_table *) |
409 bfd_alloc (abfd, sizeof (struct info_hash_table)); | 409 » » bfd_alloc (abfd, sizeof (struct info_hash_table))); |
410 if (!hash_table) | 410 if (!hash_table) |
411 return hash_table; | 411 return hash_table; |
412 | 412 |
413 if (!bfd_hash_table_init (&hash_table->base, info_hash_table_newfunc, | 413 if (!bfd_hash_table_init (&hash_table->base, info_hash_table_newfunc, |
414 sizeof (struct info_hash_entry))) | 414 sizeof (struct info_hash_entry))) |
415 { | 415 { |
416 bfd_release (abfd, hash_table); | 416 bfd_release (abfd, hash_table); |
417 return NULL; | 417 return NULL; |
418 } | 418 } |
419 | 419 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 (*_bfd_error_handler) (_("Dwarf Error: Can't find %s section."), | 496 (*_bfd_error_handler) (_("Dwarf Error: Can't find %s section."), |
497 sec->uncompressed_name); | 497 sec->uncompressed_name); |
498 bfd_set_error (bfd_error_bad_value); | 498 bfd_set_error (bfd_error_bad_value); |
499 return FALSE; | 499 return FALSE; |
500 } | 500 } |
501 | 501 |
502 *section_size = msec->rawsize ? msec->rawsize : msec->size; | 502 *section_size = msec->rawsize ? msec->rawsize : msec->size; |
503 if (syms) | 503 if (syms) |
504 { | 504 { |
505 *section_buffer | 505 *section_buffer |
506 » = bfd_simple_get_relocated_section_contents (abfd, msec, NULL, sym
s); | 506 » = bfd_simple_get_relocated_section_contents (abfd, msec, NULL, syms)
; |
507 if (! *section_buffer) | 507 if (! *section_buffer) |
508 return FALSE; | 508 return FALSE; |
509 } | 509 } |
510 else | 510 else |
511 { | 511 { |
512 *section_buffer = (bfd_byte *) bfd_malloc (*section_size); | 512 *section_buffer = (bfd_byte *) bfd_malloc (*section_size); |
513 if (! *section_buffer) | 513 if (! *section_buffer) |
514 return FALSE; | 514 return FALSE; |
515 if (! bfd_get_section_contents (abfd, msec, *section_buffer, | 515 if (! bfd_get_section_contents (abfd, msec, *section_buffer, |
516 0, *section_size)) | 516 0, *section_size)) |
517 return FALSE; | 517 return FALSE; |
518 } | 518 } |
519 } | 519 } |
520 | 520 |
521 /* It is possible to get a bad value for the offset into the section | 521 /* It is possible to get a bad value for the offset into the section |
522 that the client wants. Validate it here to avoid trouble later. */ | 522 that the client wants. Validate it here to avoid trouble later. */ |
523 if (offset != 0 && offset >= *section_size) | 523 if (offset != 0 && offset >= *section_size) |
524 { | 524 { |
525 (*_bfd_error_handler) (_("Dwarf Error: Offset (%lu) greater than or equal
to %s size (%lu)."), | 525 (*_bfd_error_handler) (_("Dwarf Error: Offset (%lu)" |
| 526 » » » " greater than or equal to %s size (%lu)."), |
526 (long) offset, section_name, *section_size); | 527 (long) offset, section_name, *section_size); |
527 bfd_set_error (bfd_error_bad_value); | 528 bfd_set_error (bfd_error_bad_value); |
528 return FALSE; | 529 return FALSE; |
529 } | 530 } |
530 | 531 |
531 return TRUE; | 532 return TRUE; |
532 } | 533 } |
533 | 534 |
534 /* VERBATIM | 535 /* VERBATIM |
535 The following function up to the END VERBATIM mark are | 536 The following function up to the END VERBATIM mark are |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 char * comp_dir; | 1008 char * comp_dir; |
1008 char ** dirs; | 1009 char ** dirs; |
1009 struct fileinfo* files; | 1010 struct fileinfo* files; |
1010 struct line_sequence* sequences; | 1011 struct line_sequence* sequences; |
1011 struct line_info* lcl_head; /* Local head; used in 'add_line_info'. */ | 1012 struct line_info* lcl_head; /* Local head; used in 'add_line_info'. */ |
1012 }; | 1013 }; |
1013 | 1014 |
1014 /* Remember some information about each function. If the function is | 1015 /* Remember some information about each function. If the function is |
1015 inlined (DW_TAG_inlined_subroutine) it may have two additional | 1016 inlined (DW_TAG_inlined_subroutine) it may have two additional |
1016 attributes, DW_AT_call_file and DW_AT_call_line, which specify the | 1017 attributes, DW_AT_call_file and DW_AT_call_line, which specify the |
1017 source code location where this function was inlined. */ | 1018 source code location where this function was inlined. */ |
1018 | 1019 |
1019 struct funcinfo | 1020 struct funcinfo |
1020 { | 1021 { |
1021 struct funcinfo *prev_func;» » /* Pointer to previous function in list
of all functions */ | 1022 /* Pointer to previous function in list of all functions. */ |
1022 struct funcinfo *caller_func;»» /* Pointer to function one scope higher
*/ | 1023 struct funcinfo *prev_func; |
1023 char *caller_file;» » » /* Source location file name where calle
r_func inlines this func */ | 1024 /* Pointer to function one scope higher. */ |
1024 int caller_line;» » » /* Source location line number where cal
ler_func inlines this func */ | 1025 struct funcinfo *caller_func; |
1025 char *file;» » » » /* Source location file name */ | 1026 /* Source location file name where caller_func inlines this func. */ |
1026 int line;» » » » /* Source location line number */ | 1027 char *caller_file; |
| 1028 /* Source location line number where caller_func inlines this func. */ |
| 1029 int caller_line; |
| 1030 /* Source location file name. */ |
| 1031 char *file; |
| 1032 /* Source location line number. */ |
| 1033 int line; |
1027 int tag; | 1034 int tag; |
1028 char *name; | 1035 char *name; |
1029 struct arange arange; | 1036 struct arange arange; |
1030 asection *sec;» » » /* Where the symbol is defined */ | 1037 /* Where the symbol is defined. */ |
| 1038 asection *sec; |
1031 }; | 1039 }; |
1032 | 1040 |
1033 struct varinfo | 1041 struct varinfo |
1034 { | 1042 { |
1035 /* Pointer to previous variable in list of all variables */ | 1043 /* Pointer to previous variable in list of all variables */ |
1036 struct varinfo *prev_var; | 1044 struct varinfo *prev_var; |
1037 /* Source location file name */ | 1045 /* Source location file name */ |
1038 char *file; | 1046 char *file; |
1039 /* Source location line number */ | 1047 /* Source location line number */ |
1040 int line; | 1048 int line; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 sprintf (name, "%s/%s", dir_name, filename); | 1249 sprintf (name, "%s/%s", dir_name, filename); |
1242 } | 1250 } |
1243 | 1251 |
1244 return name; | 1252 return name; |
1245 } | 1253 } |
1246 | 1254 |
1247 return strdup (filename); | 1255 return strdup (filename); |
1248 } | 1256 } |
1249 | 1257 |
1250 static bfd_boolean | 1258 static bfd_boolean |
1251 arange_add (bfd *abfd, struct arange *first_arange, | 1259 arange_add (const struct comp_unit *unit, struct arange *first_arange, |
1252 bfd_vma low_pc, bfd_vma high_pc) | 1260 bfd_vma low_pc, bfd_vma high_pc) |
1253 { | 1261 { |
1254 struct arange *arange; | 1262 struct arange *arange; |
1255 | 1263 |
1256 /* If the first arange is empty, use it. */ | 1264 /* Ignore empty ranges. */ |
| 1265 if (low_pc == high_pc) |
| 1266 return TRUE; |
| 1267 |
| 1268 /* If the first arange is empty, use it. */ |
1257 if (first_arange->high == 0) | 1269 if (first_arange->high == 0) |
1258 { | 1270 { |
1259 first_arange->low = low_pc; | 1271 first_arange->low = low_pc; |
1260 first_arange->high = high_pc; | 1272 first_arange->high = high_pc; |
1261 return TRUE; | 1273 return TRUE; |
1262 } | 1274 } |
1263 | 1275 |
1264 /* Next see if we can cheaply extend an existing range. */ | 1276 /* Next see if we can cheaply extend an existing range. */ |
1265 arange = first_arange; | 1277 arange = first_arange; |
1266 do | 1278 do |
1267 { | 1279 { |
1268 if (low_pc == arange->high) | 1280 if (low_pc == arange->high) |
1269 { | 1281 { |
1270 arange->high = high_pc; | 1282 arange->high = high_pc; |
1271 return TRUE; | 1283 return TRUE; |
1272 } | 1284 } |
1273 if (high_pc == arange->low) | 1285 if (high_pc == arange->low) |
1274 { | 1286 { |
1275 arange->low = low_pc; | 1287 arange->low = low_pc; |
1276 return TRUE; | 1288 return TRUE; |
1277 } | 1289 } |
1278 arange = arange->next; | 1290 arange = arange->next; |
1279 } | 1291 } |
1280 while (arange); | 1292 while (arange); |
1281 | 1293 |
1282 /* Need to allocate a new arange and insert it into the arange list. | 1294 /* Need to allocate a new arange and insert it into the arange list. |
1283 Order isn't significant, so just insert after the first arange. */ | 1295 Order isn't significant, so just insert after the first arange. */ |
1284 arange = (struct arange *) bfd_zalloc (abfd, sizeof (*arange)); | 1296 arange = (struct arange *) bfd_alloc (unit->abfd, sizeof (*arange)); |
1285 if (arange == NULL) | 1297 if (arange == NULL) |
1286 return FALSE; | 1298 return FALSE; |
1287 arange->low = low_pc; | 1299 arange->low = low_pc; |
1288 arange->high = high_pc; | 1300 arange->high = high_pc; |
1289 arange->next = first_arange->next; | 1301 arange->next = first_arange->next; |
1290 first_arange->next = arange; | 1302 first_arange->next = arange; |
1291 return TRUE; | 1303 return TRUE; |
1292 } | 1304 } |
1293 | 1305 |
1294 /* Compare function for line sequences. */ | 1306 /* Compare function for line sequences. */ |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) | 1406 decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) |
1395 { | 1407 { |
1396 bfd *abfd = unit->abfd; | 1408 bfd *abfd = unit->abfd; |
1397 struct line_info_table* table; | 1409 struct line_info_table* table; |
1398 bfd_byte *line_ptr; | 1410 bfd_byte *line_ptr; |
1399 bfd_byte *line_end; | 1411 bfd_byte *line_end; |
1400 struct line_head lh; | 1412 struct line_head lh; |
1401 unsigned int i, bytes_read, offset_size; | 1413 unsigned int i, bytes_read, offset_size; |
1402 char *cur_file, *cur_dir; | 1414 char *cur_file, *cur_dir; |
1403 unsigned char op_code, extended_op, adj_opcode; | 1415 unsigned char op_code, extended_op, adj_opcode; |
| 1416 unsigned int exop_len; |
1404 bfd_size_type amt; | 1417 bfd_size_type amt; |
1405 | 1418 |
1406 if (! read_section (abfd, &stash->debug_sections[debug_line], | 1419 if (! read_section (abfd, &stash->debug_sections[debug_line], |
1407 stash->syms, unit->line_offset, | 1420 stash->syms, unit->line_offset, |
1408 &stash->dwarf_line_buffer, &stash->dwarf_line_size)) | 1421 &stash->dwarf_line_buffer, &stash->dwarf_line_size)) |
1409 return NULL; | 1422 return NULL; |
1410 | 1423 |
1411 amt = sizeof (struct line_info_table); | 1424 amt = sizeof (struct line_info_table); |
1412 table = (struct line_info_table *) bfd_alloc (abfd, amt); | 1425 table = (struct line_info_table *) bfd_alloc (abfd, amt); |
1413 if (table == NULL) | 1426 if (table == NULL) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 while (! end_sequence) | 1587 while (! end_sequence) |
1575 { | 1588 { |
1576 op_code = read_1_byte (abfd, line_ptr); | 1589 op_code = read_1_byte (abfd, line_ptr); |
1577 line_ptr += 1; | 1590 line_ptr += 1; |
1578 | 1591 |
1579 if (op_code >= lh.opcode_base) | 1592 if (op_code >= lh.opcode_base) |
1580 { | 1593 { |
1581 /* Special operand. */ | 1594 /* Special operand. */ |
1582 adj_opcode = op_code - lh.opcode_base; | 1595 adj_opcode = op_code - lh.opcode_base; |
1583 if (lh.maximum_ops_per_insn == 1) | 1596 if (lh.maximum_ops_per_insn == 1) |
1584 » » address += (adj_opcode / lh.line_range) | 1597 » » address += (adj_opcode / lh.line_range |
1585 » » » * lh.minimum_instruction_length; | 1598 » » » * lh.minimum_instruction_length); |
1586 else | 1599 else |
1587 { | 1600 { |
1588 » » address += ((op_index + (adj_opcode / lh.line_range)) | 1601 » » address += ((op_index + adj_opcode / lh.line_range) |
1589 » » » / lh.maximum_ops_per_insn) | 1602 » » » / lh.maximum_ops_per_insn |
1590 » » » * lh.minimum_instruction_length; | 1603 » » » * lh.minimum_instruction_length); |
1591 » » op_index = (op_index + (adj_opcode / lh.line_range)) | 1604 » » op_index = ((op_index + adj_opcode / lh.line_range) |
1592 » » » % lh.maximum_ops_per_insn; | 1605 » » » % lh.maximum_ops_per_insn); |
1593 } | 1606 } |
1594 line += lh.line_base + (adj_opcode % lh.line_range); | 1607 line += lh.line_base + (adj_opcode % lh.line_range); |
1595 /* Append row to matrix using current values. */ | 1608 /* Append row to matrix using current values. */ |
1596 if (!add_line_info (table, address, op_index, filename, | 1609 if (!add_line_info (table, address, op_index, filename, |
1597 line, column, 0)) | 1610 line, column, 0)) |
1598 goto line_fail; | 1611 goto line_fail; |
1599 if (address < low_pc) | 1612 if (address < low_pc) |
1600 low_pc = address; | 1613 low_pc = address; |
1601 if (address > high_pc) | 1614 if (address > high_pc) |
1602 high_pc = address; | 1615 high_pc = address; |
1603 } | 1616 } |
1604 else switch (op_code) | 1617 else switch (op_code) |
1605 { | 1618 { |
1606 case DW_LNS_extended_op: | 1619 case DW_LNS_extended_op: |
1607 » /* Ignore length. */ | 1620 » exop_len = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
1608 » line_ptr += 1; | 1621 » line_ptr += bytes_read; |
1609 extended_op = read_1_byte (abfd, line_ptr); | 1622 extended_op = read_1_byte (abfd, line_ptr); |
1610 line_ptr += 1; | 1623 line_ptr += 1; |
1611 | 1624 |
1612 switch (extended_op) | 1625 switch (extended_op) |
1613 { | 1626 { |
1614 case DW_LNE_end_sequence: | 1627 case DW_LNE_end_sequence: |
1615 end_sequence = 1; | 1628 end_sequence = 1; |
1616 if (!add_line_info (table, address, op_index, filename, | 1629 if (!add_line_info (table, address, op_index, filename, |
1617 line, column, end_sequence)) | 1630 line, column, end_sequence)) |
1618 goto line_fail; | 1631 goto line_fail; |
1619 if (address < low_pc) | 1632 if (address < low_pc) |
1620 low_pc = address; | 1633 low_pc = address; |
1621 if (address > high_pc) | 1634 if (address > high_pc) |
1622 high_pc = address; | 1635 high_pc = address; |
1623 » » if (!arange_add (unit->abfd, &unit->arange, low_pc, high_pc)) | 1636 » » if (!arange_add (unit, &unit->arange, low_pc, high_pc)) |
1624 goto line_fail; | 1637 goto line_fail; |
1625 break; | 1638 break; |
1626 case DW_LNE_set_address: | 1639 case DW_LNE_set_address: |
1627 address = read_address (unit, line_ptr); | 1640 address = read_address (unit, line_ptr); |
1628 op_index = 0; | 1641 op_index = 0; |
1629 line_ptr += unit->addr_size; | 1642 line_ptr += unit->addr_size; |
1630 break; | 1643 break; |
1631 case DW_LNE_define_file: | 1644 case DW_LNE_define_file: |
1632 cur_file = read_string (abfd, line_ptr, &bytes_read); | 1645 cur_file = read_string (abfd, line_ptr, &bytes_read); |
1633 line_ptr += bytes_read; | 1646 line_ptr += bytes_read; |
(...skipping 17 matching lines...) Expand all Loading... |
1651 line_ptr += bytes_read; | 1664 line_ptr += bytes_read; |
1652 table->files[table->num_files].size = | 1665 table->files[table->num_files].size = |
1653 read_unsigned_leb128 (abfd, line_ptr, &bytes_read); | 1666 read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
1654 line_ptr += bytes_read; | 1667 line_ptr += bytes_read; |
1655 table->num_files++; | 1668 table->num_files++; |
1656 break; | 1669 break; |
1657 case DW_LNE_set_discriminator: | 1670 case DW_LNE_set_discriminator: |
1658 (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read); | 1671 (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
1659 line_ptr += bytes_read; | 1672 line_ptr += bytes_read; |
1660 break; | 1673 break; |
| 1674 case DW_LNE_HP_source_file_correlation: |
| 1675 line_ptr += exop_len - 1; |
| 1676 break; |
1661 default: | 1677 default: |
1662 » » (*_bfd_error_handler) (_("Dwarf Error: mangled line number sec
tion.")); | 1678 » » (*_bfd_error_handler) |
| 1679 » » (_("Dwarf Error: mangled line number section.")); |
1663 bfd_set_error (bfd_error_bad_value); | 1680 bfd_set_error (bfd_error_bad_value); |
1664 line_fail: | 1681 line_fail: |
1665 if (filename != NULL) | 1682 if (filename != NULL) |
1666 free (filename); | 1683 free (filename); |
1667 goto fail; | 1684 goto fail; |
1668 } | 1685 } |
1669 break; | 1686 break; |
1670 case DW_LNS_copy: | 1687 case DW_LNS_copy: |
1671 if (!add_line_info (table, address, op_index, | 1688 if (!add_line_info (table, address, op_index, |
1672 filename, line, column, 0)) | 1689 filename, line, column, 0)) |
1673 goto line_fail; | 1690 goto line_fail; |
1674 if (address < low_pc) | 1691 if (address < low_pc) |
1675 low_pc = address; | 1692 low_pc = address; |
1676 if (address > high_pc) | 1693 if (address > high_pc) |
1677 high_pc = address; | 1694 high_pc = address; |
1678 break; | 1695 break; |
1679 case DW_LNS_advance_pc: | 1696 case DW_LNS_advance_pc: |
1680 if (lh.maximum_ops_per_insn == 1) | 1697 if (lh.maximum_ops_per_insn == 1) |
1681 » » address += lh.minimum_instruction_length | 1698 » » address += (lh.minimum_instruction_length |
1682 » » » * read_unsigned_leb128 (abfd, line_ptr, | 1699 » » » * read_unsigned_leb128 (abfd, line_ptr, |
1683 » » » » » » &bytes_read); | 1700 » » » » » » &bytes_read)); |
1684 else | 1701 else |
1685 { | 1702 { |
1686 bfd_vma adjust = read_unsigned_leb128 (abfd, line_ptr, | 1703 bfd_vma adjust = read_unsigned_leb128 (abfd, line_ptr, |
1687 &bytes_read); | 1704 &bytes_read); |
1688 » » address = ((op_index + adjust) / lh.maximum_ops_per_insn) | 1705 » » address = ((op_index + adjust) / lh.maximum_ops_per_insn |
1689 » » » * lh.minimum_instruction_length; | 1706 » » » * lh.minimum_instruction_length); |
1690 op_index = (op_index + adjust) % lh.maximum_ops_per_insn; | 1707 op_index = (op_index + adjust) % lh.maximum_ops_per_insn; |
1691 } | 1708 } |
1692 line_ptr += bytes_read; | 1709 line_ptr += bytes_read; |
1693 break; | 1710 break; |
1694 case DW_LNS_advance_line: | 1711 case DW_LNS_advance_line: |
1695 line += read_signed_leb128 (abfd, line_ptr, &bytes_read); | 1712 line += read_signed_leb128 (abfd, line_ptr, &bytes_read); |
1696 line_ptr += bytes_read; | 1713 line_ptr += bytes_read; |
1697 break; | 1714 break; |
1698 case DW_LNS_set_file: | 1715 case DW_LNS_set_file: |
1699 { | 1716 { |
(...skipping 12 matching lines...) Expand all Loading... |
1712 column = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); | 1729 column = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
1713 line_ptr += bytes_read; | 1730 line_ptr += bytes_read; |
1714 break; | 1731 break; |
1715 case DW_LNS_negate_stmt: | 1732 case DW_LNS_negate_stmt: |
1716 is_stmt = (!is_stmt); | 1733 is_stmt = (!is_stmt); |
1717 break; | 1734 break; |
1718 case DW_LNS_set_basic_block: | 1735 case DW_LNS_set_basic_block: |
1719 break; | 1736 break; |
1720 case DW_LNS_const_add_pc: | 1737 case DW_LNS_const_add_pc: |
1721 if (lh.maximum_ops_per_insn == 1) | 1738 if (lh.maximum_ops_per_insn == 1) |
1722 » » address += lh.minimum_instruction_length | 1739 » » address += (lh.minimum_instruction_length |
1723 » » » * ((255 - lh.opcode_base) / lh.line_range); | 1740 » » » * ((255 - lh.opcode_base) / lh.line_range)); |
1724 else | 1741 else |
1725 { | 1742 { |
1726 bfd_vma adjust = ((255 - lh.opcode_base) / lh.line_range); | 1743 bfd_vma adjust = ((255 - lh.opcode_base) / lh.line_range); |
1727 » » address += lh.minimum_instruction_length | 1744 » » address += (lh.minimum_instruction_length |
1728 » » » * ((op_index + adjust) / lh.maximum_ops_per_insn); | 1745 » » » * ((op_index + adjust) |
| 1746 » » » » / lh.maximum_ops_per_insn)); |
1729 op_index = (op_index + adjust) % lh.maximum_ops_per_insn; | 1747 op_index = (op_index + adjust) % lh.maximum_ops_per_insn; |
1730 } | 1748 } |
1731 break; | 1749 break; |
1732 case DW_LNS_fixed_advance_pc: | 1750 case DW_LNS_fixed_advance_pc: |
1733 address += read_2_bytes (abfd, line_ptr); | 1751 address += read_2_bytes (abfd, line_ptr); |
1734 op_index = 0; | 1752 op_index = 0; |
1735 line_ptr += 2; | 1753 line_ptr += 2; |
1736 break; | 1754 break; |
1737 default: | 1755 default: |
1738 /* Unknown standard opcode, ignore it. */ | 1756 /* Unknown standard opcode, ignore it. */ |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1844 for (each_func = unit->function_table; | 1862 for (each_func = unit->function_table; |
1845 each_func; | 1863 each_func; |
1846 each_func = each_func->prev_func) | 1864 each_func = each_func->prev_func) |
1847 { | 1865 { |
1848 for (arange = &each_func->arange; | 1866 for (arange = &each_func->arange; |
1849 arange; | 1867 arange; |
1850 arange = arange->next) | 1868 arange = arange->next) |
1851 { | 1869 { |
1852 if (addr >= arange->low && addr < arange->high) | 1870 if (addr >= arange->low && addr < arange->high) |
1853 { | 1871 { |
1854 » if (!best_fit || | 1872 » if (!best_fit |
1855 » » ((arange->high - arange->low) < (best_fit->arange.high - best_
fit->arange.low))) | 1873 » » || (arange->high - arange->low |
| 1874 » » < best_fit->arange.high - best_fit->arange.low)) |
1856 best_fit = each_func; | 1875 best_fit = each_func; |
1857 } | 1876 } |
1858 } | 1877 } |
1859 } | 1878 } |
1860 | 1879 |
1861 if (best_fit) | 1880 if (best_fit) |
1862 { | 1881 { |
1863 *functionname_ptr = best_fit->name; | 1882 *functionname_ptr = best_fit->name; |
1864 *function_ptr = best_fit; | 1883 *function_ptr = best_fit; |
1865 return TRUE; | 1884 return TRUE; |
(...skipping 27 matching lines...) Expand all Loading... |
1893 for (arange = &each_func->arange; | 1912 for (arange = &each_func->arange; |
1894 arange; | 1913 arange; |
1895 arange = arange->next) | 1914 arange = arange->next) |
1896 { | 1915 { |
1897 if ((!each_func->sec || each_func->sec == sec) | 1916 if ((!each_func->sec || each_func->sec == sec) |
1898 && addr >= arange->low | 1917 && addr >= arange->low |
1899 && addr < arange->high | 1918 && addr < arange->high |
1900 && each_func->name | 1919 && each_func->name |
1901 && strcmp (name, each_func->name) == 0 | 1920 && strcmp (name, each_func->name) == 0 |
1902 && (!best_fit | 1921 && (!best_fit |
1903 » » || ((arange->high - arange->low) | 1922 » » || (arange->high - arange->low |
1904 » » < (best_fit->arange.high - best_fit->arange.low)))) | 1923 » » < best_fit->arange.high - best_fit->arange.low))) |
1905 best_fit = each_func; | 1924 best_fit = each_func; |
1906 } | 1925 } |
1907 } | 1926 } |
1908 | 1927 |
1909 if (best_fit) | 1928 if (best_fit) |
1910 { | 1929 { |
1911 best_fit->sec = sec; | 1930 best_fit->sec = sec; |
1912 *filename_ptr = best_fit->file; | 1931 *filename_ptr = best_fit->file; |
1913 *linenumber_ptr = best_fit->line; | 1932 *linenumber_ptr = best_fit->line; |
1914 return TRUE; | 1933 return TRUE; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 else | 1998 else |
1980 info_ptr = unit->info_ptr_unit + die_ref; | 1999 info_ptr = unit->info_ptr_unit + die_ref; |
1981 abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); | 2000 abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); |
1982 info_ptr += bytes_read; | 2001 info_ptr += bytes_read; |
1983 | 2002 |
1984 if (abbrev_number) | 2003 if (abbrev_number) |
1985 { | 2004 { |
1986 abbrev = lookup_abbrev (abbrev_number, unit->abbrevs); | 2005 abbrev = lookup_abbrev (abbrev_number, unit->abbrevs); |
1987 if (! abbrev) | 2006 if (! abbrev) |
1988 { | 2007 { |
1989 » (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u
."), | 2008 » (*_bfd_error_handler) |
1990 » » » » abbrev_number); | 2009 » (_("Dwarf Error: Could not find abbrev number %u."), abbrev_number); |
1991 bfd_set_error (bfd_error_bad_value); | 2010 bfd_set_error (bfd_error_bad_value); |
1992 } | 2011 } |
1993 else | 2012 else |
1994 { | 2013 { |
1995 for (i = 0; i < abbrev->num_attrs; ++i) | 2014 for (i = 0; i < abbrev->num_attrs; ++i) |
1996 { | 2015 { |
1997 info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, | 2016 info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, |
1998 info_ptr); | 2017 info_ptr); |
1999 if (info_ptr == NULL) | 2018 if (info_ptr == NULL) |
2000 break; | 2019 break; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2045 ranges_ptr += unit->addr_size; | 2064 ranges_ptr += unit->addr_size; |
2046 high_pc = read_address (unit, ranges_ptr); | 2065 high_pc = read_address (unit, ranges_ptr); |
2047 ranges_ptr += unit->addr_size; | 2066 ranges_ptr += unit->addr_size; |
2048 | 2067 |
2049 if (low_pc == 0 && high_pc == 0) | 2068 if (low_pc == 0 && high_pc == 0) |
2050 break; | 2069 break; |
2051 if (low_pc == -1UL && high_pc != -1UL) | 2070 if (low_pc == -1UL && high_pc != -1UL) |
2052 base_address = high_pc; | 2071 base_address = high_pc; |
2053 else | 2072 else |
2054 { | 2073 { |
2055 » if (!arange_add (unit->abfd, arange, | 2074 » if (!arange_add (unit, arange, |
2056 base_address + low_pc, base_address + high_pc)) | 2075 base_address + low_pc, base_address + high_pc)) |
2057 return FALSE; | 2076 return FALSE; |
2058 } | 2077 } |
2059 } | 2078 } |
2060 return TRUE; | 2079 return TRUE; |
2061 } | 2080 } |
2062 | 2081 |
2063 /* DWARF2 Compilation unit functions. */ | 2082 /* DWARF2 Compilation unit functions. */ |
2064 | 2083 |
2065 /* Scan over each die in a comp. unit looking for functions to add | 2084 /* Scan over each die in a comp. unit looking for functions to add |
2066 to the function table and variables to the variable table. */ | 2085 to the function table and variables to the variable table. */ |
2067 | 2086 |
2068 static bfd_boolean | 2087 static bfd_boolean |
2069 scan_unit_for_symbols (struct comp_unit *unit) | 2088 scan_unit_for_symbols (struct comp_unit *unit) |
2070 { | 2089 { |
2071 bfd *abfd = unit->abfd; | 2090 bfd *abfd = unit->abfd; |
2072 bfd_byte *info_ptr = unit->first_child_die_ptr; | 2091 bfd_byte *info_ptr = unit->first_child_die_ptr; |
2073 int nesting_level = 1; | 2092 int nesting_level = 1; |
2074 struct funcinfo **nested_funcs; | 2093 struct funcinfo **nested_funcs; |
2075 int nested_funcs_size; | 2094 int nested_funcs_size; |
2076 | 2095 |
2077 /* Maintain a stack of in-scope functions and inlined functions, which we | 2096 /* Maintain a stack of in-scope functions and inlined functions, which we |
2078 can use to set the caller_func field. */ | 2097 can use to set the caller_func field. */ |
2079 nested_funcs_size = 32; | 2098 nested_funcs_size = 32; |
2080 nested_funcs = (struct funcinfo **) | 2099 nested_funcs = (struct funcinfo **) |
2081 bfd_malloc (nested_funcs_size * sizeof (struct funcinfo *)); | 2100 bfd_malloc (nested_funcs_size * sizeof (struct funcinfo *)); |
2082 if (nested_funcs == NULL) | 2101 if (nested_funcs == NULL) |
2083 return FALSE; | 2102 return FALSE; |
2084 nested_funcs[nesting_level] = 0; | 2103 nested_funcs[nesting_level] = 0; |
2085 | 2104 |
2086 while (nesting_level) | 2105 while (nesting_level) |
2087 { | 2106 { |
2088 unsigned int abbrev_number, bytes_read, i; | 2107 unsigned int abbrev_number, bytes_read, i; |
2089 struct abbrev_info *abbrev; | 2108 struct abbrev_info *abbrev; |
2090 struct attribute attr; | 2109 struct attribute attr; |
2091 struct funcinfo *func; | 2110 struct funcinfo *func; |
2092 struct varinfo *var; | 2111 struct varinfo *var; |
2093 bfd_vma low_pc = 0; | 2112 bfd_vma low_pc = 0; |
2094 bfd_vma high_pc = 0; | 2113 bfd_vma high_pc = 0; |
| 2114 bfd_boolean high_pc_relative = FALSE; |
2095 | 2115 |
2096 abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); | 2116 abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); |
2097 info_ptr += bytes_read; | 2117 info_ptr += bytes_read; |
2098 | 2118 |
2099 if (! abbrev_number) | 2119 if (! abbrev_number) |
2100 { | 2120 { |
2101 nesting_level--; | 2121 nesting_level--; |
2102 continue; | 2122 continue; |
2103 } | 2123 } |
2104 | 2124 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2190 case DW_AT_MIPS_linkage_name: | 2210 case DW_AT_MIPS_linkage_name: |
2191 func->name = attr.u.str; | 2211 func->name = attr.u.str; |
2192 break; | 2212 break; |
2193 | 2213 |
2194 case DW_AT_low_pc: | 2214 case DW_AT_low_pc: |
2195 low_pc = attr.u.val; | 2215 low_pc = attr.u.val; |
2196 break; | 2216 break; |
2197 | 2217 |
2198 case DW_AT_high_pc: | 2218 case DW_AT_high_pc: |
2199 high_pc = attr.u.val; | 2219 high_pc = attr.u.val; |
| 2220 high_pc_relative = attr.form != DW_FORM_addr; |
2200 break; | 2221 break; |
2201 | 2222 |
2202 case DW_AT_ranges: | 2223 case DW_AT_ranges: |
2203 if (!read_rangelist (unit, &func->arange, attr.u.val)) | 2224 if (!read_rangelist (unit, &func->arange, attr.u.val)) |
2204 goto fail; | 2225 goto fail; |
2205 break; | 2226 break; |
2206 | 2227 |
2207 case DW_AT_decl_file: | 2228 case DW_AT_decl_file: |
2208 func->file = concat_filename (unit->line_table, | 2229 func->file = concat_filename (unit->line_table, |
2209 attr.u.val); | 2230 attr.u.val); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2268 break; | 2289 break; |
2269 } | 2290 } |
2270 break; | 2291 break; |
2271 | 2292 |
2272 default: | 2293 default: |
2273 break; | 2294 break; |
2274 } | 2295 } |
2275 } | 2296 } |
2276 } | 2297 } |
2277 | 2298 |
| 2299 if (high_pc_relative) |
| 2300 high_pc += low_pc; |
| 2301 |
2278 if (func && high_pc != 0) | 2302 if (func && high_pc != 0) |
2279 { | 2303 { |
2280 » if (!arange_add (unit->abfd, &func->arange, low_pc, high_pc)) | 2304 » if (!arange_add (unit, &func->arange, low_pc, high_pc)) |
2281 goto fail; | 2305 goto fail; |
2282 } | 2306 } |
2283 | 2307 |
2284 if (abbrev->has_children) | 2308 if (abbrev->has_children) |
2285 { | 2309 { |
2286 nesting_level++; | 2310 nesting_level++; |
2287 | 2311 |
2288 if (nesting_level >= nested_funcs_size) | 2312 if (nesting_level >= nested_funcs_size) |
2289 { | 2313 { |
2290 struct funcinfo **tmp; | 2314 struct funcinfo **tmp; |
2291 | 2315 |
2292 nested_funcs_size *= 2; | 2316 nested_funcs_size *= 2; |
2293 tmp = (struct funcinfo **) | 2317 tmp = (struct funcinfo **) |
2294 bfd_realloc (nested_funcs, | 2318 » » bfd_realloc (nested_funcs, |
2295 (nested_funcs_size * sizeof (struct funcinfo *))); | 2319 » » » nested_funcs_size * sizeof (struct funcinfo *)); |
2296 if (tmp == NULL) | 2320 if (tmp == NULL) |
2297 goto fail; | 2321 goto fail; |
2298 nested_funcs = tmp; | 2322 nested_funcs = tmp; |
2299 } | 2323 } |
2300 nested_funcs[nesting_level] = 0; | 2324 nested_funcs[nesting_level] = 0; |
2301 } | 2325 } |
2302 } | 2326 } |
2303 | 2327 |
2304 free (nested_funcs); | 2328 free (nested_funcs); |
2305 return TRUE; | 2329 return TRUE; |
(...skipping 25 matching lines...) Expand all Loading... |
2331 struct abbrev_info** abbrevs; | 2355 struct abbrev_info** abbrevs; |
2332 unsigned int abbrev_number, bytes_read, i; | 2356 unsigned int abbrev_number, bytes_read, i; |
2333 struct abbrev_info *abbrev; | 2357 struct abbrev_info *abbrev; |
2334 struct attribute attr; | 2358 struct attribute attr; |
2335 bfd_byte *info_ptr = stash->info_ptr; | 2359 bfd_byte *info_ptr = stash->info_ptr; |
2336 bfd_byte *end_ptr = info_ptr + unit_length; | 2360 bfd_byte *end_ptr = info_ptr + unit_length; |
2337 bfd_size_type amt; | 2361 bfd_size_type amt; |
2338 bfd_vma low_pc = 0; | 2362 bfd_vma low_pc = 0; |
2339 bfd_vma high_pc = 0; | 2363 bfd_vma high_pc = 0; |
2340 bfd *abfd = stash->bfd_ptr; | 2364 bfd *abfd = stash->bfd_ptr; |
| 2365 bfd_boolean high_pc_relative = FALSE; |
2341 | 2366 |
2342 version = read_2_bytes (abfd, info_ptr); | 2367 version = read_2_bytes (abfd, info_ptr); |
2343 info_ptr += 2; | 2368 info_ptr += 2; |
2344 BFD_ASSERT (offset_size == 4 || offset_size == 8); | 2369 BFD_ASSERT (offset_size == 4 || offset_size == 8); |
2345 if (offset_size == 4) | 2370 if (offset_size == 4) |
2346 abbrev_offset = read_4_bytes (abfd, info_ptr); | 2371 abbrev_offset = read_4_bytes (abfd, info_ptr); |
2347 else | 2372 else |
2348 abbrev_offset = read_8_bytes (abfd, info_ptr); | 2373 abbrev_offset = read_8_bytes (abfd, info_ptr); |
2349 info_ptr += offset_size; | 2374 info_ptr += offset_size; |
2350 addr_size = read_1_byte (abfd, info_ptr); | 2375 addr_size = read_1_byte (abfd, info_ptr); |
2351 info_ptr += 1; | 2376 info_ptr += 1; |
2352 | 2377 |
2353 if (version != 2 && version != 3 && version != 4) | 2378 if (version != 2 && version != 3 && version != 4) |
2354 { | 2379 { |
2355 (*_bfd_error_handler) (_("Dwarf Error: found dwarf version '%u', this read
er only handles version 2, 3 and 4 information."), version); | 2380 (*_bfd_error_handler) |
| 2381 » (_("Dwarf Error: found dwarf version '%u', this reader" |
| 2382 » " only handles version 2, 3 and 4 information."), version); |
2356 bfd_set_error (bfd_error_bad_value); | 2383 bfd_set_error (bfd_error_bad_value); |
2357 return 0; | 2384 return 0; |
2358 } | 2385 } |
2359 | 2386 |
2360 if (addr_size > sizeof (bfd_vma)) | 2387 if (addr_size > sizeof (bfd_vma)) |
2361 { | 2388 { |
2362 (*_bfd_error_handler) (_("Dwarf Error: found address size '%u', this reade
r can not handle sizes greater than '%u'."), | 2389 (*_bfd_error_handler) |
2363 » » » addr_size, | 2390 » (_("Dwarf Error: found address size '%u', this reader" |
2364 » » » (unsigned int) sizeof (bfd_vma)); | 2391 » " can not handle sizes greater than '%u'."), |
| 2392 » addr_size, |
| 2393 » (unsigned int) sizeof (bfd_vma)); |
2365 bfd_set_error (bfd_error_bad_value); | 2394 bfd_set_error (bfd_error_bad_value); |
2366 return 0; | 2395 return 0; |
2367 } | 2396 } |
2368 | 2397 |
2369 if (addr_size != 2 && addr_size != 4 && addr_size != 8) | 2398 if (addr_size != 2 && addr_size != 4 && addr_size != 8) |
2370 { | 2399 { |
2371 (*_bfd_error_handler) ("Dwarf Error: found address size '%u', this reader
can only handle address sizes '2', '4' and '8'.", addr_size); | 2400 (*_bfd_error_handler) |
| 2401 » ("Dwarf Error: found address size '%u', this reader" |
| 2402 » " can only handle address sizes '2', '4' and '8'.", addr_size); |
2372 bfd_set_error (bfd_error_bad_value); | 2403 bfd_set_error (bfd_error_bad_value); |
2373 return 0; | 2404 return 0; |
2374 } | 2405 } |
2375 | 2406 |
2376 /* Read the abbrevs for this compilation unit into a table. */ | 2407 /* Read the abbrevs for this compilation unit into a table. */ |
2377 abbrevs = read_abbrevs (abfd, abbrev_offset, stash); | 2408 abbrevs = read_abbrevs (abfd, abbrev_offset, stash); |
2378 if (! abbrevs) | 2409 if (! abbrevs) |
2379 return 0; | 2410 return 0; |
2380 | 2411 |
2381 abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); | 2412 abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); |
2382 info_ptr += bytes_read; | 2413 info_ptr += bytes_read; |
2383 if (! abbrev_number) | 2414 if (! abbrev_number) |
2384 { | 2415 { |
2385 (*_bfd_error_handler) (_("Dwarf Error: Bad abbrev number: %u."), | 2416 (*_bfd_error_handler) (_("Dwarf Error: Bad abbrev number: %u."), |
2386 » » » abbrev_number); | 2417 » » » abbrev_number); |
2387 bfd_set_error (bfd_error_bad_value); | 2418 bfd_set_error (bfd_error_bad_value); |
2388 return 0; | 2419 return 0; |
2389 } | 2420 } |
2390 | 2421 |
2391 abbrev = lookup_abbrev (abbrev_number, abbrevs); | 2422 abbrev = lookup_abbrev (abbrev_number, abbrevs); |
2392 if (! abbrev) | 2423 if (! abbrev) |
2393 { | 2424 { |
2394 (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."), | 2425 (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."), |
2395 » » » abbrev_number); | 2426 » » » abbrev_number); |
2396 bfd_set_error (bfd_error_bad_value); | 2427 bfd_set_error (bfd_error_bad_value); |
2397 return 0; | 2428 return 0; |
2398 } | 2429 } |
2399 | 2430 |
2400 amt = sizeof (struct comp_unit); | 2431 amt = sizeof (struct comp_unit); |
2401 unit = (struct comp_unit *) bfd_zalloc (abfd, amt); | 2432 unit = (struct comp_unit *) bfd_zalloc (abfd, amt); |
2402 if (unit == NULL) | 2433 if (unit == NULL) |
2403 return NULL; | 2434 return NULL; |
2404 unit->abfd = abfd; | 2435 unit->abfd = abfd; |
2405 unit->version = version; | 2436 unit->version = version; |
(...skipping 22 matching lines...) Expand all Loading... |
2428 | 2459 |
2429 case DW_AT_name: | 2460 case DW_AT_name: |
2430 unit->name = attr.u.str; | 2461 unit->name = attr.u.str; |
2431 break; | 2462 break; |
2432 | 2463 |
2433 case DW_AT_low_pc: | 2464 case DW_AT_low_pc: |
2434 low_pc = attr.u.val; | 2465 low_pc = attr.u.val; |
2435 /* If the compilation unit DIE has a DW_AT_low_pc attribute, | 2466 /* If the compilation unit DIE has a DW_AT_low_pc attribute, |
2436 this is the base address to use when reading location | 2467 this is the base address to use when reading location |
2437 lists or range lists. */ | 2468 lists or range lists. */ |
2438 » unit->base_address = low_pc; | 2469 » if (abbrev->tag == DW_TAG_compile_unit) |
| 2470 » unit->base_address = low_pc; |
2439 break; | 2471 break; |
2440 | 2472 |
2441 case DW_AT_high_pc: | 2473 case DW_AT_high_pc: |
2442 high_pc = attr.u.val; | 2474 high_pc = attr.u.val; |
| 2475 high_pc_relative = attr.form != DW_FORM_addr; |
2443 break; | 2476 break; |
2444 | 2477 |
2445 case DW_AT_ranges: | 2478 case DW_AT_ranges: |
2446 if (!read_rangelist (unit, &unit->arange, attr.u.val)) | 2479 if (!read_rangelist (unit, &unit->arange, attr.u.val)) |
2447 return NULL; | 2480 return NULL; |
2448 break; | 2481 break; |
2449 | 2482 |
2450 case DW_AT_comp_dir: | 2483 case DW_AT_comp_dir: |
2451 { | 2484 { |
2452 char *comp_dir = attr.u.str; | 2485 char *comp_dir = attr.u.str; |
2453 if (comp_dir) | 2486 if (comp_dir) |
2454 { | 2487 { |
2455 /* Irix 6.2 native cc prepends <machine>.: to the compilation | 2488 /* Irix 6.2 native cc prepends <machine>.: to the compilation |
2456 directory, get rid of it. */ | 2489 directory, get rid of it. */ |
2457 char *cp = strchr (comp_dir, ':'); | 2490 char *cp = strchr (comp_dir, ':'); |
2458 | 2491 |
2459 if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/') | 2492 if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/') |
2460 comp_dir = cp + 1; | 2493 comp_dir = cp + 1; |
2461 } | 2494 } |
2462 unit->comp_dir = comp_dir; | 2495 unit->comp_dir = comp_dir; |
2463 break; | 2496 break; |
2464 } | 2497 } |
2465 | 2498 |
2466 default: | 2499 default: |
2467 break; | 2500 break; |
2468 } | 2501 } |
2469 } | 2502 } |
| 2503 if (high_pc_relative) |
| 2504 high_pc += low_pc; |
2470 if (high_pc != 0) | 2505 if (high_pc != 0) |
2471 { | 2506 { |
2472 if (!arange_add (unit->abfd, &unit->arange, low_pc, high_pc)) | 2507 if (!arange_add (unit, &unit->arange, low_pc, high_pc)) |
2473 return NULL; | 2508 return NULL; |
2474 } | 2509 } |
2475 | 2510 |
2476 unit->first_child_die_ptr = info_ptr; | 2511 unit->first_child_die_ptr = info_ptr; |
2477 return unit; | 2512 return unit; |
2478 } | 2513 } |
2479 | 2514 |
2480 /* Return TRUE if UNIT may contain the address given by ADDR. When | 2515 /* Return TRUE if UNIT may contain the address given by ADDR. When |
2481 there are functions written entirely with inline asm statements, the | 2516 there are functions written entirely with inline asm statements, the |
2482 range info in the compilation unit header may not be correct. We | 2517 range info in the compilation unit header may not be correct. We |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2732 This is a variation on the .debug_info section which has a checksum | 2767 This is a variation on the .debug_info section which has a checksum |
2733 describing the contents appended onto the name. This allows the linker to | 2768 describing the contents appended onto the name. This allows the linker to |
2734 identify and discard duplicate debugging sections for different | 2769 identify and discard duplicate debugging sections for different |
2735 compilation units. */ | 2770 compilation units. */ |
2736 #define GNU_LINKONCE_INFO ".gnu.linkonce.wi." | 2771 #define GNU_LINKONCE_INFO ".gnu.linkonce.wi." |
2737 | 2772 |
2738 static asection * | 2773 static asection * |
2739 find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections, | 2774 find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections, |
2740 asection *after_sec) | 2775 asection *after_sec) |
2741 { | 2776 { |
2742 asection * msec; | 2777 asection *msec; |
| 2778 const char *look; |
2743 | 2779 |
2744 msec = after_sec != NULL ? after_sec->next : abfd->sections; | 2780 if (after_sec == NULL) |
2745 | |
2746 while (msec) | |
2747 { | 2781 { |
2748 if (strcmp (msec->name, | 2782 look = debug_sections[debug_info].uncompressed_name; |
2749 debug_sections[debug_info].uncompressed_name) == 0) | 2783 msec = bfd_get_section_by_name (abfd, look); |
| 2784 if (msec != NULL) |
2750 return msec; | 2785 return msec; |
2751 | 2786 |
2752 if (debug_sections[debug_info].compressed_name != NULL | 2787 look = debug_sections[debug_info].compressed_name; |
2753 && strcmp (msec->name, | 2788 if (look != NULL) |
2754 debug_sections[debug_info].compressed_name) == 0) | 2789 » { |
| 2790 » msec = bfd_get_section_by_name (abfd, look); |
| 2791 » if (msec != NULL) |
| 2792 » return msec; |
| 2793 » } |
| 2794 |
| 2795 for (msec = abfd->sections; msec != NULL; msec = msec->next) |
| 2796 » if (CONST_STRNEQ (msec->name, GNU_LINKONCE_INFO)) |
| 2797 » return msec; |
| 2798 |
| 2799 return NULL; |
| 2800 } |
| 2801 |
| 2802 for (msec = after_sec->next; msec != NULL; msec = msec->next) |
| 2803 { |
| 2804 look = debug_sections[debug_info].uncompressed_name; |
| 2805 if (strcmp (msec->name, look) == 0) |
| 2806 » return msec; |
| 2807 |
| 2808 look = debug_sections[debug_info].compressed_name; |
| 2809 if (look != NULL && strcmp (msec->name, look) == 0) |
2755 return msec; | 2810 return msec; |
2756 | 2811 |
2757 if (CONST_STRNEQ (msec->name, GNU_LINKONCE_INFO)) | 2812 if (CONST_STRNEQ (msec->name, GNU_LINKONCE_INFO)) |
2758 return msec; | 2813 return msec; |
2759 | |
2760 msec = msec->next; | |
2761 } | 2814 } |
2762 | 2815 |
2763 return NULL; | 2816 return NULL; |
2764 } | 2817 } |
2765 | 2818 |
2766 /* Unset vmas for adjusted sections in STASH. */ | 2819 /* Unset vmas for adjusted sections in STASH. */ |
2767 | 2820 |
2768 static void | 2821 static void |
2769 unset_sections (struct dwarf2_debug *stash) | 2822 unset_sections (struct dwarf2_debug *stash) |
2770 { | 2823 { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2824 continue; | 2877 continue; |
2825 | 2878 |
2826 sz = sect->rawsize ? sect->rawsize : sect->size; | 2879 sz = sect->rawsize ? sect->rawsize : sect->size; |
2827 if (sz == 0) | 2880 if (sz == 0) |
2828 continue; | 2881 continue; |
2829 | 2882 |
2830 i++; | 2883 i++; |
2831 } | 2884 } |
2832 | 2885 |
2833 amt = i * sizeof (struct adjusted_section); | 2886 amt = i * sizeof (struct adjusted_section); |
2834 p = (struct adjusted_section *) bfd_zalloc (abfd, amt); | 2887 p = (struct adjusted_section *) bfd_alloc (abfd, amt); |
2835 if (! p) | 2888 if (! p) |
2836 return FALSE; | 2889 return FALSE; |
2837 | 2890 |
2838 stash->adjusted_sections = p; | 2891 stash->adjusted_sections = p; |
2839 stash->adjusted_section_count = i; | 2892 stash->adjusted_section_count = i; |
2840 | 2893 |
2841 for (sect = abfd->sections; sect != NULL; sect = sect->next) | 2894 for (sect = abfd->sections; sect != NULL; sect = sect->next) |
2842 { | 2895 { |
2843 bfd_size_type sz; | 2896 bfd_size_type sz; |
2844 int is_debug_info; | 2897 int is_debug_info; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2918 { | 2971 { |
2919 each_func = (struct funcinfo *) node->info; | 2972 each_func = (struct funcinfo *) node->info; |
2920 for (arange = &each_func->arange; | 2973 for (arange = &each_func->arange; |
2921 arange; | 2974 arange; |
2922 arange = arange->next) | 2975 arange = arange->next) |
2923 { | 2976 { |
2924 if ((!each_func->sec || each_func->sec == sec) | 2977 if ((!each_func->sec || each_func->sec == sec) |
2925 && addr >= arange->low | 2978 && addr >= arange->low |
2926 && addr < arange->high | 2979 && addr < arange->high |
2927 && (!best_fit | 2980 && (!best_fit |
2928 » » || ((arange->high - arange->low) | 2981 » » || (arange->high - arange->low |
2929 » » < (best_fit->arange.high - best_fit->arange.low)))) | 2982 » » < best_fit->arange.high - best_fit->arange.low))) |
2930 best_fit = each_func; | 2983 best_fit = each_func; |
2931 } | 2984 } |
2932 } | 2985 } |
2933 | 2986 |
2934 if (best_fit) | 2987 if (best_fit) |
2935 { | 2988 { |
2936 best_fit->sec = sec; | 2989 best_fit->sec = sec; |
2937 *filename_ptr = best_fit->file; | 2990 *filename_ptr = best_fit->file; |
2938 *linenumber_ptr = best_fit->line; | 2991 *linenumber_ptr = best_fit->line; |
2939 return TRUE; | 2992 return TRUE; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3110 { | 3163 { |
3111 BFD_ASSERT (stash->info_hash_status == STASH_INFO_HASH_ON); | 3164 BFD_ASSERT (stash->info_hash_status == STASH_INFO_HASH_ON); |
3112 | 3165 |
3113 if (sym->flags & BSF_FUNCTION) | 3166 if (sym->flags & BSF_FUNCTION) |
3114 return info_hash_lookup_funcinfo (stash->funcinfo_hash_table, sym, addr, | 3167 return info_hash_lookup_funcinfo (stash->funcinfo_hash_table, sym, addr, |
3115 filename_ptr, linenumber_ptr); | 3168 filename_ptr, linenumber_ptr); |
3116 return info_hash_lookup_varinfo (stash->varinfo_hash_table, sym, addr, | 3169 return info_hash_lookup_varinfo (stash->varinfo_hash_table, sym, addr, |
3117 filename_ptr, linenumber_ptr); | 3170 filename_ptr, linenumber_ptr); |
3118 } | 3171 } |
3119 | 3172 |
| 3173 /* Read debug information from DEBUG_BFD when DEBUG_BFD is specified. |
| 3174 If DEBUG_BFD is not specified, we read debug information from ABFD |
| 3175 or its gnu_debuglink. The results will be stored in PINFO. |
| 3176 The function returns TRUE iff debug information is ready. */ |
| 3177 |
| 3178 bfd_boolean |
| 3179 _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd, |
| 3180 const struct dwarf_debug_section *debug_sections, |
| 3181 asymbol **symbols, |
| 3182 void **pinfo) |
| 3183 { |
| 3184 bfd_size_type amt = sizeof (struct dwarf2_debug); |
| 3185 bfd_size_type total_size; |
| 3186 asection *msec; |
| 3187 struct dwarf2_debug *stash = (struct dwarf2_debug *) *pinfo; |
| 3188 |
| 3189 if (stash != NULL) |
| 3190 return TRUE; |
| 3191 |
| 3192 stash = (struct dwarf2_debug *) bfd_zalloc (abfd, amt); |
| 3193 if (! stash) |
| 3194 return FALSE; |
| 3195 stash->debug_sections = debug_sections; |
| 3196 |
| 3197 *pinfo = stash; |
| 3198 |
| 3199 if (debug_bfd == NULL) |
| 3200 debug_bfd = abfd; |
| 3201 |
| 3202 msec = find_debug_info (debug_bfd, debug_sections, NULL); |
| 3203 if (msec == NULL && abfd == debug_bfd) |
| 3204 { |
| 3205 char * debug_filename = bfd_follow_gnu_debuglink (abfd, DEBUGDIR); |
| 3206 |
| 3207 if (debug_filename == NULL) |
| 3208 /* No dwarf2 info, and no gnu_debuglink to follow. |
| 3209 Note that at this point the stash has been allocated, but |
| 3210 contains zeros. This lets future calls to this function |
| 3211 fail more quickly. */ |
| 3212 return FALSE; |
| 3213 |
| 3214 if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL |
| 3215 || ! bfd_check_format (debug_bfd, bfd_object) |
| 3216 || (msec = find_debug_info (debug_bfd, |
| 3217 debug_sections, NULL)) == NULL) |
| 3218 { |
| 3219 if (debug_bfd) |
| 3220 bfd_close (debug_bfd); |
| 3221 /* FIXME: Should we report our failure to follow the debuglink ? */ |
| 3222 free (debug_filename); |
| 3223 return FALSE; |
| 3224 } |
| 3225 } |
| 3226 |
| 3227 /* There can be more than one DWARF2 info section in a BFD these |
| 3228 days. First handle the easy case when there's only one. If |
| 3229 there's more than one, try case two: none of the sections is |
| 3230 compressed. In that case, read them all in and produce one |
| 3231 large stash. We do this in two passes - in the first pass we |
| 3232 just accumulate the section sizes, and in the second pass we |
| 3233 read in the section's contents. (The allows us to avoid |
| 3234 reallocing the data as we add sections to the stash.) If |
| 3235 some or all sections are compressed, then do things the slow |
| 3236 way, with a bunch of reallocs. */ |
| 3237 |
| 3238 if (! find_debug_info (debug_bfd, debug_sections, msec)) |
| 3239 { |
| 3240 /* Case 1: only one info section. */ |
| 3241 total_size = msec->size; |
| 3242 if (! read_section (debug_bfd, &stash->debug_sections[debug_info], |
| 3243 symbols, 0, |
| 3244 &stash->info_ptr_memory, &total_size)) |
| 3245 return FALSE; |
| 3246 } |
| 3247 else |
| 3248 { |
| 3249 /* Case 2: multiple sections. */ |
| 3250 for (total_size = 0; |
| 3251 msec; |
| 3252 msec = find_debug_info (debug_bfd, debug_sections, msec)) |
| 3253 total_size += msec->size; |
| 3254 |
| 3255 stash->info_ptr_memory = (bfd_byte *) bfd_malloc (total_size); |
| 3256 if (stash->info_ptr_memory == NULL) |
| 3257 return FALSE; |
| 3258 |
| 3259 total_size = 0; |
| 3260 for (msec = find_debug_info (debug_bfd, debug_sections, NULL); |
| 3261 msec; |
| 3262 msec = find_debug_info (debug_bfd, debug_sections, msec)) |
| 3263 { |
| 3264 bfd_size_type size; |
| 3265 |
| 3266 size = msec->size; |
| 3267 if (size == 0) |
| 3268 continue; |
| 3269 |
| 3270 if (!(bfd_simple_get_relocated_section_contents |
| 3271 (debug_bfd, msec, stash->info_ptr_memory + total_size, |
| 3272 symbols))) |
| 3273 return FALSE; |
| 3274 |
| 3275 total_size += size; |
| 3276 } |
| 3277 } |
| 3278 |
| 3279 stash->info_ptr = stash->info_ptr_memory; |
| 3280 stash->info_ptr_end = stash->info_ptr + total_size; |
| 3281 stash->sec = find_debug_info (debug_bfd, debug_sections, NULL); |
| 3282 stash->sec_info_ptr = stash->info_ptr; |
| 3283 stash->syms = symbols; |
| 3284 stash->bfd_ptr = debug_bfd; |
| 3285 |
| 3286 return TRUE; |
| 3287 } |
| 3288 |
3120 /* Find the source code location of SYMBOL. If SYMBOL is NULL | 3289 /* Find the source code location of SYMBOL. If SYMBOL is NULL |
3121 then find the nearest source code location corresponding to | 3290 then find the nearest source code location corresponding to |
3122 the address SECTION + OFFSET. | 3291 the address SECTION + OFFSET. |
3123 Returns TRUE if the line is found without error and fills in | 3292 Returns TRUE if the line is found without error and fills in |
3124 FILENAME_PTR and LINENUMBER_PTR. In the case where SYMBOL was | 3293 FILENAME_PTR and LINENUMBER_PTR. In the case where SYMBOL was |
3125 NULL the FUNCTIONNAME_PTR is also filled in. | 3294 NULL the FUNCTIONNAME_PTR is also filled in. |
3126 SYMBOLS contains the symbol table for ABFD. | 3295 SYMBOLS contains the symbol table for ABFD. |
3127 DEBUG_SECTIONS contains the name of the dwarf debug sections. | 3296 DEBUG_SECTIONS contains the name of the dwarf debug sections. |
3128 ADDR_SIZE is the number of bytes in the initial .debug_info length | 3297 ADDR_SIZE is the number of bytes in the initial .debug_info length |
3129 field and in the abbreviation offset, or zero to indicate that the | 3298 field and in the abbreviation offset, or zero to indicate that the |
(...skipping 20 matching lines...) Expand all Loading... |
3150 We keep a list of all the previously read compilation units, and | 3319 We keep a list of all the previously read compilation units, and |
3151 a pointer to the next un-read compilation unit. Check the | 3320 a pointer to the next un-read compilation unit. Check the |
3152 previously read units before reading more. */ | 3321 previously read units before reading more. */ |
3153 struct dwarf2_debug *stash; | 3322 struct dwarf2_debug *stash; |
3154 /* What address are we looking for? */ | 3323 /* What address are we looking for? */ |
3155 bfd_vma addr; | 3324 bfd_vma addr; |
3156 struct comp_unit* each; | 3325 struct comp_unit* each; |
3157 bfd_vma found = FALSE; | 3326 bfd_vma found = FALSE; |
3158 bfd_boolean do_line; | 3327 bfd_boolean do_line; |
3159 | 3328 |
| 3329 *filename_ptr = NULL; |
| 3330 if (functionname_ptr != NULL) |
| 3331 *functionname_ptr = NULL; |
| 3332 *linenumber_ptr = 0; |
| 3333 |
| 3334 if (! _bfd_dwarf2_slurp_debug_info (abfd, NULL, |
| 3335 debug_sections, symbols, pinfo)) |
| 3336 return FALSE; |
| 3337 |
3160 stash = (struct dwarf2_debug *) *pinfo; | 3338 stash = (struct dwarf2_debug *) *pinfo; |
3161 | 3339 |
3162 if (! stash) | |
3163 { | |
3164 bfd_size_type amt = sizeof (struct dwarf2_debug); | |
3165 | |
3166 stash = (struct dwarf2_debug *) bfd_zalloc (abfd, amt); | |
3167 if (! stash) | |
3168 return FALSE; | |
3169 stash->debug_sections = debug_sections; | |
3170 } | |
3171 | |
3172 /* In a relocatable file, 2 functions may have the same address. | 3340 /* In a relocatable file, 2 functions may have the same address. |
3173 We change the section vma so that they won't overlap. */ | 3341 We change the section vma so that they won't overlap. */ |
3174 if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) | 3342 if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) |
3175 { | 3343 { |
3176 if (! place_sections (abfd, stash)) | 3344 if (! place_sections (abfd, stash)) |
3177 return FALSE; | 3345 return FALSE; |
3178 } | 3346 } |
3179 | 3347 |
3180 do_line = (section == NULL | 3348 do_line = (section == NULL |
3181 && offset == 0 | 3349 && offset == 0 |
3182 && functionname_ptr == NULL | 3350 && functionname_ptr == NULL |
3183 && symbol != NULL); | 3351 && symbol != NULL); |
3184 if (do_line) | 3352 if (do_line) |
3185 { | 3353 { |
3186 addr = symbol->value; | 3354 addr = symbol->value; |
3187 section = bfd_get_section (symbol); | 3355 section = bfd_get_section (symbol); |
3188 } | 3356 } |
3189 else if (section != NULL | 3357 else if (section != NULL |
3190 && functionname_ptr != NULL | 3358 && functionname_ptr != NULL |
3191 && symbol == NULL) | 3359 && symbol == NULL) |
3192 addr = offset; | 3360 addr = offset; |
3193 else | 3361 else |
3194 abort (); | 3362 abort (); |
3195 | 3363 |
3196 if (section->output_section) | 3364 if (section->output_section) |
3197 addr += section->output_section->vma + section->output_offset; | 3365 addr += section->output_section->vma + section->output_offset; |
3198 else | 3366 else |
3199 addr += section->vma; | 3367 addr += section->vma; |
3200 *filename_ptr = NULL; | |
3201 if (! do_line) | |
3202 *functionname_ptr = NULL; | |
3203 *linenumber_ptr = 0; | |
3204 | |
3205 if (! *pinfo) | |
3206 { | |
3207 bfd *debug_bfd; | |
3208 bfd_size_type total_size; | |
3209 asection *msec; | |
3210 | |
3211 *pinfo = stash; | |
3212 | |
3213 msec = find_debug_info (abfd, debug_sections, NULL); | |
3214 if (msec == NULL) | |
3215 { | |
3216 char * debug_filename = bfd_follow_gnu_debuglink (abfd, DEBUGDIR); | |
3217 | |
3218 if (debug_filename == NULL) | |
3219 /* No dwarf2 info, and no gnu_debuglink to follow. | |
3220 Note that at this point the stash has been allocated, but | |
3221 contains zeros. This lets future calls to this function | |
3222 fail more quickly. */ | |
3223 goto done; | |
3224 | |
3225 if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL | |
3226 || ! bfd_check_format (debug_bfd, bfd_object) | |
3227 || (msec = find_debug_info (debug_bfd, | |
3228 debug_sections, NULL)) == NULL) | |
3229 { | |
3230 if (debug_bfd) | |
3231 bfd_close (debug_bfd); | |
3232 /* FIXME: Should we report our failure to follow the debuglink ?
*/ | |
3233 free (debug_filename); | |
3234 goto done; | |
3235 } | |
3236 } | |
3237 else | |
3238 debug_bfd = abfd; | |
3239 | |
3240 /* There can be more than one DWARF2 info section in a BFD these | |
3241 days. First handle the easy case when there's only one. If | |
3242 there's more than one, try case two: none of the sections is | |
3243 compressed. In that case, read them all in and produce one | |
3244 large stash. We do this in two passes - in the first pass we | |
3245 just accumulate the section sizes, and in the second pass we | |
3246 read in the section's contents. (The allows us to avoid | |
3247 reallocing the data as we add sections to the stash.) If | |
3248 some or all sections are compressed, then do things the slow | |
3249 way, with a bunch of reallocs. */ | |
3250 | |
3251 if (! find_debug_info (debug_bfd, debug_sections, msec)) | |
3252 { | |
3253 /* Case 1: only one info section. */ | |
3254 total_size = msec->size; | |
3255 if (! read_section (debug_bfd, &stash->debug_sections[debug_info], | |
3256 symbols, 0, | |
3257 &stash->info_ptr_memory, &total_size)) | |
3258 goto done; | |
3259 } | |
3260 else | |
3261 { | |
3262 /* Case 2: multiple sections. */ | |
3263 for (total_size = 0; | |
3264 msec; | |
3265 msec = find_debug_info (debug_bfd, debug_sections, msec)) | |
3266 total_size += msec->size; | |
3267 | |
3268 stash->info_ptr_memory = (bfd_byte *) bfd_malloc (total_size); | |
3269 if (stash->info_ptr_memory == NULL) | |
3270 goto done; | |
3271 | |
3272 total_size = 0; | |
3273 for (msec = find_debug_info (debug_bfd, debug_sections, NULL); | |
3274 msec; | |
3275 msec = find_debug_info (debug_bfd, debug_sections, msec)) | |
3276 { | |
3277 bfd_size_type size; | |
3278 | |
3279 size = msec->size; | |
3280 if (size == 0) | |
3281 continue; | |
3282 | |
3283 if (!(bfd_simple_get_relocated_section_contents | |
3284 (debug_bfd, msec, stash->info_ptr_memory + total_size, | |
3285 symbols))) | |
3286 goto done; | |
3287 | |
3288 total_size += size; | |
3289 } | |
3290 } | |
3291 | |
3292 stash->info_ptr = stash->info_ptr_memory; | |
3293 stash->info_ptr_end = stash->info_ptr + total_size; | |
3294 stash->sec = find_debug_info (debug_bfd, debug_sections, NULL); | |
3295 stash->sec_info_ptr = stash->info_ptr; | |
3296 stash->syms = symbols; | |
3297 stash->bfd_ptr = debug_bfd; | |
3298 } | |
3299 | 3368 |
3300 /* A null info_ptr indicates that there is no dwarf2 info | 3369 /* A null info_ptr indicates that there is no dwarf2 info |
3301 (or that an error occured while setting up the stash). */ | 3370 (or that an error occured while setting up the stash). */ |
3302 if (! stash->info_ptr) | 3371 if (! stash->info_ptr) |
3303 goto done; | 3372 return FALSE; |
3304 | 3373 |
3305 stash->inliner_chain = NULL; | 3374 stash->inliner_chain = NULL; |
3306 | 3375 |
3307 /* Check the previously read comp. units first. */ | 3376 /* Check the previously read comp. units first. */ |
3308 if (do_line) | 3377 if (do_line) |
3309 { | 3378 { |
3310 /* The info hash tables use quite a bit of memory. We may not want to | 3379 /* The info hash tables use quite a bit of memory. We may not want to |
3311 always use them. We use some heuristics to decide if and when to | 3380 always use them. We use some heuristics to decide if and when to |
3312 turn it on. */ | 3381 turn it on. */ |
3313 if (stash->info_hash_status == STASH_INFO_HASH_OFF) | 3382 if (stash->info_hash_status == STASH_INFO_HASH_OFF) |
3314 stash_maybe_enable_info_hash_tables (abfd, stash); | 3383 stash_maybe_enable_info_hash_tables (abfd, stash); |
3315 | 3384 |
3316 /* Keep info hash table up to date if they are available. Note that we | 3385 /* Keep info hash table up to date if they are available. Note that we |
3317 may disable the hash tables if there is any error duing update. */ | 3386 may disable the hash tables if there is any error duing update. */ |
3318 if (stash->info_hash_status == STASH_INFO_HASH_ON) | 3387 if (stash->info_hash_status == STASH_INFO_HASH_ON) |
3319 stash_maybe_update_info_hash_tables (stash); | 3388 stash_maybe_update_info_hash_tables (stash); |
3320 | 3389 |
3321 if (stash->info_hash_status == STASH_INFO_HASH_ON) | 3390 if (stash->info_hash_status == STASH_INFO_HASH_ON) |
3322 { | 3391 { |
3323 found = stash_find_line_fast (stash, symbol, addr, filename_ptr, | 3392 found = stash_find_line_fast (stash, symbol, addr, filename_ptr, |
3324 linenumber_ptr); | 3393 linenumber_ptr); |
3325 if (found) | 3394 if (found) |
3326 goto done; | 3395 goto done; |
3327 } | 3396 } |
3328 else | 3397 else |
3329 { | 3398 { |
3330 /* Check the previously read comp. units first. */ | 3399 /* Check the previously read comp. units first. */ |
3331 for (each = stash->all_comp_units; each; each = each->next_unit) | 3400 for (each = stash->all_comp_units; each; each = each->next_unit) |
3332 if ((symbol->flags & BSF_FUNCTION) == 0 | 3401 if ((symbol->flags & BSF_FUNCTION) == 0 |
| 3402 || each->arange.high == 0 |
3333 || comp_unit_contains_address (each, addr)) | 3403 || comp_unit_contains_address (each, addr)) |
3334 { | 3404 { |
3335 found = comp_unit_find_line (each, symbol, addr, filename_ptr, | 3405 found = comp_unit_find_line (each, symbol, addr, filename_ptr, |
3336 linenumber_ptr, stash); | 3406 linenumber_ptr, stash); |
3337 if (found) | 3407 if (found) |
3338 goto done; | 3408 goto done; |
3339 } | 3409 } |
3340 } | 3410 } |
3341 } | 3411 } |
3342 else | 3412 else |
3343 { | 3413 { |
3344 for (each = stash->all_comp_units; each; each = each->next_unit) | 3414 for (each = stash->all_comp_units; each; each = each->next_unit) |
3345 { | 3415 { |
3346 » found = (comp_unit_contains_address (each, addr) | 3416 » found = ((each->arange.high == 0 |
| 3417 » » || comp_unit_contains_address (each, addr)) |
3347 && comp_unit_find_nearest_line (each, addr, | 3418 && comp_unit_find_nearest_line (each, addr, |
3348 filename_ptr, | 3419 filename_ptr, |
3349 functionname_ptr, | 3420 functionname_ptr, |
3350 linenumber_ptr, | 3421 linenumber_ptr, |
3351 stash)); | 3422 stash)); |
3352 if (found) | 3423 if (found) |
3353 goto done; | 3424 goto done; |
3354 } | 3425 } |
3355 } | 3426 } |
3356 | 3427 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3449 stash->sec = find_debug_info (stash->bfd_ptr, debug_sections, | 3520 stash->sec = find_debug_info (stash->bfd_ptr, debug_sections, |
3450 stash->sec); | 3521 stash->sec); |
3451 stash->sec_info_ptr = stash->info_ptr; | 3522 stash->sec_info_ptr = stash->info_ptr; |
3452 } | 3523 } |
3453 | 3524 |
3454 if (found) | 3525 if (found) |
3455 goto done; | 3526 goto done; |
3456 } | 3527 } |
3457 } | 3528 } |
3458 | 3529 |
3459 done: | 3530 done: |
3460 if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) | 3531 if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) |
3461 unset_sections (stash); | 3532 unset_sections (stash); |
3462 | 3533 |
3463 return found; | 3534 return found; |
3464 } | 3535 } |
3465 | 3536 |
3466 /* The DWARF2 version of find_nearest_line. | 3537 /* The DWARF2 version of find_nearest_line. |
3467 Return TRUE if the line is found without error. */ | 3538 Return TRUE if the line is found without error. */ |
3468 | 3539 |
3469 bfd_boolean | 3540 bfd_boolean |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3520 *linenumber_ptr = func->caller_line; | 3591 *linenumber_ptr = func->caller_line; |
3521 stash->inliner_chain = func->caller_func; | 3592 stash->inliner_chain = func->caller_func; |
3522 return TRUE; | 3593 return TRUE; |
3523 } | 3594 } |
3524 } | 3595 } |
3525 | 3596 |
3526 return FALSE; | 3597 return FALSE; |
3527 } | 3598 } |
3528 | 3599 |
3529 void | 3600 void |
3530 _bfd_dwarf2_cleanup_debug_info (bfd *abfd) | 3601 _bfd_dwarf2_cleanup_debug_info (bfd *abfd, void **pinfo) |
3531 { | 3602 { |
| 3603 struct dwarf2_debug *stash = (struct dwarf2_debug *) *pinfo;; |
3532 struct comp_unit *each; | 3604 struct comp_unit *each; |
3533 struct dwarf2_debug *stash; | |
3534 | 3605 |
3535 if (abfd == NULL || elf_tdata (abfd) == NULL) | 3606 if (abfd == NULL || stash == NULL) |
3536 return; | |
3537 | |
3538 stash = (struct dwarf2_debug *) elf_tdata (abfd)->dwarf2_find_line_info; | |
3539 | |
3540 if (stash == NULL) | |
3541 return; | 3607 return; |
3542 | 3608 |
3543 for (each = stash->all_comp_units; each; each = each->next_unit) | 3609 for (each = stash->all_comp_units; each; each = each->next_unit) |
3544 { | 3610 { |
3545 struct abbrev_info **abbrevs = each->abbrevs; | 3611 struct abbrev_info **abbrevs = each->abbrevs; |
3546 struct funcinfo *function_table = each->function_table; | 3612 struct funcinfo *function_table = each->function_table; |
3547 struct varinfo *variable_table = each->variable_table; | 3613 struct varinfo *variable_table = each->variable_table; |
3548 size_t i; | 3614 size_t i; |
3549 | 3615 |
3550 for (i = 0; i < ABBREV_HASH_SIZE; i++) | 3616 for (i = 0; i < ABBREV_HASH_SIZE; i++) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3596 free (stash->dwarf_abbrev_buffer); | 3662 free (stash->dwarf_abbrev_buffer); |
3597 if (stash->dwarf_line_buffer) | 3663 if (stash->dwarf_line_buffer) |
3598 free (stash->dwarf_line_buffer); | 3664 free (stash->dwarf_line_buffer); |
3599 if (stash->dwarf_str_buffer) | 3665 if (stash->dwarf_str_buffer) |
3600 free (stash->dwarf_str_buffer); | 3666 free (stash->dwarf_str_buffer); |
3601 if (stash->dwarf_ranges_buffer) | 3667 if (stash->dwarf_ranges_buffer) |
3602 free (stash->dwarf_ranges_buffer); | 3668 free (stash->dwarf_ranges_buffer); |
3603 if (stash->info_ptr_memory) | 3669 if (stash->info_ptr_memory) |
3604 free (stash->info_ptr_memory); | 3670 free (stash->info_ptr_memory); |
3605 } | 3671 } |
OLD | NEW |