Blame SOURCES/gdb-rhbz1228556-bpt-inlined-func-name-1of2.patch

8f6b9e
commit 06871ae84096ed1672eb76f44cea4d5dbe79ae24
8f6b9e
Author: Pedro Alves <palves@redhat.com>
8f6b9e
Date:   Wed Sep 20 16:12:54 2017 +0100
8f6b9e
8f6b9e
    Make "list ambiguous" show symbol names too
8f6b9e
    
8f6b9e
    Currently, with an ambiguous "list first,last", we get:
8f6b9e
    
8f6b9e
      (gdb) list bar,main
8f6b9e
      Specified first line 'bar' is ambiguous:
8f6b9e
      file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97
8f6b9e
      file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98
8f6b9e
    
8f6b9e
    This commit makes gdb's output above a bit clearer by printing the
8f6b9e
    symbol name as well:
8f6b9e
    
8f6b9e
      (gdb) list bar,main
8f6b9e
      Specified first line 'bar' is ambiguous:
8f6b9e
      file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97, symbol: "bar(A)"
8f6b9e
      file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98, symbol: "bar(B)"
8f6b9e
    
8f6b9e
    And while at it, makes gdb print the symbol name when actually listing
8f6b9e
    multiple locations too.  I.e., before (with "set listsize 2"):
8f6b9e
    
8f6b9e
      (gdb) list bar
8f6b9e
      file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97
8f6b9e
      96
8f6b9e
      97      int bar (A) { return 11; }
8f6b9e
      file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98
8f6b9e
      97      int bar (A) { return 11; }
8f6b9e
      98      int bar (B) { return 22; }
8f6b9e
    
8f6b9e
    After:
8f6b9e
    
8f6b9e
      (gdb) list bar
8f6b9e
      file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97, symbol: "bar(A)"
8f6b9e
      96
8f6b9e
      97      int bar (A) { return 11; }
8f6b9e
      file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98, symbol: "bar(B)"
8f6b9e
      97      int bar (A) { return 11; }
8f6b9e
      98      int bar (B) { return 22; }
8f6b9e
    
8f6b9e
    Currently, the result of decoding a linespec loses information about
8f6b9e
    the original symbol that was found.  All we end up with is an address.
8f6b9e
    This makes it difficult to find the original symbol again to get at
8f6b9e
    its print name.  Fix that by storing a pointer to the symbol in the
8f6b9e
    sal.  We already store the symtab and obj_section, so it feels like a
8f6b9e
    natural progression to me.  This avoids having to do any extra symbol
8f6b9e
    lookup too.
8f6b9e
    
8f6b9e
    gdb/ChangeLog:
8f6b9e
    2017-09-20  Pedro Alves  <palves@redhat.com>
8f6b9e
    
8f6b9e
            * cli/cli-cmds.c (list_command): Use print_sal_location.
8f6b9e
            (print_sal_location): New function.
8f6b9e
            (ambiguous_line_spec): Use print_sal_location.
8f6b9e
            * linespec.c (symbol_to_sal): Record the symbol in the sal.
8f6b9e
            * symtab.c (find_function_start_sal): Likewise.
8f6b9e
            * symtab.h (symtab_and_line::symbol): New field.
8f6b9e
    
8f6b9e
    gdb/testsuite/ChangeLog:
8f6b9e
    2017-09-20  Pedro Alves  <palves@redhat.com>
8f6b9e
    
8f6b9e
            * gdb.base/list-ambiguous.exp (test_list_ambiguous_symbol): Expect
8f6b9e
            symbol names in gdb's output.
8f6b9e
            * gdb.cp/overload.exp ("list all overloads"): Likewise.
8f6b9e
8f6b9e
### a/gdb/ChangeLog
8f6b9e
### b/gdb/ChangeLog
8f6b9e
## -1,5 +1,14 @@
8f6b9e
 2017-09-20  Pedro Alves  <palves@redhat.com>
8f6b9e
 
8f6b9e
+	* cli/cli-cmds.c (list_command): Use print_sal_location.
8f6b9e
+	(print_sal_location): New function.
8f6b9e
+	(ambiguous_line_spec): Use print_sal_location.
8f6b9e
+	* linespec.c (symbol_to_sal): Record the symbol in the sal.
8f6b9e
+	* symtab.c (find_function_start_sal): Likewise.
8f6b9e
+	* symtab.h (symtab_and_line::symbol): New field.
8f6b9e
+
8f6b9e
+2017-09-20  Pedro Alves  <palves@redhat.com>
8f6b9e
+
8f6b9e
 	* linespec.c (minsym_found): Handle non-text minsyms.
