From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27822 invoked by alias); 21 Mar 2014 17:43:29 -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 27812 invoked by uid 89); 21 Mar 2014 17:43:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Mar 2014 17:43:28 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2LHhPXR016334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Mar 2014 13:43:26 -0400 Received: from host2.jankratochvil.net (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s2LHhMOH021440 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 21 Mar 2014 13:43:24 -0400 Date: Fri, 21 Mar 2014 17:43:00 -0000 From: Jan Kratochvil To: Markus Metzger Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] btrace: only search for lines in current symtab Message-ID: <20140321174322.GA15430@host2.jankratochvil.net> References: <1394182665-14164-1-git-send-email-markus.t.metzger@intel.com> <1394182665-14164-2-git-send-email-markus.t.metzger@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1394182665-14164-2-git-send-email-markus.t.metzger@intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00537.txt.bz2 On Fri, 07 Mar 2014 09:57:44 +0100, Markus Metzger wrote: [...] > @@ -543,32 +532,39 @@ ftrace_update_function (struct gdbarch *gdbarch, > static void > ftrace_update_lines (struct btrace_function *bfun, CORE_ADDR pc) > { > - struct symtab_and_line sal; > - const char *fullname; > + struct linetable *lines; > + struct symtab *symtab; > + int i; > > - sal = find_pc_line (pc, 0); > - if (sal.symtab == NULL || sal.line == 0) > - { > - DEBUG_FTRACE ("no lines at %s", core_addr_to_string_nz (pc)); > - return; > - } > + symtab = bfun->symtab; > + if (symtab == NULL) > + return; > + > + lines = LINETABLE (symtab); > + if (lines == NULL) > + return; > > - /* Check if we switched files. This could happen if, say, a macro that > - is defined in another file is expanded here. */ > - fullname = symtab_to_fullname (sal.symtab); > - if (ftrace_skip_file (bfun, fullname)) > + for (i = 0; i < lines->nitems; ++i) The line table has ordered PC values so one can find the right line in logarithmic time. > { > - DEBUG_FTRACE ("ignoring file at %s, file=%s", > - core_addr_to_string_nz (pc), fullname); > - return; > - } > + struct linetable_entry *entry; > > - /* Update the line range. */ > - bfun->lbegin = min (bfun->lbegin, sal.line); > - bfun->lend = max (bfun->lend, sal.line); > + entry = &lines->item[i]; > + if (entry->pc == pc) This is not right, PC can be between two ENTRY->PC values and it should match the former line. This implementation would not find a matching line. > + { > + int line; > > - if (record_debug > 1) > - ftrace_debug (bfun, "update lines"); > + line = entry->line; > + > + /* Update the line range. */ > + bfun->lbegin = min (bfun->lbegin, line); > + bfun->lend = max (bfun->lend, line); > + > + if (record_debug > 1) > + ftrace_debug (bfun, "update lines"); > + > + break; > + } > + } > } > > /* Add the instruction at PC to BFUN's instructions. */ I do not think this is the right approach, find_pc_sect_line() can be improved to at least look up the lines in logarithmic time by bisecting the range. It could also use some cache of recent lookups. Also I am not sure this new implementation handles correctly include files and their boundaries, which find_pc_sect_line() has to take care of. This is my personal opinion unrelated to GDB project maintainers' opinion. Regards, Jan