From patchwork Mon Apr 16 18:44:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 26757 Received: (qmail 116150 invoked by alias); 16 Apr 2018 18:44:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 116132 invoked by uid 89); 16 Apr 2018 18:44:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=LAST X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Apr 2018 18:44:41 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3GIidxO116739 for ; Mon, 16 Apr 2018 14:44:39 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hcwe33jt6-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 16 Apr 2018 14:44:31 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Apr 2018 19:44:27 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 16 Apr 2018 19:44:25 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3GIiPm659572284 for ; Mon, 16 Apr 2018 18:44:25 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A2CD4C044 for ; Mon, 16 Apr 2018 19:36:57 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E3F124C052 for ; Mon, 16 Apr 2018 19:36:56 +0100 (BST) Received: from oc1027705133.ibm.com (unknown [9.152.212.201]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS for ; Mon, 16 Apr 2018 19:36:56 +0100 (BST) From: Andreas Arnez To: gdb-patches@sourceware.org Subject: [PATCH] Don't print symbol definition's line number in rbreak output Date: Mon, 16 Apr 2018 20:44:23 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18041618-0012-0000-0000-000005CB822A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041618-0013-0000-0000-00001947C7ED Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-16_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804160161 This commit: b744723f57 -- Show line numbers in output for "info var/func/type" added the symbol definition's line number to the output of certain GDB commands. It also changes the `rbreak' command's output, although it shouldn't. This is fixed. In order to distinguish when to print location information, the meaning of print_symbol_info()'s parameter `last' is changed. Now NULL means to skip any filename or line number information. Previously NULL meant to always print the filename. gdb/ChangeLog: * symtab.c (print_symbol_info): Skip printing filename and line number when `last' is NULL. (symtab_symbol_info): Use empty string instead of NULL for first invocation of print_symbol_info. (rbreak_command): Pass NULL to `last' parameter of print_symbol_info. --- gdb/symtab.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index f66b6f00f0..cebfdac46c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4500,7 +4500,9 @@ search_symbols (const char *regexp, enum search_domain kind, /* Helper function for symtab_symbol_info, this function uses the data returned from search_symbols() to print information - regarding the match to gdb_stdout. */ + regarding the match to gdb_stdout. If LAST is not NULL, + print file- and line number information for the symbol as + well. Skip printing the filename if it matches LAST. */ static void print_symbol_info (enum search_domain kind, @@ -4508,19 +4510,23 @@ print_symbol_info (enum search_domain kind, int block, const char *last) { struct symtab *s = symbol_symtab (sym); - const char *s_filename = symtab_to_filename_for_display (s); - if (last == NULL || filename_cmp (last, s_filename) != 0) + if (last != NULL) { - fputs_filtered ("\nFile ", gdb_stdout); - fputs_filtered (s_filename, gdb_stdout); - fputs_filtered (":\n", gdb_stdout); - } + const char *s_filename = symtab_to_filename_for_display (s); - if (SYMBOL_LINE (sym) != 0) - printf_filtered ("%d:\t", SYMBOL_LINE (sym)); - else - puts_filtered ("\t"); + if (filename_cmp (last, s_filename) != 0) + { + fputs_filtered ("\nFile ", gdb_stdout); + fputs_filtered (s_filename, gdb_stdout); + fputs_filtered (":\n", gdb_stdout); + } + + if (SYMBOL_LINE (sym) != 0) + printf_filtered ("%d:\t", SYMBOL_LINE (sym)); + else + puts_filtered ("\t"); + } if (kind != TYPES_DOMAIN && block == STATIC_BLOCK) printf_filtered ("static "); @@ -4573,7 +4579,7 @@ symtab_symbol_info (const char *regexp, enum search_domain kind, int from_tty) { static const char * const classnames[] = {"variable", "function", "type"}; - const char *last_filename = NULL; + const char *last_filename = ""; int first = 1; gdb_assert (kind <= TYPES_DOMAIN); @@ -4684,10 +4690,7 @@ rbreak_command (const char *regexp, int from_tty) string = string_printf ("%s:'%s'", fullname, SYMBOL_LINKAGE_NAME (p.symbol)); break_command (&string[0], from_tty); - print_symbol_info (FUNCTIONS_DOMAIN, - p.symbol, - p.block, - symtab_to_filename_for_display (symtab)); + print_symbol_info (FUNCTIONS_DOMAIN, p.symbol, p.block, NULL); } else {