From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29810 invoked by alias); 11 Dec 2002 22:19:05 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 29803 invoked from network); 11 Dec 2002 22:19:05 -0000 Received: from unknown (HELO lacrosse.corp.redhat.com) (66.187.233.200) by sources.redhat.com with SMTP; 11 Dec 2002 22:19:05 -0000 Received: from free.redhat.lsd.ic.unicamp.br (aoliva2.cipe.redhat.com [10.0.1.156]) by lacrosse.corp.redhat.com (8.11.6/8.9.3) with ESMTP id gBBMJ3N05707 for ; Wed, 11 Dec 2002 17:19:03 -0500 Received: from free.redhat.lsd.ic.unicamp.br (localhost.localdomain [127.0.0.1]) by free.redhat.lsd.ic.unicamp.br (8.12.5/8.12.5) with ESMTP id gBBMJ2LL022108 for ; Wed, 11 Dec 2002 20:19:02 -0200 Received: (from aoliva@localhost) by free.redhat.lsd.ic.unicamp.br (8.12.5/8.12.5/Submit) id gBBMJ2US022104; Wed, 11 Dec 2002 20:19:02 -0200 To: gdb-patches@sources.redhat.com Subject: non-contiguous files break dwarf2 init-file recognition From: Alexandre Oliva Organization: GCC Team, Red Hat Date: Wed, 11 Dec 2002 14:27:00 -0000 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SW-Source: 2002-12/txt/msg00377.txt.bz2 --=-=-= Content-length: 426 If an object file contains functions in CODE sections that are mapped to different segments, or just non-contiguous memory areas, and the entry point of the program happens to be in between such areas, we may end up picking the wrong comp_unit as init file. This patch fixes it (as long as the code of the init file itself is contiguous, this should be fine, otherwise the whole thing has to be redesigned). Ok to install? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=gdb-non-contig-comp-unit.patch Content-length: 1901 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; --=-=-= Content-length: 289 -- Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/ Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org} CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org} Free Software Evangelist Professional serial bug killer --=-=-=--