From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10795 invoked by alias); 7 Mar 2014 08:57:54 -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 10681 invoked by uid 89); 7 Mar 2014 08:57:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Mar 2014 08:57:51 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 07 Mar 2014 00:57:48 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 07 Mar 2014 00:57:46 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s278vjG2020386; Fri, 7 Mar 2014 08:57:46 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id s278vjxf014449; Fri, 7 Mar 2014 09:57:45 +0100 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id s278vjnS014445; Fri, 7 Mar 2014 09:57:45 +0100 From: Markus Metzger To: jan.kratochvil@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH 2/2] btrace: avoid symbol lookup Date: Fri, 07 Mar 2014 08:57:00 -0000 Message-Id: <1394182665-14164-3-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1394182665-14164-1-git-send-email-markus.t.metzger@intel.com> References: <1394182665-14164-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00179.txt.bz2 The debug symbol lookup is quite expensive, particularly if no symbol is found for a given PC. Avoid the lookup when computing the function trace if we already found a minimal symbol. The only different seems to be that some function names are now printed without '()'. 2014-03-07 Markus Metzger * btrace.c (ftrace_update_function): Lookup symbol only if there is no minimal symbol. testsuite/ * gdb.btrace/exception.exp: Update. * gdb.btrace/static_functions.exp: New. --- gdb/btrace.c | 12 ++++-- gdb/testsuite/gdb.btrace/exception.exp | 4 +- gdb/testsuite/gdb.btrace/static_functions.exp | 62 +++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 gdb/testsuite/gdb.btrace/static_functions.exp diff --git a/gdb/btrace.c b/gdb/btrace.c index b2e34b7..feb7bea 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -451,13 +451,17 @@ ftrace_update_function (struct gdbarch *gdbarch, struct symbol *fun; struct btrace_insn *last; - /* Try to determine the function we're in. We use both types of symbols - to avoid surprises when we sometimes get a full symbol and sometimes - only a minimal symbol. */ - fun = find_pc_function (pc); + /* Try to determine the function we're in. */ bmfun = lookup_minimal_symbol_by_pc (pc); mfun = bmfun.minsym; + /* We only lookup the symbol in the debug information if we have not found + a minimal symbol. This avoids the expensive lookup for globally visible + symbols. */ + fun = NULL; + if (mfun == NULL) + fun = find_pc_function (pc); + if (fun == NULL && mfun == NULL) DEBUG_FTRACE ("no symbol at %s", core_addr_to_string_nz (pc)); diff --git a/gdb/testsuite/gdb.btrace/exception.exp b/gdb/testsuite/gdb.btrace/exception.exp index 0279a7f..71f54a2 100755 --- a/gdb/testsuite/gdb.btrace/exception.exp +++ b/gdb/testsuite/gdb.btrace/exception.exp @@ -47,7 +47,7 @@ gdb_continue_to_breakpoint "cont to bp.2" ".*$srcfile:$bp_2\r\n.*" send_gdb "record function-call-history 1\n" gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \ [join [list \ - "1\tmain\\(\\)" \ + "1\tmain" \ "2\ttest\\(\\)" \ "3\tfoo\\(\\)" \ "4\tbar\\(\\)" \ @@ -60,7 +60,7 @@ gdb_expect_list "flat" "\r\n$gdb_prompt $" [list \ send_gdb "record function-call-history /c 1\n" gdb_expect_list "indented" "\r\n$gdb_prompt $" [list \ [join [list \ - "1\tmain\\(\\)" \ + "1\tmain" \ "2\t test\\(\\)" \ "3\t foo\\(\\)" \ "4\t bar\\(\\)" \ diff --git a/gdb/testsuite/gdb.btrace/static_functions.exp b/gdb/testsuite/gdb.btrace/static_functions.exp new file mode 100644 index 0000000..34ed485 --- /dev/null +++ b/gdb/testsuite/gdb.btrace/static_functions.exp @@ -0,0 +1,62 @@ +# This testcase is part of GDB, the GNU debugger. +# +# Copyright 2013 Free Software Foundation, Inc. +# +# Contributed by Intel Corp. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# check for btrace support +if { [skip_btrace_tests] } { return -1 } + +# start inferior +standard_testfile unknown_functions.c + +# discard local symbols +set ldflags "additional_flags=-Wl,-x" +if [prepare_for_testing $testfile.exp $testfile $srcfile {$ldflags debug}] { + return -1 +} +if ![runto test] { + return -1 +} + +# we want to see the full trace for this test +gdb_test_no_output "set record function-call-history-size 0" + +# trace from one call of test to the next +gdb_test_no_output "record btrace" +gdb_continue_to_breakpoint "cont to test" ".*test.*" + +# show the flat branch trace +gdb_test "record function-call-history 1" [join [list \ + "1\ttest" \ + "2\tfoo" \ + "3\tbar" \ + "4\tfoo" \ + "5\ttest" \ + "6\tmain" \ + "7\ttest" \ + ] "\r\n"] "flat" + +# show the branch trace with calls indented +gdb_test "record function-call-history /c 1" [join [list \ + "1\t test" \ + "2\t foo" \ + "3\t bar" \ + "4\t foo" \ + "5\t test" \ + "6\tmain" \ + "7\t test" \ + ] "\r\n"] "indented" -- 1.8.3.1