From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26012 invoked by alias); 15 Mar 2007 04:30:31 -0000 Received: (qmail 25994 invoked by uid 22791); 15 Mar 2007 04:30:30 -0000 X-Spam-Check-By: sourceware.org Received: from hq.tensilica.com (HELO mailapp.tensilica.com) (65.205.227.29) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 15 Mar 2007 04:30:26 +0000 Received: from localhost ([127.0.0.1]) by mailapp.tensilica.com with esmtp (Exim 4.34) id 1HRhbc-0005EQ-25; Wed, 14 Mar 2007 20:30:24 -0800 Received: from mailapp.tensilica.com ([127.0.0.1]) by localhost (mailapp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19976-02; Wed, 14 Mar 2007 20:30:23 -0800 (PST) Received: from maxim_fc5.hq.tensilica.com ([192.168.11.68]) by mailapp.tensilica.com with esmtp (Exim 4.34) id 1HRhbb-0005EJ-IK; Wed, 14 Mar 2007 20:30:23 -0800 Message-ID: <45F8CBDF.9090501@hq.tensilica.com> Date: Thu, 15 Mar 2007 04:30:00 -0000 From: Maxim Grigoriev User-Agent: Thunderbird 1.5.0.9 (X11/20070102) MIME-Version: 1.0 To: Maxim Grigoriev , gdb-patches@sources.redhat.com Subject: Re: Handling corner case in building symbol table when "debug_line" includes compilation directory References: <45F8A771.2060008@hq.tensilica.com> <20070315022735.GA9613@caradoc.them.org> In-Reply-To: <20070315022735.GA9613@caradoc.them.org> Content-Type: multipart/mixed; boundary="------------000107070507030600000106" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-03/txt/msg00142.txt.bz2 This is a multi-part message in MIME format. --------------000107070507030600000106 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 3043 I've attached the patch separately. Now, it should be fine. Sorry for inconvenience. 1) test case extern int printf(const char *fmt,...); int main() { printf("Hello, World !\n"); printf("Let's make DWARF consistent across all the tools !\n"); } 2) output from "readelf --debug-dump" The section .debug_info contains: Compilation Unit @ 0: Length: 241 Version: 2 Abbrev Offset: 0 Pointer Size: 4 <0>: Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_name : test.c DW_AT_comp_dir : /home/maxim/W/BadgerPass/PR_14999 DW_AT_producer : xt-xcc for 7.1.2-development -O0 -OPT:align_instructions=32 -g2 DW_AT_language : 1 (ANSI C) DW_AT_identifier_case: 0 (case_sensitive) DW_AT_stmt_list : 0 [ . . . . . ] Dump of debug contents of section .debug_line: Length: 101 DWARF Version: 2 Prologue Length: 65 [ . . . . .] The Directory Table: /home/maxim/W/BadgerPass/PR_14999 The File Name Table: Entry Dir Time Size Name 1 1 1173897037 152 test.c * * * * * So the compilation directory is listed in the directory table. And, there is a reference from the file table pointing to this directory. Normally, we wouldn't see a compilation directory in a line table prologue. With my native GCC on the same test case I have: <0>: Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_stmt_list : 0 DW_AT_high_pc : 0x80483b6 DW_AT_low_pc : 0x8048384 DW_AT_producer : GNU C 4.1.1 20060525 (Red Hat 4.1.1-1) DW_AT_language : 1 (ANSI C) DW_AT_name : test.c DW_AT_comp_dir : /home/maxim/W/BadgerPass/PR_14999 [ . . . . ] The Directory Table is empty. The File Name Table: Entry Dir Time Size Name 1 0 0 0 test.c So the compilation directory gets always described and referenced explicitly. Thanks for looking into this. 2007-03-15 Maxim Grigoriev * buildsym.c (start_subfile): Add handling missing case while building symbol table for a compilation unit. < Patch is attached > Daniel Jacobowitz wrote: > On Wed, Mar 14, 2007 at 06:54:57PM -0700, Maxim Grigoriev wrote: > >> Hello All, >> > > >> Tensilica compiler seems to provide a unique approach in building DWARF >> line tables. It confuses GDB algorithms being used to build symbol tables. >> > > >> First in DW_TAG_compile_unit entry >> > > >> DW_AT_name is a source file name as it was used in a command line; >> DW_AT_comp_dir is a full path name to a compilation directory; >> Then in the statement program prologue, the directory table includes at >> least one entry, which is again the compilation directory. And, there is >> a corresponding file table entry referencing to this directory. >> > > >> Assuming that this combination of the names of the directories and files >> does not contradict DWARF standard, I think GDB has to handle this situation. >> > > >> I suggest the following patch to fix this problem: >> > > First of all, your mailer ate whitespace in the patch again - very > hard to read. > > Unfortunately, I do not understand your description. Could you show > me an example? > > --------------000107070507030600000106 Content-Type: text/x-patch; name="PATCH.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="PATCH.diff" Content-length: 807 Index: gdb/buildsym.c =================================================================== RCS file: /cvs/src/src/gdb/buildsym.c,v retrieving revision 1.47 diff -u -r1.47 buildsym.c --- gdb/buildsym.c 27 Feb 2007 22:57:42 -0000 1.47 +++ gdb/buildsym.c 15 Mar 2007 01:14:14 -0000 @@ -549,7 +549,18 @@ for (subfile = subfiles; subfile; subfile = subfile->next) { - if (FILENAME_CMP (subfile->name, name) == 0) + char *subfile_name; + if (IS_ABSOLUTE_PATH(name) && !IS_ABSOLUTE_PATH (subfile->name)) + { + subfile_name = concat (dirname, SLASH_STRING, + subfile->name, (char *)NULL); + make_cleanup (xfree, subfile_name); + } + else + { + subfile_name = subfile->name; + } + if (FILENAME_CMP (subfile_name, name) == 0) { current_subfile = subfile; return; --------------000107070507030600000106--