Index: gdb/ChangeLog from Alexandre Oliva * dwarf2read.c (read_file_scope): Handle non-contiguous comp_units, testing entry_point for every subprogram. Index: gdb/dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.78 diff -u -p -r1.78 dwarf2read.c --- gdb/dwarf2read.c 11 Dec 2002 20:55:37 -0000 1.78 +++ gdb/dwarf2read.c 11 Dec 2002 21:42:29 -0000 @@ -1710,9 +1710,15 @@ read_file_scope (struct die_info *die, s struct die_info *child_die; bfd *abfd = objfile->obfd; struct line_header *line_header = 0; + CORE_ADDR entry_point = objfile->ei.entry_point - baseaddr; + int init_file = 0; if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, objfile)) { + if (entry_point >= lowpc && entry_point < highpc + && lowpc != ((CORE_ADDR) -1)) + init_file = 1; + if (die->has_children) { child_die = die->next; @@ -1724,6 +1730,17 @@ read_file_scope (struct die_info *die, s if (dwarf2_get_pc_bounds (child_die, &low, &high, objfile)) { + /* We want to do this test per subprogram, so + that, if the comp_unit is not contiguous + (e.g., it has code in several sections that + are not mapped to a single segment, such that + there is code from other comp_units + interspersed with code from this one), we + don't get false positives. */ + if (entry_point >= low && entry_point < high + && lowpc != ((CORE_ADDR) -1)) + init_file = 1; + lowpc = min (lowpc, low); highpc = max (highpc, high); } @@ -1760,8 +1777,7 @@ read_file_scope (struct die_info *die, s } } - if (objfile->ei.entry_point >= lowpc && - objfile->ei.entry_point < highpc) + if (init_file) { objfile->ei.entry_file_lowpc = lowpc; objfile->ei.entry_file_highpc = highpc;