From patchwork Tue Apr 17 16:38:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 26764 Received: (qmail 27731 invoked by alias); 17 Apr 2018 16:39:12 -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 27712 invoked by uid 89); 17 Apr 2018 16:39:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 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= 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; Tue, 17 Apr 2018 16:39:10 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3HGaLgX122995 for ; Tue, 17 Apr 2018 12:39:08 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hdj3sh2p4-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 17 Apr 2018 12:39:08 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Apr 2018 17:39:06 +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; Tue, 17 Apr 2018 17:39:04 +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 w3HGd4Hf52953174; Tue, 17 Apr 2018 16:39:04 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D76C4C046; Tue, 17 Apr 2018 17:31:35 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED0524C040; Tue, 17 Apr 2018 17:31:34 +0100 (BST) Received: from oc1027705133.ibm.com (unknown [9.152.212.201]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 17 Apr 2018 17:31:34 +0100 (BST) From: Andreas Arnez To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Don't print symbol definition's line number in rbreak output References: <4eae39d3-c6ca-ef5b-4127-0ad29ee792c9@redhat.com> Date: Tue, 17 Apr 2018 18:38:59 +0200 In-Reply-To: <4eae39d3-c6ca-ef5b-4127-0ad29ee792c9@redhat.com> (Pedro Alves's message of "Tue, 17 Apr 2018 16:17:59 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18041716-0012-0000-0000-000005CBE742 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041716-0013-0000-0000-000019483319 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-17_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804170145 On Tue, Apr 17 2018, Pedro Alves wrote: > On 04/17/2018 01:28 PM, Andreas Arnez wrote: [...] >> No declaration line number was shown before. Instead, the function >> declaration started at the first column. This old behavior is restored. > > IMHO it's always better to also paste the output after, so the > reader doesn't have to imagine it from the description. OK. > >> /* 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. */ > > Nit, I don't think use of suspense hyphen in this case is common > in English: . > I'd just write plain "file". Hehe, good catch. > > The patch looks fine to me. However, I notice now that this doesn't > tweak any existing testcase or add any new one. Was the problem > caught by some existing testcase? Yes, it was. The attached v2 now provides this information and should also address all your previous comments. OK to push? --- Andreas -- >8 -- Subject: [PATCH v2] Don't print symbol declaration's line number in rbreak output This commit: b744723f57 -- Show line numbers in output for "info var/func/type" adds the symbol declaration's line number to the output of certain GDB commands. It also (inadvertently) changes the `rbreak' command's output, like this: (gdb) rbreak foo Breakpoint 1 at 0x40049b: file rbreak.c, line 6. 4: static int foo1(void); Breakpoint 2 at 0x4004b1: file rbreak.c, line 12. 10: static int foo2(void); (gdb) where the function declaration is now prefixed by its source line number, followed by a colon. But without showing the declaration's file name, the line number is useless and can possibly cause severe confusion. No declaration line number was shown before. Instead, the function declaration started at the first column: (gdb) rbreak foo Breakpoint 1 at 0x40049b: file rbreak.c, line 6. static int foo1(void); Breakpoint 2 at 0x4004b1: file rbreak.c, line 12. static int foo2(void); (gdb) This old behavior is restored, fixing some FAILs in fullpath-expand.exp, realname-expand.exp, and pr10179.exp. 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..c1ead701ec 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 {