From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29796 invoked by alias); 31 Jul 2013 09:57:37 -0000 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 Received: (qmail 29787 invoked by uid 89); 31 Jul 2013 09:57:37 -0000 X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_05,KHOP_THREADED,RCVD_IN_DNSWL_MED,RCVD_IN_HOSTKARMA_W,RDNS_NONE,SPF_PASS autolearn=ham version=3.3.1 Received: from Unknown (HELO e28smtp07.in.ibm.com) (122.248.162.7) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 31 Jul 2013 09:57:36 +0000 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 Jul 2013 15:17:34 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 31 Jul 2013 15:17:31 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id E7B77394006F for ; Wed, 31 Jul 2013 15:25:38 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6V9teiA35717370 for ; Wed, 31 Jul 2013 15:25:41 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r6V9tgOe019667 for ; Wed, 31 Jul 2013 19:55:43 +1000 Received: from d23ml188.in.ibm.com (d23ml188.in.ibm.com [9.182.8.144]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r6V9tgL8019617; Wed, 31 Jul 2013 19:55:42 +1000 In-Reply-To: <51F69F1E.40808@redhat.com> References: <51F69F1E.40808@redhat.com> Subject: Re: [PATCH 2/5] powerpc64-aix processing xlC generated line table X-KeepSent: 668B9A7A:5414653D-65257BB9:00351B5A; type=4; name=$KeepSent To: Pedro Alves Cc: gdb-patches@sourceware.org, Mark Kettenis , tromey@redhat.com Message-ID: From: Raunaq 12 Date: Wed, 31 Jul 2013 09:57:00 -0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13073109-8878-0000-0000-0000082F2098 X-SW-Source: 2013-07/txt/msg00811.txt.bz2 > > + for (jj = 0; jj < lineTb->nitems; jj++) > > + { > > + if (lineTb->item[jj].line == 0 && (lineTb->item[jj].pc > > + != lineTb->item[jj + 1].pc)) > > + lineTb->item[jj].line = lineTb->item[jj + 1].line; > > + } > > Seems to me this duplicate code could/should be factored out to a helper > function. Agreed. Implementation looks much cleaner after using a function for the duplicate code. Here is the modified patch and changelog. --- ChangeLog :- * xcoffread.c (modify_xlc_linenos): New function to modify xlc generated linetables. (process_linenos): make calls to the 'modify_xlc_linenos' to correctly process linenos is case of xlc compiled binaries. --- Index: ./gdb/xcoffread.c =================================================================== --- ./gdb.orig/xcoffread.c +++ ./gdb/xcoffread.c @@ -241,6 +241,8 @@ static struct linetable *arrange_linetable (struct linetable *); +static struct linetable *modify_xlc_linenos (struct linetable *); + static void record_include_end (struct coff_symbol *); static void process_linenos (CORE_ADDR, CORE_ADDR); @@ -589,6 +591,24 @@ } } +/* xlc compiled binaries have one less entry in the line table. + So the function entry lines marked as line number equal to 0 + will be retained in the line table with line numbers equal + to its succeeding line table entry. */ + +static struct linetable * +modify_xlc_linenos ( struct linetable *lineTb ) +{ + int jj; + for (jj = 0; jj < lineTb->nitems; jj++) + { + if (lineTb -> item[jj].line == 0 && (lineTb -> item[jj].pc + != lineTb->item[jj + 1].pc)) + lineTb->item[jj].line = lineTb->item[jj+1].line; + } + return lineTb; +} + /* Global variable to pass the psymtab down to all the routines involved in psymtab to symtab processing. */ static struct partial_symtab *this_symtab_psymtab; @@ -698,10 +718,14 @@ lv = main_subfile.line_vector; + /* Add extra line entry in case of xlc compiled binaries. */ + + lineTb = modify_xlc_linenos (lv); + /* Line numbers are not necessarily ordered. xlc compilation will put static function to the end. */ - lineTb = arrange_linetable (lv); + lineTb = arrange_linetable (lineTb); if (lv == lineTb) { current_subfile->line_vector = (struct linetable *) @@ -730,10 +754,14 @@ lv = (inclTable[ii].subfile)->line_vector; + /* Add extra line entry in case of xlc compiled binaries */ + + lineTb = modify_xlc_linenos (lv); + /* Line numbers are not necessarily ordered. xlc compilation will put static function to the end. */ - lineTb = arrange_linetable (lv); + lineTb = arrange_linetable (lineTb); push_subfile (); --- this is ok? Note :- without this patch we are not able to break into functions at the entry point and we are not able to list functions by their name. eg :- list main Regards, Raunaq