Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Arnez <arnez@linux.ibm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Don't print symbol definition's line number in rbreak output
Date: Mon, 16 Apr 2018 18:44:00 -0000	[thread overview]
Message-ID: <m3sh7v3sag.fsf@oc1027705133.ibm.com> (raw)

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
 	{
-- 
2.14.3


             reply	other threads:[~2018-04-16 18:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 18:44 Andreas Arnez [this message]
2018-04-16 19:01 ` Pedro Alves
2018-04-17 12:28   ` Andreas Arnez
2018-04-17 15:18     ` Pedro Alves
2018-04-17 16:39       ` Andreas Arnez
2018-04-17 16:56         ` Pedro Alves
2018-04-17 17:33           ` Andreas Arnez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3sh7v3sag.fsf@oc1027705133.ibm.com \
    --to=arnez@linux.ibm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox