public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFAv3 3/3] Make symtab.c better styled.
  2019-01-19 12:33 [RFAv3 0/3] Have GDB better styled Philippe Waroquiers
@ 2019-01-19 12:33 ` Philippe Waroquiers
  2019-01-19 12:33 ` [RFAv3 1/3] Use function_name_style to print Ada and C function names Philippe Waroquiers
  2019-01-19 12:33 ` [RFAv3 2/3] Use address style to print addresses in breakpoint information Philippe Waroquiers
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Waroquiers @ 2019-01-19 12:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Philippe Waroquiers

Note that print_msymbol_info does not (yet?) print data msymbol
using variable_name_style, as otherwise 'info variables'
would show the non debugging symbols in variable name style,
but 'real' variables would be not styled.

2019-01-19  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* symtab.h (struct minimal_symbol data_p): New const method.
	(struct minimal_symbol text_p): Likewise.
	* 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.
	Use function name style to print executable text symbols.
	(expand_symtab_containing_pc): Use data_p.
	(find_pc_sect_compunit_symtab): Likewise.
---
 gdb/symtab.c | 55 +++++++++++++++++++++++++++++++++++++---------------
 gdb/symtab.h |  8 ++++++++
 2 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index a2bd4dd54d..ad2a1599a3 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"
@@ -311,6 +312,31 @@ compunit_language (const struct compunit_symtab *cust)
   return SYMTAB_LANGUAGE (symtab);
 }
 
+/* See symtab.h.  */
+
+bool
+minimal_symbol::data_p () const
+{
+  return type == mst_data
+    || type == mst_bss
+    || type == mst_abs
+    || type == mst_file_data
+    || type == mst_file_bss;
+}
+
+/* See symtab.h.  */
+
+bool
+minimal_symbol::text_p () const
+{
+  return type == mst_text
+    || type == mst_text_gnu_ifunc
+    || type == mst_data_gnu_ifunc
+    || type == mst_slot_got_plt
+    || type == mst_solib_trampoline
+    || type == mst_file_text;
+}
+
 /* See whether FILENAME matches SEARCH_NAME using the rule that we
    advertise to the user.  (The manual's description of linespecs
    describes what we advertise).  Returns true if they match, false
@@ -1039,12 +1065,7 @@ expand_symtab_containing_pc (CORE_ADDR pc, struct obj_section *section)
      necessary because we loop based on texthigh and textlow, which do
      not include the data ranges.  */
   msymbol = lookup_minimal_symbol_by_pc_section (pc, section);
-  if (msymbol.minsym
-      && (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))
+  if (msymbol.minsym && msymbol.minsym->data_p ())
     return;
 
   for (objfile *objfile : current_program_space->objfiles ())
@@ -2879,12 +2900,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
      we call find_pc_sect_psymtab which has a similar restriction based
      on the partial_symtab's texthigh and textlow.  */
   msymbol = lookup_minimal_symbol_by_pc_section (pc, section);
-  if (msymbol.minsym
-      && (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))
+  if (msymbol.minsym && msymbol.minsym->data_p ())
     return NULL;
 
   /* Search all symtabs for the one whose file contains our address, and which
@@ -4168,7 +4184,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 +4636,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 +4683,15 @@ 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);
+  fputs_filtered ("  ", gdb_stdout);
+  if (msymbol.minsym->text_p ())
+    fputs_styled (MSYMBOL_PRINT_NAME (msymbol.minsym),
+		  function_name_style.style (),
+		  gdb_stdout);
+  else
+    fputs_filtered (MSYMBOL_PRINT_NAME (msymbol.minsym), gdb_stdout);
+  fputs_filtered ("\n", gdb_stdout);
 }
 
 /* This is the guts of the commands "info functions", "info types", and
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 57ed2c0948..e3e7177afa 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -686,6 +686,14 @@ struct minimal_symbol
      the `next' pointer for the demangled hash table.  */
 
   struct minimal_symbol *demangled_hash_next;
+
+/* True if this symbol is of some data type.  */
+
+  bool data_p () const;
+
+  /* True if MSYMBOL is of some text type.  */
+
+  bool text_p () const;
 };
 
 #define MSYMBOL_TARGET_FLAG_1(msymbol)  (msymbol)->target_flag_1
-- 
2.20.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFAv3 0/3] Have GDB better styled.
@ 2019-01-19 12:33 Philippe Waroquiers
  2019-01-19 12:33 ` [RFAv3 3/3] Make symtab.c " Philippe Waroquiers
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Philippe Waroquiers @ 2019-01-19 12:33 UTC (permalink / raw)
  To: gdb-patches

In particular, 'info functions', rbreak, info sources will now be
styled.

Compared to the second version, this handles the comment of Tom
indicating that msymbol_type_data_p and msymbol_type_text_p
should be (const) methods on minsym.
Also, a detailed explanation about why print_func_type will only
style a function name has been given in message
https://sourceware.org/ml/gdb-patches/2019-01/msg00429.html.

Compared to the first version, the second version handled the comments of Tom:
* when doing 'info functions', the non debugging min symbols are printed
  using function name style, when the non debugging min symbol corresponds
  to some text.
* the commit log for function name style in the Ada and C type print gives
  more details about how these are called to print a function type and
  a function name.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFAv3 1/3] Use function_name_style to print Ada and C function names
  2019-01-19 12:33 [RFAv3 0/3] Have GDB better styled Philippe Waroquiers
  2019-01-19 12:33 ` [RFAv3 3/3] Make symtab.c " Philippe Waroquiers
