aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorAndreas Arnez <arnez@linux.vnet.ibm.com>2018-04-17 19:31:58 +0200
committerAndreas Arnez <arnez@linux.vnet.ibm.com>2018-04-17 19:31:58 +0200
commitc7dcbf88c6557f35d9e75ae6223a3e61e1f70578 (patch)
tree290b1e701a621a12f0f10dd0c770306306c32465 /gdb/symtab.c
parent808346fcfcff1c3f2471c98e48613afd7bce3679 (diff)
downloadgdb-c7dcbf88c6557f35d9e75ae6223a3e61e1f70578.zip
gdb-c7dcbf88c6557f35d9e75ae6223a3e61e1f70578.tar.gz
gdb-c7dcbf88c6557f35d9e75ae6223a3e61e1f70578.tar.bz2
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.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index f66b6f0..c1ead70 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
{