[RFA,3/3] Make symtab.c better styled.

Message ID 20190110220113.26169-4-philippe.waroquiers@skynet.be
State New, archived
Headers

Commit Message

Philippe Waroquiers Jan. 10, 2019, 10:01 p.m. UTC
  2019-01-10  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* symtab.c (output_source_filename): Use file name style
	to print file name.
	(print_symbol_info): Likewise.
	(print_msymbol_info): Use address style to print addresses.
---
 gdb/symtab.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
  

Comments

Tom Tromey Jan. 12, 2019, 4:26 p.m. UTC | #1
>>>>> "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:

Philippe> 2019-01-10  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
Philippe> 	* symtab.c (output_source_filename): Use file name style
Philippe> 	to print file name.
Philippe> 	(print_symbol_info): Likewise.
Philippe> 	(print_msymbol_info): Use address style to print addresses.

Thanks, this is ok.

Philippe> +  printf_filtered ("  %s\n",
Philippe> +		   MSYMBOL_PRINT_NAME (msymbol.minsym));

I suppose this could look at the minsymbol type and use either the
function or variable styling.

Tom
  
Philippe Waroquiers Jan. 12, 2019, 4:48 p.m. UTC | #2
On Sat, 2019-01-12 at 09:26 -0700, Tom Tromey wrote:
> > > > > > "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:
> 
> Philippe> 2019-01-10  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
> Philippe> 	* symtab.c (output_source_filename): Use file name style
> Philippe> 	to print file name.
> Philippe> 	(print_symbol_info): Likewise.
> Philippe> 	(print_msymbol_info): Use address style to print addresses.
> 
> Thanks, this is ok.
> 
> Philippe> +  printf_filtered ("  %s\n",
> Philippe> +		   MSYMBOL_PRINT_NAME (msymbol.minsym));
> 
> I suppose this could look at the minsymbol type and use either the
> function or variable styling.
That looks relatively easy to do.
To differentiate between data and text, would the condition
in expand_symtab_containing_pc be ok ?

i.e.  variable styling would be used for data, i.e. :
        (MSYMBOL_TYPE (msymbol.minsym) == mst_data
	  || MSYMBOL_TYPE (msymbol.minsym) == mst_bss
	  || MSYMBOL_TYPE (msymbol.minsym) == mst_abs
	  || MSYMBOL_TYPE (msymbol.minsym) == mst_file_data
	  || MSYMBOL_TYPE (msymbol.minsym) == mst_file_bss))

and function name styling would be used for the rest i.e.:
  mst_text,			/* Generally executable instructions */
  mst_text_gnu_ifunc,           /* Executable code returning address
				   of executable code */

  mst_data_gnu_ifunc,		/* Executable code returning address
				   of executable code */

  mst_slot_got_plt,		/* GOT entries for .plt sections */
  mst_solib_trampoline,		/* Shared library trampoline code */
  mst_file_text,		/* Static version of mst_text */


Philippe
  
Tom Tromey Jan. 12, 2019, 10:58 p.m. UTC | #3
>>>>> "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:

Philippe> To differentiate between data and text, would the condition
Philippe> in expand_symtab_containing_pc be ok ?

Philippe> i.e.  variable styling would be used for data, i.e. :
Philippe>         (MSYMBOL_TYPE (msymbol.minsym) == mst_data
Philippe> 	  || MSYMBOL_TYPE (msymbol.minsym) == mst_bss
Philippe> 	  || MSYMBOL_TYPE (msymbol.minsym) == mst_abs
Philippe> 	  || MSYMBOL_TYPE (msymbol.minsym) == mst_file_data
Philippe> 	  || MSYMBOL_TYPE (msymbol.minsym) == mst_file_bss))

Philippe> and function name styling would be used for the rest i.e.:
Philippe>   mst_text,			/* Generally executable instructions */
Philippe>   mst_text_gnu_ifunc,           /* Executable code returning address
Philippe> 				   of executable code */

Philippe>   mst_data_gnu_ifunc,		/* Executable code returning address
Philippe> 				   of executable code */

Philippe>   mst_slot_got_plt,		/* GOT entries for .plt sections */
Philippe>   mst_solib_trampoline,		/* Shared library trampoline code */
Philippe>   mst_file_text,		/* Static version of mst_text */

Yes, I think that's reasonable.

Tom
  

Patch

diff --git a/gdb/symtab.c b/gdb/symtab.c
index d5e18a64d0..9363bf555a 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -41,6 +41,7 @@ 
 #include "p-lang.h"
 #include "addrmap.h"
 #include "cli/cli-utils.h"
+#include "cli/cli-style.h"
 #include "fnmatch.h"
 #include "hashtab.h"
 #include "typeprint.h"
@@ -4168,7 +4169,7 @@  output_source_filename (const char *name,
   data->first = 0;
 
   wrap_here ("");
-  fputs_filtered (name, gdb_stdout);
+  fputs_styled (name, file_name_style.style (), gdb_stdout);
 }
 
 /* A callback for map_partial_symbol_filenames.  */
@@ -4620,7 +4621,7 @@  print_symbol_info (enum search_domain kind,
       if (filename_cmp (last, s_filename) != 0)
 	{
 	  fputs_filtered ("\nFile ", gdb_stdout);
-	  fputs_filtered (s_filename, gdb_stdout);
+	  fputs_styled (s_filename, file_name_style.style (), gdb_stdout);
 	  fputs_filtered (":\n", gdb_stdout);
 	}
 
@@ -4667,8 +4668,9 @@  print_msymbol_info (struct bound_minimal_symbol msymbol)
   else
     tmp = hex_string_custom (BMSYMBOL_VALUE_ADDRESS (msymbol),
 			     16);
-  printf_filtered ("%s  %s\n",
-		   tmp, MSYMBOL_PRINT_NAME (msymbol.minsym));
+  fputs_styled (tmp, address_style.style (), gdb_stdout);
+  printf_filtered ("  %s\n",
+		   MSYMBOL_PRINT_NAME (msymbol.minsym));
 }
 
 /* This is the guts of the commands "info functions", "info types", and