@ 2019-01-19 12:33 ` Philippe Waroquiers
  2019-01-19 12:33 ` [RFAv3 2/3] Use address style to print addresses in breakpoint information Philippe Waroquiers
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Waroquiers @ 2019-01-19 12:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Philippe Waroquiers

Note that ada-typeprint.c print_func_type is called with
types representing functions and is also called to print
a function NAME together with its type.  In such a case, the function
name will be printed using function name style.

Similarly, c_print_type_1 is called to print a type, optionally
with the name of an object of this type in the VARSTRING arg.
So, c_print_type_1 uses function name style to print varstring
when the type code indicates that c_print_type_1 TYPE is some
'real code'.

gdb/ChangeLog
2019-01-19  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* ada-typeprint.c (print_func_type): Print function name
	style to print function name.
	* c-typeprint.c (c_print_type_1): Likewise.
---
 gdb/ada-typeprint.c | 6 +++++-
 gdb/c-typeprint.c   | 8 ++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 2b6cdaf264..8c42e8140d 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -30,6 +30,7 @@
 #include "language.h"
 #include "demangle.h"
 #include "c-lang.h"
+#include "cli/cli-style.h"
 #include "typeprint.h"
 #include "target-float.h"
 #include "ada-lang.h"
@@ -779,7 +780,10 @@ print_func_type (struct type *type, struct ui_file *stream, const char *name,
     fprintf_filtered (stream, "function");
 
   if (name != NULL && name[0] != '\0')
-    fprintf_filtered (stream, " %s", name);
+    {
+      fputs_filtered (" ", stream);
+      fputs_styled (name, function_name_style.style (), stream);
+    }
 
   if (len > 0)
     {
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 5e7e672e02..6690ca53bc 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -28,6 +28,7 @@
 #include "language.h"
 #include "demangle.h"
 #include "c-lang.h"
+#include "cli/cli-style.h"
 #include "typeprint.h"
 #include "cp-abi.h"
 #include "cp-support.h"
@@ -115,6 +116,7 @@ c_print_type_1 (struct type *type,
     type = check_typedef (type);
 
   local_name = typedef_hash_table::find_typedef (flags, type);
+  code = TYPE_CODE (type);
   if (local_name != NULL)
     {
       fputs_filtered (local_name, stream);
@@ -124,7 +126,6 @@ c_print_type_1 (struct type *type,
   else
     {
       c_type_print_base_1 (type, stream, show, level, language, flags, podata);
-      code = TYPE_CODE (type);
       if ((varstring != NULL && *varstring != '\0')
 	  /* Need a space if going to print stars or brackets;
 	     but not if we will print just a type name.  */
@@ -144,7 +145,10 @@ c_print_type_1 (struct type *type,
 
   if (varstring != NULL)
     {
-      fputs_filtered (varstring, stream);
+      if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
+	fputs_styled (varstring, function_name_style.style (), stream);
+      else
+	fputs_filtered (varstring, stream);
 
       /* For demangled function names, we have the arglist as part of
          the name, so don't print an additional pair of ()'s.  */
-- 
2.20.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFAv3 2/3] Use address style to print addresses in breakpoint information.
  2019-01-19 12:33 [RFAv3 0/3] Have GDB better styled Philippe Waroquiers
  2019-01-19 12:33 ` [RFAv3 3/3] Make symtab.c " Philippe Waroquiers
  2019-01-19 12:33 ` [RFAv3 1/3] Use function_name_style to print Ada and C function names Philippe Waroquiers
@ 2019-01-19 12:33 ` Philippe Waroquiers
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Waroquiers @ 2019-01-19 12:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Philippe Waroquiers

gdb/ChangeLog
2019-01-19  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* breakpoint.c (describe_other_breakpoints): Use address style
	to print addresses.
	(say_where): Likewise.
---
 gdb/breakpoint.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 3166fa0129..05a017d6ea 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -6701,7 +6701,7 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
 			     : ((others == 1) ? " and" : ""));
 	  }
       printf_filtered (_("also set at pc "));
-      fputs_filtered (paddress (gdbarch, pc), gdb_stdout);
+      fputs_styled (paddress (gdbarch, pc), address_style.style (), gdb_stdout);
       printf_filtered (".\n");
     }
 }
@@ -12183,8 +12183,9 @@ say_where (struct breakpoint *b)
       if (opts.addressprint || b->loc->symtab == NULL)
 	{
 	  printf_filtered (" at ");
-	  fputs_filtered (paddress (b->loc->gdbarch, b->loc->address),
-			  gdb_stdout);
+	  fputs_styled (paddress (b->loc->gdbarch, b->loc->address),
+			address_style.style (),
+			gdb_stdout);
 	}
       if (b->loc->symtab != NULL)
 	{
-- 
2.20.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-19 12:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-19 12:33 [RFAv3 0/3] Have GDB better styled Philippe Waroquiers
2019-01-19 12:33 ` [RFAv3 3/3] Make symtab.c " Philippe Waroquiers
2019-01-19 12:33 ` [RFAv3 1/3] Use function_name_style to print Ada and C function names Philippe Waroquiers
2019-01-19 12:33 ` [RFAv3 2/3] Use address style to print addresses in breakpoint information Philippe Waroquiers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).