8f6b9e
 	(symbol_to_sal): Record a sal.pc for non-block, non-label symbols.
8f6b9e
 
8f6b9e
Index: gdb-7.6.1/gdb/linespec.c
8f6b9e
===================================================================
8f6b9e
--- gdb-7.6.1.orig/gdb/linespec.c	2017-10-27 20:44:32.493790183 +0200
8f6b9e
+++ gdb-7.6.1/gdb/linespec.c	2017-10-27 20:49:52.460307350 +0200
8f6b9e
@@ -3648,6 +3648,7 @@
8f6b9e
 	{
8f6b9e
 	  init_sal (result);
8f6b9e
 	  result->symtab = SYMBOL_SYMTAB (sym);
8f6b9e
+	  result->symbol = sym;
8f6b9e
 	  result->line = SYMBOL_LINE (sym);
8f6b9e
 	  result->pc = SYMBOL_VALUE_ADDRESS (sym);
8f6b9e
 	  result->pspace = SYMTAB_PSPACE (SYMBOL_SYMTAB (sym));
8f6b9e
@@ -3663,6 +3664,7 @@
8f6b9e
 	  /* We know its line number.  */
8f6b9e
 	  init_sal (result);
8f6b9e
 	  result->symtab = SYMBOL_SYMTAB (sym);
8f6b9e
+	  result->symbol = sym;
8f6b9e
 	  result->line = SYMBOL_LINE (sym);
8f6b9e
 	  result->pspace = SYMTAB_PSPACE (SYMBOL_SYMTAB (sym));
8f6b9e
 	  return 1;
8f6b9e
Index: gdb-7.6.1/gdb/symtab.c
8f6b9e
===================================================================
8f6b9e
--- gdb-7.6.1.orig/gdb/symtab.c	2017-10-27 20:44:32.493790183 +0200
8f6b9e
+++ gdb-7.6.1/gdb/symtab.c	2017-10-27 21:02:02.162058159 +0200
8f6b9e
@@ -872,6 +872,7 @@
8f6b9e
 {
8f6b9e
   sal->pspace = NULL;
8f6b9e
   sal->symtab = 0;
8f6b9e
+  sal->symbol = NULL;
8f6b9e
   sal->section = 0;
8f6b9e
   sal->line = 0;
8f6b9e
   sal->pc = 0;
8f6b9e
@@ -2774,6 +2775,7 @@
8f6b9e
   fixup_symbol_section (sym, NULL);
8f6b9e
   sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)),
8f6b9e
 			   SYMBOL_OBJ_SECTION (sym), 0);
8f6b9e
+  sal.symbol = sym;
8f6b9e
 
8f6b9e
   if (funfirstline && sal.symtab != NULL
8f6b9e
       && (sal.symtab->locations_valid
8f6b9e
@@ -2797,6 +2799,7 @@
8f6b9e
       sal.pspace = current_program_space;
8f6b9e
       sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
8f6b9e
       sal.section = SYMBOL_OBJ_SECTION (sym);
8f6b9e
+      sal.symbol = sym;
8f6b9e
     }
8f6b9e
 
8f6b9e
   if (funfirstline)
8f6b9e
Index: gdb-7.6.1/gdb/symtab.h
8f6b9e
===================================================================
8f6b9e
--- gdb-7.6.1.orig/gdb/symtab.h	2017-10-27 20:44:32.493790183 +0200
8f6b9e
+++ gdb-7.6.1/gdb/symtab.h	2017-10-27 21:01:41.522895501 +0200
8f6b9e
@@ -1105,6 +1105,7 @@
8f6b9e
   struct program_space *pspace;
8f6b9e
 
8f6b9e
   struct symtab *symtab;
8f6b9e
+  struct symbol *symbol;
8f6b9e
   struct obj_section *section;
8f6b9e
   /* Line number.  Line numbers start at 1 and proceed through symtab->nlines.
8f6b9e
      0 is never a valid line number; it is used to indicate that line number